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 ConnectToProxyWithDialer(rootCtx context.Context, proxyURL string, headers http.Header, ...) error
- func DefaultErrorWriter(rw http.ResponseWriter, req *http.Request, code int, err error)
- type Authorizer
- type ConnectAuthorizer
- type Dialer
- type ErrorWriter
- type Server
- type Session
Constants ¶
View Source
const ( // Data is the main message type, used to transport application data Data messageType = iota + 1 // Connect is a control message type, used to request opening a new connection Connect // Error is a message type used to send an error during the communication. // Any receiver of an Error message can assume the connection can be closed. // io.EOF is used for graceful termination of connections. Error // AddClient is a message type used to open a new client to the peering session AddClient // RemoveClient is a message type used to remove an existing client from a peering session RemoveClient // Pause is a message type used to temporarily stop a given connection Pause // Resume is a message type used to resume a paused connection Resume // SyncConnections is a message type used to communicate active connection IDs. // The receiver can consider any ID not present in this message as stale and free any associated resource. SyncConnections )
View Source
const ( PingWaitDuration = 60 * time.Second PingWriteInterval = 5 * time.Second // SyncConnectionsInterval is the time after which the client will send the list of active connection IDs SyncConnectionsInterval = 60 * time.Second // SyncConnectionsTimeout sets the maximum duration for a SyncConnections operation SyncConnectionsTimeout = 60 * time.Second MaxRead = 8192 HandshakeTimeOut = 10 * time.Second // SendErrorTimeout sets the maximum duration for sending an error message to close a single connection SendErrorTimeout = 5 * time.Second )
View Source
const (
MaxBuffer = 1 << 21
)
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.3.0
func ConnectToProxy(rootCtx context.Context, proxyURL string, headers http.Header, auth ConnectAuthorizer, dialer *websocket.Dialer, onConnect func(context.Context, *Session) error) error
ConnectToProxy connects to the websocket server. Local connections on behalf of the remote host will be dialed using a default net.Dialer.
func ConnectToProxyWithDialer ¶ added in v0.4.1
func ConnectToProxyWithDialer(rootCtx context.Context, proxyURL string, headers http.Header, auth ConnectAuthorizer, dialer *websocket.Dialer, localDialer Dialer, onConnect func(context.Context, *Session) error) error
ConnectToProxyWithDialer connects to the websocket server. Local connections on behalf of the remote host will be dialed using the provided Dialer function.
func DefaultErrorWriter ¶
Types ¶
type Authorizer ¶
type ConnectAuthorizer ¶
ConnectAuthorizer custom for authorization
type ErrorWriter ¶
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.3.0
func NewClientSessionWithDialer(auth ConnectAuthorizer, conn *websocket.Conn, dialer Dialer) *Session
Source Files ¶
Click to show internal directories.
Click to hide internal directories.