host

package
v0.0.0-...-61b8474 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRemotes = 10
)

Variables

This section is empty.

Functions

func NewUDPAddrFromLH4

func NewUDPAddrFromLH4(ipp *api.Ipv4Addr) *udp.Addr

func NewUDPAddrFromLH6

func NewUDPAddrFromLH6(ipp *api.Ipv6Addr) *udp.Addr

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is an internal struct that splits v4 and v6 addresses inside the cache map

func (*Cache) GetV4

func (c *Cache) GetV4() *CacheV4

func (*Cache) GetV46

func (c *Cache) GetV46() *CacheV6

type CacheRelay

type CacheRelay struct {
	// contains filtered or unexported fields
}

func (*CacheRelay) Relay

func (c *CacheRelay) Relay() []uint32

type CacheV4

type CacheV4 struct {
	// contains filtered or unexported fields
}

func (*CacheV4) Learned

func (c *CacheV4) Learned() *api.Ipv4Addr

func (*CacheV4) Reported

func (c *CacheV4) Reported() []*api.Ipv4Addr

type CacheV6

type CacheV6 struct {
	// contains filtered or unexported fields
}

func (*CacheV6) Learned

func (c *CacheV6) Learned() *api.Ipv6Addr

func (*CacheV6) Reported

func (c *CacheV6) Reported() []*api.Ipv6Addr

type HostInfo

type HostInfo struct {
	Remote  *udp.Addr
	Remotes *RemoteList
	//RemoteIndexId uint32
	//LocalIndexId  uint32
	Name string
}

func (*HostInfo) SetRemote

func (h *HostInfo) SetRemote(remote *udp.Addr)

func (*HostInfo) String

func (h *HostInfo) String() string

type HostMap

type HostMap struct {
	sync.RWMutex //Because we concurrently read and write to our maps
	//Indexes         map[uint32]*HostInfo
	//Relays          map[uint32]*HostInfo // Maps a Relay IDX to a Relay HostInfo object
	//RemoteIndexes   map[uint32]*HostInfo
	Hosts map[string]*HostInfo
	// contains filtered or unexported fields
}

func NewHostMap

func NewHostMap(logger *zap.Logger) *HostMap

func (*HostMap) AddHost

func (hm *HostMap) AddHost(hostInfo *HostInfo)

func (*HostMap) GetHost

func (hm *HostMap) GetHost(name string) *HostInfo

type RemoteList

type RemoteList struct {
	// Every interaction with internals requires a lock!
	sync.RWMutex
	// contains filtered or unexported fields
}

RemoteList is a unifying concept for lighthouse servers and clients as well as hostinfos. It serves as a local cache of query replies, host update notifications, and locally learned addresses

func NewRemoteList

func NewRemoteList() *RemoteList

func (*RemoteList) CopyAddrs

func (r *RemoteList) CopyAddrs() []*udp.Addr

CopyAddrs locks and makes a deep copy of the deduplicated address list

func (*RemoteList) ForEach

func (r *RemoteList) ForEach(forEach func(addr *udp.Addr))

func (*RemoteList) GetCache

func (r *RemoteList) GetCache(name string) *Cache

func (*RemoteList) LearnRemote

func (r *RemoteList) LearnRemote(name string, addr *udp.Addr)

LearnRemote 锁定并设置拥有者 VPN IP 的已学习地址槽位为提供的 addr。 目前仅在调用 HostInfo.SetRemote 时需要使用,因为该方法应涵盖握手和漫游两种情况。 它将标记去重后的地址列表为脏状态,因此仅在有新信息可用时调用它。 TODO: 需要支持允许列表

func (*RemoteList) Rebuild

func (r *RemoteList) Rebuild()

func (*RemoteList) ResetBlockedRemotes

func (r *RemoteList) ResetBlockedRemotes()

ResetBlockedRemotes 锁定并清除阻止的远程列表

func (*RemoteList) UnlockedPrependV4

func (r *RemoteList) UnlockedPrependV4(name string, to *api.Ipv4Addr)

func (*RemoteList) UnlockedPrependV6

func (r *RemoteList) UnlockedPrependV6(name string, to *api.Ipv6Addr)

func (*RemoteList) UnlockedSetV4

func (r *RemoteList) UnlockedSetV4(name string, to []*api.Ipv4Addr)

func (*RemoteList) UnlockedSetV6

func (r *RemoteList) UnlockedSetV6(name string, to []*api.Ipv6Addr)

Jump to

Keyboard shortcuts

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