45 lines
674 B
Go
45 lines
674 B
Go
package app
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
JWTSecret string
|
|
Host string
|
|
SNI string
|
|
NameFormat string
|
|
}
|
|
|
|
var cfg *Config
|
|
var hysteriaCfg *HysteriaConfig
|
|
|
|
func LoadConfig() {
|
|
cfg = &Config{
|
|
JWTSecret: os.Getenv("JWT_SECRET"),
|
|
Host: LoadIP(),
|
|
SNI: os.Getenv("SNI"),
|
|
NameFormat: os.Getenv("NAME_FORMAT"),
|
|
}
|
|
hysteriaCfg = &HysteriaConfig{}
|
|
|
|
f, err := os.Open("config.yaml")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer f.Close()
|
|
data, err := io.ReadAll(f)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
err = yaml.Unmarshal(data, hysteriaCfg)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
log.Println(cfg, hysteriaCfg)
|
|
}
|