FILE / ScuroNeko/H2Node

app/config.go

Исходный файл и его история в репозитории.
FILE 951f3ab482fa0b6c9f38df670ed6c4a5348728e1
This repository has been archived on 2026-04-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
H2Node/app/config.go
T
2026-03-04 18:23:00 +03:00

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)
}