Documentation ¶
Index ¶
- Constants
- Variables
- func ClientConnect(ctx context.Context, wsURL string, headers http.Header, ...) error
- func ConnectToProxy(rootCtx context.Context, proxyURL string, headers http.Header, ...) error
- func DefaultErrorWriter(rw http.ResponseWriter, req *http.Request, code int, err error)
- func SetLogger(logger Logger)
- type Authorizer
- type ConnectAuthorizer
- type Dialer
- type ErrorWriter
- type Logger
- type Server
- type Session
Constants ¶
View Source
const ( Data messageType = iota + 1 Connect Error AddClient RemoveClient )
View Source
const ( PingWaitDuration = 60 * time.Second PingWriteInterval = 5 * time.Second MaxRead = 8192 HandshakeTimeOut = 10 * time.Second )
View Source
const (
MaxBuffer = 1 << 20
)
Variables ¶
View Source
var ( Token = "X-API-Tunnel-Token" ID = "X-API-Tunnel-ID" )
View Source
var PrintTunnelData bool
PrintTunnelData No tunnel logging by default
Functions ¶
func ClientConnect ¶
func ClientConnect(ctx context.Context, wsURL string, headers http.Header, dialer *websocket.Dialer, auth ConnectAuthorizer, onConnect func(context.Context, *Session) error) error
ClientConnect connect to WS and wait 5 seconds when error
func ConnectToProxy ¶ added in v0.2.8
func ConnectToProxy(rootCtx context.Context, proxyURL string, headers http.Header, auth ConnectAuthorizer, dialer *websocket.Dialer, onConnect func(context.Context, *Session) error) error
ConnectToProxy connect to websocket server
func DefaultErrorWriter ¶
Types ¶
type Authorizer ¶
type ConnectAuthorizer ¶
ConnectAuthorizer custom for authorization
type ErrorWriter ¶
type Logger ¶ added in v0.2.9
type Logger interface { // Debugf uses fmt.Sprintf to log a templated message. Debugf(template string, args ...interface{}) // Infof uses fmt.Sprintf to log a templated message. Infof(template string, args ...interface{}) // Warnf uses fmt.Sprintf to log a templated message. Warnf(template string, args ...interface{}) // Errorf uses fmt.Sprintf to log a templated message. Errorf(template string, args ...interface{}) }
Logger like zap.Sugar
type Server ¶
type Server struct { PeerID string PeerToken string ClientConnectAuthorizer ConnectAuthorizer // contains filtered or unexported fields }
func New ¶
func New(auth Authorizer, errorWriter ErrorWriter) *Server
func (*Server) HasSession ¶
func (*Server) RemovePeer ¶
type Session ¶
func NewClientSession ¶
func NewClientSession(auth ConnectAuthorizer, conn *websocket.Conn) *Session
func NewClientSessionWithDialer ¶ added in v0.2.12
func NewClientSessionWithDialer(auth ConnectAuthorizer, conn *websocket.Conn, dialer Dialer) *Session
Source Files ¶
Click to show internal directories.
Click to hide internal directories.