Merge branch 'master' into new-torrent

This commit is contained in:
nikk gitanes
2021-09-13 08:14:24 +03:00

View File

@@ -7,6 +7,7 @@ import (
"os"
"os/user"
"path/filepath"
"runtime"
"time"
"github.com/anacrolix/dms/dlna/dms"
@@ -27,10 +28,12 @@ func Start() {
log.TLogln(err)
os.Exit(1)
}
for _, element := range ifaces {
if element.Flags&net.FlagLoopback == 0 && element.Flags&net.FlagUp == net.FlagUp && element.Flags&net.FlagMulticast == net.FlagMulticast && utils.IsPhysicalInterface(element.HardwareAddr.String()) {
ifs = append(ifs, element)
for _, i := range ifaces {
// interface flags seem to always be 0 on Windows
if runtime.GOOS != "windows" && (i.Flags&net.FlagLoopback != 0 || i.Flags&net.FlagUp == 0 || i.Flags&net.FlagMulticast == 0) || !utils.IsPhysicalInterface(i.HardwareAddr.String()) {
continue
}
ifs = append(ifs, i)
}
return
}(),
@@ -164,8 +167,11 @@ func getDefaultFriendlyName() string {
}
var list []string
for _, i := range ifaces {
// interface flags seem to always be 0 on Windows
if runtime.GOOS != "windows" && (i.Flags&net.FlagLoopback != 0 || i.Flags&net.FlagUp == 0 || i.Flags&net.FlagMulticast == 0) || !utils.IsPhysicalInterface(i.HardwareAddr.String()) {
continue
}
addrs, _ := i.Addrs()
if i.Flags&net.FlagLoopback == 0 && i.Flags&net.FlagUp == net.FlagUp && i.Flags&net.FlagMulticast == net.FlagMulticast && utils.IsPhysicalInterface(i.HardwareAddr.String()) {
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
@@ -174,12 +180,11 @@ func getDefaultFriendlyName() string {
case *net.IPAddr:
ip = v.IP
}
if !ip.IsLoopback() {
if !ip.IsLoopback() && ip.To4() != nil {
list = append(list, ip.String())
}
}
}
}
if len(list) > 0 {
return ret + " " + list[0]
}