Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyLimits(cfg *servercfg.Snapshot)
- func ApplyNTP(cfg *servercfg.Snapshot)
- func GetCurrentYear() int
- func GetVersion() string
- type Config
- type HostState
- type Server
- func (s *Server) AddConfigApplier(a servercfg.Applier)
- func (s *Server) AddTunnel(t *model.Tunnel) error
- func (s *Server) ApplyWebhook(cfg servercfg.WebhookConfig)
- func (s *Server) Bridge() *bridge.Bridge
- func (s *Server) BuildTunnelsReport() TunnelsReport
- func (s *Server) CanUpdateSelf() bool
- func (s *Server) ClientCanUpdate(clientId int) bool
- func (s *Server) ClientConnected(id int) bool
- func (s *Server) ClientLink(id int) *model.ClientLink
- func (s *Server) Close() error
- func (s *Server) ConfigAppliers() []servercfg.Applier
- func (s *Server) DashboardData(force bool) map[string]any
- func (s *Server) DeleteClientResources(id int)
- func (s *Server) DeleteTunnel(id int) error
- func (s *Server) DisconnectClient(clientId int)
- func (s *Server) Done() <-chan struct{}
- func (s *Server) GenerateTunnelPort(t *model.Tunnel) int
- func (s *Server) Identity() *crypt.Identity
- func (s *Server) ListClients(start, length int, search, sortField, order string, clientId int) (list []*model.Client, cnt int)
- func (s *Server) ListHosts(start, length, clientId int, search, sortField, order string) (list []*model.Host, cnt int)
- func (s *Server) ListTunnels(start, length int, typeVal string, clientId int, search string, ...) ([]*model.Tunnel, int)
- func (s *Server) PingClient(id int, addr string) int
- func (s *Server) ReloadConfig() servercfg.Report
- func (s *Server) RemoveHostCache(id int)
- func (s *Server) RequestClientUpdate(clientId int) (int, error)
- func (s *Server) SetIPRegisterHandler(handler http.Handler)
- func (s *Server) SetWebHandler(handler http.Handler)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) StartTunnel(id int) error
- func (s *Server) StopTunnel(id int) error
- func (s *Server) Store() *file.DbUtils
- func (s *Server) TunnelPortAvailable(t *model.Tunnel) bool
- func (s *Server) TunnelRunning(id int) bool
- func (s *Server) UpdateSelf() (string, error)
- func (s *Server) VirtualServices() []bridge.VirtualService
- type TunnelState
- type TunnelsReport
- type WebServer
Constants ¶
const ServiceName = "Nps"
ServiceName is the name nps is installed as a system service under.
Variables ¶
var ( // ErrUpdateDisabled is returned by UpdateSelf when remote update is off. ErrUpdateDisabled = errors.New("remote update is disabled") // ErrUpdateRunning is returned by UpdateSelf while an update runs. ErrUpdateRunning = errors.New("an update is already running") )
var ErrClosed = errors.New("server closed")
ErrClosed is returned by the operations of a server that is closed.
var EventTunnelsReport = logevent.TunnelsReport.Name
EventTunnelsReport is the type of the periodic full report.
Functions ¶
func ApplyLimits ¶ added in v0.35.0
ApplyLimits hands the flow and history settings to lib/model.
func GetCurrentYear ¶
func GetCurrentYear() int
func GetVersion ¶
func GetVersion() string
Types ¶
type Config ¶ added in v0.35.0
type Config struct {
// DisconnectTimeout is how long, in seconds, a silent client tunnel lives.
DisconnectTimeout int
// Transports are the bridge transports that listen on a port of their own.
Transports bridge.Transports
// SecureMode refuses the handshakes of npc versions that predate secure
// mode.
SecureMode bool
// SelectMode is how a client with several nodes picks the node of a new
// link.
SelectMode bridge.SelectMode
// DisableRemoteUpdate keeps the web interface from updating the server.
DisableRemoteUpdate bool
// LatestVersion returns the latest release as last known, or "" when
// unknown, without waiting for the network; npc older than it can be
// updated from the web. Nil compares with the server's own version.
LatestVersion func() string
// AllowedPorts are the ports tunnels may listen on; the zero value
// allows every port.
AllowedPorts ports.Allowed
// Identity is the certificate of the bridge and the encrypted links, and
// the key of the web login.
Identity *crypt.Identity
// AccessLog, if set, is called with every request to the domain proxy
// when it ends, whatever the log level (httpproxy.HttpProxy.AccessLog).
AccessLog func(httpproxy.AccessRecord)
// CoreEntry is the new protocol on the bridge ports.
CoreEntry coreapi.Entry
}
Config holds what a Server needs beyond the store and the current configuration.
type HostState ¶ added in v0.35.0
type HostState struct {
model.HostInfo
ClientOnline bool `json:"client_online"`
NowConn int32 `json:"now_conn"`
InletFlow int64 `json:"inlet_flow"`
ExportFlow int64 `json:"export_flow"`
}
HostState is a domain entry in the full report.
type Server ¶ added in v0.35.0
type Server struct {
// contains filtered or unexported fields
}
Server is a running nps: the bridge the clients connect to, the tasks it serves, the web manager and the background work around them. Start starts it, Close stops it and waits for everything it started.
func (*Server) AddConfigApplier ¶ added in v0.35.0
AddConfigApplier adds a, applied after those of the server in a reload.
func (*Server) AddTunnel ¶ added in v0.35.0
AddTunnel starts task t. Services that own a listening socket bind it before AddTunnel returns, so address errors are reported to the caller and a later StopTunnel always finds the running instance.
func (*Server) ApplyWebhook ¶ added in v0.35.0
func (s *Server) ApplyWebhook(cfg servercfg.WebhookConfig)
ApplyWebhook makes the webhook run as cfg says; it restarts it, discarding what is queued, only if cfg changed. The hub exists only while a webhook is configured, so entry changes cost nothing otherwise.
func (*Server) BuildTunnelsReport ¶ added in v0.35.0
func (s *Server) BuildTunnelsReport() TunnelsReport
BuildTunnelsReport snapshots all tunnels and domain entries, by id.
func (*Server) CanUpdateSelf ¶ added in v0.35.0
CanUpdateSelf reports whether the web interface may update the server.
func (*Server) ClientCanUpdate ¶ added in v0.35.0
ClientCanUpdate reports whether a connected npc of client clientId can be updated from the web.
func (*Server) ClientConnected ¶ added in v0.35.0
ClientConnected reads live bridge membership without refreshing or sorting lists.
func (*Server) ClientLink ¶ added in v0.35.4
func (s *Server) ClientLink(id int) *model.ClientLink
ClientLink describes how the core sessions of client id are carried now; nil without one.
func (*Server) Close ¶ added in v0.35.0
Close stops the server and returns once every goroutine it started has returned. It first stops accepting management and registration requests, then closes the tasks, then the bridge with its clients, then the webhook. It returns the failure that stopped the server, if one did.
func (*Server) ConfigAppliers ¶ added in v0.35.0
ConfigAppliers returns the appliers of a reload in their order: those of the process and the server, then those added with AddConfigApplier.
func (*Server) DashboardData ¶ added in v0.35.0
DashboardData returns the dashboard data, refreshed when force or when the cache is old.
func (*Server) DeleteClientResources ¶ added in v0.35.0
DeleteClientResources removes all tasks and domain entries of client id.
func (*Server) DeleteTunnel ¶ added in v0.35.0
DeleteTunnel stops task id and removes it from the store.
func (*Server) DisconnectClient ¶ added in v0.35.0
DisconnectClient closes the connections of client clientId.
func (*Server) Done ¶ added in v0.35.0
func (s *Server) Done() <-chan struct{}
Done is closed when the server starts stopping: by Close, by the end of the context given to Start, or by a failure after Start.
func (*Server) GenerateTunnelPort ¶ added in v0.35.0
GenerateTunnelPort picks a free port for t.
func (*Server) Identity ¶ added in v0.35.0
Identity returns the certificate and login key of the server.
func (*Server) ListClients ¶ added in v0.35.0
func (s *Server) ListClients(start, length int, search, sortField, order string, clientId int) (list []*model.Client, cnt int)
ListClients returns a page of the clients that match, and how many match.
func (*Server) ListHosts ¶ added in v0.35.0
func (s *Server) ListHosts(start, length, clientId int, search, sortField, order string) (list []*model.Host, cnt int)
ListHosts returns a page of the domain entries that match, and how many match.
func (*Server) ListTunnels ¶ added in v0.35.0
func (s *Server) ListTunnels(start, length int, typeVal string, clientId int, search string, sortField string, order string) ([]*model.Tunnel, int)
ListTunnels returns a page of the tasks that match, and how many match.
func (*Server) PingClient ¶ added in v0.35.0
PingClient measures the round trip to client id, -1 when it fails.
func (*Server) ReloadConfig ¶ added in v0.35.0
ReloadConfig reloads the config file and logs and returns the outcome.
func (*Server) RemoveHostCache ¶ added in v0.35.0
RemoveHostCache drops what the HTTP proxy cached of domain entry id.
func (*Server) RequestClientUpdate ¶ added in v0.35.0
RequestClientUpdate asks the connected npc of client clientId to update themselves; it returns how many were asked.
func (*Server) SetIPRegisterHandler ¶ added in v0.35.0
SetIPRegisterHandler sets the registration page that Start serves; call it before Start. Without it the page does not run.
func (*Server) SetWebHandler ¶ added in v0.35.0
SetWebHandler sets the handler of the web manager; it applies to a running server, so a config reload replaces it.
func (*Server) Start ¶ added in v0.35.0
Start opens the bridge listeners, starts the tasks of the store, the web manager and the background work. It returns the first error that keeps nps from starting; Close then releases what was started. A failure after that, of the web manager or of a bridge listener, stops the server: Done is closed and Close returns the failure. The server also stops when ctx is done.
func (*Server) StartTunnel ¶ added in v0.35.0
StartTunnel starts task id of the store and marks it started.
func (*Server) StopTunnel ¶ added in v0.35.0
StopTunnel stops task id and marks it stopped in the store.
func (*Server) TunnelPortAvailable ¶ added in v0.35.0
TunnelPortAvailable reports whether t may listen on its port.
func (*Server) TunnelRunning ¶ added in v0.35.0
TunnelRunning reports whether task id runs.
func (*Server) UpdateSelf ¶ added in v0.35.0
UpdateSelf updates the server to the latest release and restarts it shortly as the new version. It returns the version updated to, or "" when the running version is the latest.
func (*Server) VirtualServices ¶ added in v0.35.0
func (s *Server) VirtualServices() []bridge.VirtualService
VirtualServices lists the services connected clients report.
type TunnelState ¶ added in v0.35.0
type TunnelState struct {
model.TunnelInfo
Running bool `json:"running"`
ClientOnline bool `json:"client_online"`
NowConn int32 `json:"now_conn"`
InletFlow int64 `json:"inlet_flow"`
ExportFlow int64 `json:"export_flow"`
}
TunnelState is a tunnel in the full report.
type TunnelsReport ¶ added in v0.35.0
type TunnelsReport struct {
Tunnels []TunnelState `json:"tunnels"`
Hosts []HostState `json:"hosts"`
}
TunnelsReport lets a receiver correct what it missed of the events.
type WebServer ¶ added in v0.32.2
type WebServer struct {
// contains filtered or unexported fields
}
WebServer serves the web manager of a Server on the web port and on the in-memory listener that bridge://web targets reach.
func NewWebServer ¶ added in v0.32.2
NewWebServer returns the web manager of srv.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ports checks and picks the ports that tunnels listen on, within the ports the server config allows.
|
Package ports checks and picks the ports that tunnels listen on, within the ports the server config allows. |
|
Package stats samples the load, memory and traffic of the server for the dashboard.
|
Package stats samples the load, memory and traffic of the server for the dashboard. |