mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
24w18c
This commit is contained in:
parent
52fdaf5f81
commit
57ba06e01e
5 changed files with 26 additions and 17 deletions
|
|
@ -1,5 +1,11 @@
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
24w18c
|
||||||
|
---
|
||||||
|
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
||||||
|
- CHANGE: 修正配置命名,改为驼峰式命名
|
||||||
|
- CHANGE: 修正函数命名
|
||||||
|
|
||||||
24w18b
|
24w18b
|
||||||
---
|
---
|
||||||
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
- PRE-RELEASE: 此版本是预发布版本,请勿在生产环境中使用
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
24w18b
|
24w18c
|
||||||
|
|
@ -16,12 +16,12 @@ type Config struct {
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
Port int `toml:"port"`
|
Port int `toml:"port"`
|
||||||
Host string `toml:"host"`
|
Host string `toml:"host"`
|
||||||
SizeLimit int `toml:"sizelimit"`
|
SizeLimit int `toml:"sizeLimit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogConfig struct {
|
type LogConfig struct {
|
||||||
LogFilePath string `toml:"logfilepath"`
|
LogFilePath string `toml:"logFilePath"`
|
||||||
MaxLogSize int `toml:"maxlogsize"`
|
MaxLogSize int `toml:"maxLogSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CORSConfig struct {
|
type CORSConfig struct {
|
||||||
|
|
@ -30,17 +30,17 @@ type CORSConfig struct {
|
||||||
|
|
||||||
type AuthConfig struct {
|
type AuthConfig struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
AuthToken string `toml:"authtoken"`
|
AuthToken string `toml:"authToken"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlacklistConfig struct {
|
type BlacklistConfig struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
BlacklistFile string `toml:"blacklistfile"`
|
BlacklistFile string `toml:"blacklistFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WhitelistConfig struct {
|
type WhitelistConfig struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
WhitelistFile string `toml:"whitelistfile"`
|
WhitelistFile string `toml:"whitelistFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig 从 TOML 配置文件加载配置
|
// LoadConfig 从 TOML 配置文件加载配置
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,26 @@
|
||||||
[server]
|
[server]
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
port = 8080
|
port = 8080
|
||||||
sizelimit = 131072000 # 125MB
|
sizeLimit = 131072000 # 125MB
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
logfilepath = "/data/ghproxy/log/ghproxy.log"
|
logFilePath = "/data/ghproxy/log/ghproxy.log"
|
||||||
maxlogsize = 5 # MB
|
maxLogSize = 5 # MB
|
||||||
|
|
||||||
[cors]
|
[cors]
|
||||||
enabled = true
|
enabled = true
|
||||||
|
|
||||||
[auth]
|
[auth]
|
||||||
authtoken = "test"
|
authToken = "test"
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[blacklist]
|
[blacklist]
|
||||||
blacklistfile = "/data/ghproxy/config/blacklist.json"
|
blacklistFile = "/data/ghproxy/config/blacklist.json"
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
enabled = false
|
enabled = false
|
||||||
whitelistfile = "/data/ghproxy/config/whitelist.json"
|
whitelistFile = "/data/ghproxy/config/whitelist.json"
|
||||||
|
|
||||||
|
[downloadFolder]
|
||||||
|
enabled = false
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -30,7 +30,7 @@ var (
|
||||||
logError = logger.LogError
|
logError = logger.LogError
|
||||||
)
|
)
|
||||||
|
|
||||||
func ReadFlag() {
|
func readFlag() {
|
||||||
flag.StringVar(&cfgfile, "cfg", configfile, "config file path")
|
flag.StringVar(&cfgfile, "cfg", configfile, "config file path")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ func setupLogger(cfg *config.Config) {
|
||||||
logInfo("Init Completed")
|
logInfo("Init Completed")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Loadlist(cfg *config.Config) {
|
func loadlist(cfg *config.Config) {
|
||||||
auth.Init(cfg)
|
auth.Init(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,11 +67,11 @@ func setupApi(cfg *config.Config, router *gin.Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
ReadFlag()
|
readFlag()
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
loadConfig()
|
loadConfig()
|
||||||
setupLogger(cfg)
|
setupLogger(cfg)
|
||||||
Loadlist(cfg)
|
loadlist(cfg)
|
||||||
|
|
||||||
// 设置 Gin 模式
|
// 设置 Gin 模式
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue