mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 13:44:42 -05:00
fix
This commit is contained in:
parent
4f4a633035
commit
354379b12a
@ -4,4 +4,5 @@ CLASH_TEMPLATE=clash_template.json
|
||||
REQUEST_RETRY_TIMES=3
|
||||
REQUEST_MAX_FILE_SIZE=1048576
|
||||
CACHE_EXPIRE=300
|
||||
LOG_LEVEL=info
|
||||
LOG_LEVEL=info
|
||||
BASE_PATH=/
|
21
README.md
21
README.md
@ -25,15 +25,16 @@
|
||||
|
||||
可以通过编辑 .env 文件来修改默认配置,docker 直接添加环境变量
|
||||
|
||||
| 变量名 | 说明 | 默认值 |
|
||||
|-----------------------|----------------------------------------|-----------------------|
|
||||
| PORT | 端口 | `8011` |
|
||||
| META_TEMPLATE | meta 模板文件名 | `template_meta.yaml` |
|
||||
| CLASH_TEMPLATE | clash 模板文件名 | `template_clash.yaml` |
|
||||
| REQUEST_RETRY_TIMES | Get 请求重试次数 | `3` |
|
||||
| REQUEST_MAX_FILE_SIZE | Get 请求订阅文件最大大小(byte) | `1048576` |
|
||||
| CACHE_EXPIRE | 订阅缓存时间(秒) | `300` |
|
||||
| LOG_LEVEL | 日志等级,可选值 `debug`,`info`,`warn`,`error` | `info` |
|
||||
| 变量名 | 说明 | 默认值 |
|
||||
|-----------------------|-----------------------------------------------------------|-----------------------|
|
||||
| BASE_PATH | 程序运行子路径,例如将服务反代在 `https://example.com/sub` 则此变量值应为 `/sub` | `/` |
|
||||
| PORT | 端口 | `8011` |
|
||||
| META_TEMPLATE | meta 模板文件名 | `template_meta.yaml` |
|
||||
| CLASH_TEMPLATE | clash 模板文件名 | `template_clash.yaml` |
|
||||
| REQUEST_RETRY_TIMES | Get 请求重试次数 | `3` |
|
||||
| REQUEST_MAX_FILE_SIZE | Get 请求订阅文件最大大小(byte) | `1048576` |
|
||||
| CACHE_EXPIRE | 订阅缓存时间(秒) | `300` |
|
||||
| LOG_LEVEL | 日志等级,可选值 `debug`,`info`,`warn`,`error` | `info` |
|
||||
|
||||
### API
|
||||
|
||||
@ -63,5 +64,3 @@
|
||||
[代理链接解析](./parser)还没有经过严格测试,可能会出现解析错误的情况,如果出现问题请提交 issue
|
||||
|
||||
## TODO
|
||||
|
||||
- [x] 可视化面板
|
@ -4,6 +4,8 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"sub2clash/config"
|
||||
"sub2clash/model"
|
||||
"sub2clash/utils/database"
|
||||
"sub2clash/validator"
|
||||
@ -46,5 +48,6 @@ func ShortLinkGetHandler(c *gin.Context) {
|
||||
c.String(404, "未找到短链接")
|
||||
return
|
||||
}
|
||||
c.Redirect(302, "../"+shortLink.Url)
|
||||
uri := config.Default.BasePath + shortLink.Url
|
||||
c.Redirect(http.StatusTemporaryRedirect, uri)
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ type Config struct {
|
||||
RequestMaxFileSize int64
|
||||
CacheExpire int64
|
||||
LogLevel string
|
||||
BasePath string
|
||||
}
|
||||
|
||||
var Default *Config
|
||||
@ -27,6 +28,7 @@ func init() {
|
||||
Port: 8011,
|
||||
CacheExpire: 60 * 5,
|
||||
LogLevel: "info",
|
||||
BasePath: "/",
|
||||
}
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
@ -69,4 +71,10 @@ func init() {
|
||||
if os.Getenv("LOG_LEVEL") != "" {
|
||||
Default.LogLevel = os.Getenv("LOG_LEVEL")
|
||||
}
|
||||
if os.Getenv("BASE_PATH") != "" {
|
||||
Default.BasePath = os.Getenv("BASE_PATH")
|
||||
if Default.BasePath[len(Default.BasePath)-1] != '/' {
|
||||
Default.BasePath += "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user