initial commit
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//go:embed version
|
||||
var version string
|
||||
|
||||
//go:embed name
|
||||
var name string
|
||||
|
||||
//go:embed config.json
|
||||
var defaultConfig 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("SUI_LOG_LEVEL")
|
||||
if logLevel == "" {
|
||||
return Info
|
||||
}
|
||||
return LogLevel(logLevel)
|
||||
}
|
||||
|
||||
func IsDebug() bool {
|
||||
return os.Getenv("SUI_DEBUG") == "true"
|
||||
}
|
||||
|
||||
func GetBinFolderPath() string {
|
||||
binFolderPath := os.Getenv("SUI_BIN_FOLDER")
|
||||
if binFolderPath == "" {
|
||||
binFolderPath = "bin"
|
||||
}
|
||||
return binFolderPath
|
||||
}
|
||||
|
||||
func GetDBFolderPath() string {
|
||||
dbFolderPath := os.Getenv("SUI_DB_FOLDER")
|
||||
if dbFolderPath == "" {
|
||||
dbFolderPath = "db"
|
||||
}
|
||||
return dbFolderPath
|
||||
}
|
||||
|
||||
func GetDBPath() string {
|
||||
return fmt.Sprintf("%s/%s.db", GetDBFolderPath(), GetName())
|
||||
}
|
||||
|
||||
func GetDefaultConfig() string {
|
||||
return defaultConfig
|
||||
}
|
||||
|
||||
func GetEnvApi() string {
|
||||
return os.Getenv("SINGBOX_API")
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"log": {
|
||||
"level": "info"
|
||||
},
|
||||
"dns": {},
|
||||
"inbounds": [],
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
},
|
||||
{
|
||||
"type": "dns",
|
||||
"tag": "dns-out"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"protocol": "dns",
|
||||
"outbound": "dns-out"
|
||||
}
|
||||
]
|
||||
},
|
||||
"experimental": {
|
||||
"v2ray_api": {
|
||||
"listen": "127.0.0.1:1080",
|
||||
"stats": {
|
||||
"enabled": true,
|
||||
"inbounds": [],
|
||||
"outbounds": [
|
||||
"direct"
|
||||
],
|
||||
"users": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
s-ui
|
||||
@@ -0,0 +1 @@
|
||||
0.0.0
|
||||
Reference in New Issue
Block a user