Add command server

This commit is contained in:
problematicconsumer
2023-08-28 13:07:21 +03:30
parent c7fae3d09b
commit cb1d08734a
3 changed files with 18 additions and 3 deletions

16
custom/command_server.go Normal file
View File

@@ -0,0 +1,16 @@
package main
import "github.com/sagernet/sing-box/experimental/libbox"
var commandServer *libbox.CommandServer
type CommandServerHandler struct{}
func (csh *CommandServerHandler) ServiceReload() error {
return nil
}
func startCommandServer() error {
commandServer = libbox.NewCommandServer(&CommandServerHandler{}, 300)
return commandServer.Start()
}

View File

@@ -15,7 +15,6 @@ import (
)
var (
sBasePath string
sWorkingPath string
sTempPath string
sUserID int
@@ -23,7 +22,7 @@ var (
)
func Setup(basePath string, workingPath string, tempPath string) {
sBasePath = basePath
libbox.Setup(basePath, workingPath, tempPath, false)
sWorkingPath = workingPath
sTempPath = tempPath
sUserID = os.Getuid()

2
go.mod
View File

@@ -5,7 +5,7 @@ go 1.21
require (
github.com/sagernet/gomobile v0.0.0-20230728014906-3de089147f59
github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a
github.com/sagernet/sing-box v1.3.6
github.com/sagernet/sing-box v1.4.0-rc.1.0.20230824140328-442370093191
github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1
github.com/xmdhs/clash2singbox v0.0.0-20230827075945-bb6d561314bb
gopkg.in/yaml.v3 v3.0.1