A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
at lambda-fork/main 92 lines 4.2 kB view raw
1// SiYuan - Refactor your thinking 2// Copyright (c) 2020-present, b3log.org 3// 4// This program is free software: you can redistribute it and/or modify 5// it under the terms of the GNU Affero General Public License as published by 6// the Free Software Foundation, either version 3 of the License, or 7// (at your option) any later version. 8// 9// This program is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU Affero General Public License for more details. 13// 14// You should have received a copy of the GNU Affero General Public License 15// along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17package conf 18 19type Sync struct { 20 CloudName string `json:"cloudName"` // 云端同步目录名称 21 Enabled bool `json:"enabled"` // 是否开启同步 22 Perception bool `json:"perception"` // 是否开启感知 23 Mode int `json:"mode"` // 同步模式,0:未设置(为兼容已有配置,initConf 函数中会转换为 1),1:自动,2:手动 https://github.com/siyuan-note/siyuan/issues/5089,3:完全手动 https://github.com/siyuan-note/siyuan/issues/7295 24 Interval int `json:"interval"` // 自动同步间隔,单位:秒 25 Synced int64 `json:"synced"` // 最近同步时间 26 Stat string `json:"stat"` // 最近同步统计信息 27 GenerateConflictDoc bool `json:"generateConflictDoc"` // 云端同步冲突时是否生成冲突文档 28 Provider int `json:"provider"` // 云端存储服务提供者 29 S3 *S3 `json:"s3"` // S3 对象存储服务配置 30 WebDAV *WebDAV `json:"webdav"` // WebDAV 服务配置 31 Local *Local `json:"local"` // 本地文件系统 服务配置 32} 33 34func NewSync() *Sync { 35 return &Sync{ 36 CloudName: "main", 37 Enabled: false, 38 Perception: false, 39 Mode: 1, 40 GenerateConflictDoc: false, 41 Provider: ProviderSiYuan, 42 Interval: 30, 43 } 44} 45 46type S3 struct { 47 Endpoint string `json:"endpoint"` // 服务端点 48 AccessKey string `json:"accessKey"` // Access Key 49 SecretKey string `json:"secretKey"` // Secret Key 50 Bucket string `json:"bucket"` // 存储空间 51 Region string `json:"region"` // 存储区域 52 PathStyle bool `json:"pathStyle"` // 是否使用路径风格 53 SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证 54 Timeout int `json:"timeout"` // 超时时间,单位:秒 55 ConcurrentReqs int `json:"concurrentReqs"` // 并发请求数 56} 57 58type WebDAV struct { 59 Endpoint string `json:"endpoint"` // 服务端点 60 Username string `json:"username"` // 用户名 61 Password string `json:"password"` // 密码 62 SkipTlsVerify bool `json:"skipTlsVerify"` // 是否跳过 TLS 验证 63 Timeout int `json:"timeout"` // 超时时间,单位:秒 64 ConcurrentReqs int `json:"concurrentReqs"` // 并发请求数 65} 66 67type Local struct { 68 Endpoint string `json:"endpoint"` // 服务端点 (本地文件系统目录) 69 Timeout int `json:"timeout"` // 超时时间,单位:秒 70 ConcurrentReqs int `json:"concurrentReqs"` // 并发请求数 71} 72 73const ( 74 ProviderSiYuan = 0 // ProviderSiYuan 为思源官方提供的云端存储服务 75 ProviderS3 = 2 // ProviderS3 为 S3 协议对象存储提供的云端存储服务 76 ProviderWebDAV = 3 // ProviderWebDAV 为 WebDAV 协议提供的云端存储服务 77 ProviderLocal = 4 // ProviderLocal 为本地文件系统提供的存储服务 78) 79 80func ProviderToStr(provider int) string { 81 switch provider { 82 case ProviderSiYuan: 83 return "SiYuan" 84 case ProviderS3: 85 return "S3" 86 case ProviderWebDAV: 87 return "WebDAV" 88 case ProviderLocal: 89 return "Local File System" 90 } 91 return "Unknown" 92}