This commit is contained in:
2026-03-04 18:23:00 +03:00
parent b81df5866b
commit 205d9cf8b0
15 changed files with 439 additions and 165 deletions

44
app/config.go Normal file
View File

@@ -0,0 +1,44 @@
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)
}