all: imp docs

This commit is contained in:
Stanislav Chzhen 2024-06-28 18:05:37 +03:00
parent e7043efcda
commit 85ccad7862
3 changed files with 18 additions and 6 deletions

View File

@ -82,21 +82,21 @@ type Persistent struct {
Upstreams []string Upstreams []string
// IPs is a list of IP addresses that identify the client. The client must // IPs is a list of IP addresses that identify the client. The client must
// have at least one ID [Persistent.IDsLen]. // have at least one ID (IP, subnet, MAC, or ClientID).
IPs []netip.Addr IPs []netip.Addr
// Subnets identifying the client. The client must have at least one ID // Subnets identifying the client. The client must have at least one ID
// [Persistent.IDsLen]. // (IP, subnet, MAC, or ClientID).
// //
// TODO(s.chzhen): Use netutil.Prefix. // TODO(s.chzhen): Use netutil.Prefix.
Subnets []netip.Prefix Subnets []netip.Prefix
// MACs identifying the client. The client must have at least one ID // MACs identifying the client. The client must have at least one ID (IP,
// [Persistent.IDsLen]. // subnet, MAC, or ClientID).
MACs []net.HardwareAddr MACs []net.HardwareAddr
// ClientIDs identifying the client. The client must have at least one ID // ClientIDs identifying the client. The client must have at least one ID
// [Persistent.IDsLen]. // (IP, subnet, MAC, or ClientID).
ClientIDs []string ClientIDs []string
// UID is the unique identifier of the persistent client. // UID is the unique identifier of the persistent client.

View File

@ -227,6 +227,8 @@ func (s *Storage) CloseUpstreams() (err error) {
// ClientRuntime returns a copy of the saved runtime client by ip. If no such // ClientRuntime returns a copy of the saved runtime client by ip. If no such
// client exists, returns nil. // client exists, returns nil.
//
// TODO(s.chzhen): Use it.
func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) { func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -236,6 +238,8 @@ func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) {
// AddRuntime saves the runtime client information in the storage. IP address // AddRuntime saves the runtime client information in the storage. IP address
// of a client must be unique. rc must not be nil. // of a client must be unique. rc must not be nil.
//
// TODO(s.chzhen): Use it.
func (s *Storage) AddRuntime(rc *Runtime) { func (s *Storage) AddRuntime(rc *Runtime) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -244,6 +248,8 @@ func (s *Storage) AddRuntime(rc *Runtime) {
} }
// SizeRuntime returns the number of the runtime clients. // SizeRuntime returns the number of the runtime clients.
//
// TODO(s.chzhen): Use it.
func (s *Storage) SizeRuntime() (n int) { func (s *Storage) SizeRuntime() (n int) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -252,6 +258,8 @@ func (s *Storage) SizeRuntime() (n int) {
} }
// RangeRuntime calls f for each runtime client in an undefined order. // RangeRuntime calls f for each runtime client in an undefined order.
//
// TODO(s.chzhen): Use it.
func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) { func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -260,6 +268,8 @@ func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) {
} }
// DeleteRuntime removes the runtime client by ip. // DeleteRuntime removes the runtime client by ip.
//
// TODO(s.chzhen): Use it.
func (s *Storage) DeleteRuntime(ip netip.Addr) { func (s *Storage) DeleteRuntime(ip netip.Addr) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
@ -269,6 +279,8 @@ func (s *Storage) DeleteRuntime(ip netip.Addr) {
// DeleteBySource removes all runtime clients that have information only from // DeleteBySource removes all runtime clients that have information only from
// the specified source and returns the number of removed clients. // the specified source and returns the number of removed clients.
//
// TODO(s.chzhen): Use it.
func (s *Storage) DeleteBySource(src Source) (n int) { func (s *Storage) DeleteBySource(src Source) (n int) {
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()

View File

@ -348,7 +348,7 @@ func (clients *clientsContainer) periodicUpdate() {
// clientSource checks if client with this IP address already exists and returns // clientSource checks if client with this IP address already exists and returns
// the source which updated it last. It returns [client.SourceNone] if the // the source which updated it last. It returns [client.SourceNone] if the
// client doesn't exist. // client doesn't exist. Note that it is only used in tests.
func (clients *clientsContainer) clientSource(ip netip.Addr) (src client.Source) { func (clients *clientsContainer) clientSource(ip netip.Addr) (src client.Source) {
clients.lock.Lock() clients.lock.Lock()
defer clients.lock.Unlock() defer clients.lock.Unlock()