Fix RetryPeersNow, move startup logging, don't set TUN address if not available

This commit is contained in:
Neil Alexander 2023-10-22 15:51:30 +01:00
parent 955aa4af79
commit 094f80f39c
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
9 changed files with 43 additions and 16 deletions

View file

@ -44,7 +44,7 @@ type TunAdapter struct {
isOpen bool
isEnabled bool // Used by the writer to drop sessionTraffic if not enabled
config struct {
fd int32
fd int32
name InterfaceName
mtu InterfaceMTU
}
@ -116,7 +116,10 @@ func (tun *TunAdapter) _start() error {
tun.addr = tun.rwc.Address()
tun.subnet = tun.rwc.Subnet()
prefix := address.GetPrefix()
addr := fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(prefix[:])-1)
var addr string
if tun.addr.IsValid() {
addr = fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(prefix[:])-1)
}
if tun.config.name == "none" || tun.config.name == "dummy" {
tun.log.Debugln("Not starting TUN as ifname is none or dummy")
tun.isEnabled = false