SpoofDPI/config/config.go

38 lines
430 B
Go
Raw Normal View History

2022-01-07 17:03:46 +00:00
package config
2021-12-29 17:08:30 +00:00
import (
2022-01-07 17:03:46 +00:00
"runtime"
"sync"
2021-12-29 17:08:30 +00:00
)
type Config struct {
2022-01-07 17:03:46 +00:00
Port string
DNS string
OS string
Debug bool
2021-12-29 17:08:30 +00:00
}
var config *Config
var once sync.Once
var err error
2022-01-03 16:54:36 +00:00
func InitConfig(port string, dns string, debug bool) error {
2022-01-07 17:03:46 +00:00
err = nil
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
once.Do(func() {
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
config = &Config{
Port: port,
DNS: dns,
OS: runtime.GOOS,
Debug: debug,
}
})
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
return err
2021-12-29 17:08:30 +00:00
}
2022-01-07 17:03:46 +00:00
func GetConfig() *Config {
return config
2021-12-29 17:08:30 +00:00
}