Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Relay reservations #67

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,19 @@ func (n *RelayNotifiee) Connected(s inet.Network, c inet.Conn) {
}(c.RemotePeer())
}

func (n *RelayNotifiee) Disconnected(s inet.Network, c inet.Conn) {}
func (n *RelayNotifiee) Disconnected(s inet.Network, c inet.Conn) {
r := n.Relay()
p := c.RemotePeer()

if r.host.Network().Connectedness(p) == inet.Connected {
// we have multiple connections
return
}

r.mx.Lock()
defer r.mx.Unlock()
if _, ok := r.rsvp[p]; ok {
delete(r.rsvp, p)
r.host.ConnManager().UntagPeer(p, "relay")
}
}
Loading