websocketDialer

package
v1.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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
)

Variables

View Source
var (
	Token = "BCS-API-Tunnel-Token"
	ID    = "BCS-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, tlsConfig *tls.Config, dialer *websocket.Dialer, auth ConnectAuthorizer)

func DefaultErrorWriter

func DefaultErrorWriter(rw http.ResponseWriter, req *http.Request, code int, err error)

Types

type Authorizer

type Authorizer func(req *http.Request) (clientKey string, authed bool, err error)

type CleanCredentials

type CleanCredentials func(clientKey string)

type ConnectAuthorizer

type ConnectAuthorizer func(proto, address string) bool

type Dialer

type Dialer func(network, address string) (net.Conn, error)

type ErrorWriter

type ErrorWriter func(rw http.ResponseWriter, req *http.Request, code int, err error)

type Server

type Server struct {
	PeerID    string
	PeerToken string
	// contains filtered or unexported fields
}

func New

func New(auth Authorizer, errorWriter ErrorWriter, clean CleanCredentials) *Server

func (*Server) AddPeer

func (s *Server) AddPeer(url, id, token string)

func (*Server) Dial

func (s *Server) Dial(clientKey string, deadline time.Duration, proto, address string) (net.Conn, error)

func (*Server) Dialer

func (s *Server) Dialer(clientKey string, deadline time.Duration) Dialer

func (*Server) HasSession

func (s *Server) HasSession(clientKey string) bool

func (*Server) RemovePeer

func (s *Server) RemovePeer(id string)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type Session

type Session struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewClientSession

func NewClientSession(auth ConnectAuthorizer, conn *websocket.Conn) *Session

func (*Session) Close

func (s *Session) Close()

func (*Session) Serve

func (s *Session) Serve(ctx context.Context) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL