Documentation
¶
Index ¶
- Constants
- Variables
- func Abort(w http.ResponseWriter, message string, code int)
- func ForkSftpClient(key string) *sftp.Client
- func GetQueryInt(r *http.Request, key string, defaultValue int) int
- func GetQueryInt32(r *http.Request, key string, defaultValue uint32) uint32
- func Hash(file string) (s string)
- func InitConfig(filepath string) error
- func Join(key string, sftpEntity SftpEntity)
- func JwtNewToken(connection JwtConnection, issuer string) (tokenString string, expire int64, err error)
- func Leave(key string)
- func MemStatic(staticDir string)
- func ModTime(file string) (t time.Time)
- func Open(name string) (io.ReadCloser, error)
- func ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func ServeJSON(w http.ResponseWriter, j interface{})
- type Claims
- type JwtConnection
- type Node
- type SSHConnInterface
- type SSHShellChannel
- type SSHShellSession
- type Session
- type SessionManager
- type SftpEntity
- type SftpNode
Constants ¶
const ( SSH_IO_MODE_CHANNEL = 0 SSH_IO_MODE_SESSION = 1 )
Variables ¶
var Config struct { Site struct { AppName string `yaml:"app_name"` RunMode string `yaml:"runmode"` DeployHost string `yaml:"deploy_host"` ListenAddr string `yaml:"listen_addr"` } `yaml:"site"` Prod struct { StaticPrefix string `yaml:"static_prefix"` // http prefix of static and views files ApiPrefix string `yaml:"api_prefix"` } `yaml:"prod"` Dev struct { StaticPrefix string `yaml:"static_prefix"` // https prefix of only static files //StaticPrefix string `yaml:"static_prefix"` // prefix of static files in dev mode. ApiPrefix string `yaml:"api_prefix"` // redirect static files requests to this address, redirect "StaticPrefix" to "StaticRedirect + StaticPrefix" // for example, StaticPrefix is "static", StaticRedirect is "localhost:8080/dist", // this will redirect all requests having prefix "static" to "localhost:8080/dist/static/" StaticRedirect string `yaml:"static_redirect"` // http server will read static file from this dir if StaticRedirect is empty StaticDir string `yaml:"static_dir"` ViewsPrefix string `yaml:"views_prefix"` // https prefix of only views files // path of view files (we can not redirect view files) to be served. ViewsDir string `yaml:"views_dir"` // todo } `yaml:"dev"` SSH struct { BufferCheckerCycleTime int `yaml:"buffer_checker_cycle_time"` } `yaml:"ssh"` Jwt struct { Secret string `yaml:"jwt_secret"` TokenLifetime int64 `yaml:"token_lifetime"` Issuer string `yaml:"issuer"` QueryTokenKey string `yaml:"query_token_key"` } `yaml:"jwt"` }
var NotFound = http.NotFound
NotFound is called when no asset is found. It defaults to http.NotFound but can be overwritten
var Server http.Handler = http.HandlerFunc(ServeHTTP)
Server is simply ServeHTTP but wrapped in http.HandlerFunc so it can be passed into net/http functions directly.
Functions ¶
func ForkSftpClient ¶ added in v0.2.2
make a copy of SftpEntity matched with given key. return sftp.client pointer or nil pointer.
func Hash ¶
Hash returns the hex-encoded SHA256 hash of the original file Used for the Etag, and useful for caching Returns an empty string if the file is not in the bundle
func InitConfig ¶ added in v0.2.0
func Join ¶ added in v0.2.2
func Join(key string, sftpEntity SftpEntity)
add a sftp client to subscribers list.
func JwtNewToken ¶
func JwtNewToken(connection JwtConnection, issuer string) (tokenString string, expire int64, err error)
create a jwt token,and return this token as string type. we can create a new token with Claims in it if login is successful. then, we can known the host and port when setting up websocket or sftp.
func MemStatic ¶ added in v0.2.0
func MemStatic(staticDir string)
read all files in views directory and map to "staticFiles"
func ModTime ¶
ModTime returns the modification time of the original file. Useful for caching purposes Returns zero time if the file is not in the bundle
func Open ¶
func Open(name string) (io.ReadCloser, error)
Open allows you to read an embedded file directly. It will return a decompressing Reader if the file is embedded in compressed format. You should close the Reader after you're done with it.
func ServeHTTP ¶
func ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP serves a request, attempting to reply with an embedded file.
func ServeJSON ¶
func ServeJSON(w http.ResponseWriter, j interface{})
Types ¶
type Claims ¶
type Claims struct { JwtConnection jwt.StandardClaims }
type JwtConnection ¶ added in v0.2.2
payload in jwt
type Node ¶
type Node struct { Host string // host, e.g: ssh.example.com Port int //port,default value is 22 // contains filtered or unexported fields }
func NewSSHNode ¶ added in v0.2.2
func (*Node) Connect ¶
func (node *Node) Connect(username string, auth ssh.AuthMethod) error
see: http://www.nljb.net/default/Go-SSH-%E4%BD%BF%E7%94%A8/ establish a ssh connection. if success return nil, than can operate ssh connection via pointer Node.client in struct Node.
type SSHConnInterface ¶
type SSHShellChannel ¶
deprecated, use session SSHShellSession instead connect to ssh server using channel.
func (*SSHShellChannel) Config ¶
func (ch *SSHShellChannel) Config(cols, rows uint32) error
type SSHShellSession ¶
type SSHShellSession struct { Node // calling Write() to write data to ssh server StdinPipe io.WriteCloser // Write() be called to receive data from ssh server WriterPipe io.Writer // contains filtered or unexported fields }
connect to ssh server using ssh session.
func (*SSHShellSession) Close ¶
func (s *SSHShellSession) Close() error
func (*SSHShellSession) Config ¶
func (s *SSHShellSession) Config(cols, rows uint32) (*ssh.Session, error)
setup ssh shell session set SSHShellSession.session and StdinPipe from created session here. and Session.Stdout and Session.Stderr are also set for outputting. Return value is a pointer of ssh session which is created by ssh client for shell interaction. If it has error in this func, ssh session will be nil.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
use jwt string as session key, store user information(username and password) in Session.
var SessionStorage SessionManager
func (*SessionManager) Delete ¶
func (s *SessionManager) Delete(key string)
func (*SessionManager) Get ¶
func (s *SessionManager) Get(key string) (sessionData Session, exist bool)
func (*SessionManager) Put ¶
func (s *SessionManager) Put(key string, expire int64, value interface{})
* * add a new session to session manager. * @params:token: token string * expire: unix time for expire * password: ssh user password
type SftpEntity ¶ added in v0.2.2
type SftpEntity struct {
// contains filtered or unexported fields
}
func Fork ¶ added in v0.2.2
func Fork(key string) (SftpEntity, bool)
make a copy of SftpEntity matched with given key. return sftpEntity and exist flag (bool).
func NewSftpEntity ¶ added in v0.2.2
func NewSftpEntity(user SftpNode, username string, auth ssh.AuthMethod) (SftpEntity, error)
func (*SftpEntity) Close ¶ added in v0.2.2
func (con *SftpEntity) Close() error
close sftp session and ssh client