Documentation
¶
Index ¶
- func CheckIsDir(path string) bool
- func CheckPort(port uint16) bool
- func CleanupSingleInstance()
- func Compare(a, b string) bool
- func DeleteFileIfExist(filePath string) error
- func DetectUTF8(s string) (valid, require bool)
- func EnsureSingleInstance(args []string, onNewArgs func(args []string) error) (bool, error)
- func GenerateImage(text string) ([]byte, error)
- func GetAbsPath(path string) string
- func GetAuthor(input string) string
- func GetContentTypeByFileName(fileName string) (contentType string)
- func GetFreePort() (int, error)
- func GetIPList() (IPList []string, err error)
- func GetImageDataBlurHash(loadedImage []byte, components int) string
- func GetImageDataBlurHashImage(loadedImage []byte, components int) []byte
- func GetOutboundIP() net.IP
- func ImageAutoCrop(loadedImage []byte, energyThreshold float32) []byte
- func ImageGray(loadedImage []byte) []byte
- func ImageResize(loadedImage []byte, width int, height int) []byte
- func ImageResizeByHeight(loadedImage []byte, height int) []byte
- func ImageResizeByMaxHeight(loadedImage []byte, maxHeight int) ([]byte, error)
- func ImageResizeByMaxWidth(loadedImage []byte, maxWidth int) ([]byte, error)
- func ImageResizeByWidth(loadedImage []byte, width int) []byte
- func ImageThumbnail(loadedImage []byte, width int, height int) []byte
- func IsExist(path string) bool
- func IsFile(path string) bool
- func IsLocalStorePath(storeURL string) bool
- func IsLoopbackHost(host string) bool
- func IsRemoteStoreURL(storeURL string) bool
- func IsSubPath(parent, child string) bool
- func IsValidDomain(host string) bool
- func LocalReaderURL(port int, customTLS bool, autoTLS bool, etcStr string) string
- func LookupOutboundIP() (net.IP, error)
- func MD5file(fName string) string
- func Md5string(s string) string
- func NormalizeAbsPath(path string) (string, error)
- func NormalizeAbsPathNoError(path string) string
- func NormalizeStoreURLForCompare(storeURL string) (normalized string, remote bool, err error)
- func NormalizeStoreURLKey(storeURL string) string
- func OpenBrowser(isHTTPS bool, host string, port int)
- func OpenBrowserByURL(uri string)
- func OpenLocalReaderURL(port int, customTLS bool, autoTLS bool, etcStr string)
- func OpenURL(uri string) error
- func PathExists(path string) bool
- func PrintAllReaderURL(Port int, PrintAllPossibleQRCode bool, ServerHost string, DisableLAN bool, ...)
- func PrintQRCode(text string)
- func RemoveExtension(filename string) string
- func RenderQRCodeLinesTerminal(text string) ([]string, error)
- func ShortName(title string) string
- func Sort(l []string)
- func StoreURLHost(storeURL string) string
- func TrackTIme(pre time.Time) time.Duration
- func WaitUntilServerReady(host string, port uint16, timeout time.Duration)
- type ConfigInterface
- type Message
- type ServerInfoParams
- type ServerStatus
- type SingleInstance
- type StoreBackendType
- type StoreURLInfo
- type SystemStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupSingleInstance ¶ added in v1.1.5
func CleanupSingleInstance()
CleanupSingleInstance 清理单实例资源(在程序退出时调用)
func Compare ¶
Compare returns true if the first string precedes the second one according to natural order
func DetectUTF8 ¶
DetectUTF8 检测 s 是否为有效的 UTF-8 字符串,以及该字符串是否必须被视为 UTF-8 编码(即,不兼容CP-437、ASCII 或任何其他常见编码)。 来自: go\src\archive\zip\reader.go
func EnsureSingleInstance ¶ added in v1.1.5
EnsureSingleInstance 确保程序以单实例模式运行 如果已有实例运行,将 args 发送给已运行的实例并返回 false 如果是第一个实例,返回 true
func GenerateImage ¶
GenerateImage 创建一个带有动态文字的JPEG图片,并返回其[]byte形式
func GetContentTypeByFileName ¶
GetContentTypeByFileName https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
func GetImageDataBlurHash ¶
GetImageDataBlurHash 获取图片的BlurHash
func GetImageDataBlurHashImage ¶
GetImageDataBlurHashImage 获取图片的BlurHash图
func GetOutboundIP ¶
GetOutboundIP 获取本机的首选出站IP 失败时回退到可用网卡或 127.0.0.1,避免工具层直接退出宿主进程。
func ImageAutoCrop ¶
ImageAutoCrop 自动裁白边
func ImageResize ¶
ImageResize 重设图片分辨率
func ImageResizeByHeight ¶
ImageResizeByHeight 根据一个固定 Height 缩放图片
func ImageResizeByMaxHeight ¶
ImageResizeByMaxHeight 设定一个图片高度上限,大于这个高度就缩放
func ImageResizeByMaxWidth ¶
ImageResizeByMaxWidth 设定一个图片宽度上限,大于这个宽度就缩放
func ImageResizeByWidth ¶
ImageResizeByWidth 根据一个固定宽度缩放图片
func ImageThumbnail ¶
ImageThumbnail 根据设定的图片大小,剪裁图片
func IsLocalStorePath ¶ added in v1.2.30
IsLocalStorePath 判断字符串是否已经是操作系统本地路径。
func IsLoopbackHost ¶ added in v1.2.38
IsLoopbackHost 判断主机名是否只指向本机;二维码遇到这类地址时需要改用现有 GetOutboundIP。
func IsRemoteStoreURL ¶ added in v1.2.30
IsRemoteStoreURL 判断 storeURL 是否为受支持的远程书库 URL。
func IsValidDomain ¶ added in v1.1.5
func LocalReaderURL ¶ added in v1.2.31
LocalReaderURL 生成本机阅读地址,供二维码打印和浏览器打开分别复用。
func LookupOutboundIP ¶ added in v1.2.30
LookupOutboundIP 获取本机的首选出站 IP,并把失败交给调用方决定是否回退。
func NormalizeAbsPath ¶ added in v1.2.12
NormalizeAbsPath 标准化文件路径为绝对路径 用于路径比较和冲突检测
func NormalizeAbsPathNoError ¶ added in v1.2.12
NormalizeAbsPathNoError 标准化文件路径为绝对路径(忽略错误,返回原路径) 适用于已知路径有效的场景,或者错误可以忽略的场景
func NormalizeStoreURLForCompare ¶ added in v1.2.30
NormalizeStoreURLForCompare 统一书库路径重叠检查的比较值。
func NormalizeStoreURLKey ¶ added in v1.2.30
NormalizeStoreURLKey 生成 VFS 缓存 key,去掉认证信息并规范 WebDAV 等价协议。
func OpenBrowser ¶
func OpenBrowserByURL ¶ added in v1.1.6
func OpenBrowserByURL(uri string)
OpenBrowserByURL 打开浏览器,为了防止阻塞,需要使用go关键字调用
func OpenLocalReaderURL ¶ added in v1.2.31
OpenLocalReaderURL 只负责打开本机阅读地址,不和二维码打印逻辑耦合。
func PathExists ¶
PathExists reports whether the named file or directory exists.
func PrintAllReaderURL ¶
func PrintAllReaderURL(Port int, PrintAllPossibleQRCode bool, ServerHost string, DisableLAN bool, customTLS bool, autoTLS bool, etcStr string)
PrintAllReaderURL 打印阅读链接与二维码,不负责打开浏览器。
func PrintQRCode ¶
func PrintQRCode(text string)
func RenderQRCodeLinesTerminal ¶ added in v1.2.23
RenderQRCodeLinesTerminal 将文本渲染为适合终端面板的二维码行内容。
说明:
- 该实现使用 qrcode-terminal-go 生成二维码 bitmap 的终端字符表现;
- 再将“单行模块”(█/空)按两行组合为 Unicode 半高块字符(▀▄█),从而保持与原 TUI 渲染方式接近的高度比例(避免 QR 面板过高被截断)。
func StoreURLHost ¶ added in v1.2.30
StoreURLHost 返回远程 URL 的主机名,解析失败或本地路径时返回空字符串。
Types ¶
type ConfigInterface ¶
type ServerInfoParams ¶
type ServerStatus ¶
type ServerStatus struct {
ServerName string // 服务器描述
Version string // Comigo 版本号
ServerHost string // ServerHost 服务器主机或 IP 地址。
ServerPort uint16 // ServerPort 服务运行的端口号。
TailscaleAuthURL string // Tailscale身份验证URL(如果适用)
TailscaleUrl string // Tailscale阅读地址(如果有)
NumberOfBooks int // 当前拥有的书籍总数
SupportUploadFile bool // 是否支持上传文件
ClientIP string // 客户端IP
OSInfo SystemStatus // 系统信息
ReScanServiceEnable bool // 是否启用自动扫描服务
ReScanServiceInterval int // 自动扫描服务间隔(分钟)
}
ServerStatus 服务器当前状况
func GetServerInfo ¶
func GetServerInfo(params ServerInfoParams) *ServerStatus
type SingleInstance ¶ added in v1.1.5
type SingleInstance struct {
// contains filtered or unexported fields
}
SingleInstance 单实例管理器
func NewSingleInstance ¶ added in v1.1.5
func NewSingleInstance(onNewArgs func(args []string) error) (*SingleInstance, error)
NewSingleInstance 创建单实例管理器
func (*SingleInstance) SendArgs ¶ added in v1.1.5
func (si *SingleInstance) SendArgs(args []string) error
SendArgs 向已运行的实例发送参数
func (*SingleInstance) StartServer ¶ added in v1.1.5
func (si *SingleInstance) StartServer() error
StartServer 启动服务器,监听来自其他实例的消息
func (*SingleInstance) Stop ¶ added in v1.1.5
func (si *SingleInstance) Stop() error
Stop 停止服务器并清理资源
func (*SingleInstance) TryLock ¶ added in v1.1.5
func (si *SingleInstance) TryLock() (bool, error)
TryLock 尝试获取锁,如果已有实例运行则返回 false
type StoreBackendType ¶ added in v1.2.30
type StoreBackendType int
StoreBackendType 是跨 config/store/vfs 共用的书库后端类型。
const ( StoreBackendLocalDisk StoreBackendType = iota StoreBackendSMB StoreBackendSFTP StoreBackendWebDAV StoreBackendS3 StoreBackendFTP StoreBackendComigo )
type StoreURLInfo ¶ added in v1.2.30
type StoreURLInfo struct {
URL string
Scheme string
Type StoreBackendType
LocalPath string
ServerHost string
ServerPort int
NeedAuth bool
AuthUsername string
AuthPassword string
RemotePath string
SMBPath string
S3BucketName string
S3ObjectPrefix string
}
StoreURLInfo 保存解析后的 store URL 信息,避免各包重复解析同一套规则。
func DetectStoreURL ¶ added in v1.2.30
func DetectStoreURL(storeURL string) StoreURLInfo
DetectStoreURL 用宽松规则识别 store URL;未知或无效 URL 按本地路径处理。
func ParseStoreURL ¶ added in v1.2.30
func ParseStoreURL(storeURL string) (StoreURLInfo, error)
ParseStoreURL 解析本地路径和远程 store URL,并对已知远程协议做严格校验。
type SystemStatus ¶
type SystemStatus struct {
// CPU相关
CPUNumLogical int `json:"cpu_num_logical_total"`
CPUNumPhysical int `json:"cpu_num_physical"`
CPUUsedPercent float64 `json:"cpu_used_percent"`
// 内存相关
MemoryTotal uint64 `json:"memory_total"`
MemoryFree uint64 `json:"memory_free"`
MemoryUsedPercent float64 `json:"memory_used_percent"`
// 设备描述
Description string `json:"description"`
}
SystemStatus Documentation: https://pkg.go.dev/github.com/shirou/gopsutil 获取服务器当前状况
func GetSystemStatus ¶
func GetSystemStatus() SystemStatus
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package vfs 提供虚拟文件系统抽象层,支持本地文件系统和远程存储(WebDAV、SFTP等)
|
Package vfs 提供虚拟文件系统抽象层,支持本地文件系统和远程存储(WebDAV、SFTP等) |