diff options
| author | MHSanaei <mc.sanaei@gmail.com> | 2023-02-09 22:18:06 +0300 |
|---|---|---|
| committer | MHSanaei <mc.sanaei@gmail.com> | 2023-02-09 22:18:06 +0300 |
| commit | b73e4173a3c1e69e02ad6b4e3b43e425e57a5be9 (patch) | |
| tree | d95d2f5e903d97082e11eb9f9023c165b1bde388 /config | |
3x-ui
Diffstat (limited to 'config')
| -rw-r--r-- | config/config.go | 50 | ||||
| -rw-r--r-- | config/name | 1 | ||||
| -rw-r--r-- | config/version | 1 |
3 files changed, 52 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go new file mode 100644 index 00000000..e1c7f911 --- /dev/null +++ b/config/config.go @@ -0,0 +1,50 @@ +package config + +import ( + _ "embed" + "fmt" + "os" + "strings" +) + +//go:embed version +var version string + +//go:embed name +var name string + +type LogLevel string + +const ( + Debug LogLevel = "debug" + Info LogLevel = "info" + Warn LogLevel = "warn" + Error LogLevel = "error" +) + +func GetVersion() string { + return strings.TrimSpace(version) +} + +func GetName() string { + return strings.TrimSpace(name) +} + +func GetLogLevel() LogLevel { + if IsDebug() { + return Debug + } + logLevel := os.Getenv("XUI_LOG_LEVEL") + if logLevel == "" { + return Info + } + return LogLevel(logLevel) +} + +func IsDebug() bool { + return os.Getenv("XUI_DEBUG") == "true" +} + +func GetDBPath() string { + return fmt.Sprintf("/etc/%s/%s.db", GetName(), GetName()) +} diff --git a/config/name b/config/name new file mode 100644 index 00000000..491114af --- /dev/null +++ b/config/name @@ -0,0 +1 @@ +x-ui
\ No newline at end of file diff --git a/config/version b/config/version new file mode 100644 index 00000000..be14282b --- /dev/null +++ b/config/version @@ -0,0 +1 @@ +0.5.3 |
