Accept exchanging an MTU of 0 to signify that TUN/TAP is disabled, don't send traffic to a node in that case

This commit is contained in:
Neil Alexander 2018-05-18 18:56:33 +01:00
parent ec371af84f
commit ca96bbf014
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 40 additions and 1 deletions

View file

@ -65,7 +65,7 @@ func (s *sessionInfo) update(p *sessionPing) bool {
s.theirNonce = boxNonce{}
s.nonceMask = 0
}
if p.mtu >= 1280 {
if p.mtu >= 1280 || p.mtu == 0 {
s.theirMTU = p.mtu
}
s.coords = append([]byte{}, p.coords...)
@ -313,6 +313,9 @@ func (n *boxNonce) minus(m *boxNonce) int64 {
}
func (sinfo *sessionInfo) getMTU() uint16 {
if sinfo.theirMTU == 0 || sinfo.myMTU == 0 {
return 0
}
if sinfo.theirMTU < sinfo.myMTU {
return sinfo.theirMTU
}