mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-10 07:20:39 +03:00
Check CKR routes when receiving packets in router
This commit is contained in:
parent
87b0f5fe24
commit
c7f2427de1
@ -253,7 +253,7 @@ func (r *router) sendPacket(bs []byte) {
|
||||
|
||||
// Called for incoming traffic by the session worker for that connection.
|
||||
// Checks that the IP address is correct (matches the session) and passes the packet to the tun/tap.
|
||||
func (r *router) recvPacket(bs []byte, theirAddr *address, theirSubnet *subnet) {
|
||||
func (r *router) recvPacket(bs []byte, sinfo *sessionInfo) {
|
||||
// Note: called directly by the session worker, not the router goroutine
|
||||
if len(bs) < 24 {
|
||||
util_putBytes(bs)
|
||||
@ -264,12 +264,15 @@ func (r *router) recvPacket(bs []byte, theirAddr *address, theirSubnet *subnet)
|
||||
var snet subnet
|
||||
copy(snet[:], bs[8:])
|
||||
switch {
|
||||
case source.isValid() && source == *theirAddr:
|
||||
case snet.isValid() && snet == *theirSubnet:
|
||||
case source.isValid() && source == sinfo.theirAddr:
|
||||
case snet.isValid() && snet == sinfo.theirSubnet:
|
||||
default:
|
||||
key, err := r.cryptokey.getPublicKeyForAddress(source)
|
||||
if err != nil || key != sinfo.theirPermPub {
|
||||
util_putBytes(bs)
|
||||
return
|
||||
}
|
||||
}
|
||||
//go func() { r.recv<-bs }()
|
||||
r.recv <- bs
|
||||
}
|
||||
|
@ -589,5 +589,5 @@ func (sinfo *sessionInfo) doRecv(p *wire_trafficPacket) {
|
||||
sinfo.updateNonce(&p.Nonce)
|
||||
sinfo.time = time.Now()
|
||||
sinfo.bytesRecvd += uint64(len(bs))
|
||||
sinfo.core.router.recvPacket(bs, &sinfo.theirAddr, &sinfo.theirSubnet)
|
||||
sinfo.core.router.recvPacket(bs, sinfo)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user