relay

package module
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 32 Imported by: 2

README

WebTeleport Relay

go.dev reference License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectHandler = NewConnectHandler()

Functions

func DefaultIndex added in v0.3.4

func DefaultIndex() http.Handler

func IsConnect added in v0.4.15

func IsConnect(r *http.Request) bool

when env CONNECT is set, filter authenticated h1/h2/h3 connect requests

func NewConnectHandler added in v0.4.15

func NewConnectHandler() 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(rt http.RoundTripper) *httputil.ReverseProxy

func RoundTripper added in v0.4.12

func RoundTripper(tssn tunnel.Session) http.RoundTripper

Types

type Dispatcher added in v0.4.19

type Dispatcher interface {
	Dispatch(r *http.Request) http.Handler

	// shortcut to Dispatch(r).ServeHTTP(w, r)
	http.Handler
}

dispatch to other http.Handler implementations

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 tunnel.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"`
}

func (*Record) Matches added in v0.4.12

func (r *Record) Matches(kvs url.Values) (ok bool)

type Relayer added in v0.3.6

type Relayer interface {
	// dispatch to HTTPUpgrader and Storage
	Dispatcher

	// builtin HTTPUpgrader
	edge.HTTPUpgrader

	// edge.Edge multiplexer
	Storage
}

edge.Edge multiplexer with builtin HTTPUpgrader

type SessionStore added in v0.3.4

type SessionStore struct {
	Lock         *sync.RWMutex
	PingInterval time.Duration
	Verbose      bool
	Webhook      string
	Client       *http.Client
	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 *edge.Edge, root string) (string, string, error)

func (*SessionStore) Dispatch added in v0.4.19

func (s *SessionStore) Dispatch(r *http.Request) http.Handler

func (*SessionStore) GetRoundTripper added in v0.4.18

func (s *SessionStore) GetRoundTripper(k string) (http.RoundTripper, bool)

func (*SessionStore) GetSession added in v0.4.1

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

func (*SessionStore) Negotiate added in v0.3.4

func (s *SessionStore) Negotiate(r *edge.Edge, root string) (string, error)

func (*SessionStore) Ping added in v0.3.4

func (s *SessionStore) Ping(r *edge.Edge)

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 tunnel.Session)

func (*SessionStore) Scan added in v0.3.4

func (s *SessionStore) Scan(r *edge.Edge)

func (*SessionStore) ServeHTTP added in v0.3.6

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

func (*SessionStore) Subscribe added in v0.4.16

func (s *SessionStore) Subscribe(upgrader edge.Upgrader)

func (*SessionStore) Upsert added in v0.4.1

func (s *SessionStore) Upsert(k string, r *edge.Edge)

func (*SessionStore) Visited added in v0.3.4

func (s *SessionStore) Visited(k string)

func (*SessionStore) WebLog added in v0.4.13

func (s *SessionStore) WebLog(msg string)

type Storage added in v0.3.4

type Storage interface {
	// Dispatch to edge.Edge
	Dispatcher

	// get Session wrapped by http.Transport
	GetRoundTripper(k string) (http.RoundTripper, bool)

	// record Info
	RecordsHandler(w http.ResponseWriter, r *http.Request)

	// subscribe to incoming stream of edge.Edge
	edge.Subscriber
}

edge.Edge multiplexer

type WSServer added in v0.3.4

type WSServer struct {
	Storage
	edge.HTTPUpgrader
	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) Dispatch added in v0.4.19

func (s *WSServer) Dispatch(r *http.Request) http.Handler

func (*WSServer) IndexHandler added in v0.3.4

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

func (*WSServer) IsRoot added in v0.4.16

func (s *WSServer) IsRoot(r *http.Request) bool

func (*WSServer) IsUpgrade added in v0.3.4

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

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
	*webtransport.Upgrader
	PostUpgrade http.Handler
}

func NewWTServer added in v0.3.6

func NewWTServer(host string, store Storage) *WTServer

func (*WTServer) ConnectHandler added in v0.4.15

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

func (*WTServer) Dispatch added in v0.4.19

func (s *WTServer) Dispatch(r *http.Request) http.Handler

func (*WTServer) IsRoot added in v0.4.16

func (s *WTServer) IsRoot(r *http.Request) bool

func (*WTServer) IsUpgrade added in v0.4.16

func (s *WTServer) IsUpgrade(r *http.Request) bool

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

Jump to

Keyboard shortcuts

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