ax(node): replace prose comments with usage examples on PeerRegistry auth methods
SetAuthMode, GetAuthMode, AllowPublicKey, and RevokePublicKey all had comments that restated the function signature rather than showing concrete usage. Replaced with call-site examples per AX Principle 2. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
caa887325d
commit
1ff90ba170
1 changed files with 5 additions and 4 deletions
|
|
@ -153,7 +153,8 @@ func NewPeerRegistryWithPath(peersPath string) (*PeerRegistry, error) {
|
|||
return pr, nil
|
||||
}
|
||||
|
||||
// SetAuthMode sets the authentication mode for peer connections.
|
||||
// registry.SetAuthMode(PeerAuthAllowlist) // require pre-registration
|
||||
// registry.SetAuthMode(PeerAuthOpen) // allow any peer (default)
|
||||
func (r *PeerRegistry) SetAuthMode(mode PeerAuthMode) {
|
||||
r.allowedPublicKeyMutex.Lock()
|
||||
defer r.allowedPublicKeyMutex.Unlock()
|
||||
|
|
@ -161,14 +162,14 @@ func (r *PeerRegistry) SetAuthMode(mode PeerAuthMode) {
|
|||
logging.Info("peer auth mode changed", logging.Fields{"mode": mode})
|
||||
}
|
||||
|
||||
// GetAuthMode returns the current authentication mode.
|
||||
// if registry.GetAuthMode() == PeerAuthAllowlist { /* enforce allowlist */ }
|
||||
func (r *PeerRegistry) GetAuthMode() PeerAuthMode {
|
||||
r.allowedPublicKeyMutex.RLock()
|
||||
defer r.allowedPublicKeyMutex.RUnlock()
|
||||
return r.authMode
|
||||
}
|
||||
|
||||
// AllowPublicKey adds a public key to the allowlist.
|
||||
// registry.AllowPublicKey(peer.PublicKey) // permit this key without pre-registration
|
||||
func (r *PeerRegistry) AllowPublicKey(publicKey string) {
|
||||
r.allowedPublicKeyMutex.Lock()
|
||||
defer r.allowedPublicKeyMutex.Unlock()
|
||||
|
|
@ -176,7 +177,7 @@ func (r *PeerRegistry) AllowPublicKey(publicKey string) {
|
|||
logging.Debug("public key added to allowlist", logging.Fields{"key": safeKeyPrefix(publicKey)})
|
||||
}
|
||||
|
||||
// RevokePublicKey removes a public key from the allowlist.
|
||||
// registry.RevokePublicKey(peer.PublicKey) // block this key on next connect attempt
|
||||
func (r *PeerRegistry) RevokePublicKey(publicKey string) {
|
||||
r.allowedPublicKeyMutex.Lock()
|
||||
defer r.allowedPublicKeyMutex.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue