Add retry in process to the promiscuous listener due to failure during boot.

This commit is contained in:
GRMrGecko 2025-01-08 11:53:51 -06:00
parent 74a6b09b97
commit d2fa2a2202
2 changed files with 21 additions and 2 deletions

View File

@ -6,7 +6,7 @@ const (
serviceDisplayName = "Virtual VXLAN"
serviceVendor = "com.mrgeckosmedia"
serviceDescription = "Virtual VXLAN using TUN interfaces"
serviceVersion = "0.1.7"
serviceVersion = "0.1.8"
defaultConfigFile = "config.yaml"
)

View File

@ -7,6 +7,7 @@ import (
"net"
"strings"
"syscall"
"time"
"unsafe"
"github.com/google/gopacket/pcap"
@ -121,7 +122,25 @@ func (p *Promiscuous) tryICMPListen(ifaceIP net.IP) (err error) {
}
// Use listen packet to start a connection.
p.conn, err = cfg.ListenPacket(context.Background(), network, ifaceIP.String())
tries := 0
for {
p.conn, err = cfg.ListenPacket(context.Background(), network, ifaceIP.String())
if err == nil {
break
}
// If the bind address wasn't found on an interface, try again for 5 minutes.
tries++
if tries < 5 {
log.Printf("Error putting interface in promiscuous mode, trying again: %v", err)
time.Sleep(time.Minute)
} else {
// If we passed 5 minutes, we should stop...
break
}
}
// If we failed too many times, stop.
if err != nil {
return
}