all: imp docs
This commit is contained in:
parent
81e8b94492
commit
c9015e732f
|
@ -84,7 +84,9 @@ type Runtime struct {
|
|||
hostsFile []string
|
||||
}
|
||||
|
||||
// NewRuntime constructs a new runtime client.
|
||||
// NewRuntime constructs a new runtime client. ip must be valid IP address.
|
||||
//
|
||||
// TODO(s.chzhen): Validate IP address.
|
||||
func NewRuntime(ip netip.Addr) (r *Runtime) {
|
||||
return &Runtime{
|
||||
ip: ip,
|
||||
|
@ -195,8 +197,10 @@ func (ri *RuntimeIndex) Client(ip netip.Addr) (rc *Runtime, ok bool) {
|
|||
return rc, ok
|
||||
}
|
||||
|
||||
// Add saves the runtime client by ip.
|
||||
func (ri *RuntimeIndex) Add(ip netip.Addr, rc *Runtime) {
|
||||
// Add saves the runtime client in the index. IP address of a client must be
|
||||
// unique. See [Client].
|
||||
func (ri *RuntimeIndex) Add(rc *Runtime) {
|
||||
ip := rc.Addr()
|
||||
ri.index[ip] = rc
|
||||
}
|
||||
|
||||
|
@ -205,7 +209,7 @@ func (ri *RuntimeIndex) Size() (n int) {
|
|||
return len(ri.index)
|
||||
}
|
||||
|
||||
// Range calls cb for each runtime client.
|
||||
// Range calls cb for each runtime client in an undefined order.
|
||||
func (ri *RuntimeIndex) Range(cb func(rc *Runtime) (cont bool)) {
|
||||
for _, rc := range ri.index {
|
||||
if !cb(rc) {
|
||||
|
|
|
@ -736,8 +736,8 @@ func (clients *clientsContainer) setWHOISInfo(ip netip.Addr, wi *whois.Info) {
|
|||
if !ok {
|
||||
// Create a RuntimeClient implicitly so that we don't do this check
|
||||
// again.
|
||||
rc = &client.Runtime{}
|
||||
clients.runtimeIndex.Add(ip, rc)
|
||||
rc = client.NewRuntime(ip)
|
||||
clients.runtimeIndex.Add(rc)
|
||||
|
||||
log.Debug("clients: set whois info for runtime client with ip %s: %+v", ip, wi)
|
||||
} else {
|
||||
|
@ -805,7 +805,7 @@ func (clients *clientsContainer) addHostLocked(
|
|||
}
|
||||
|
||||
rc = client.NewRuntime(ip)
|
||||
clients.runtimeIndex.Add(ip, rc)
|
||||
clients.runtimeIndex.Add(rc)
|
||||
}
|
||||
|
||||
rc.SetInfo(src, []string{host})
|
||||
|
|
Loading…
Reference in New Issue