From d2fa2a220205ec046f14137d9796614b8b8cd40b Mon Sep 17 00:00:00 2001 From: GRMrGecko Date: Wed, 8 Jan 2025 11:53:51 -0600 Subject: [PATCH] Add retry in process to the promiscuous listener due to failure during boot. --- main.go | 2 +- promiscuous_windows.go | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a9f93b4..c77b249 100644 --- a/main.go +++ b/main.go @@ -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" ) diff --git a/promiscuous_windows.go b/promiscuous_windows.go index 6bf7344..f64135d 100644 --- a/promiscuous_windows.go +++ b/promiscuous_windows.go @@ -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 }