Documentation
¶
Index ¶
- func CheckSign(values url.Values, key string, sign []byte) bool
- func EncodeValues(v url.Values) string
- func FixKeepAlive(conn net.Conn)
- func MakeSign(values url.Values, key string) []byte
- func MakeSignString(values url.Values, key string) string
- func WebsocketCopy(reqConn *websocket.Conn, backendConn *websocket.Conn) error
- type Client
- func (client *Client) Clone() *Client
- func (client *Client) Get(action string, params url.Values, header http.Header) (*Response, error)
- func (client *Client) GetData(action string, params url.Values, header http.Header, dataKey string, ...) error
- func (client *Client) GetResult(action string, params url.Values, header http.Header) (*api.Result, error)
- func (client *Client) Post(action string, params url.Values, header http.Header) (*Response, error)
- func (client *Client) PostData(action string, params url.Values, header http.Header, dataKey string, ...) error
- func (client *Client) PostResult(action string, params url.Values, header http.Header) (*api.Result, error)
- func (client *Client) Request(method, action string, params url.Values, header http.Header, ...) (*Response, error)
- func (client *Client) SetDefaultParam(paramName, paramValue string) *Client
- func (client *Client) SetOverrideParam(paramName, paramValue string) *Client
- func (client *Client) Upload(action string, params url.Values, header http.Header, multipartBody io.Reader) (*Response, error)
- func (client *Client) Websocket(action string, params url.Values, header http.Header, w http.ResponseWriter, ...) (*Response, error)
- func (client *Client) WebsocketHandleFunc(action string, params url.Values, header http.Header, w http.ResponseWriter, ...) (*Response, error)
- func (client *Client) WsConn(action string, params url.Values, header http.Header) (*websocket.Conn, *http.Response, error)
- func (client *Client) WsDial(u string, header http.Header, addr string) (ws *websocket.Conn, resp *http.Response, err error)
- func (client *Client) WsDialWithLocalAddr(u string, header http.Header, addr string, localAddr net.Addr) (ws *websocket.Conn, resp *http.Response, err error)
- type IgnoreDeadlineConn
- func (conn IgnoreDeadlineConn) Close() error
- func (conn IgnoreDeadlineConn) LocalAddr() net.Addr
- func (conn IgnoreDeadlineConn) Read(b []byte) (n int, err error)
- func (conn IgnoreDeadlineConn) RemoteAddr() net.Addr
- func (conn IgnoreDeadlineConn) SetDeadline(t time.Time) error
- func (conn IgnoreDeadlineConn) SetReadDeadline(t time.Time) error
- func (conn IgnoreDeadlineConn) SetWriteDeadline(t time.Time) error
- func (conn IgnoreDeadlineConn) Write(b []byte) (n int, err error)
- type Response
- type SSHClient
- func (client *SSHClient) Close() error
- func (client *SSHClient) Dial(network, addr string) (net.Conn, error)
- func (client *SSHClient) DialUnix(addr string) (net.Conn, error)
- func (client *SSHClient) WsDial(network, addr string) (net.Conn, error)
- func (client *SSHClient) WsDialUnix(addr string) (net.Conn, error)
- type SSHCommandConn
- func (conn *SSHCommandConn) Close() error
- func (conn *SSHCommandConn) LocalAddr() net.Addr
- func (conn *SSHCommandConn) Read(b []byte) (n int, err error)
- func (conn *SSHCommandConn) RemoteAddr() net.Addr
- func (conn *SSHCommandConn) SetDeadline(t time.Time) error
- func (conn *SSHCommandConn) SetReadDeadline(t time.Time) error
- func (conn *SSHCommandConn) SetWriteDeadline(t time.Time) error
- func (conn *SSHCommandConn) Write(b []byte) (n int, err error)
- type SSHTunnel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeValues ¶
EncodeValues encodes the values into "URL encoded" form ("bar=baz&foo=quux") sorted by key and values. Changed from url.Values.Encode()
func FixKeepAlive ¶
REF: http://felixge.de/2014/08/26/tcp-keepalive-with-golang.html calling SetKeepAlivePeriod with an argument of 30 seconds will cause a total timeout of 10 minutes and 30 seconds for OSX (30 + 8 * 75), but 4 minutes and 30 seconds on Linux (30 + 8 * 30).
func MakeSign ¶
MakeSign return the signature of url values signed by hmac/md5 with specified sign key.
func MakeSignString ¶
MakeSignString return the signature of url values as string signed by hmac/md5 with specified sign key.
Types ¶
type Client ¶
type Client struct { LocalAddr net.Addr // 网关设置,如果GWADDR为空,则通过DNS查询服务器IP GWURL string GWADDR string // 签名设置,SignKey为空表示不进行签名 AppId string SignKey string // Nonce设置,长度为0表示不添加Nonce参数 NonceEnabled bool NonceLength int // 默认请求参数设置 DefaultParams map[string]string // 要强制覆盖的请求参数设置 OverrideParams map[string]string // 是否启用SSH隧道,如果启用而SSHClient为空,则API调用返回错误 SSHTunnelEnabled bool // SSH客户端 SSHClient *SSHClient }
func (*Client) PostResult ¶
func (*Client) Request ¶
func (client *Client) Request(method, action string, params url.Values, header http.Header, multipartBody io.Reader) (*Response, error)
Request make a HTTP request and return as *Response.
func (*Client) SetDefaultParam ¶
SetDefaultParam set default param when request.
func (*Client) SetOverrideParam ¶
SetOverrideParam set param need be override when request.
func (*Client) Upload ¶
func (client *Client) Upload(action string, params url.Values, header http.Header, multipartBody io.Reader) (*Response, error)
Upload make a HTTP upload request and return as *Response.
func (*Client) Websocket ¶
func (client *Client) Websocket(action string, params url.Values, header http.Header, w http.ResponseWriter, r *http.Request) (*Response, error)
Websocket make a websocket request to the backend websocket server and upgrade current request.
func (*Client) WebsocketHandleFunc ¶
func (client *Client) WebsocketHandleFunc(action string, params url.Values, header http.Header, w http.ResponseWriter, r *http.Request, proxyFunc func(reqConn *websocket.Conn, backendConn *websocket.Conn) error) (*Response, error)
WebsocketFunc make a websocket request to the backend websocket server and upgrade current request, and deal with request and response by proxyFunc.
func (*Client) WsConn ¶
func (client *Client) WsConn(action string, params url.Values, header http.Header) (*websocket.Conn, *http.Response, error)
WsConn make a websocket connection to the backend websocket server.
type IgnoreDeadlineConn ¶
type IgnoreDeadlineConn struct {
// contains filtered or unexported fields
}
ssh tunnel连接调用conn.SetDeadline会报错: tcpChan: deadline not supported 因此在此封装一层SetDeadline禁止调用
func (IgnoreDeadlineConn) Close ¶
func (conn IgnoreDeadlineConn) Close() error
func (IgnoreDeadlineConn) LocalAddr ¶
func (conn IgnoreDeadlineConn) LocalAddr() net.Addr
func (IgnoreDeadlineConn) RemoteAddr ¶
func (conn IgnoreDeadlineConn) RemoteAddr() net.Addr
func (IgnoreDeadlineConn) SetDeadline ¶
func (conn IgnoreDeadlineConn) SetDeadline(t time.Time) error
func (IgnoreDeadlineConn) SetReadDeadline ¶
func (conn IgnoreDeadlineConn) SetReadDeadline(t time.Time) error
func (IgnoreDeadlineConn) SetWriteDeadline ¶
func (conn IgnoreDeadlineConn) SetWriteDeadline(t time.Time) error
type Response ¶
func (*Response) ParseData ¶
ParseData return the DATA of the result. If return code is not "ok", error return.
type SSHCommandConn ¶
type SSHCommandConn struct {
// contains filtered or unexported fields
}
func DialSSHCommand ¶
func DialSSHCommand(session *ssh.Session, cmd string) (*SSHCommandConn, error)
ssh隧道不支持unix,需要用ssh+socat的方式来处理 ssh root@ip socat STDIO UNIX-CONNECT:/path/to/unix.sock
func (*SSHCommandConn) Close ¶
func (conn *SSHCommandConn) Close() error
func (*SSHCommandConn) LocalAddr ¶
func (conn *SSHCommandConn) LocalAddr() net.Addr
func (*SSHCommandConn) RemoteAddr ¶
func (conn *SSHCommandConn) RemoteAddr() net.Addr
func (*SSHCommandConn) SetDeadline ¶
func (conn *SSHCommandConn) SetDeadline(t time.Time) error
func (*SSHCommandConn) SetReadDeadline ¶
func (conn *SSHCommandConn) SetReadDeadline(t time.Time) error
func (*SSHCommandConn) SetWriteDeadline ¶
func (conn *SSHCommandConn) SetWriteDeadline(t time.Time) error