Skip to content

Commit

Permalink
fix(connections): announce PtP links again (fixes syncthing#9730) (sy…
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh authored Sep 23, 2024
1 parent 3e501d9 commit a8e2c8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/connections/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func (s *lanChecker) isLAN(addr net.Addr) bool {
}
}

lans, err := osutil.GetLans()
lans, err := osutil.GetInterfaceAddrs(false)
if err != nil {
l.Debugln("Failed to retrieve interface IPs:", err)
priv := ip.IsPrivate()
Expand Down
2 changes: 1 addition & 1 deletion lib/connections/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func getURLsForAllAdaptersIfUnspecified(network string, uri *url.URL) []*url.URL
}

func getHostPortsForAllAdapters(port int) []string {
nets, err := osutil.GetLans()
nets, err := osutil.GetInterfaceAddrs(true)
if err != nil {
// Ignore failure.
return nil
Expand Down
6 changes: 4 additions & 2 deletions lib/osutil/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
"net"
)

func GetLans() ([]*net.IPNet, error) {
// GetInterfaceAddrs returns the IP networks of all interfaces that are up.
// Point-to-point interfaces are exluded unless includePtP is true.
func GetInterfaceAddrs(includePtP bool) ([]*net.IPNet, error) {
intfs, err := net.Interfaces()
if err != nil {
return nil, err
Expand All @@ -21,7 +23,7 @@ func GetLans() ([]*net.IPNet, error) {
if intf.Flags&net.FlagRunning == 0 {
continue
}
if intf.Flags&net.FlagPointToPoint != 0 {
if !includePtP && intf.Flags&net.FlagPointToPoint != 0 {
// Point-to-point interfaces are typically VPNs and similar
// which, for our purposes, do not qualify as LANs.
continue
Expand Down

0 comments on commit a8e2c8e

Please sign in to comment.