diff --git a/app/src/config/repos.ts b/app/src/config/repos.ts index 7ee5ac459..a6db061eb 100644 --- a/app/src/config/repos.ts +++ b/app/src/config/repos.ts @@ -77,6 +77,14 @@ const renderProvider = (provider: number) => { + +
+
TLS verify
+
+
`; } return `${tip} @@ -112,6 +120,14 @@ const renderProvider = (provider: number) => { + +`; } else if (provider === 3) { const tip = `
@@ -137,6 +153,14 @@ const renderProvider = (provider: number) => {
Password
+
+
+
TLS verify
+
+
`; } return `${tip} @@ -154,6 +178,14 @@ const renderProvider = (provider: number) => {
Password
+ +`; } return ""; @@ -222,6 +254,7 @@ const bindProviderEvent = () => { bucket: (providerPanelElement.querySelector("#bucket") as HTMLInputElement).value, pathStyle: (providerPanelElement.querySelector("#pathStyle") as HTMLInputElement).value === "true", region: (providerPanelElement.querySelector("#region") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#s3SkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderS3", {s3}, () => { window.siyuan.config.sync.s3 = s3; @@ -231,6 +264,7 @@ const bindProviderEvent = () => { endpoint: (providerPanelElement.querySelector("#endpoint") as HTMLInputElement).value, username: (providerPanelElement.querySelector("#username") as HTMLInputElement).value, password: (providerPanelElement.querySelector("#password") as HTMLInputElement).value, + skipTlsVerify: (providerPanelElement.querySelector("#webdavSkipTlsVerify") as HTMLInputElement).value === "true", }; fetchPost("/api/sync/setSyncProviderWebDAV", {webdav}, () => { window.siyuan.config.sync.webdav = webdav; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 9f5c2ea15..554faa45e 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -340,11 +340,13 @@ declare interface IConfig { secretKey: string bucket: string region: string + skipTlsVerify: boolean } webdav: { endpoint: string username: string password: string + skipTlsVerify: boolean } }, lang: string diff --git a/kernel/go.mod b/kernel/go.mod index 8f8de19b3..a998cab6d 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -36,7 +36,7 @@ require ( github.com/panjf2000/ants/v2 v2.6.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/radovskyb/watcher v1.0.7 - github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 + github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef diff --git a/kernel/go.sum b/kernel/go.sum index 7fcc2e2e7..b9bdab187 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -359,8 +359,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5 h1:m4+9OWYEKS832LJ9E1eAiUz0ATQAUo7gFs7E5S9JSho= -github.com/siyuan-note/dejavu v0.0.0-20221116031102-5d5af638b8e5/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e h1:gwI3Zo+ce5GPZlau8kMcUipZwY1yJFjeG8ghwxB6YW4= +github.com/siyuan-note/dejavu v0.0.0-20221116103627-5fbf73fe103e/go.mod h1:PiWhnZhdVqhY0FifDg6kXwn75V97Dg3U/nFeD76fBis= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE= github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw= github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90= diff --git a/kernel/model/repository.go b/kernel/model/repository.go index e35f5b1a6..9ff57f12f 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -828,7 +828,7 @@ func newRepository() (ret *dejavu.Repo, err error) { s3HTTPClient.Timeout = 30 * time.Second cloudRepo = cloud.NewS3(&cloud.BaseCloud{Conf: cloudConf}, s3HTTPClient) case conf.ProviderWebDAV: - webdavClient := gowebdav.NewClient(cloudConf.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password) + webdavClient := gowebdav.NewClient(cloudConf.WebDAV.Endpoint, cloudConf.WebDAV.Username, cloudConf.WebDAV.Password) a := cloudConf.WebDAV.Username + ":" + cloudConf.WebDAV.Password auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a)) webdavClient.SetHeader("Authorization", auth) @@ -1049,18 +1049,22 @@ func buildCloudConf() (ret *cloud.Conf, err error) { case conf.ProviderSiYuan: ret.Endpoint = "https://siyuan-data.b3logfile.com/" case conf.ProviderS3: - ret.Endpoint = Conf.Sync.S3.Endpoint - ret.S3.AccessKey = Conf.Sync.S3.AccessKey - ret.S3.SecretKey = Conf.Sync.S3.SecretKey - ret.S3.Bucket = Conf.Sync.S3.Bucket - ret.S3.Region = Conf.Sync.S3.Region - ret.S3.PathStyle = Conf.Sync.S3.PathStyle - ret.S3.SkipTlsVerify = Conf.Sync.S3.SkipTlsVerify + ret.S3 = &cloud.ConfS3{ + Endpoint: Conf.Sync.S3.Endpoint, + AccessKey: Conf.Sync.S3.AccessKey, + SecretKey: Conf.Sync.S3.SecretKey, + Bucket: Conf.Sync.S3.Bucket, + Region: Conf.Sync.S3.Region, + PathStyle: Conf.Sync.S3.PathStyle, + SkipTlsVerify: Conf.Sync.S3.SkipTlsVerify, + } case conf.ProviderWebDAV: - ret.Endpoint = Conf.Sync.WebDAV.Endpoint - ret.WebDAV.Username = Conf.Sync.WebDAV.Username - ret.WebDAV.Password = Conf.Sync.WebDAV.Password - ret.WebDAV.SkipTlsVerify = Conf.Sync.WebDAV.SkipTlsVerify + ret.WebDAV = &cloud.ConfWebDAV{ + Endpoint: Conf.Sync.WebDAV.Endpoint, + Username: Conf.Sync.WebDAV.Username, + Password: Conf.Sync.WebDAV.Password, + SkipTlsVerify: Conf.Sync.WebDAV.SkipTlsVerify, + } default: err = fmt.Errorf("invalid provider [%d]", Conf.Sync.Provider) return