🎨 S3/WebDAV 数据同步支持设置跳过 HTTPS 证书验证 Fix https://github.com/siyuan-note/siyuan/issues/6609

This commit is contained in:
Liang Ding 2022-11-16 19:39:15 +08:00
parent f9e670a3f6
commit ad3f7d8964
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 55 additions and 15 deletions

View file

@ -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

View file

@ -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=

View file

@ -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