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
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go50
-rw-r--r--config/name1
-rw-r--r--config/version1
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