mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 列出 在浏览器上使用 的 IP 中默认加入 127.0.0.1 https://github.com/siyuan-note/siyuan/issues/5177
This commit is contained in:
parent
df1bba4341
commit
5c0525c359
1 changed files with 7 additions and 2 deletions
|
|
@ -84,12 +84,15 @@ func IsIDPattern(str string) bool {
|
|||
var LocalIPs []string
|
||||
|
||||
func GetLocalIPs() (ret []string) {
|
||||
if 0 < len(LocalIPs) {
|
||||
if "android" == Container {
|
||||
// Android 上用不了 net.InterfaceAddrs() https://github.com/golang/go/issues/40569,所以前面使用启动内核传入的参数 localIPs
|
||||
LocalIPs = append(LocalIPs, "127.0.0.1")
|
||||
LocalIPs = RemoveDuplicatedElem(LocalIPs)
|
||||
return LocalIPs
|
||||
}
|
||||
|
||||
ret = []string{}
|
||||
addrs, err := net.InterfaceAddrs() // Android 上用不了 https://github.com/golang/go/issues/40569,所以前面使用启动内核传入的参数 localIPs
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if nil != err {
|
||||
LogWarnf("get interface addresses failed: %s", err)
|
||||
return
|
||||
|
|
@ -100,6 +103,8 @@ func GetLocalIPs() (ret []string) {
|
|||
ret = append(ret, networkIp.IP.String())
|
||||
}
|
||||
}
|
||||
ret = append(ret, "127.0.0.1")
|
||||
ret = RemoveDuplicatedElem(ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue