relay

package module
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 32 Imported by: 5

README

WebTeleport Relay

go.dev reference License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIndex added in v0.3.4

func DefaultIndex() http.Handler

func NewProxyHandler added in v0.3.1

func NewProxyHandler() http.Handler

func ProxyBasicAuth added in v0.3.1

func ProxyBasicAuth(r *http.Request) (username, password string, ok bool)

func ReverseProxy added in v0.4.5

func ReverseProxy(tssn transport.Session) *httputil.ReverseProxy

func Transport added in v0.3.12

func Transport(tssn transport.Session) *http.Transport

Types

type ExpVarStruct added in v0.3.1

type ExpVarStruct struct {
	WebteleportRelayStreamsSpawned   *expvar.Int
	WebteleportRelayStreamsClosed    *expvar.Int
	WebteleportRelaySessionsAccepted *expvar.Int
	WebteleportRelaySessionsClosed   *expvar.Int
}

func NewExpVarStruct added in v0.3.1

func NewExpVarStruct() *ExpVarStruct

type Record added in v0.3.1

type Record struct {
	Key     string            `json:"key"`
	Session transport.Session `json:"-"`
	Header  tags.Tags         `json:"header"`
	Tags    tags.Tags         `json:"tags"`
	Since   time.Time         `json:"since"`
	Visited int               `json:"visited"`
	IP      string            `json:"ip"`
}

type Relayer added in v0.3.6

type Relayer interface {
	Upgrader
	Storage
	http.Handler
}

type SessionStore added in v0.3.4

type SessionStore struct {
	Lock         *sync.RWMutex
	PingInterval time.Duration
	Verbose      bool
	Record       map[string]*Record
}

func NewSessionStore added in v0.3.4

func NewSessionStore() *SessionStore

func (*SessionStore) Allocate added in v0.3.4

func (s *SessionStore) Allocate(r *http.Request, root string) (string, string, error)

func (*SessionStore) GetSession added in v0.4.1

func (s *SessionStore) GetSession(k string) (transport.Session, bool)

func (*SessionStore) Negotiate added in v0.3.4

func (s *SessionStore) Negotiate(r *http.Request, root string, tssn transport.Session, tstm transport.Stream) (string, error)

func (*SessionStore) Ping added in v0.3.4

func (s *SessionStore) Ping(tssn transport.Session, tstm transport.Stream)

Ping proactively pings the client to keep the connection alive and to detect if the client has disconnected. If the client has disconnected, the session is removed from the session store.

This function has been found mostly unnecessary since the disconnect is automatically detected by the underlying transport layer and handled by the Scan function. However, it is kept here for completeness.

func (*SessionStore) Records added in v0.3.4

func (s *SessionStore) Records() (all []*Record)

func (*SessionStore) RecordsHandler added in v0.3.4

func (s *SessionStore) RecordsHandler(w http.ResponseWriter, r *http.Request)

func (*SessionStore) RemoveSession added in v0.4.1

func (s *SessionStore) RemoveSession(tssn transport.Session)

func (*SessionStore) Scan added in v0.3.4

func (s *SessionStore) Scan(tssn transport.Session, tstm transport.Stream)

func (*SessionStore) ServeHTTP added in v0.3.6

func (s *SessionStore) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*SessionStore) Upsert added in v0.4.1

func (s *SessionStore) Upsert(k string, tssn transport.Session, tstm transport.Stream, r *http.Request)

func (*SessionStore) Visited added in v0.3.4

func (s *SessionStore) Visited(k string)

type Storage added in v0.3.4

type Storage interface {
	// Upsert
	Upsert(k string, tssn transport.Session, tstm transport.Stream, r *http.Request)
	// Read
	GetSession(k string) (transport.Session, bool)
	Records() []*Record
	RecordsHandler(w http.ResponseWriter, r *http.Request)
	// Update
	Visited(k string)
	// Remove Session
	// if session is already removed, subsequent calls will be no-op
	// NOTE: the signature is not Remove(k string) because the key doesn't
	// uniquely identify the session. If a new session is created with the same key,
	// it should not be removed by the previous call
	RemoveSession(tssn transport.Session)
	// Rand
	Allocate(r *http.Request, root string) (key string, hostnamePath string, err error)
	Negotiate(r *http.Request, root string, tssn transport.Session, tstm transport.Stream) (key string, err error)
	// Serve
	http.Handler
}

/ transport agnostic CRUD

type Upgrader added in v0.3.4

type Upgrader interface {
	Root() string
	IsRoot(r *http.Request) bool
	IsUpgrade(r *http.Request) bool
	Upgrade(w http.ResponseWriter, r *http.Request) (transport.Session, transport.Stream, error)
}

type WSServer added in v0.3.4

type WSServer struct {
	HOST string
	Storage
	Upgrader
	Proxy       http.Handler
	PostUpgrade http.Handler
}

func NewWSServer added in v0.3.4

func NewWSServer(host string, store Storage) *WSServer

func (*WSServer) ConnectHandler added in v0.3.4

func (s *WSServer) ConnectHandler(w http.ResponseWriter, r *http.Request)

func (*WSServer) IndexHandler added in v0.3.4

func (s *WSServer) IndexHandler(w http.ResponseWriter, r *http.Request)

func (*WSServer) ServeHTTP added in v0.3.4

func (s *WSServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WSServer) WithPostUpgrade added in v0.3.11

func (s *WSServer) WithPostUpgrade(h http.Handler) *WSServer

type WTServer added in v0.3.6

type WTServer struct {
	HOST string
	Storage
	*WebtransportUpgrader
	PostUpgrade http.Handler
}

func NewWTServer added in v0.3.6

func NewWTServer(host string, store Storage) *WTServer

func (*WTServer) ServeHTTP added in v0.3.6

func (s *WTServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WTServer) WithAddr added in v0.3.7

func (s *WTServer) WithAddr(a string) *WTServer

func (*WTServer) WithPostUpgrade added in v0.3.11

func (s *WTServer) WithPostUpgrade(h http.Handler) *WTServer

func (*WTServer) WithTLSConfig added in v0.3.7

func (s *WTServer) WithTLSConfig(tlsConfig *tls.Config) *WTServer

type WebsocketUpgrader added in v0.3.4

type WebsocketUpgrader struct {
	// contains filtered or unexported fields
}

func (*WebsocketUpgrader) IsRoot added in v0.3.6

func (s *WebsocketUpgrader) IsRoot(r *http.Request) (result bool)

func (*WebsocketUpgrader) IsUpgrade added in v0.3.6

func (s *WebsocketUpgrader) IsUpgrade(r *http.Request) (result bool)

func (*WebsocketUpgrader) Root added in v0.3.6

func (s *WebsocketUpgrader) Root() string

func (*WebsocketUpgrader) Upgrade added in v0.3.4

type WebtransportUpgrader added in v0.3.6

type WebtransportUpgrader struct {
	*wt.Server
	// contains filtered or unexported fields
}

func (*WebtransportUpgrader) IsRoot added in v0.3.6

func (s *WebtransportUpgrader) IsRoot(r *http.Request) (result bool)

func (*WebtransportUpgrader) IsUpgrade added in v0.3.6

func (s *WebtransportUpgrader) IsUpgrade(r *http.Request) (result bool)

func (*WebtransportUpgrader) Root added in v0.3.6

func (s *WebtransportUpgrader) Root() string

func (*WebtransportUpgrader) Upgrade added in v0.3.6

Directories

Path Synopsis
cmd module

Jump to

Keyboard shortcuts

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