Repository: syncthing/syncthing (language: go)

Issue:
Check interface for FlagRunning
As of #7458 we're checking if an interface is considered up. Go 1.20 added an additional flag which would be more useful:

> [Interface.Flags](https://go.dev/pkg/net/#Interface.Flags) now includes the new flag FlagRunning, indicating an operationally active interface. An interface which is administratively configured but not active (for example, because the network cable is not connected) will have FlagUp set but not FlagRunning.


Discussion / hints:

Fix patch:
diff --git a/lib/osutil/net.go b/lib/osutil/net.go
index 214284cf5f0..eeb8bafde26 100644
--- a/lib/osutil/net.go
+++ b/lib/osutil/net.go
@@ -18,7 +18,7 @@ func GetLans() ([]*net.IPNet, error) {
 	var addrs []net.Addr
 
 	for _, currentIf := range ifs {
-		if currentIf.Flags&net.FlagUp != net.FlagUp {
+		if currentIf.Flags&net.FlagRunning == 0 {
 			continue
 		}
 		currentAddrs, err := currentIf.Addrs()
diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go
index 0553dd9eb05..d566ce0e45d 100644
--- a/lib/upnp/upnp.go
+++ b/lib/upnp/upnp.go
@@ -47,7 +47,6 @@ import (
 	"sync"
 	"time"
 
-	"github.com/syncthing/syncthing/lib/build"
 	"github.com/syncthing/syncthing/lib/dialer"
 	"github.com/syncthing/syncthing/lib/nat"
 	"github.com/syncthing/syncthing/lib/osutil"
@@ -100,7 +99,7 @@ func Discover(ctx context.Context, _, timeout time.Duration) []nat.Device {
 
 	for _, intf := range interfaces {
 		// Interface flags seem to always be 0 on Windows
-		if !build.IsWindows && (intf.Flags&net.FlagUp == 0 || intf.Flags&net.FlagMulticast == 0) {
+		if intf.Flags&net.FlagRunning == 0 || intf.Flags&net.FlagMulticast == 0 {
 			continue
 		}
 


Test patch: