check root before accepting that a message is good and unblocking a new peer

This commit is contained in:
Arceliar 2018-06-08 17:33:16 -05:00
parent f30d040366
commit 1dcc60f054
2 changed files with 28 additions and 0 deletions

View file

@ -297,6 +297,13 @@ func (p *peer) handleSwitchMsg(packet []byte) {
prevKey = hop.Next
}
p.core.switchTable.handleMsg(&msg, p.port)
if !p.core.switchTable.checkRoot(&msg) {
// Bad switch message
// Stop forwarding traffic from it
// Stop refreshing it in the DHT
p.dinfo = nil
return
}
// Pass a mesage to the dht informing it that this peer (still) exists
loc.coords = loc.coords[:len(loc.coords)-1]
dinfo := dhtInfo{