Documentation
¶
Index ¶
- func ActorCanAccessClient(actor *Actor, clientID int) bool
- func ActorPrimaryClientID(actor *Actor) (int, bool)
- func ApplySessionIdentity(c Context, identity *webservice.SessionIdentity) error
- func PageSpecEnabled(cfg *servercfg.Snapshot, spec PageSpec) bool
- func PrincipalFromActor(actor *Actor) webservice.Principal
- func VisitorIP(c Context, cfg *servercfg.Snapshot) string
- type ActionEntry
- type ActionOwnership
- type ActionSpec
- type Actor
- func ActorFromSessionIdentity(identity *webservice.SessionIdentity) *Actor
- func ActorFromSessionIdentityWithFallback(identity *webservice.SessionIdentity, fallbackAdminUsername string) *Actor
- func AdminActorWithFallback(username, fallbackAdminUsername string) *Actor
- func AnonymousActor() *Actor
- func UserActor(username string, clientIDs []int) *Actor
- type App
- func (a *App) AddClient(c Context)
- func (a *App) AddHost(c Context)
- func (a *App) AddTunnel(c Context)
- func (a *App) BanClean(c Context)
- func (a *App) BanList(c Context)
- func (a *App) Bootstrap(c Context)
- func (a *App) CertSuggestion(c Context)
- func (a *App) ChangeClientStatus(c Context)
- func (a *App) ClearClient(c Context)
- func (a *App) ClearHost(c Context)
- func (a *App) ClearTunnel(c Context)
- func (a *App) ClientQRCode(c Context)
- func (a *App) CurrentConfig() *servercfg.Snapshot
- func (a *App) DashboardStats(c Context)
- func (a *App) DeleteClient(c Context)
- func (a *App) DeleteHost(c Context)
- func (a *App) DeleteTunnel(c Context)
- func (a *App) EditClient(c Context)
- func (a *App) EditHost(c Context)
- func (a *App) EditTunnel(c Context)
- func (a *App) ExportConfig(c Context)
- func (a *App) GetAuthKey(c Context)
- func (a *App) GetCert(c Context)
- func (a *App) GetClient(c Context)
- func (a *App) GetClientLaunch(c Context)
- func (a *App) GetHost(c Context)
- func (a *App) GetOneTunnel(c Context)
- func (a *App) GetTime(c Context)
- func (a *App) GetTunnel(c Context)
- func (a *App) GetTunnelLaunch(c Context)
- func (a *App) HostExclude(c Context)
- func (a *App) HostList(c Context)
- func (a *App) HostMatch(c Context)
- func (a *App) HostMove(c Context)
- func (a *App) HostPreview(c Context)
- func (a *App) IPRegister(c Context)
- func (a *App) IPRegisterPage(c Context)
- func (a *App) ImportConfig(c Context)
- func (a *App) KickClient(c Context)
- func (a *App) ListClients(c Context)
- func (a *App) LiveStatus(c Context)
- func (a *App) LogEntries(c Context)
- func (a *App) LogLevels(c Context)
- func (a *App) LogOverride(c Context)
- func (a *App) LoginVerify(c Context)
- func (a *App) Logout(c Context)
- func (a *App) LogoutRedirect(c Context)
- func (a *App) ManagementShell(c Context)
- func (a *App) PageModel(c Context, controller, action string)
- func (a *App) PageModelController(c Context, controller string, defaultAction string)
- func (a *App) PingClient(c Context)
- func (a *App) RegisterUser(c Context)
- func (a *App) ReloadConfig(c Context)
- func (a *App) ReloadShaping(c Context)
- func (a *App) RenderControllerPage(c Context, controller string, defaultAction string)
- func (a *App) RenderPage(c Context, controller, action string)
- func (a *App) SaveClientLaunch(c Context)
- func (a *App) SaveGlobal(c Context)
- func (a *App) SaveTunnelLaunch(c Context)
- func (a *App) StandaloneIPRegisterPage(c Context)
- func (a *App) StartHost(c Context)
- func (a *App) StartTunnel(c Context)
- func (a *App) StopHost(c Context)
- func (a *App) StopTunnel(c Context)
- func (a *App) Unban(c Context)
- func (a *App) UnbanAll(c Context)
- func (a *App) UpdateClient(c Context)
- func (a *App) UpdateGeoData(c Context)
- func (a *App) UpdateServer(c Context)
- type AuthKeyResponse
- type BootstrapApp
- type BootstrapAuthorizationExtension
- type BootstrapClusterExtension
- type BootstrapExtensions
- type BootstrapFeatures
- type BootstrapPayload
- type BootstrapRoutes
- type BootstrapSecurity
- type BootstrapSession
- type BootstrapUI
- type CertResponse
- type ClientListResponse
- type CodeDataResponse
- type CodeRTTResponse
- type CodeResponse
- type Context
- type GlobalTrafficPayload
- type Handler
- type IPRegisterHourOption
- type IPRegisterResponse
- type Options
- type PageEntry
- type PageFeature
- type PageModelResponse
- type PageOwnership
- type PageParam
- type PageSpec
- type ReloadConfigResponse
- type RequestMetadata
- type StatusMessageIDResponse
- type StatusMessageResponse
- type StatusNonceBitsResponse
- type StatusNonceCertResponse
- type StatusNonceResponse
- type StatusNonceTimestampResponse
- type TableResponse
- type TimeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActorCanAccessClient ¶
func ActorPrimaryClientID ¶
func ApplySessionIdentity ¶
func ApplySessionIdentity(c Context, identity *webservice.SessionIdentity) error
ApplySessionIdentity stores identity in the session; an error says that the session could not be saved.
func PrincipalFromActor ¶
func PrincipalFromActor(actor *Actor) webservice.Principal
func VisitorIP ¶ added in v0.35.0
VisitorIP returns the address of the visitor of a web request: the peer, or the X-Real-IP header a trusted proxy sets, or that a request carrying the HTTP-only pass sets. A header value that is not an IP address, with or without a port, is ignored. It is the one resolver of the visitor address for the web interface; gin's own ClientIP is not used.
Types ¶
type ActionEntry ¶
type ActionEntry struct {
Controller string `json:"controller"`
Name string `json:"name"`
Method string `json:"method"`
APIPath string `json:"api_path"`
LegacyPath string `json:"legacy_path,omitempty"`
Permission string `json:"permission,omitempty"`
Ownership ActionOwnership `json:"ownership,omitempty"`
RequiredFeatures []PageFeature `json:"required_features,omitempty"`
ClientScope bool `json:"client_scope"`
Protected bool `json:"protected"`
}
func VisibleActionEntries ¶
func VisibleActionEntries(cfg *servercfg.Snapshot, baseURL string, actor *Actor, authz webservice.AuthorizationService, specs []ActionSpec) []ActionEntry
type ActionOwnership ¶
type ActionOwnership string
const ( ActionOwnershipNone ActionOwnership = "" ActionOwnershipClient ActionOwnership = "client" ActionOwnershipTunnel ActionOwnership = "tunnel" ActionOwnershipHost ActionOwnership = "host" )
type ActionSpec ¶
type ActionSpec struct {
Controller string
Name string
Method string
APIPath string
LegacyPath string
Permission string
Ownership ActionOwnership
RequiredFeatures []PageFeature
Handler Handler
// Audit names the admin_action event of an action that changes
// state, such as tunnel_delete; empty for one that only reads.
Audit string
ClientScope bool
Protected bool
}
func ProtectedActionCatalog ¶
func ProtectedActionCatalog(app *App) []ActionSpec
func SessionActionCatalog ¶
func SessionActionCatalog(app *App) []ActionSpec
type Actor ¶
type Actor struct {
Kind string `json:"kind"`
SubjectID string `json:"subject_id,omitempty"`
Username string `json:"username,omitempty"`
IsAdmin bool `json:"is_admin"`
ClientIDs []int `json:"client_ids,omitempty"`
Roles []string `json:"roles,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
}
func ActorFromSessionIdentity ¶
func ActorFromSessionIdentity(identity *webservice.SessionIdentity) *Actor
func ActorFromSessionIdentityWithFallback ¶
func ActorFromSessionIdentityWithFallback(identity *webservice.SessionIdentity, fallbackAdminUsername string) *Actor
func AdminActorWithFallback ¶
func AnonymousActor ¶
func AnonymousActor() *Actor
type App ¶
type App struct {
// Identity holds the key the login pages encrypt credentials to.
Identity *crypt.Identity
Services webservice.Services
ConfigProvider func() *servercfg.Snapshot
NodeID string
}
func (*App) CertSuggestion ¶ added in v0.35.0
CertSuggestion offers a certificate of another entry for a name. Only an administrator is offered those of other clients.
func (*App) ChangeClientStatus ¶
func (*App) ClearClient ¶
func (*App) ClearTunnel ¶
func (*App) ClientQRCode ¶
func (*App) CurrentConfig ¶
func (*App) DashboardStats ¶
func (*App) DeleteClient ¶
func (*App) DeleteHost ¶
func (*App) DeleteTunnel ¶
func (*App) EditClient ¶
func (*App) EditTunnel ¶
func (*App) ExportConfig ¶ added in v0.35.0
ExportConfig sends the stored configuration, secrets included, as a file.
func (*App) GetAuthKey ¶
func (*App) GetClientLaunch ¶ added in v0.35.0
GetClientLaunch returns the saved start command form.
func (*App) GetOneTunnel ¶
func (*App) GetTunnelLaunch ¶ added in v0.35.0
GetTunnelLaunch returns the saved start command form.
func (*App) HostExclude ¶ added in v0.35.7
HostExclude adds host to the SubtreeExclude of the subtree entry id (exclude=1), so that host no longer inherits it, or removes it.
func (*App) HostMatch ¶ added in v0.35.7
HostMatch is the hit tester: the effective order of the site of host and, if path is given, the entry that serves host, scheme and path, with why each other entry lost. It calls what the proxy calls.
func (*App) HostMove ¶ added in v0.35.7
HostMove moves a regular expression entry one place up or down among the regular expressions of its site.
func (*App) HostPreview ¶ added in v0.35.7
HostPreview previews the entry of the add or edit form in the request: where it would stand in its site, how each sample path would be served and, for a subtree entry, which stored sites it would reach. It runs the proxy's selection on the stored entries with the draft in place of the entry id; nothing is saved. An invalid draft is answered with error, the message saving it would give.
func (*App) IPRegister ¶ added in v0.34.9
IPRegister registers the address of the visitor. Wrong keys count as failed logins, so that guessing them leads to a ban.
func (*App) IPRegisterPage ¶ added in v0.34.9
IPRegisterPage renders the registration page of the web interface; a key query parameter fills in the key, so that a link can be shared.
func (*App) ImportConfig ¶ added in v0.35.0
ImportConfig adds the entries of an exported file, taken from the form field "data" verbatim.
func (*App) KickClient ¶ added in v0.35.0
func (*App) ListClients ¶
func (*App) LiveStatus ¶ added in v0.34.10
LiveStatus accepts only explicit runtime fields, never configuration or credentials. Each resource is checked against the current owner, not a caller-supplied client ID.
func (*App) LogEntries ¶ added in v0.35.0
LogEntries returns the log lines kept in memory (log_memory), oldest first: those after seq "after", at or above "level", of the comma-separated "module" and "event" lists, containing "text". "seq" in the answer is what to pass as after next time, so a viewer can follow the log by asking again.
func (*App) LogLevels ¶ added in v0.35.0
LogLevels returns the levels of the log as log_level reads them.
func (*App) LogOverride ¶ added in v0.35.0
LogOverride sets the level of "module" (empty for every module) to "level" for "ttl" seconds, for troubleshooting; a ttl of 0 ends it. log_level in nps.conf is not changed.
func (*App) LoginVerify ¶
func (*App) LogoutRedirect ¶
func (*App) ManagementShell ¶
func (*App) PageModelController ¶
func (*App) PingClient ¶
func (*App) RegisterUser ¶
func (*App) ReloadConfig ¶ added in v0.35.0
ReloadConfig reloads the config file into the running server.
func (*App) ReloadShaping ¶ added in v0.35.5
ReloadShaping fetches or reads the shaping bundle now. The answer carries the state of the source in data either way; code 0 when the reload failed.
func (*App) RenderControllerPage ¶
func (*App) RenderPage ¶
func (*App) SaveClientLaunch ¶ added in v0.35.0
SaveClientLaunch stores the start command form; an empty form restores the default.
func (*App) SaveGlobal ¶
func (*App) SaveTunnelLaunch ¶ added in v0.35.0
SaveTunnelLaunch stores the start command form; an empty form restores the default.
func (*App) StandaloneIPRegisterPage ¶ added in v0.34.9
StandaloneIPRegisterPage renders the registration page of its own listener, which serves it from the root.
func (*App) StartTunnel ¶
func (*App) StopTunnel ¶
func (*App) UpdateClient ¶ added in v0.34.9
func (*App) UpdateGeoData ¶ added in v0.34.9
func (*App) UpdateServer ¶ added in v0.34.9
type AuthKeyResponse ¶
type BootstrapApp ¶
type BootstrapAuthorizationExtension ¶
type BootstrapAuthorizationExtension struct {
Roles []string `json:"roles,omitempty"`
Permissions []string `json:"permissions,omitempty"`
ClientIDs []int `json:"client_ids,omitempty"`
KnownRoles []string `json:"known_roles,omitempty"`
KnownPermissions []string `json:"known_permissions,omitempty"`
ManagementAdmin string `json:"management_admin"`
ResourcePermissions map[string][]string `json:"resource_permissions,omitempty"`
}
type BootstrapExtensions ¶
type BootstrapExtensions struct {
Authorization BootstrapAuthorizationExtension `json:"authorization"`
Cluster BootstrapClusterExtension `json:"cluster"`
}
type BootstrapFeatures ¶
type BootstrapFeatures struct {
AllowUserLogin bool `json:"allow_user_login"`
AllowUserRegister bool `json:"allow_user_register"`
AllowUserVkeyLogin bool `json:"allow_user_vkey_login"`
AllowFlowLimit bool `json:"allow_flow_limit"`
AllowRateLimit bool `json:"allow_rate_limit"`
AllowTimeLimit bool `json:"allow_time_limit"`
AllowConnectionNumLimit bool `json:"allow_connection_num_limit"`
AllowMultiIP bool `json:"allow_multi_ip"`
AllowTunnelNumLimit bool `json:"allow_tunnel_num_limit"`
AllowLocalProxy bool `json:"allow_local_proxy"`
AllowUserLocal bool `json:"allow_user_local"`
AllowUserChangeUsername bool `json:"allow_user_change_username"`
SystemInfoDisplay bool `json:"system_info_display"`
OpenCaptcha bool `json:"open_captcha"`
}
type BootstrapPayload ¶
type BootstrapPayload struct {
Status int `json:"status"`
App BootstrapApp `json:"app"`
Session BootstrapSession `json:"session"`
Actor *Actor `json:"actor"`
Pages []PageEntry `json:"pages"`
Actions []ActionEntry `json:"actions"`
Features BootstrapFeatures `json:"features"`
Security BootstrapSecurity `json:"security"`
Routes BootstrapRoutes `json:"routes"`
UI BootstrapUI `json:"ui"`
Extensions BootstrapExtensions `json:"extensions"`
Request RequestMetadata `json:"request"`
PublicKey string `json:"public_key,omitempty"`
}
type BootstrapRoutes ¶
type BootstrapRoutes struct {
Page string `json:"page"`
Render string `json:"render"`
AppShell string `json:"app_shell"`
StaticBase string `json:"static_base"`
AppAssetsBase string `json:"app_assets_base"`
CaptchaNew string `json:"captcha_new"`
CaptchaBase string `json:"captcha_base"`
APIBase string `json:"api_base"`
ManagementAPIBase string `json:"management_api_base"`
APIAuth string `json:"api_auth"`
APILogin string `json:"api_login"`
APICaptcha string `json:"api_captcha"`
APIGetAuthKey string `json:"api_get_auth_key"`
APIGetTime string `json:"api_get_time"`
APIGetCert string `json:"api_get_cert"`
GetAuthKey string `json:"get_auth_key"`
GetTime string `json:"get_time"`
GetCert string `json:"get_cert"`
Login string `json:"login"`
Logout string `json:"logout"`
}
type BootstrapSecurity ¶
type BootstrapSession ¶
type BootstrapSession struct {
Authenticated bool `json:"authenticated"`
IsAdmin bool `json:"is_admin"`
Username string `json:"username,omitempty"`
ClientID *int `json:"client_id"`
ClientIDs []int `json:"client_ids,omitempty"`
SubjectID string `json:"subject_id,omitempty"`
Provider string `json:"provider,omitempty"`
Kind string `json:"kind,omitempty"`
}
type BootstrapUI ¶
type BootstrapUI struct {
Mode string `json:"mode"`
ManagementShell string `json:"management_shell"`
LegacyPagesEnabled bool `json:"legacy_pages_enabled"`
SPAFallbackEnabled bool `json:"spa_fallback_enabled"`
ReactBootstrapReady bool `json:"react_bootstrap_ready"`
ShellAssetsReady bool `json:"shell_assets_ready"`
ShellAssets ui.ManagementShellAssets `json:"shell_assets"`
}
type CertResponse ¶
type ClientListResponse ¶
type ClientListResponse struct {
Rows any `json:"rows"`
Total int `json:"total"`
IP string `json:"ip"`
Addr string `json:"addr"`
BridgeType string `json:"bridgeType"`
BridgePort int `json:"bridgePort"`
// Traffic is the server-wide forwarded traffic, for administrators.
Traffic *GlobalTrafficPayload `json:"traffic,omitempty"`
}
type CodeDataResponse ¶
type CodeRTTResponse ¶
type CodeResponse ¶
type CodeResponse struct {
Code int `json:"code"`
}
type Context ¶
type Context interface {
BaseContext() context.Context
String(string) string
Int(string, ...int) int
Bool(string, ...bool) bool
Method() string
Host() string
RemoteAddr() string
RequestHeader(string) string
SessionValue(string) any
// SetSessionValue and DeleteSessionValue change the session and save it
// in the response; an error says that it could not be saved.
SetSessionValue(string, any) error
DeleteSessionValue(string) error
RespondJSON(int, any)
RespondString(int, string)
RespondData(int, string, []byte)
Redirect(int, string)
SetResponseHeader(string, string)
IsWritten() bool
Actor() *Actor
SetActor(*Actor)
Metadata() RequestMetadata
}
type GlobalTrafficPayload ¶ added in v0.34.9
type GlobalTrafficPayload struct {
In int64 `json:"in"`
Out int64 `json:"out"`
InBps int64 `json:"inBps"`
OutBps int64 `json:"outBps"`
Limit int64 `json:"limit"`
}
GlobalTrafficPayload is the traffic forwarded by the whole server: In from visitors to clients and Out back, in bytes and bytes per second, and the global rate limit in bytes per second, 0 for none.
type IPRegisterHourOption ¶ added in v0.34.9
IPRegisterHourOption is a duration offered on the registration page.
type IPRegisterResponse ¶ added in v0.34.9
type IPRegisterResponse struct {
Status int `json:"status"`
Msg string `json:"msg"`
IP string `json:"ip,omitempty"`
Until string `json:"until,omitempty"`
}
IPRegisterResponse answers a registration.
type Options ¶
type Options struct {
NodeID string
Services *webservice.Services
ConfigureServices func(*webservice.Services)
ConfigProvider func() *servercfg.Snapshot
// Identity holds the key the login pages encrypt credentials to.
Identity *crypt.Identity
// Store is the store the services act on.
Store *file.DbUtils
// Runtime is the running server the services act on; nil means none.
Runtime webservice.Runtime
}
type PageEntry ¶
type PageEntry struct {
Controller string `json:"controller"`
Action string `json:"action"`
Section string `json:"section,omitempty"`
Menu string `json:"menu,omitempty"`
Template string `json:"template,omitempty"`
Permission string `json:"permission,omitempty"`
Ownership PageOwnership `json:"ownership,omitempty"`
Protected bool `json:"protected"`
Params []PageParam `json:"params,omitempty"`
RequiredFeatures []PageFeature `json:"required_features,omitempty"`
PagePath string `json:"page_path"`
RenderPath string `json:"render_path"`
DirectPath string `json:"direct_path"`
}
func VisiblePageEntries ¶
func VisiblePageEntries(cfg *servercfg.Snapshot, baseURL string, actor *Actor, authz webservice.AuthorizationService) []PageEntry
type PageFeature ¶
type PageFeature string
const (
PageFeatureAllowUserRegister PageFeature = "allow_user_register"
)
type PageModelResponse ¶
type PageOwnership ¶
type PageOwnership string
const ( PageOwnershipClient PageOwnership = "client" PageOwnershipTunnel PageOwnership = "tunnel" PageOwnershipHost PageOwnership = "host" )
type PageSpec ¶
type PageSpec struct {
Controller string
Action string
Permission string
Ownership PageOwnership
Section string
Menu string
Template string
Params []PageParam
RequiredFeatures []PageFeature
IncludeControllerRoot bool
Protected bool
}
func AllPageSpecs ¶
func AllPageSpecs() []PageSpec
func AvailablePageSpecs ¶
func FindPageSpec ¶
func ProtectedPageSpecs ¶
func ProtectedPageSpecs() []PageSpec
func SessionPageSpecs ¶
func SessionPageSpecs() []PageSpec
type ReloadConfigResponse ¶ added in v0.35.0
type ReloadConfigResponse struct {
Status int `json:"status"`
Msg string `json:"msg"`
Report servercfg.Report `json:"report"`
}
ReloadConfigResponse is the answer of ReloadConfig: status 1 when the new settings are current, msg sums the report up.
type RequestMetadata ¶
type StatusMessageIDResponse ¶
type StatusMessageResponse ¶
type StatusNonceBitsResponse ¶
type StatusNonceCertResponse ¶
type StatusNonceResponse ¶
type TableResponse ¶
type TimeResponse ¶
type TimeResponse struct {
Time int64 `json:"time"`
}