Documentation
¶
Index ¶
- Constants
- Variables
- func AutoSetCacheDir()
- func DefaultConfigLocation() string
- func DeleteConfigIn(in string) error
- func GetConfigDir() (dir string, err error)
- func GetHomeDirectoryConfig() string
- func GetJwtSigningKey() string
- func GetProgramDirectoryConfig() string
- func GetQrcodeURL() string
- func GetVersion() string
- func GetWorkingDirectoryConfig() string
- func SaveConfig(to string) error
- func SetByExecutableFilename()
- func SetPort(port int)
- func SetUploadPath(path string)
- func UpdateConfigByJson(jsonString string) error
- func UpdateConfigFile() error
- type Config
- func (c *Config) AddStoreUrl(storeURL string) error
- func (c *Config) AddStringArrayConfig(fieldName, addValue string) ([]string, error)
- func (c *Config) DeleteStringArrayConfig(fieldName, deleteValue string) ([]string, error)
- func (c *Config) GetClearDatabaseWhenExit() bool
- func (c *Config) GetDebug() bool
- func (c *Config) GetEnableDatabase() bool
- func (c *Config) GetEnableUpload() bool
- func (c *Config) GetExcludePath() []string
- func (c *Config) GetHost() string
- func (c *Config) GetMaxScanDepth() int
- func (c *Config) GetMinImageNum() int
- func (c *Config) GetPort() int
- func (c *Config) GetStoreUrls() []string
- func (c *Config) GetSupportFileType() []string
- func (c *Config) GetSupportMediaType() []string
- func (c *Config) GetSupportTemplateFile() []string
- func (c *Config) GetTimeoutLimitForScan() int
- func (c *Config) GetTopStoreName() string
- func (c *Config) GetZipFileTextEncoding() string
- func (c *Config) InitStoreUrls()
- func (c *Config) RequiresAuth() bool
- func (c *Config) SetConfigValue(fieldName, fieldValue string) error
- func (c *Config) StoreUrlIsExits(url string) bool
- type FrpClientConfig
- type Status
- type UploadDirOption
- type WebPServerConfig
Constants ¶
View Source
const ( HomeDirectory = "HomeDirectory" WorkingDirectory = "WorkingDirectory" ProgramDirectory = "ProgramDirectory" )
Variables ¶
View Source
var ( Server *http.Server Mutex sync.Mutex )
View Source
var CfgStatus = Status{}
Functions ¶
func AutoSetCacheDir ¶ added in v1.1.0
func AutoSetCacheDir()
func DefaultConfigLocation ¶ added in v1.0.0
func DefaultConfigLocation() string
DefaultConfigLocation 判断当前配置文件应该保存到哪里。 逻辑:
- 是否在HomeDirectory已有 config.toml
- 否则是否在WorkingDirectory已有 config.toml
- 否则是否在ProgramDirectory已有 config.toml 若都没有,则返回 "HomeDirectory"。
返回:location字符串
func DeleteConfigIn ¶
func GetConfigDir ¶ added in v1.1.0
GetConfigDir 获取配置文件所在目录
func GetHomeDirectoryConfig ¶ added in v1.0.0
func GetHomeDirectoryConfig() string
func GetJwtSigningKey ¶ added in v1.0.0
func GetJwtSigningKey() string
GetJwtSigningKey JWT令牌签名key,目前是用户名+密码(如果两者都设置了的话)
func GetProgramDirectoryConfig ¶ added in v1.0.0
func GetProgramDirectoryConfig() string
func GetQrcodeURL ¶
func GetQrcodeURL() string
func GetVersion ¶ added in v1.0.0
func GetVersion() string
func GetWorkingDirectoryConfig ¶ added in v1.0.0
func GetWorkingDirectoryConfig() string
func SaveConfig ¶
func SetByExecutableFilename ¶ added in v1.0.0
func SetByExecutableFilename()
SetByExecutableFilename 通过执行文件名设置默认网页模板参数
func SetUploadPath ¶ added in v1.0.0
func SetUploadPath(path string)
func UpdateConfigByJson ¶ added in v1.0.0
UpdateConfigByJson 使用 JSON 字符串反序列化将更新的配置解析为映射,遍历映射并更新配置,减少重复的代码。
func UpdateConfigFile ¶ added in v1.1.0
func UpdateConfigFile() error
UpdateConfigFile 如果存在本地配置,更新本地配置
Types ¶
type Config ¶
type Config struct {
AutoRescan bool `json:"AutoRescan" comment:"刷新页面时,是否自动重新扫描书籍是否存在"`
CacheDir string `json:"CacheDir" comment:"本地图片缓存位置,默认系统临时文件夹"`
CertFile string `json:"CertFile" comment:"TLS/SSL 证书文件路径 (default: ~/.config/.comigo/cert.crt)"`
ClearCacheExit bool `json:"ClearCacheExit" comment:"退出程序的时候,清理web图片缓存"`
ClearDatabaseWhenExit bool `json:"ClearDatabaseWhenExit" comment:"启用本地数据库时,扫描完成后,清除不存在的书籍。"`
ConfigFile string `json:"-" toml:"-" comment:"用户指定的的yaml设置文件路径"`
ConfigLocked bool `json:"ConfigLocked" comment:"配置文件锁定,防止被网页端修改,用于展示模式"`
Debug bool `json:"Debug" comment:"开启Debug模式"`
DefaultMode string `json:"DefaultMode" comment:"默认阅读模式,默认为空,可以设置为scroll或flip"`
DisableLAN bool `json:"DisableLAN" comment:"只在本机提供阅读服务,不对外共享"`
EnableDatabase bool `json:"EnableDatabase" comment:"启用本地数据库,保存扫描到的书籍数据。"`
EnableTLS bool `json:"EnableTLS" comment:"是否启用HTTPS协议。需要设置证书于key文件。"`
EnableUpload bool `json:"EnableUpload" comment:"启用上传功能"`
ExcludePath []string `json:"ExcludePath" comment:"扫描书籍的时候,需要排除的文件或文件夹的名字"`
GenerateMetaData bool `json:"GenerateMetaData" toml:"GenerateMetaData" comment:"生成书籍元数据"`
Host string `json:"Host" comment:"自定义二维码显示的主机名"`
KeyFile string `json:"KeyFile" comment:"TLS/SSL key文件路径 (default: ~/.config/.comigo/key.key)"`
StoreUrls []string `json:"StoreUrls" comment:"本地书库路径列表,支持多个路径。可以是本地文件夹或网络书库地址。"` // 书库地址列表
LogFileName string `json:"LogFileName" comment:"Log文件名"`
LogFilePath string `json:"LogFilePath" comment:"Log文件的保存位置"`
LogToFile bool `json:"LogToFile" comment:"是否保存程序Log到本地文件。默认不保存。"`
MaxScanDepth int `json:"MaxScanDepth" comment:"最大扫描深度"`
MinImageNum int `json:"MinImageNum" comment:"压缩包或文件夹内,至少有几张图片,才算作书籍"`
OpenBrowser bool `json:"OpenBrowser" comment:"是否同时打开浏览器,windows默认true,其他默认false"`
Password string `json:"Password" comment:"登录界面需要的密码。"`
Port int `` /* 279-byte string literal not displayed */
PrintAllPossibleQRCode bool `json:"PrintAllPossibleQRCode" comment:"扫描完成后,打印所有可能的阅读链接二维码"`
SupportFileType []string `json:"SupportFileType" comment:"支持的书籍压缩包后缀"`
SupportMediaType []string `json:"SupportMediaType" comment:"扫描压缩包时,用于统计图片数量的图片文件后缀"`
SupportTemplateFile []string `json:"SupportTemplateFile" comment:"支持的模板文件类型,默认为html"`
Timeout int `json:"Timeout" comment:"cookie过期的时间。单位为分钟。默认60*24*30分钟后过期。"`
TimeoutLimitForScan int `` /* 130-byte string literal not displayed */
UploadDirOption UploadDirOption `` /* 132-byte string literal not displayed */
UploadPath string `json:"UploadPath" comment:"指定上传路径时,上传文件的存储位置"`
UseCache bool `json:"UseCache" comment:"开启本地图片缓存,可以加快二次读取,但会占用硬盘空间"`
Username string `json:"Username" comment:"登录界用的用户名。"`
EnableTailscale bool `json:"EnableTailscale" comment:"启用Tailscale网络支持"`
TailscaleHostname string `json:"TailscaleHostname" comment:"Tailscale网络的主机名,默认为comigo"`
FunnelTunnel bool `json:"FunnelTunnel" comment:"启用Tailscale的Funnel模式,允许通过Tailscale公开comigo服务到公网。"`
FunnelLoginCheck bool `json:"funnel_enforce_password" comment:"启用Funnel模式时,强制要求使用密码登录comigo服务。"`
TailscalePort int `json:"TailscalePort" comment:"Tailscale网络的端口,默认为443"`
TailscaleAuthKey string `` /* 142-byte string literal not displayed */
ZipFileTextEncoding string `json:"ZipFileTextEncoding" comment:"非utf-8编码的ZIP文件,尝试用什么编码解析,默认GBK"`
}
Config Comigo全局配置
func (*Config) AddStoreUrl ¶ added in v1.1.0
AddStoreUrl 添加本地书库(单个路径)
func (*Config) AddStringArrayConfig ¶ added in v1.0.0
AddStringArrayConfig 往指定的 []string 字段中添加一个新字符串
func (*Config) DeleteStringArrayConfig ¶ added in v1.0.0
DeleteStringArrayConfig 从指定的 []string 字段中删除某个字符串
func (*Config) GetClearDatabaseWhenExit ¶ added in v1.0.0
func (*Config) GetEnableDatabase ¶ added in v1.0.0
func (*Config) GetEnableUpload ¶ added in v1.1.0
func (*Config) GetExcludePath ¶ added in v1.0.0
func (*Config) GetMaxScanDepth ¶ added in v1.0.0
func (*Config) GetMinImageNum ¶ added in v1.0.0
func (*Config) GetStoreUrls ¶ added in v1.1.0
func (*Config) GetSupportFileType ¶ added in v1.0.0
func (*Config) GetSupportMediaType ¶ added in v1.0.0
func (*Config) GetSupportTemplateFile ¶ added in v1.0.0
func (*Config) GetTimeoutLimitForScan ¶ added in v1.0.0
func (*Config) GetTopStoreName ¶ added in v1.0.0
func (*Config) GetZipFileTextEncoding ¶ added in v1.0.0
func (*Config) InitStoreUrls ¶ added in v1.1.0
func (c *Config) InitStoreUrls()
InitStoreUrls 初始化配置文件中的书库
func (*Config) RequiresAuth ¶ added in v1.1.0
RequiresAuth 是否需要登录
func (*Config) SetConfigValue ¶ added in v1.0.0
SetConfigValue 更新 Config 的相应字段,如果【fieldName】不存在、或【fieldValue】类型有问题,都返回错误。
func (*Config) StoreUrlIsExits ¶ added in v1.1.0
StoreUrlIsExits 检查书库URL是否可添加
type FrpClientConfig ¶ added in v1.0.0
type FrpClientConfig struct {
FrpcCommand string `comment:"手动设定frpc可执行程序的路径,默认为frpc"`
ServerAddr string
ServerPort int
Token string
FrpType string // 本地转发端口设置
RemotePort int
RandomRemotePort bool
}
FrpClientConfig frp客户端配置
type Status ¶
type Status struct {
// 当前生效的配置文件路径 None、HomeDirectory、WorkingDirectory、ProgramDirectory
// 设置读取顺序:None(默认值) -> HomeDirectory -> ProgramDirectory -> WorkingDirectory
In string
Path struct {
// 对应配置文件的绝对路径
WorkingDirectory string
HomeDirectory string
ProgramDirectory string
}
}
func (*Status) SetConfigStatus ¶ added in v1.0.0
type UploadDirOption ¶ added in v1.0.0
type UploadDirOption int
Click to show internal directories.
Click to hide internal directories.