Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go50
1 files changed, 50 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())
+}