fix: bugs and issues

This commit is contained in:
Hiddify
2024-03-09 21:07:15 +01:00
parent d05deef499
commit 8ecd0d9644
13 changed files with 79 additions and 60 deletions

View File

@@ -163,6 +163,7 @@ func stop() error {
if box == nil {
return errors.New("instance not found")
}
config.DeactivateTunnelService()
propagateStatus(Stopping)
commandServer.SetService(nil)
@@ -292,10 +293,10 @@ func StopServiceC() error {
// if status != Started {
// return errors.New("instance not started")
// }
config.DeactivateTunnelService()
if box == nil {
return errors.New("instance not found")
}
// propagateStatus(Stopping)
err := box.Close()
// commandServer.SetService(nil)

View File

@@ -18,6 +18,27 @@ import (
"github.com/sagernet/sing-box/option"
)
func RunStandalone(hiddifySettingPath string, configPath string) error {
fmt.Println("Running in standalone mode")
current, err := readAndBuildConfig(hiddifySettingPath, configPath)
if err != nil {
fmt.Printf("Error in read and build config %v", err)
return err
}
go StartServiceC(false, current.Config)
go updateConfigInterval(current, hiddifySettingPath, configPath)
fmt.Printf("Press CTRL+C to stop\n")
fmt.Printf("Open http://localhost:6756/?secret=hiddify in your browser\n")
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
err = StopServiceC()
return err
}
type ConfigResult struct {
Config string
RefreshInterval int
@@ -155,22 +176,6 @@ func updateConfigInterval(current ConfigResult, hiddifySettingPath string, confi
}
}
func RunStandalone(hiddifySettingPath string, configPath string) error {
current, err := readAndBuildConfig(hiddifySettingPath, configPath)
if err != nil {
return err
}
go StartServiceC(false, current.Config)
go updateConfigInterval(current, hiddifySettingPath, configPath)
fmt.Printf("Press CTRL+C to stop\n")
fmt.Printf("Open http://localhost:6756/?secret=hiddify in your browser\n")
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
err = StopServiceC()
return err
}
func readConfigBytes(content []byte) (*option.Options, error) {
var options option.Options