mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-02-28 05:32:52 +00:00
🎨 Support configuration of cloud provider connectivity check URL https://github.com/siyuan-note/siyuan/issues/7805
This commit is contained in:
@@ -47,6 +47,7 @@ type S3 struct {
|
||||
PathStyle bool `json:"pathStyle"` // 是否使用路径风格
|
||||
SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证
|
||||
Timeout int `json:"timeout"` // 超时时间,单位:秒
|
||||
CheckURL string `json:"checkURL"` // 连通性检查 URL // https://github.com/siyuan-note/siyuan/issues/7805
|
||||
}
|
||||
|
||||
type WebDAV struct {
|
||||
@@ -55,6 +56,7 @@ type WebDAV struct {
|
||||
Password string `json:"password"` // 密码
|
||||
SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证
|
||||
Timeout int `json:"timeout"` // 超时时间,单位:秒
|
||||
CheckURL string `json:"checkUrl"` // 连通性检查 URL // https://github.com/siyuan-note/siyuan/issues/7805
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -62,3 +64,7 @@ const (
|
||||
ProviderS3 = 2 // ProviderS3 为 S3 协议对象存储提供的云端存储服务
|
||||
ProviderWebDAV = 3 // ProviderWebDAV 为 WebDAV 协议提供的云端存储服务
|
||||
)
|
||||
|
||||
func NewSyncProviderCheckURL() string {
|
||||
return "https://www.baidu.com https://icanhazip.com https://api.ipify.org"
|
||||
}
|
||||
|
||||
@@ -268,11 +268,17 @@ func InitConf() {
|
||||
}
|
||||
Conf.Sync.S3.Endpoint = util.NormalizeEndpoint(Conf.Sync.S3.Endpoint)
|
||||
Conf.Sync.S3.Timeout = util.NormalizeTimeout(Conf.Sync.S3.Timeout)
|
||||
if "" == strings.TrimSpace(Conf.Sync.S3.CheckURL) {
|
||||
Conf.Sync.S3.CheckURL = conf.NewSyncProviderCheckURL()
|
||||
}
|
||||
if nil == Conf.Sync.WebDAV {
|
||||
Conf.Sync.WebDAV = &conf.WebDAV{}
|
||||
}
|
||||
Conf.Sync.WebDAV.Endpoint = util.NormalizeEndpoint(Conf.Sync.WebDAV.Endpoint)
|
||||
Conf.Sync.WebDAV.Timeout = util.NormalizeTimeout(Conf.Sync.WebDAV.Timeout)
|
||||
if "" == strings.TrimSpace(Conf.Sync.WebDAV.CheckURL) {
|
||||
Conf.Sync.WebDAV.CheckURL = conf.NewSyncProviderCheckURL()
|
||||
}
|
||||
|
||||
if nil == Conf.Api {
|
||||
Conf.Api = conf.NewAPI()
|
||||
@@ -297,7 +303,7 @@ func InitConf() {
|
||||
if 0 > Conf.Editor.BacklinkExpandCount {
|
||||
Conf.Editor.BacklinkExpandCount = 0
|
||||
}
|
||||
if 0> Conf.Editor.BackmentionExpandCount {
|
||||
if 0 > Conf.Editor.BackmentionExpandCount {
|
||||
Conf.Editor.BackmentionExpandCount = 0
|
||||
}
|
||||
|
||||
|
||||
@@ -365,6 +365,10 @@ func SetSyncProviderS3(s3 *conf.S3) (err error) {
|
||||
s3.Bucket = strings.TrimSpace(s3.Bucket)
|
||||
s3.Region = strings.TrimSpace(s3.Region)
|
||||
s3.Timeout = util.NormalizeTimeout(s3.Timeout)
|
||||
s3.CheckURL = strings.TrimSpace(s3.CheckURL)
|
||||
if "" == s3.CheckURL {
|
||||
s3.CheckURL = conf.NewSyncProviderCheckURL()
|
||||
}
|
||||
|
||||
Conf.Sync.S3 = s3
|
||||
Conf.Save()
|
||||
@@ -384,6 +388,10 @@ func SetSyncProviderWebDAV(webdav *conf.WebDAV) (err error) {
|
||||
webdav.Username = strings.TrimSpace(webdav.Username)
|
||||
webdav.Password = strings.TrimSpace(webdav.Password)
|
||||
webdav.Timeout = util.NormalizeTimeout(webdav.Timeout)
|
||||
webdav.CheckURL = strings.TrimSpace(webdav.CheckURL)
|
||||
if "" == webdav.CheckURL {
|
||||
webdav.CheckURL = conf.NewSyncProviderCheckURL()
|
||||
}
|
||||
|
||||
Conf.Sync.WebDAV = webdav
|
||||
Conf.Save()
|
||||
|
||||
Reference in New Issue
Block a user