This commit is contained in:
WJQSERVER 2024-09-24 17:16:21 +08:00
parent c21149b17f
commit 749093c8d5
20 changed files with 1282 additions and 1 deletions

31
config/config.go Normal file
View file

@ -0,0 +1,31 @@
package config
import (
"os"
"gopkg.in/yaml.v3"
)
type Config struct {
Port int `yaml:"port"`
Host string `yaml:"host"`
SizeLimit int `yaml:"sizelimit"`
LogFilePath string `yaml:"logfilepath"`
CORSOrigin bool `yaml:"CorsAllowOrigins"`
Auth bool `yaml:"auth"`
AuthToken string `yaml:"authtoken"`
}
// LoadConfig 从 YAML 配置文件加载配置
func LoadConfig(filePath string) (*Config, error) {
var config Config
data, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
err = yaml.Unmarshal(data, &config)
if err != nil {
return nil, err
}
return &config, nil
}

7
config/config.yaml Normal file
View file

@ -0,0 +1,7 @@
port: 8080
host: "127.0.0.1"
sizelimit: 131072000 # 125MB
logfilepath: "/data/ghproxy/log/ghproxy-0rtt.log"
CorsAllowOrigins: true
auth: true
authtoken: "test"