Documentation
¶
Index ¶
- func GetMapKeys(m *sync.Map, isSort bool, sortKey, order string) (keys []int)
- func RefreshAccessLists()
- func ReportGeoData()
- func WatchAccessLists(ctx context.Context, interval time.Duration)
- type DbUtils
- func (s *DbUtils) ClientChanged(c *model.Client)
- func (s *DbUtils) ClientEntryCount(c *model.Client) (num int)
- func (s *DbUtils) ClientHost(c *model.Client, h *model.Host) (hh *model.Host, exist bool)
- func (s *DbUtils) ClientPresence(id int, c *model.Client, online bool)
- func (s *DbUtils) ClientTunnel(c *model.Client, t *model.Tunnel) (tt *model.Tunnel, exist bool)
- func (s *DbUtils) DelClient(id int) error
- func (s *DbUtils) DelHost(id int) error
- func (s *DbUtils) DelTask(id int) error
- func (s *DbUtils) FindCertByHost(host string) (*model.Host, error)
- func (s *DbUtils) FindReusableCert(host string, excludeID, clientID int) (*model.Host, error)
- func (s *DbUtils) GetClient(id int) (c *model.Client, err error)
- func (s *DbUtils) GetClientIdByBlake2bVkey(vkey string) (id int, err error)
- func (s *DbUtils) GetClientIdByMd5Vkey(vkey string) (id int, err error)
- func (s *DbUtils) GetClientList(start, length int, search, sort, order string, clientId int) ([]*model.Client, int)
- func (s *DbUtils) GetGlobal() (c *model.Glob)
- func (s *DbUtils) GetHost(start, length int, id int, search string) ([]*model.Host, int)
- func (s *DbUtils) GetHostById(id int) (h *model.Host, err error)
- func (s *DbUtils) GetIdByVerifyKey(vKey, addr, localAddr string, hashFunc func(string) string) (id int, err error)
- func (s *DbUtils) GetInfoByHost(host string, r *http.Request) (h *model.Host, err error)
- func (s *DbUtils) GetTask(id int) (t *model.Tunnel, err error)
- func (s *DbUtils) GetTaskByAccessID(id []byte) *model.Tunnel
- func (s *DbUtils) GetTaskBySecretIndex(p string) (t *model.Tunnel)
- func (s *DbUtils) GlobalDenied(addr net.Addr, what string) bool
- func (s *DbUtils) GlobalDeniedString(addr, what string) bool
- func (s *DbUtils) HostChanged(h *model.Host)
- func (s *DbUtils) IsHostExist(h *model.Host) bool
- func (s *DbUtils) IsHostModify(h *model.Host) bool
- func (s *DbUtils) IsPubClient(id int) bool
- func (s *DbUtils) NewClient(c *model.Client) error
- func (s *DbUtils) NewHost(t *model.Host) error
- func (s *DbUtils) NewTask(t *model.Tunnel) error
- func (s *DbUtils) NextHostID() int
- func (s *DbUtils) NextTunnelID() int
- func (s *DbUtils) OnClientChanged(f func(c *model.Client, deleted bool))
- func (s *DbUtils) OnEntriesChanged(f func())
- func (s *DbUtils) RangeClientCertHosts(clientID int, fn func(*model.Host) bool)
- func (s *DbUtils) RangeHosts(fn func(*model.Host) bool)
- func (s *DbUtils) RangeTunnels(fn func(*model.Tunnel) bool)
- func (s *DbUtils) ReplaceClientVKey(oldKey, newKey string, id int)
- func (s *DbUtils) ReserveTaskPassword(t *model.Tunnel) error
- func (s *DbUtils) SaveGlobal(t *model.Glob) error
- func (s *DbUtils) SaveHost(h *model.Host, oldHost string) error
- func (s *DbUtils) SetEventBus(bus *event.Bus)
- func (s *DbUtils) TunnelChanged(t *model.Tunnel)
- func (s *DbUtils) UpdateClient(t *model.Client) error
- func (s *DbUtils) UpdateTask(t *model.Tunnel) error
- func (s *DbUtils) VerifyUserName(username string, id int) (res bool)
- func (s *DbUtils) VerifyVkey(vkey string, id int) (res bool)
- type JsonDb
- func (s *JsonDb) GetClient(id int) (c *model.Client, err error)
- func (s *JsonDb) GetClientId() int32
- func (s *JsonDb) GetHostId() int32
- func (s *JsonDb) GetTaskId() int32
- func (s *JsonDb) LoadClientFromJsonFile() error
- func (s *JsonDb) LoadGlobalFromJsonFile() error
- func (s *JsonDb) LoadHostFromJsonFile() error
- func (s *JsonDb) LoadTaskFromJsonFile() error
- func (s *JsonDb) StoreClientsToJsonFile() error
- func (s *JsonDb) StoreGlobalToJsonFile() error
- func (s *JsonDb) StoreHostToJsonFile() error
- func (s *JsonDb) StoreTasksToJsonFile() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RefreshAccessLists ¶ added in v0.35.0
func RefreshAccessLists()
RefreshAccessLists recompiles the access lists whose geodata changed, and logs the lists that keep their rules because the new geodata breaks some.
func ReportGeoData ¶ added in v0.35.0
func ReportGeoData()
ReportGeoData logs the geodata files the access lists use, as source_loaded for each file present.
func WatchAccessLists ¶ added in v0.34.9
WatchAccessLists checks the geodata files every interval until ctx ends and refreshes the access lists when one of them changed, so that updated geodata takes effect. Checking reads file metadata only.
Types ¶
type DbUtils ¶
type DbUtils struct {
JsonDb *JsonDb
// contains filtered or unexported fields
}
func Open ¶ added in v0.35.0
Open returns the store kept in the conf directory of runPath, loaded from its files.
func (*DbUtils) ClientChanged ¶ added in v0.35.0
ClientChanged reports that the client c was changed in place.
func (*DbUtils) ClientEntryCount ¶ added in v0.35.0
ClientEntryCount returns how many tunnels and hosts c has.
func (*DbUtils) ClientHost ¶ added in v0.35.0
ClientHost returns the stored host of c with the host and location of h.
func (*DbUtils) ClientPresence ¶ added in v0.35.0
ClientPresence reports that client id got or lost its session; c is nil if the client was deleted already. Sessions of the public and visitor keys, not being clients an administrator manages, are left out. A session joined by more connections reports online once.
func (*DbUtils) ClientTunnel ¶ added in v0.35.0
ClientTunnel returns the stored tunnel of c on the port or with the password of t.
func (*DbUtils) FindCertByHost ¶
FindCertByHost returns the host entry that terminates TLS for the server name host. An entry for the exact name beats a wildcard one, and a longer wildcard suffix a shorter one; among entries for the same name, one with TLS configured (a certificate or AutoSSL) wins, then the one with the shortest location, then the lowest id, so the choice never depends on map order. Names compare case-insensitively, ignoring a trailing dot.
func (*DbUtils) FindReusableCert ¶ added in v0.35.0
FindReusableCert returns the entry whose certificate FindCertByHost would choose for the server name host among those with certificate files, leaving out the entry excludeID and, unless clientID is 0, entries of other clients.
func (*DbUtils) GetClientIdByBlake2bVkey ¶ added in v0.29.9
func (*DbUtils) GetClientIdByMd5Vkey ¶ added in v0.27.0
func (*DbUtils) GetClientList ¶
func (*DbUtils) GetIdByVerifyKey ¶
func (*DbUtils) GetInfoByHost ¶
GetInfoByHost get key by host from x
func (*DbUtils) GetTaskByAccessID ¶ added in v0.35.0
GetTaskByAccessID returns the task whose password has the access id (coreapi.AccessID), nil if none has.
func (*DbUtils) GetTaskBySecretIndex ¶ added in v0.35.0
GetTaskBySecretIndex returns the task whose password has index p (crypt.SecretIndex), nil if none has.
func (*DbUtils) GlobalDenied ¶ added in v0.34.9
GlobalDenied reports whether the global access lists, the firewall in front of every listener of nps, deny addr, and logs a denial. what names the listener in the log.
func (*DbUtils) GlobalDeniedString ¶ added in v0.34.9
GlobalDeniedString is GlobalDenied for an address given as text.
func (*DbUtils) HostChanged ¶ added in v0.35.0
HostChanged reports that the entry h was changed in place.
func (*DbUtils) IsPubClient ¶
func (*DbUtils) NewTask ¶
NewTask adds t. A password explicitly set on a task created through the web or API that is already used by another task is rejected; for tasks delivered by a client configuration (NoStore) it is replaced by a random one, see taskPasswords.reserve.
func (*DbUtils) NextHostID ¶ added in v0.35.0
NextHostID reserves the id of a new host.
func (*DbUtils) NextTunnelID ¶ added in v0.35.0
NextTunnelID reserves the id of a new tunnel.
func (*DbUtils) OnClientChanged ¶ added in v0.35.0
OnClientChanged makes f called after a client was created, changed or deleted (deleted true). It runs on the changing goroutine and returns promptly.
func (*DbUtils) OnEntriesChanged ¶ added in v0.35.0
func (s *DbUtils) OnEntriesChanged(f func())
OnEntriesChanged makes f called after tunnels or hosts of s were stored or changed in place, without any lock held; f must return promptly. The server that owns s sets it before it starts.
func (*DbUtils) RangeClientCertHosts ¶ added in v0.34.8
RangeClientCertHosts calls fn, until it returns false, for each host entry of the client clientID with a certificate configured.
func (*DbUtils) RangeHosts ¶ added in v0.35.0
RangeHosts calls fn for every stored host until fn returns false.
func (*DbUtils) RangeTunnels ¶ added in v0.35.0
RangeTunnels calls fn for every stored tunnel until fn returns false.
func (*DbUtils) ReplaceClientVKey ¶ added in v0.35.0
ReplaceClientVKey moves the authentication index entry of client id from the verify key oldKey to newKey.
func (*DbUtils) ReserveTaskPassword ¶ added in v0.34.8
ReserveTaskPassword claims t.Password for t.Id under the same rules as NewTask and UpdateTask. It is used before an existing task is updated in place from t.
func (*DbUtils) SaveHost ¶ added in v0.35.0
SaveHost stores the entry h, edited in place, which was named oldHost before.
func (*DbUtils) SetEventBus ¶ added in v0.35.0
SetEventBus makes s publish to bus; nil stops it, and then changes cost nothing.
func (*DbUtils) TunnelChanged ¶ added in v0.35.0
TunnelChanged reports that the entry t was changed in place.
func (*DbUtils) UpdateTask ¶
UpdateTask stores t in place of the task with the same id. t may be the stored object itself or an edited copy; the password the task held before is tracked separately and released when it changes. A rejected password leaves the stored task and the password index unchanged.
func (*DbUtils) VerifyUserName ¶
type JsonDb ¶
type JsonDb struct {
Tasks sync.Map
Hosts sync.Map
HostsTmp sync.Map
Clients sync.Map
Global *model.Glob
RunPath string
ClientIncreaseId int32 //client increased id
TaskIncreaseId int32 //task increased id
HostIncreaseId int32 //host increased id
TaskFilePath string //task file path
HostFilePath string //host file path
ClientFilePath string //client file path
GlobalFilePath string //global file path
// contains filtered or unexported fields
}