mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve data sync network connectivity check Fix https://github.com/siyuan-note/siyuan/issues/9251
This commit is contained in:
parent
f5f9b1a393
commit
388ab0a352
1 changed files with 5 additions and 0 deletions
|
|
@ -55,6 +55,7 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
|||
if skipTlsVerify {
|
||||
c.EnableInsecureSkipVerify()
|
||||
}
|
||||
c.SetUserAgent(UserAgent)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
resp, err := c.R().Get(checkURL)
|
||||
|
|
@ -66,6 +67,7 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
|||
case *url.Error:
|
||||
if err.(*url.Error).URL != checkURL {
|
||||
// DNS 重定向
|
||||
logging.LogWarnf("network is online [DNS redirect, checkURL=%s, retURL=%s]", checkURL, err.(*url.Error).URL)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +76,9 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
|||
if ret {
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
logging.LogWarnf("check url [%s] is online failed: %s", checkURL, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue