Skip to content

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

:art: 网络没有连通时记录日志

Liang Ding3826741cf159
diff --git a/kernel/util/net.go b/kernel/util/net.go
index fde90eae53..6a6ca030a2 100644
--- a/kernel/util/net.go
+++ b/kernel/util/net.go
@@ -17,19 +17,20 @@
package util
import (
- "github.com/88250/lute/ast"
- "github.com/imroc/req/v3"
- "github.com/siyuan-note/httpclient"
"net/http"
"strings"
"time"
"github.com/88250/gulu"
+ "github.com/88250/lute/ast"
"github.com/gin-gonic/gin"
+ "github.com/imroc/req/v3"
"github.com/olahol/melody"
+ "github.com/siyuan-note/httpclient"
+ "github.com/siyuan-note/logging"
)
-func IsOnline() bool {
+func IsOnline() (ret bool) {
c := req.C().SetTimeout(1 * time.Second)
resp, err := c.R().Head("https://www.baidu.com")
if nil != err {
@@ -38,7 +39,12 @@ func IsOnline() bool {
resp, err = c.R().Head("https://api.ipify.org")
}
}
- return nil == err && nil != resp && nil != resp.Response
+
+ ret = nil == err && nil != resp && nil != resp.Response
+ if !ret {
+ logging.LogWarnf("network is offline")
+ }
+ return
}
func GetRemoteAddr(session *melody.Session) string {