From b30f694cf2da044d7ac7e00bc32800349b6f9a88 Mon Sep 17 00:00:00 2001 From: zijiren Date: Sun, 3 Nov 2024 23:25:48 +0800 Subject: [PATCH] chore: update readme and config comment --- README-CN.md | 8 +++++--- README.md | 8 +++++--- internal/conf/server.go | 4 ++-- server/handlers/proxy/proxy.go | 8 ++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README-CN.md b/README-CN.md index fed56f1..0567310 100644 --- a/README-CN.md +++ b/README-CN.md @@ -46,18 +46,20 @@ SyncTV 的同步观影功能确保所有观看视频的人都在同一点上。 - [x] 代理 - [x] 视频代理 - [x] 直播代理 + - [x] 代理缓存 - [x] 解析 - [x] 视频解析 - [x] Alist - [x] Bilibili - [x] Emby - - [ ] 直播解析 + - [x] 直播解析 + - [x] 哔哩哔哩 --- # 演示站点 -https://demo.synctv.wiki +[https://demo.synctv.wiki](https://demo.synctv.wiki) --- @@ -105,7 +107,7 @@ synctv server --data-dir ./ # 文档 -https://docs.synctv.wiki +[https://docs.synctv.wiki](https://docs.synctv.wiki) # 特别赞助商 diff --git a/README.md b/README.md index c19bc7f..da996ec 100644 --- a/README.md +++ b/README.md @@ -46,18 +46,20 @@ SyncTV's synchronized viewing feature ensures that everyone watching the video i - [x] Proxy - [x] Videos proxy - [x] Live proxy + - [x] Proxy cache - [x] Parse - [x] Parse video - [x] Alist - [x] Bilibili - [x] Emby - - [ ] Parse live + - [x] Parse live + - [x] Bilibili --- # Demo - +[https://demo.synctv.wiki](https://demo.synctv.wiki) --- @@ -105,7 +107,7 @@ synctv server --data-dir ./ # Documentation - +[https://docs.synctv.wiki](https://docs.synctv.wiki) # Special sponsors diff --git a/internal/conf/server.go b/internal/conf/server.go index 3d07dc6..9ffe215 100644 --- a/internal/conf/server.go +++ b/internal/conf/server.go @@ -3,8 +3,8 @@ package conf type ServerConfig struct { Http HttpServerConfig `yaml:"http"` Rtmp RtmpServerConfig `yaml:"rtmp"` - ProxyCachePath string `yaml:"proxy_cache_path" env:"SERVER_PROXY_CACHE_PATH"` - ProxyCacheSize string `yaml:"proxy_cache_size" env:"SERVER_PROXY_CACHE_SIZE"` + ProxyCachePath string `yaml:"proxy_cache_path" env:"SERVER_PROXY_CACHE_PATH" hc:"proxy cache path storage path, empty means use memory cache"` + ProxyCacheSize string `yaml:"proxy_cache_size" env:"SERVER_PROXY_CACHE_SIZE" hc:"proxy cache max size, example: 1MB 1GB, default 1GB"` } type HttpServerConfig struct { diff --git a/server/handlers/proxy/proxy.go b/server/handlers/proxy/proxy.go index 90a051a..17cc5ac 100644 --- a/server/handlers/proxy/proxy.go +++ b/server/handlers/proxy/proxy.go @@ -25,10 +25,14 @@ var ( fileCache Cache ) +const ( + defaultCacheSize = 1024 * 1024 * 1024 // 1GB +) + // MB GB KB func parseProxyCacheSize(sizeStr string) (int64, error) { if sizeStr == "" { - return 0, nil + return defaultCacheSize, nil } sizeStr = strings.ToLower(sizeStr) sizeStr = strings.TrimSpace(sizeStr) @@ -61,7 +65,7 @@ func getCache() Cache { log.Fatalf("parse proxy cache size error: %v", err) } if size == 0 { - size = 1024 * 1024 * 1024 + size = defaultCacheSize } if conf.Conf.Server.ProxyCachePath == "" { log.Infof("proxy cache path is empty, use memory cache, size: %d", size)