Skip to content

Commit

Permalink
all: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Jun 28, 2024
1 parent e7043ef commit 85ccad7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/client/persistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@ type Persistent struct {
Upstreams []string

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

// 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.
Subnets []netip.Prefix

// MACs identifying the client. The client must have at least one ID
// [Persistent.IDsLen].
// MACs identifying the client. The client must have at least one ID (IP,
// subnet, MAC, or ClientID).
MACs []net.HardwareAddr

// ClientIDs identifying the client. The client must have at least one ID
// [Persistent.IDsLen].
// (IP, subnet, MAC, or ClientID).
ClientIDs []string

// UID is the unique identifier of the persistent client.
Expand Down
12 changes: 12 additions & 0 deletions internal/client/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ func (s *Storage) CloseUpstreams() (err error) {

// ClientRuntime returns a copy of the saved runtime client by ip. If no such
// client exists, returns nil.
//
// TODO(s.chzhen): Use it.
func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) {
s.mu.Lock()
defer s.mu.Unlock()
Expand All @@ -236,6 +238,8 @@ func (s *Storage) ClientRuntime(ip netip.Addr) (rc *Runtime) {

// AddRuntime saves the runtime client information in the storage. IP address
// of a client must be unique. rc must not be nil.
//
// TODO(s.chzhen): Use it.
func (s *Storage) AddRuntime(rc *Runtime) {
s.mu.Lock()
defer s.mu.Unlock()
Expand All @@ -244,6 +248,8 @@ func (s *Storage) AddRuntime(rc *Runtime) {
}

// SizeRuntime returns the number of the runtime clients.
//
// TODO(s.chzhen): Use it.
func (s *Storage) SizeRuntime() (n int) {
s.mu.Lock()
defer s.mu.Unlock()
Expand All @@ -252,6 +258,8 @@ func (s *Storage) SizeRuntime() (n int) {
}

// 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)) {
s.mu.Lock()
defer s.mu.Unlock()
Expand All @@ -260,6 +268,8 @@ func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) {
}

// DeleteRuntime removes the runtime client by ip.
//
// TODO(s.chzhen): Use it.
func (s *Storage) DeleteRuntime(ip netip.Addr) {
s.mu.Lock()
defer s.mu.Unlock()
Expand All @@ -269,6 +279,8 @@ func (s *Storage) DeleteRuntime(ip netip.Addr) {

// DeleteBySource removes all runtime clients that have information only from
// the specified source and returns the number of removed clients.
//
// TODO(s.chzhen): Use it.
func (s *Storage) DeleteBySource(src Source) (n int) {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion internal/home/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (clients *clientsContainer) periodicUpdate() {

// clientSource checks if client with this IP address already exists and returns
// 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) {
clients.lock.Lock()
defer clients.lock.Unlock()
Expand Down

0 comments on commit 85ccad7

Please sign in to comment.