dlna icons: looks like order matters

and avoid useless localhost - use 1st IP instead
This commit is contained in:
nikk gitanes
2021-08-26 14:14:42 +03:00
parent e331e38453
commit c9b8112c4c

View File

@@ -40,13 +40,6 @@ func Start() {
NoTranscode: true,
NoProbe: true,
Icons: []dms.Icon{
dms.Icon{
Width: 192,
Height: 192,
Depth: 32,
Mimetype: "image/png",
ReadSeeker: bytes.NewReader(template.Androidchrome192x192png),
},
dms.Icon{
Width: 32,
Height: 32,
@@ -54,6 +47,13 @@ func Start() {
Mimetype: "image/png",
ReadSeeker: bytes.NewReader(template.Favicon32x32png),
},
dms.Icon{
Width: 192,
Height: 192,
Depth: 32,
Mimetype: "image/png",
ReadSeeker: bytes.NewReader(template.Androidchrome192x192png),
},
},
NotifyInterval: 30 * time.Second,
AllowedIpNets: func() []*net.IPNet {
@@ -129,5 +129,33 @@ func getDefaultFriendlyName() string {
}
return ret + ": " + userName + " on " + host
}
return ret + ": " + userName + host
if host == "localhost" { // useless host, use 1st IP
ifaces, err := net.Interfaces()
if err != nil {
return ret + ": " + userName + "@" + host
}
var list []string
for _, i := range ifaces {
addrs, _ := i.Addrs()
if i.Flags&net.FlagUp == net.FlagUp {
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
ip = v.IP
}
if !ip.IsLoopback() {
list = append(list, ip.String())
}
}
}
}
if len(list) > 0 {
return ret + " • " + list[0]
}
}
return ret + ": " + userName + "@" + host
}