service

package
v0.34.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: GPL-3.0 Imports: 32 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SessionIdentityKey     = "session_identity"
	SessionIdentityVersion = 1
)
View Source
const (
	RoleAnonymous = "anonymous"
	RoleAdmin     = "admin"
	RoleUser      = "user"
)
View Source
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

View Source
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")
	ErrServerUpdateUnavailable  = errors.New("server update is unavailable")
	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")
	ErrPortUnavailable          = errors.New("port unavailable")
	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")
)
View Source
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 ClearClientStatus(client *file.Client, name string)

func DefaultRolePermissions

func DefaultRolePermissions(role string) []string

func MarshalSessionIdentity

func MarshalSessionIdentity(identity *SessionIdentity) (string, error)

func MarshalSessionIdentityWithResolver

func MarshalSessionIdentityWithResolver(identity *SessionIdentity, resolver PermissionResolver) (string, error)

func UniqueStringsPreserveOrder

func UniqueStringsPreserveOrder(values []string) []string

func ValidAuthKey

func ValidAuthKey(configKey, md5Key string, timestamp int, nowUnix int64) bool

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 AuthenticateInput struct {
	Username string
	Password string
	TOTP     string
}

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 BridgeEndpoint

type BridgeEndpoint struct {
	Type string
	Addr string
	IP   string
	Port string
}

func BestBridge

func BestBridge(cfg *servercfg.Snapshot, host string) BridgeEndpoint

type BridgeTransport

type BridgeTransport struct {
	Enabled bool
	Type    string
	IP      string
	Port    string
	Addr    string
	ALPN    string
}

type ClientQRCodeInput

type ClientQRCodeInput struct {
	Text    string
	Account string
	Secret  string
	AppName string
}

type ClientScope

type ClientScope struct {
	All             bool
	PrimaryClientID int
	ClientIDs       []int
}

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 ClientVisibility struct {
	IsAdmin         bool
	PrimaryClientID int
	ClientIDs       []int
}

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

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

type DefaultClientService struct {
	ConfigProvider func() *servercfg.Snapshot
	Backend        Backend
}

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 (DefaultClientService) Get

func (s DefaultClientService) Get(id int) (*file.Client, error)

func (DefaultClientService) List

func (DefaultClientService) Ping

func (s DefaultClientService) Ping(id int, remoteAddr string) (int, error)

func (DefaultClientService) RegisterVisitorIP added in v0.34.9

func (s DefaultClientService) RegisterVisitorIP(key, ip string, hours int) (int, time.Time, error)

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 (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 (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 (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

type DefaultPageService

type DefaultPageService struct {
	Clients ClientService
	Globals GlobalService
	Index   IndexService
	System  SystemService
}

func (DefaultPageService) Build

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) 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

type GeoFileStatus struct {
	Name    string
	Path    string
	Exists  bool
	Size    int64
	ModTime string
}

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 HostListInput struct {
	Offset   int
	Limit    int
	ClientID int
	Search   string
	Sort     string
	Order    string
}

type HostMutation

type HostMutation struct {
	ID       int
	ClientID int
}

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 ListClientsInput struct {
	Offset     int
	Limit      int
	Search     string
	Sort       string
	Order      string
	Host       string
	Visibility ClientVisibility
}

type ListClientsResult

type ListClientsResult struct {
	Rows       []*file.Client
	Total      int
	BridgeType string
	BridgeAddr string
	BridgeIP   string
	BridgePort int
}

type LoginBanRecord

type LoginBanRecord struct {
	Key           string `json:"key"`
	FailTimes     int    `json:"fail_times"`
	LastLoginTime string `json:"last_login_time"`
	IsBanned      bool   `json:"is_banned"`
	BanType       string `json:"ban_type"`
}

type LoginPolicyService

type LoginPolicyService interface {
	Settings() LoginPolicySettings
	IsIPBanned(ip string) bool
	IsUserBanned(username string) bool
	RecordFailure(key string, explicit bool)
	RemoveBan(key string) bool
	RemoveAllBans()
	Clean(force bool)
	BanList() []LoginBanRecord
}

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 PageBuildInput struct {
	Config     *servercfg.Snapshot
	Controller string
	Action     string
	Host       string
	IsAdmin    bool
	Username   string
	Params     map[string]string
}

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 Principal

type Principal struct {
	Kind          string
	SubjectID     string
	Username      string
	ClientIDs     []int
	Roles         []string
	Permissions   []string
	Attributes    map[string]string
	Authenticated bool
	IsAdmin       bool
}

type RegisterUserInput

type RegisterUserInput struct {
	Username string
	Password string
}

type RegisterUserResult

type RegisterUserResult struct {
	SubjectID string
	Username  string
	ClientIDs []int
}

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.

func New

func New() Services

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 SystemInfo struct {
	Version string
	Year    int
	// CanUpdate tells whether the server can be updated from the web to a
	// newer release.
	CanUpdate bool
}

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)
}

type TunnelListInput

type TunnelListInput struct {
	Offset   int
	Limit    int
	Type     string
	ClientID int
	Search   string
	Sort     string
	Order    string
}

type TunnelMutation

type TunnelMutation struct {
	ID       int
	ClientID int
	Mode     string
}

Jump to

Keyboard shortcuts

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