瀏覽代碼

lib/osutil, lib/upnp: Check FlagRunning (fixes #8767) (#9047)

bt90 2 年之前
父節點
當前提交
c2c6133aa5
共有 2 個文件被更改,包括 2 次插入3 次删除
  1. 1 1
      lib/osutil/net.go
  2. 1 2
      lib/upnp/upnp.go

+ 1 - 1
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()

+ 1 - 2
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
 		}