mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
add a dedicated switch worker and start using it for lookups
This commit is contained in:
parent
2ae213c255
commit
988f4ad265
4 changed files with 53 additions and 22 deletions
|
@ -229,19 +229,7 @@ func (p *peer) handleTraffic(packet []byte, pTypeLen int) {
|
|||
// Drop traffic until the peer manages to send us at least one good switchMsg
|
||||
return
|
||||
}
|
||||
coords, coordLen := wire_decode_coords(packet[pTypeLen:])
|
||||
if coordLen >= len(packet) {
|
||||
return
|
||||
} // No payload
|
||||
toPort := p.core.switchTable.lookup(coords)
|
||||
if toPort == p.port {
|
||||
return
|
||||
}
|
||||
to := p.core.peers.getPorts()[toPort]
|
||||
if to == nil {
|
||||
return
|
||||
}
|
||||
to.sendPacket(packet)
|
||||
p.core.switchTable.packetIn <- packet
|
||||
}
|
||||
|
||||
// This just calls p.out(packet) for now.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue