Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 列出 `在浏览器上使用` 的 IP 中默认加入 `127.0.0.1` https://github.com/siyuan-note/siyuan/issues/5177

Liang Ding5c0525c359e8
diff --git a/kernel/util/path.go b/kernel/util/path.go
index d127f7f17e..80a793c303 100644
--- a/kernel/util/path.go
+++ b/kernel/util/path.go
@@ -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
}