delete old codes
This commit is contained in:
+1
-4
@@ -48,10 +48,7 @@ func (a *APP) Init() error {
|
||||
a.subServer = sub.NewServer()
|
||||
|
||||
a.configService = service.NewConfigService(a.core)
|
||||
err = a.configService.InitConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ var version string
|
||||
//go:embed name
|
||||
var name string
|
||||
|
||||
//go:embed config.json
|
||||
var defaultConfig string
|
||||
|
||||
type LogLevel string
|
||||
|
||||
const (
|
||||
@@ -72,24 +69,3 @@ func GetDBFolderPath() string {
|
||||
func GetDBPath() string {
|
||||
return fmt.Sprintf("%s/%s.db", GetDBFolderPath(), GetName())
|
||||
}
|
||||
|
||||
func GetDefaultConfig() string {
|
||||
apiEnv := GetEnvApi()
|
||||
if len(apiEnv) > 0 {
|
||||
return strings.Replace(defaultConfig, "127.0.0.1:1080", apiEnv, 1)
|
||||
}
|
||||
return defaultConfig
|
||||
}
|
||||
|
||||
func GetEnvApi() string {
|
||||
return os.Getenv("SINGBOX_API")
|
||||
}
|
||||
|
||||
func IsSystemd() bool {
|
||||
pid := os.Getppid()
|
||||
cmdline, err := os.ReadFile(fmt.Sprintf("/proc/%d/comm", pid))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return string(cmdline) == "systemd\n"
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"log": {
|
||||
"level": "info"
|
||||
},
|
||||
"dns": {},
|
||||
"inbounds": [],
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "direct",
|
||||
"type": "direct"
|
||||
},
|
||||
{
|
||||
"type": "dns",
|
||||
"tag": "dns-out"
|
||||
}
|
||||
],
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"protocol": [
|
||||
"dns"
|
||||
],
|
||||
"outbound": "dns-out",
|
||||
"action": "route"
|
||||
}
|
||||
]
|
||||
},
|
||||
"experimental": {}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package logger
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"s-ui/config"
|
||||
"time"
|
||||
|
||||
"github.com/op/go-logging"
|
||||
@@ -29,7 +28,7 @@ func InitLogger(level logging.Level) {
|
||||
fmt.Println("Unable to use syslog: " + err.Error())
|
||||
backend = logging.NewLogBackend(os.Stderr, "", 0)
|
||||
}
|
||||
if config.IsSystemd() && err != nil {
|
||||
if err != nil {
|
||||
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
|
||||
} else {
|
||||
format = logging.MustStringFormatter(`%{level} - %{message}`)
|
||||
|
||||
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/config"
|
||||
"s-ui/core"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
|
||||
var (
|
||||
LastUpdate int64
|
||||
IsSystemd bool
|
||||
corePtr *core.Core
|
||||
)
|
||||
|
||||
@@ -43,11 +41,6 @@ func NewConfigService(core *core.Core) *ConfigService {
|
||||
return &ConfigService{}
|
||||
}
|
||||
|
||||
func (s *ConfigService) InitConfig() error {
|
||||
IsSystemd = config.IsSystemd()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ConfigService) GetConfig(data string) (*SingBoxConfig, error) {
|
||||
var err error
|
||||
if len(data) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user