api

package
v0.0.0-...-ba13dd4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

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

APIServer serves the REST API and the embedded frontend.

func New

func New(
	cfg config.Config,
	store *proxy.Store,
	intercept *proxy.InterceptQueue,
	scope *proxy.Scope,
	noise *proxy.NoiseFilter,
	replace *proxy.MatchReplace,
	customData *proxy.CustomData,
	transport *proxy.TransportConfig,
	wsStore *proxy.WSStore,
	ca *cert.CA,
	hub *Hub,
	noteStore *notes.Store,
	pluginManager *plugins.Manager,
	buildInfo BuildInfo,
	cancelFunc context.CancelFunc,
) *APIServer

New creates an APIServer.

func NewListenerMode

func NewListenerMode(cfg config.Config, cbStore *callback.Store, xssStore *xsshunter.Store, hub *Hub, token string) *APIServer

NewListenerMode creates an APIServer in listener mode (no proxy components).

func NewTeamServerMode

func NewTeamServerMode(cfg config.Config, cbStore *callback.Store, xssStore *xsshunter.Store, hub *Hub, teamStore *team.Store, token string) *APIServer

NewTeamServerMode creates an APIServer in team server mode (listener + team features, no frontend).

func (*APIServer) RestartRequested

func (s *APIServer) RestartRequested() bool

RestartRequested returns true if the server was shut down for a restart (e.g. after update).

func (*APIServer) Start

func (s *APIServer) Start(ctx context.Context) error

Start begins serving and blocks until ctx is cancelled.

type BuildInfo

type BuildInfo struct {
	Version         string `json:"version"`
	Commit          string `json:"commit"`
	UpdateAvailable bool   `json:"updateAvailable"`
	LatestVersion   string `json:"latestVersion"`
}

BuildInfo holds version information embedded at build time.

type Hub

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

Hub manages WebSocket clients and broadcasts events to all of them.

func NewHub

func NewHub() *Hub

NewHub creates a Hub. Call Run() in a goroutine before accepting connections.

func (*Hub) ActiveUsers

func (h *Hub) ActiveUsers() []string

ActiveUsers returns a deduplicated list of connected nicknames (non-empty only).

func (*Hub) Broadcast

func (h *Hub) Broadcast() chan<- any

Broadcast returns the write-only broadcast channel.

func (*Hub) HasNickname

func (h *Hub) HasNickname(nickname string) bool

HasNickname returns true if a client with the given nickname is already connected.

func (*Hub) Rename

func (h *Hub) Rename(oldNick, newNick string) (bool, error)

Rename swaps oldNick → newNick on an existing conn and emits team.nickname_changed. Returns (false, nil) if oldNick has no conn.

func (*Hub) Run

func (h *Hub) Run()

Run reads from the broadcast channel and fans out to all connected clients. It blocks until the channel is closed.

func (*Hub) ServeWS

func (h *Hub) ServeWS(w http.ResponseWriter, r *http.Request)

ServeWS upgrades the HTTP connection to WebSocket and registers the client.

func (*Hub) SetOnConnect

func (h *Hub) SetOnConnect(fn OnConnectFunc)

SetOnConnect sets a callback invoked when a named user connects.

type ListenerRelay

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

ListenerRelay maintains a WebSocket connection to the remote teamserver and relays team.* events to the local Hub.

func NewListenerRelay

func NewListenerRelay(hub *Hub) *ListenerRelay

NewListenerRelay creates a relay. Call Update() to start connecting.

func (*ListenerRelay) SetNickname

func (lr *ListenerRelay) SetNickname(newNickname string)

SetNickname updates the cached nickname for the next reconnect, without closing the current connection.

func (*ListenerRelay) Update

func (lr *ListenerRelay) Update(listenerURL, token, nickname string)

Update sets the connection parameters and (re)starts the relay. Pass empty url or token to stop the relay.

type OnConnectFunc

type OnConnectFunc func(nickname, ip string)

OnConnectFunc is called when a named user connects with their nickname and IP.

type Settings

type Settings struct {
	ProxyPort           int    `json:"proxyPort"`
	UIPort              int    `json:"uiPort"`
	InterceptEnabled    bool   `json:"interceptEnabled"`
	InterceptTimeout    int    `json:"interceptTimeout"` // seconds
	ListenerURL         string `json:"listenerUrl"`
	HTTP2Enabled        bool   `json:"http2Enabled"`
	KeepAliveEnabled    bool   `json:"keepAliveEnabled"`
	SOCKSHost           string `json:"socksHost"`
	SOCKSPort           int    `json:"socksPort"`
	SOCKSUsername       string `json:"socksUsername"`
	SOCKSPassword       string `json:"socksPassword"`
	SOCKSDNS            bool   `json:"socksDns"`
	TeamToken           string `json:"teamToken"`
	TeamNickname        string `json:"teamNickname"`
	MaxRequests         int    `json:"maxRequests"`
	DisableUpdateChecks bool   `json:"disableUpdateChecks"`
}

Settings holds runtime-adjustable configuration exposed via the API.

Jump to

Keyboard shortcuts

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