Documentation
¶
Index ¶
- Constants
- Variables
- func ClearClientStatus(client *file.Client, name string)
- func DefaultRolePermissions(role string) []string
- func MarshalSessionIdentity(identity *SessionIdentity) (string, error)
- func MarshalSessionIdentityWithResolver(identity *SessionIdentity, resolver PermissionResolver) (string, error)
- func UniqueStringsPreserveOrder(values []string) []string
- func ValidAuthKey(configKey, md5Key string, timestamp int, nowUnix int64) bool
- type AccessListInput
- type AddClientInput
- type AddHostInput
- type AddTunnelInput
- type AuthService
- type AuthenticateInput
- type AuthorizationService
- type Backend
- type BridgeDisplay
- type BridgeEndpoint
- type BridgeTransport
- type ClientQRCodeInput
- type ClientScope
- type ClientService
- type ClientVisibility
- type DefaultAuthService
- type DefaultAuthorizationService
- func (s DefaultAuthorizationService) Allows(principal Principal, permission string) bool
- func (s DefaultAuthorizationService) ClientScope(principal Principal) ClientScope
- func (s DefaultAuthorizationService) NormalizePrincipal(principal Principal) Principal
- func (s DefaultAuthorizationService) Permissions(principal Principal) []string
- func (s DefaultAuthorizationService) RequireAdmin(principal Principal) error
- func (s DefaultAuthorizationService) RequireClient(principal Principal, clientID int) error
- func (s DefaultAuthorizationService) RequireHost(principal Principal, hostID int) error
- func (s DefaultAuthorizationService) RequirePermission(principal Principal, permission string) error
- func (s DefaultAuthorizationService) RequireTunnel(principal Principal, tunnelID int) error
- func (s DefaultAuthorizationService) ResolveClient(principal Principal, requestedClientID int) (int, error)
- type DefaultClientService
- func (s DefaultClientService) Add(input AddClientInput) (int, error)
- func (DefaultClientService) BuildQRCode(input ClientQRCodeInput) ([]byte, error)
- func (s DefaultClientService) ChangeStatus(id int, status bool) error
- func (DefaultClientService) Clear(id int, mode string, isAdmin bool) error
- func (s DefaultClientService) Delete(id int) error
- func (s DefaultClientService) Edit(input EditClientInput) error
- func (s DefaultClientService) Get(id int) (*file.Client, error)
- func (s DefaultClientService) List(input ListClientsInput) ListClientsResult
- func (s DefaultClientService) Ping(id int, remoteAddr string) (int, error)
- func (s DefaultClientService) RegisterVisitorIP(key, ip string, hours int) (int, time.Time, error)
- func (s DefaultClientService) RequestUpdate(id int) (int, error)
- type DefaultGlobalService
- func (s DefaultGlobalService) BanList() []LoginBanRecord
- func (s DefaultGlobalService) CleanBans()
- func (s DefaultGlobalService) Get() *file.Glob
- func (s DefaultGlobalService) Save(input SaveGlobalInput) error
- func (s DefaultGlobalService) Unban(key string) bool
- func (s DefaultGlobalService) UnbanAll()
- type DefaultIndexService
- func (s DefaultIndexService) AddHost(input AddHostInput) (HostMutation, error)
- func (s DefaultIndexService) AddTunnel(input AddTunnelInput) (TunnelMutation, error)
- func (s DefaultIndexService) ClearHost(id int, mode string) error
- func (DefaultIndexService) ClearTunnel(id int, mode string) error
- func (s DefaultIndexService) DashboardData(force bool) map[string]interface{}
- func (s DefaultIndexService) DeleteHost(id int) error
- func (s DefaultIndexService) DeleteTunnel(id int) error
- func (s DefaultIndexService) EditHost(input EditHostInput) (HostMutation, error)
- func (s DefaultIndexService) EditTunnel(input EditTunnelInput) (TunnelMutation, error)
- func (s DefaultIndexService) GetHost(id int) (*file.Host, error)
- func (s DefaultIndexService) GetTunnel(id int) (*file.Tunnel, error)
- func (s DefaultIndexService) ListHosts(input HostListInput) ([]*file.Host, int)
- func (s DefaultIndexService) ListTunnels(input TunnelListInput) ([]*file.Tunnel, int)
- func (s DefaultIndexService) StartHost(id int, mode string) error
- func (s DefaultIndexService) StartTunnel(id int, mode string) error
- func (s DefaultIndexService) StopHost(id int, mode string) error
- func (s DefaultIndexService) StopTunnel(id int, mode string) error
- type DefaultLoginPolicy
- func (s *DefaultLoginPolicy) BanList() []LoginBanRecord
- func (s *DefaultLoginPolicy) Clean(force bool)
- func (s *DefaultLoginPolicy) IsBannedForTTL(key string, ttl int64) bool
- func (s *DefaultLoginPolicy) IsIPBanned(ip string) bool
- func (s *DefaultLoginPolicy) IsUserBanned(username string) bool
- func (s *DefaultLoginPolicy) RecordFailure(key string, explicit bool)
- func (s *DefaultLoginPolicy) RemoveAllBans()
- func (s *DefaultLoginPolicy) RemoveBan(key string) bool
- func (s *DefaultLoginPolicy) Settings() LoginPolicySettings
- type DefaultPageService
- type DefaultSystemService
- func (DefaultSystemService) BridgeDisplay(cfg *servercfg.Snapshot, host string) BridgeDisplay
- func (DefaultSystemService) GeoDataStatus() GeoDataStatus
- func (DefaultSystemService) Info() SystemInfo
- func (DefaultSystemService) RegisterManagementAccess(remoteAddr string, clientIDs []int, isAdmin bool)
- func (s DefaultSystemService) UpdateGeoData() (GeoDataStatus, error)
- func (DefaultSystemService) UpdateServer() (string, error)
- type EditClientInput
- type EditHostInput
- type EditTunnelInput
- type GeoDataStatus
- type GeoFileStatus
- type GlobalService
- type HostListInput
- type HostMutation
- type IndexService
- type ListClientsInput
- type ListClientsResult
- type LoginBanRecord
- type LoginPolicyService
- type LoginPolicySettings
- type PageBuildInput
- type PageBuildResult
- type PageService
- type PermissionResolver
- type Principal
- type RegisterUserInput
- type RegisterUserResult
- type Repository
- type Runtime
- type SaveGlobalInput
- type Services
- type SessionIdentity
- func AutoAdminIdentity(cfg *servercfg.Snapshot) (*SessionIdentity, bool)
- func NormalizeSessionIdentityWithResolver(identity *SessionIdentity, resolver PermissionResolver) *SessionIdentity
- func ParseSessionIdentity(raw string) (*SessionIdentity, error)
- func ParseSessionIdentityWithResolver(raw string, resolver PermissionResolver) (*SessionIdentity, error)
- type StaticPermissionResolver
- func (StaticPermissionResolver) KnownPermissions() []string
- func (StaticPermissionResolver) KnownRoles() []string
- func (r StaticPermissionResolver) NormalizeIdentity(identity *SessionIdentity) *SessionIdentity
- func (StaticPermissionResolver) NormalizePrincipal(principal Principal) Principal
- func (StaticPermissionResolver) PermissionCatalog() map[string][]string
- type SystemInfo
- type SystemService
- type TunnelListInput
- type TunnelMutation
Constants ¶
const ( SessionIdentityKey = "session_identity" SessionIdentityVersion = 1 )
const ( RoleAnonymous = "anonymous" RoleAdmin = "admin" RoleUser = "user" )
const ( PermissionAll = "*" PermissionManagementAdmin = "management:admin" PermissionClientsCreate = "clients:create" PermissionClientsRead = "clients:read" PermissionClientsUpdate = "clients:update" PermissionClientsDelete = "clients:delete" PermissionClientsStatus = "clients:status" PermissionTunnelsCreate = "tunnels:create" PermissionTunnelsRead = "tunnels:read" PermissionTunnelsUpdate = "tunnels:update" PermissionTunnelsDelete = "tunnels:delete" PermissionTunnelsControl = "tunnels:control" PermissionHostsCreate = "hosts:create" PermissionHostsRead = "hosts:read" PermissionHostsUpdate = "hosts:update" PermissionHostsDelete = "hosts:delete" PermissionHostsControl = "hosts:control" PermissionGlobalManage = "global:manage" )
Variables ¶
var ( ErrClientQRCodeTextRequired = errors.New("missing qr code text") ErrClientModifyFailed = errors.New("client modify failed") ErrClientVKeyDuplicate = errors.New("client verify key duplicate") ErrWebUsernameDuplicate = errors.New("client web username duplicate") ErrInvalidRegistration = errors.New("invalid registration") ErrReservedUsername = errors.New("reserved username") ErrClientNotFound = errors.New("client not found") ErrClientOffline = errors.New("client is offline") ErrClientUpdateUnsupported = errors.New("client version does not support remote update") ErrServerUpdateRunning = errors.New("server update is already running") ErrGeoDataUpdateRunning = errors.New("geodata update is already running") ErrRegisterKeyInvalid = errors.New("invalid registration key") ErrRegisterKeyDuplicate = errors.New("registration key duplicate") ErrTunnelNotFound = errors.New("tunnel not found") ErrHostNotFound = errors.New("host not found") ErrHostExists = errors.New("host already exists") ErrModeRequired = errors.New("mode is required") ErrTunnelLimitExceeded = errors.New("tunnel limit exceeded") ErrInvalidCredentials = errors.New("invalid credentials") ErrUnauthenticated = errors.New("unauthenticated") ErrForbidden = errors.New("forbidden") ErrPageNotFound = errors.New("page not found") )
var ErrInvalidAccessList = errors.New("invalid access list rules")
ErrInvalidAccessList is wrapped by the errors that report rejected rules of an access list; the message names the list and the lines.
Functions ¶
func ClearClientStatus ¶
func DefaultRolePermissions ¶
func MarshalSessionIdentity ¶
func MarshalSessionIdentity(identity *SessionIdentity) (string, error)
func MarshalSessionIdentityWithResolver ¶
func MarshalSessionIdentityWithResolver(identity *SessionIdentity, resolver PermissionResolver) (string, error)
Types ¶
type AccessListInput ¶ added in v0.34.9
type AccessListInput struct {
Priority int
Black string
White string
// RegisteredOnly additionally requires visitor addresses to be
// registered; the global settings ignore it.
RegisteredOnly bool
}
AccessListInput holds the source access lists of a level as entered in the web interface, one rule per line.
type AddClientInput ¶
type AddClientInput struct {
VKey string
Remark string
User string
Password string
Compress bool
Crypt bool
ConfigConnAllow bool
RateLimit int
MaxConn int
WebUserName string
WebPassword string
WebTotpSecret string
MaxTunnelNum int
FlowLimit int64
TimeLimit string
Access AccessListInput
RegisterKey string
RegisterMaxHours int
}
type AddHostInput ¶
type AddHostInput struct {
ClientID int
Host string
Target string
ProxyProtocol int
Auth string
Header string
RespHeader string
HostChange string
Remark string
Location string
PathRewrite string
RedirectURL string
Access AccessListInput
FlowLimit int64
TimeLimit string
Scheme string
KeyFile string
CertFile string
IsAdmin bool
AllowUserLocal bool
LocalProxy bool
HTTPSJustProxy bool
TLSOffload bool
AutoSSL bool
AutoHTTPS bool
AutoCORS bool
CompatMode bool
TargetIsHTTPS bool
}
type AddTunnelInput ¶
type AddTunnelInput struct {
ClientID int
Port int
ServerIP string
Mode string
TargetType string
Target string
ProxyProtocol int
Auth string
Remark string
Password string
LocalPath string
StripPre string
DestACLMode int
DestACLRules string
Access AccessListInput
FlowLimit int64
TimeLimit string
IsAdmin bool
AllowUserLocal bool
LocalProxy bool
EnableHTTP bool
EnableSocks5 bool
}
type AuthService ¶
type AuthService interface {
Authenticate(AuthenticateInput) (*SessionIdentity, error)
RegisterUser(RegisterUserInput) (*RegisterUserResult, error)
}
type AuthenticateInput ¶
type AuthorizationService ¶
type AuthorizationService interface {
NormalizePrincipal(Principal) Principal
ClientScope(Principal) ClientScope
Permissions(Principal) []string
Allows(Principal, string) bool
ResolveClient(Principal, int) (int, error)
RequirePermission(Principal, string) error
RequireAdmin(Principal) error
RequireClient(Principal, int) error
RequireTunnel(Principal, int) error
RequireHost(Principal, int) error
}
type Backend ¶
type Backend struct {
Repository Repository
Runtime Runtime
}
func DefaultBackend ¶
func DefaultBackend() Backend
type BridgeDisplay ¶
type BridgeDisplay struct {
Primary BridgeEndpoint
Path string
TCP BridgeTransport
KCP BridgeTransport
TLS BridgeTransport
QUIC BridgeTransport
WS BridgeTransport
WSS BridgeTransport
}
type BridgeEndpoint ¶
func BestBridge ¶
func BestBridge(cfg *servercfg.Snapshot, host string) BridgeEndpoint
type BridgeTransport ¶
type ClientQRCodeInput ¶
type ClientScope ¶
type ClientService ¶
type ClientService interface {
List(ListClientsInput) ListClientsResult
Add(AddClientInput) (int, error)
Ping(id int, remoteAddr string) (int, error)
Get(id int) (*file.Client, error)
Edit(EditClientInput) error
Clear(id int, mode string, isAdmin bool) error
ChangeStatus(id int, status bool) error
RequestUpdate(id int) (int, error)
Delete(id int) error
BuildQRCode(ClientQRCodeInput) ([]byte, error)
// RegisterVisitorIP registers ip for the client whose registration key
// or verify key is key, for hours, at most the client's limit.
RegisterVisitorIP(key, ip string, hours int) (clientID int, until time.Time, err error)
}
type ClientVisibility ¶
type DefaultAuthService ¶
type DefaultAuthService struct {
Resolver PermissionResolver
ConfigProvider func() *servercfg.Snapshot
Backend Backend
}
func (DefaultAuthService) Authenticate ¶
func (s DefaultAuthService) Authenticate(input AuthenticateInput) (*SessionIdentity, error)
func (DefaultAuthService) RegisterUser ¶
func (s DefaultAuthService) RegisterUser(input RegisterUserInput) (*RegisterUserResult, error)
type DefaultAuthorizationService ¶
type DefaultAuthorizationService struct {
Resolver PermissionResolver
Backend Backend
}
func (DefaultAuthorizationService) Allows ¶
func (s DefaultAuthorizationService) Allows(principal Principal, permission string) bool
func (DefaultAuthorizationService) ClientScope ¶
func (s DefaultAuthorizationService) ClientScope(principal Principal) ClientScope
func (DefaultAuthorizationService) NormalizePrincipal ¶
func (s DefaultAuthorizationService) NormalizePrincipal(principal Principal) Principal
func (DefaultAuthorizationService) Permissions ¶
func (s DefaultAuthorizationService) Permissions(principal Principal) []string
func (DefaultAuthorizationService) RequireAdmin ¶
func (s DefaultAuthorizationService) RequireAdmin(principal Principal) error
func (DefaultAuthorizationService) RequireClient ¶
func (s DefaultAuthorizationService) RequireClient(principal Principal, clientID int) error
func (DefaultAuthorizationService) RequireHost ¶
func (s DefaultAuthorizationService) RequireHost(principal Principal, hostID int) error
func (DefaultAuthorizationService) RequirePermission ¶
func (s DefaultAuthorizationService) RequirePermission(principal Principal, permission string) error
func (DefaultAuthorizationService) RequireTunnel ¶
func (s DefaultAuthorizationService) RequireTunnel(principal Principal, tunnelID int) error
func (DefaultAuthorizationService) ResolveClient ¶
func (s DefaultAuthorizationService) ResolveClient(principal Principal, requestedClientID int) (int, error)
type DefaultClientService ¶
func (DefaultClientService) Add ¶
func (s DefaultClientService) Add(input AddClientInput) (int, error)
func (DefaultClientService) BuildQRCode ¶
func (DefaultClientService) BuildQRCode(input ClientQRCodeInput) ([]byte, error)
func (DefaultClientService) ChangeStatus ¶
func (s DefaultClientService) ChangeStatus(id int, status bool) error
func (DefaultClientService) Clear ¶
func (DefaultClientService) Clear(id int, mode string, isAdmin bool) error
func (DefaultClientService) Delete ¶
func (s DefaultClientService) Delete(id int) error
func (DefaultClientService) Edit ¶
func (s DefaultClientService) Edit(input EditClientInput) error
func (DefaultClientService) List ¶
func (s DefaultClientService) List(input ListClientsInput) ListClientsResult
func (DefaultClientService) Ping ¶
func (s DefaultClientService) Ping(id int, remoteAddr string) (int, error)
func (DefaultClientService) RegisterVisitorIP ¶ added in v0.34.9
func (DefaultClientService) RequestUpdate ¶ added in v0.34.9
func (s DefaultClientService) RequestUpdate(id int) (int, error)
RequestUpdate asks the connected npc of client id to update themselves to the latest release and returns how many were asked.
type DefaultGlobalService ¶
type DefaultGlobalService struct {
LoginPolicy LoginPolicyService
Backend Backend
}
func (DefaultGlobalService) BanList ¶
func (s DefaultGlobalService) BanList() []LoginBanRecord
func (DefaultGlobalService) CleanBans ¶
func (s DefaultGlobalService) CleanBans()
func (DefaultGlobalService) Get ¶
func (s DefaultGlobalService) Get() *file.Glob
func (DefaultGlobalService) Save ¶
func (s DefaultGlobalService) Save(input SaveGlobalInput) error
func (DefaultGlobalService) Unban ¶
func (s DefaultGlobalService) Unban(key string) bool
func (DefaultGlobalService) UnbanAll ¶
func (s DefaultGlobalService) UnbanAll()
type DefaultIndexService ¶
type DefaultIndexService struct {
Backend Backend
}
func (DefaultIndexService) AddHost ¶
func (s DefaultIndexService) AddHost(input AddHostInput) (HostMutation, error)
func (DefaultIndexService) AddTunnel ¶
func (s DefaultIndexService) AddTunnel(input AddTunnelInput) (TunnelMutation, error)
func (DefaultIndexService) ClearHost ¶
func (s DefaultIndexService) ClearHost(id int, mode string) error
func (DefaultIndexService) ClearTunnel ¶
func (DefaultIndexService) ClearTunnel(id int, mode string) error
func (DefaultIndexService) DashboardData ¶
func (s DefaultIndexService) DashboardData(force bool) map[string]interface{}
func (DefaultIndexService) DeleteHost ¶
func (s DefaultIndexService) DeleteHost(id int) error
func (DefaultIndexService) DeleteTunnel ¶
func (s DefaultIndexService) DeleteTunnel(id int) error
func (DefaultIndexService) EditHost ¶
func (s DefaultIndexService) EditHost(input EditHostInput) (HostMutation, error)
func (DefaultIndexService) EditTunnel ¶
func (s DefaultIndexService) EditTunnel(input EditTunnelInput) (TunnelMutation, error)
func (DefaultIndexService) GetHost ¶
func (s DefaultIndexService) GetHost(id int) (*file.Host, error)
func (DefaultIndexService) GetTunnel ¶
func (s DefaultIndexService) GetTunnel(id int) (*file.Tunnel, error)
func (DefaultIndexService) ListHosts ¶
func (s DefaultIndexService) ListHosts(input HostListInput) ([]*file.Host, int)
func (DefaultIndexService) ListTunnels ¶
func (s DefaultIndexService) ListTunnels(input TunnelListInput) ([]*file.Tunnel, int)
func (DefaultIndexService) StartHost ¶
func (s DefaultIndexService) StartHost(id int, mode string) error
func (DefaultIndexService) StartTunnel ¶
func (s DefaultIndexService) StartTunnel(id int, mode string) error
func (DefaultIndexService) StopHost ¶
func (s DefaultIndexService) StopHost(id int, mode string) error
func (DefaultIndexService) StopTunnel ¶
func (s DefaultIndexService) StopTunnel(id int, mode string) error
type DefaultLoginPolicy ¶
type DefaultLoginPolicy struct {
ConfigProvider func() *servercfg.Snapshot
// contains filtered or unexported fields
}
func NewDefaultLoginPolicy ¶
func NewDefaultLoginPolicy(provider func() *servercfg.Snapshot) *DefaultLoginPolicy
func SharedLoginPolicy ¶
func SharedLoginPolicy() *DefaultLoginPolicy
func (*DefaultLoginPolicy) BanList ¶
func (s *DefaultLoginPolicy) BanList() []LoginBanRecord
func (*DefaultLoginPolicy) Clean ¶
func (s *DefaultLoginPolicy) Clean(force bool)
func (*DefaultLoginPolicy) IsBannedForTTL ¶
func (s *DefaultLoginPolicy) IsBannedForTTL(key string, ttl int64) bool
func (*DefaultLoginPolicy) IsIPBanned ¶
func (s *DefaultLoginPolicy) IsIPBanned(ip string) bool
func (*DefaultLoginPolicy) IsUserBanned ¶
func (s *DefaultLoginPolicy) IsUserBanned(username string) bool
func (*DefaultLoginPolicy) RecordFailure ¶
func (s *DefaultLoginPolicy) RecordFailure(key string, explicit bool)
func (*DefaultLoginPolicy) RemoveAllBans ¶
func (s *DefaultLoginPolicy) RemoveAllBans()
func (*DefaultLoginPolicy) RemoveBan ¶
func (s *DefaultLoginPolicy) RemoveBan(key string) bool
func (*DefaultLoginPolicy) Settings ¶
func (s *DefaultLoginPolicy) Settings() LoginPolicySettings
type DefaultPageService ¶
type DefaultPageService struct {
Clients ClientService
Globals GlobalService
Index IndexService
System SystemService
}
func (DefaultPageService) Build ¶
func (s DefaultPageService) Build(input PageBuildInput) (PageBuildResult, error)
type DefaultSystemService ¶
type DefaultSystemService struct{}
func (DefaultSystemService) BridgeDisplay ¶
func (DefaultSystemService) BridgeDisplay(cfg *servercfg.Snapshot, host string) BridgeDisplay
func (DefaultSystemService) GeoDataStatus ¶ added in v0.34.9
func (DefaultSystemService) GeoDataStatus() GeoDataStatus
func (DefaultSystemService) Info ¶
func (DefaultSystemService) Info() SystemInfo
func (DefaultSystemService) RegisterManagementAccess ¶
func (DefaultSystemService) RegisterManagementAccess(remoteAddr string, clientIDs []int, isAdmin bool)
func (DefaultSystemService) UpdateGeoData ¶ added in v0.34.9
func (s DefaultSystemService) UpdateGeoData() (GeoDataStatus, error)
func (DefaultSystemService) UpdateServer ¶ added in v0.34.9
func (DefaultSystemService) UpdateServer() (string, error)
type EditClientInput ¶
type EditClientInput struct {
ID int
ReservedAdminUsername string
VKey string
Remark string
User string
Password string
RateLimit int
MaxConn int
WebUserName string
WebPassword string
WebTotpSecret string
MaxTunnelNum int
FlowLimit int64
TimeLimit string
Access AccessListInput
RegisterKey string
RegisterMaxHours int
IsAdmin bool
AllowUserChangeUsername bool
Compress bool
Crypt bool
ConfigConnAllow bool
ResetFlow bool
}
type EditHostInput ¶
type EditHostInput struct {
ID int
ClientID int
Host string
Target string
ProxyProtocol int
Auth string
Header string
RespHeader string
HostChange string
Remark string
Location string
PathRewrite string
RedirectURL string
Access AccessListInput
FlowLimit int64
TimeLimit string
Scheme string
KeyFile string
CertFile string
IsAdmin bool
AllowUserLocal bool
LocalProxy bool
ResetFlow bool
HTTPSJustProxy bool
TLSOffload bool
AutoSSL bool
AutoHTTPS bool
AutoCORS bool
CompatMode bool
TargetIsHTTPS bool
}
type EditTunnelInput ¶
type EditTunnelInput struct {
ID int
ClientID int
Port int
ServerIP string
Mode string
TargetType string
Target string
ProxyProtocol int
Auth string
Remark string
Password string
LocalPath string
StripPre string
DestACLMode int
DestACLRules string
Access AccessListInput
FlowLimit int64
TimeLimit string
IsAdmin bool
AllowUserLocal bool
LocalProxy bool
EnableHTTP bool
EnableSocks5 bool
ResetFlow bool
}
type GeoDataStatus ¶ added in v0.34.9
type GeoDataStatus struct {
// Version is the release the files come from, "" when unknown.
Version string
Files []GeoFileStatus
}
GeoDataStatus describes the geodata files of the access lists.
type GeoFileStatus ¶ added in v0.34.9
GeoFileStatus describes one geodata file.
type GlobalService ¶
type GlobalService interface {
Save(SaveGlobalInput) error
Get() *file.Glob
BanList() []LoginBanRecord
Unban(key string) bool
UnbanAll()
CleanBans()
}
type HostListInput ¶
type HostMutation ¶
type IndexService ¶
type IndexService interface {
DashboardData(force bool) map[string]interface{}
ListTunnels(TunnelListInput) ([]*file.Tunnel, int)
AddTunnel(AddTunnelInput) (TunnelMutation, error)
GetTunnel(id int) (*file.Tunnel, error)
EditTunnel(EditTunnelInput) (TunnelMutation, error)
StopTunnel(id int, mode string) error
DeleteTunnel(id int) error
StartTunnel(id int, mode string) error
ClearTunnel(id int, mode string) error
ListHosts(HostListInput) ([]*file.Host, int)
GetHost(id int) (*file.Host, error)
DeleteHost(id int) error
StartHost(id int, mode string) error
StopHost(id int, mode string) error
ClearHost(id int, mode string) error
AddHost(AddHostInput) (HostMutation, error)
EditHost(EditHostInput) (HostMutation, error)
}
type ListClientsInput ¶
type ListClientsResult ¶
type LoginBanRecord ¶
type LoginPolicyService ¶
type LoginPolicySettings ¶
type LoginPolicySettings struct {
BanTime int64
IPBanTime int64
UserBanTime int64
MaxFailTimes int
MaxLoginBody int64
MaxSkew int64
}
func (LoginPolicySettings) LoginDelayMillis ¶
func (s LoginPolicySettings) LoginDelayMillis() int64
type PageBuildInput ¶
type PageBuildResult ¶
type PageBuildResult struct {
Data map[string]interface{}
}
type PageService ¶
type PageService interface {
Build(PageBuildInput) (PageBuildResult, error)
}
type PermissionResolver ¶
type PermissionResolver interface {
NormalizePrincipal(Principal) Principal
NormalizeIdentity(*SessionIdentity) *SessionIdentity
KnownRoles() []string
KnownPermissions() []string
PermissionCatalog() map[string][]string
}
func DefaultPermissionResolver ¶
func DefaultPermissionResolver() PermissionResolver
type RegisterUserInput ¶
type RegisterUserResult ¶
type Repository ¶
type Repository interface {
RangeClients(func(*file.Client) bool)
RangeTunnels(func(*file.Tunnel) bool)
RangeHosts(func(*file.Host) bool)
ListVisibleClients(ListClientsInput) ([]*file.Client, int)
NextClientID() int
NextTunnelID() int
NextHostID() int
CreateClient(*file.Client) error
GetClient(int) (*file.Client, error)
SaveClient(*file.Client) error
PersistClients() error
PersistGlobal() error
DeleteClient(int) error
VerifyUserName(string, int) bool
VerifyVKey(string, int) bool
ReplaceClientVKeyIndex(oldKey, newKey string, clientID int)
CreateTunnel(*file.Tunnel) error
GetTunnel(int) (*file.Tunnel, error)
SaveTunnel(*file.Tunnel) error
DeleteTunnelRecord(int) error
CreateHost(*file.Host) error
GetHost(int) (*file.Host, error)
SaveHost(*file.Host, string) error
PersistHosts() error
DeleteHostRecord(int) error
HostExists(*file.Host) bool
GetGlobal() *file.Glob
SaveGlobal(*file.Glob) error
ClientOwnsTunnel(int, int) bool
ClientOwnsHost(int, int) bool
}
type Runtime ¶
type Runtime interface {
DashboardData(bool) map[string]interface{}
ListClients(offset, limit int, search, sort, order string, clientID int) ([]*file.Client, int)
PingClient(int, string) int
DisconnectClient(int)
RequestClientUpdate(int) (int, error)
DeleteClientResources(int)
GenerateTunnelPort(*file.Tunnel) int
TunnelPortAvailable(*file.Tunnel) bool
ListTunnels(offset, limit int, tunnelType string, clientID int, search, sort, order string) ([]*file.Tunnel, int)
AddTunnel(*file.Tunnel) error
StopTunnel(int) error
StartTunnel(int) error
DeleteTunnel(int) error
ListHosts(offset, limit, clientID int, search, sort, order string) ([]*file.Host, int)
RemoveHostCache(int)
}
type SaveGlobalInput ¶
type SaveGlobalInput struct {
Access AccessListInput
// RateLimit limits all forwarded traffic together, in KB/s; 0 means
// unlimited.
RateLimit int
}
type Services ¶
type Services struct {
System SystemService
Permissions PermissionResolver
Auth AuthService
Authz AuthorizationService
LoginPolicy LoginPolicyService
Clients ClientService
Globals GlobalService
Index IndexService
Pages PageService
}
Services groups the default application services behind replaceable interfaces. Swapping framework or storage backends should not require transport-layer rewrites.
type SessionIdentity ¶
type SessionIdentity struct {
Version int `json:"version"`
Kind string `json:"kind,omitempty"`
Provider string `json:"provider,omitempty"`
SubjectID string `json:"subject_id,omitempty"`
Username string `json:"username,omitempty"`
ClientIDs []int `json:"client_ids,omitempty"`
Roles []string `json:"roles,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
Authenticated bool `json:"authenticated"`
IsAdmin bool `json:"is_admin"`
}
func AutoAdminIdentity ¶
func AutoAdminIdentity(cfg *servercfg.Snapshot) (*SessionIdentity, bool)
func NormalizeSessionIdentityWithResolver ¶
func NormalizeSessionIdentityWithResolver(identity *SessionIdentity, resolver PermissionResolver) *SessionIdentity
func ParseSessionIdentity ¶
func ParseSessionIdentity(raw string) (*SessionIdentity, error)
func ParseSessionIdentityWithResolver ¶
func ParseSessionIdentityWithResolver(raw string, resolver PermissionResolver) (*SessionIdentity, error)
func (*SessionIdentity) Normalize ¶
func (identity *SessionIdentity) Normalize() *SessionIdentity
type StaticPermissionResolver ¶
type StaticPermissionResolver struct{}
func (StaticPermissionResolver) KnownPermissions ¶
func (StaticPermissionResolver) KnownPermissions() []string
func (StaticPermissionResolver) KnownRoles ¶
func (StaticPermissionResolver) KnownRoles() []string
func (StaticPermissionResolver) NormalizeIdentity ¶
func (r StaticPermissionResolver) NormalizeIdentity(identity *SessionIdentity) *SessionIdentity
func (StaticPermissionResolver) NormalizePrincipal ¶
func (StaticPermissionResolver) NormalizePrincipal(principal Principal) Principal
func (StaticPermissionResolver) PermissionCatalog ¶
func (StaticPermissionResolver) PermissionCatalog() map[string][]string
type SystemInfo ¶
type SystemService ¶
type SystemService interface {
Info() SystemInfo
BridgeDisplay(*servercfg.Snapshot, string) BridgeDisplay
// RegisterManagementAccess registers the address of a web login for the
// clients the user manages, or every client for an administrator.
RegisterManagementAccess(remoteAddr string, clientIDs []int, isAdmin bool)
// UpdateServer updates the server to the latest release and restarts it
// shortly. It returns the version updated to, or "" when the running
// version is the latest.
UpdateServer() (string, error)
// GeoDataStatus describes the geodata files of the access lists.
GeoDataStatus() GeoDataStatus
// UpdateGeoData downloads the latest geodata files and applies them.
UpdateGeoData() (GeoDataStatus, error)
}