Skip to content

Commit

Permalink
Merge pull request #76 from libp2p/feat/protected-query
Browse files Browse the repository at this point in the history
Implement IsProtected interface
  • Loading branch information
vyzo authored Jun 3, 2020
2 parents 9fba560 + f237862 commit c66854c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions p2p/net/connmgr/connmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ func (cm *BasicConnMgr) Unprotect(id peer.ID, tag string) (protected bool) {
return true
}

func (cm *BasicConnMgr) IsProtected(id peer.ID, tag string) (protected bool) {
cm.plk.Lock()
defer cm.plk.Unlock()

tags, ok := cm.protected[id]
if !ok {
return false
}

if tag == "" {
return true
}

_, protected = tags[tag]
return protected
}

// peerInfo stores metadata for a given peer.
type peerInfo struct {
id peer.ID
Expand Down

0 comments on commit c66854c

Please sign in to comment.