mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 16:21:11 +08:00
update
This commit is contained in:
parent
c21149b17f
commit
749093c8d5
20 changed files with 1282 additions and 1 deletions
31
config/config.go
Normal file
31
config/config.go
Normal 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
7
config/config.yaml
Normal 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue