relay

package module
v0.4.50 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 36 Imported by: 5

README

WebTeleport Relay

go.dev reference License

Documentation

Index

Constants

View Source
const ROOT_INTERNAL = "root.internal"

Variables

View Source
var DefaultStorage = NewStore()

Functions

func DefaultIndex added in v0.3.4

func DefaultIndex() http.Handler

func IsInternal added in v0.4.37

func IsInternal(r *http.Request) bool

func RoundTripper added in v0.4.12

func RoundTripper(tssn tunnel.Session) http.RoundTripper

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 Ingress added in v0.4.47

type Ingress interface {
	// shortcut to dispatcher
	http.Handler

	// apply middleware to dispatcher
	Use(middlewares ...muxr.Middleware)

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

	// alias Info
	AliasHandler(w http.ResponseWriter, r *http.Request)

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

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

storage exposed as HTTP server

func NewIngress added in v0.4.47

func NewIngress() Ingress

type IngressHandler added in v0.4.47

type IngressHandler struct {
	*muxr.Router
	// contains filtered or unexported fields
}

func NewIngressHandler added in v0.4.47

func NewIngressHandler(storage Storage) *IngressHandler

func (*IngressHandler) AliasHandler added in v0.4.50

func (i *IngressHandler) AliasHandler(w http.ResponseWriter, r *http.Request)

func (*IngressHandler) Dispatch added in v0.4.47

func (i *IngressHandler) Dispatch(r *http.Request) http.Handler

func (*IngressHandler) GetRoundTripper added in v0.4.47

func (i *IngressHandler) GetRoundTripper(h string) (http.RoundTripper, bool)

func (*IngressHandler) RecordsHandler added in v0.4.47

func (i *IngressHandler) RecordsHandler(w http.ResponseWriter, r *http.Request)

func (*IngressHandler) ServeHTTP added in v0.4.47

func (i *IngressHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*IngressHandler) Subscribe added in v0.4.47

func (i *IngressHandler) Subscribe(upgrader edge.Upgrader)

func (*IngressHandler) Use added in v0.4.47

func (i *IngressHandler) Use(middlewares ...muxr.Middleware)

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"`
	Path    string         `json:"path"`
}

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.Dispatcher

	// builtin HTTPUpgrader
	edge.HTTPUpgrader

	// edge.Edge consumer
	Ingress
}

edge.Edge multiplexer with builtin HTTPUpgrader

type Storage added in v0.3.4

type Storage interface {
	// allocate new session
	Allocate(r *edge.Edge) (string, error)

	// remove session
	RemoveSession(tssn tunnel.Session)

	// upsert session
	Upsert(k string, r *edge.Edge)

	// get session
	GetSession(h string) (tunnel.Session, bool)

	// get all records
	Records() (all []*Record)

	// scan edge.Edge
	Scan(r *edge.Edge)

	// ping edge.Edge
	Ping(r *edge.Edge)

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

	// log message
	WebLog(msg string)

	// mark visited
	Visited(k string)

	// alias
	Alias(k string, v string)

	// unalias
	Unalias(k string)

	// get all aliases
	Aliases() (all map[string]string)

	// lookup record
	LookupRecord(k string) (rec *Record, ok bool)
}

edge.Edge multiplexer

type Store added in v0.4.47

type Store struct {
	Lock         *sync.RWMutex
	PingInterval time.Duration
	Verbose      bool
	Webhook      string
	Client       *http.Client
	RecordMap    map[string]*Record
	AliasMap     map[string]string
}

func NewStore added in v0.4.47

func NewStore() *Store

func (*Store) Alias added in v0.4.50

func (s *Store) Alias(k string, v string)

func (*Store) Aliases added in v0.4.50

func (s *Store) Aliases() (all map[string]string)

func (*Store) Allocate added in v0.4.47

func (s *Store) Allocate(r *edge.Edge) (string, error)

func (*Store) GetSession added in v0.4.47

func (s *Store) GetSession(h string) (tunnel.Session, bool)

func (*Store) LookupRecord added in v0.4.50

func (s *Store) LookupRecord(k string) (rec *Record, ok bool)

lookup record by key, or alias

func (*Store) Ping added in v0.4.47

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

func (*Store) Records added in v0.4.47

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

func (*Store) RemoveSession added in v0.4.47

func (s *Store) RemoveSession(tssn tunnel.Session)

func (*Store) Scan added in v0.4.47

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

func (*Store) Subscribe added in v0.4.47

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

func (*Store) Unalias added in v0.4.50

func (s *Store) Unalias(k string)

func (*Store) Upsert added in v0.4.47

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

func (*Store) Visited added in v0.4.47

func (s *Store) Visited(k string)

func (*Store) WebLog added in v0.4.47

func (s *Store) WebLog(msg string)

type VerboseConn added in v0.4.32

type VerboseConn struct {
	net.Conn
}

func (*VerboseConn) Read added in v0.4.32

func (c *VerboseConn) Read(b []byte) (n int, err error)

func (*VerboseConn) Write added in v0.4.32

func (c *VerboseConn) Write(b []byte) (n int, err error)

type WSServer added in v0.3.4

type WSServer struct {
	Ingress
	edge.HTTPUpgrader
}

func DefaultWSServer added in v0.4.48

func DefaultWSServer(host string) *WSServer

func NewWSServer added in v0.3.4

func NewWSServer(host string, ingress Ingress) *WSServer

func (*WSServer) Dispatch added in v0.4.19

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

func (*WSServer) IsRootExternal added in v0.4.40

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

func (*WSServer) IsRootInternal added in v0.4.38

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

func (*WSServer) IsUpgrade added in v0.3.4

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

func (*WSServer) RootHandler added in v0.4.38

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

rewrite requests targeting example.com/sub/* to sub.example.com/*

func (*WSServer) RootInternalHandler added in v0.4.38

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

func (*WSServer) ServeHTTP added in v0.3.4

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

type WTServer added in v0.3.6

type WTServer struct {
	Ingress
	*webtransport.Upgrader
}

func DefaultWTServer added in v0.4.48

func DefaultWTServer(host string) *WTServer

func NewWTServer added in v0.3.6

func NewWTServer(host string, ingress Ingress) *WTServer

func (*WTServer) Dispatch added in v0.4.19

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

func (*WTServer) IsRootExternal added in v0.4.40

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

func (*WTServer) IsRootInternal added in v0.4.38

func (s *WTServer) IsRootInternal(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) WithTLSConfig added in v0.3.7

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

Directories

Path Synopsis
cmd module

Jump to

Keyboard shortcuts

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