mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +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 {
|
if skipTlsVerify {
|
||||||
c.EnableInsecureSkipVerify()
|
c.EnableInsecureSkipVerify()
|
||||||
}
|
}
|
||||||
|
c.SetUserAgent(UserAgent)
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
resp, err := c.R().Get(checkURL)
|
resp, err := c.R().Get(checkURL)
|
||||||
|
|
@ -66,6 +67,7 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
||||||
case *url.Error:
|
case *url.Error:
|
||||||
if err.(*url.Error).URL != checkURL {
|
if err.(*url.Error).URL != checkURL {
|
||||||
// DNS 重定向
|
// DNS 重定向
|
||||||
|
logging.LogWarnf("network is online [DNS redirect, checkURL=%s, retURL=%s]", checkURL, err.(*url.Error).URL)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -74,6 +76,9 @@ func isOnline(checkURL string, skipTlsVerify bool) (ret bool) {
|
||||||
if ret {
|
if ret {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
logging.LogWarnf("check url [%s] is online failed: %s", checkURL, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue