Skip to content

Commit

Permalink
move isRelayAddr helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Oct 12, 2021
1 parent 2828a61 commit a157b1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 7 additions & 2 deletions p2p/protocol/circuitv2/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (r *Relay) handleReserve(s network.Stream) {
p := s.Conn().RemotePeer()
a := s.Conn().RemoteMultiaddr()

if util.IsRelayAddr(a) {
if isRelayAddr(a) {
log.Debugf("refusing relay reservation for %s; reservation attempt over relay connection")
r.handleError(s, pbv2.Status_PERMISSION_DENIED)
return
Expand Down Expand Up @@ -184,7 +184,7 @@ func (r *Relay) handleConnect(s network.Stream, msg *pbv2.HopMessage) {
src := s.Conn().RemotePeer()
a := s.Conn().RemoteMultiaddr()

if util.IsRelayAddr(a) {
if isRelayAddr(a) {
log.Debugf("refusing connection from %s; connection attempt over relay connection")
r.handleError(s, pbv2.Status_PERMISSION_DENIED)
return
Expand Down Expand Up @@ -531,3 +531,8 @@ func (r *Relay) disconnected(n network.Network, c network.Conn) {

delete(r.rsvp, p)
}

func isRelayAddr(a ma.Multiaddr) bool {
_, err := a.ValueForProtocol(ma.P_CIRCUIT)
return err == nil
}
10 changes: 0 additions & 10 deletions p2p/protocol/circuitv2/util/ma.go

This file was deleted.

0 comments on commit a157b1b

Please sign in to comment.