fix: bugs and issues
This commit is contained in:
@@ -17,21 +17,18 @@ type hiddifyNext struct{}
|
||||
var port int = 18020
|
||||
|
||||
func (m *hiddifyNext) Start(s service.Service) error {
|
||||
go m.run()
|
||||
go StartWebServer(port, false)
|
||||
return nil
|
||||
}
|
||||
func (m *hiddifyNext) Stop(s service.Service) error {
|
||||
err := global.StopServiceC()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
// Stop should not block. Return with a few seconds.
|
||||
// <-time.After(time.Second * 1)
|
||||
return nil
|
||||
}
|
||||
func (m *hiddifyNext) run() {
|
||||
StartWebServer(port, false)
|
||||
}
|
||||
|
||||
func getCurrentExecutableDirectory() string {
|
||||
executablePath, err := os.Executable()
|
||||
@@ -63,7 +60,7 @@ func StartService(goArg string) (int, string) {
|
||||
return 1, fmt.Sprintf("Error: %v", err)
|
||||
}
|
||||
|
||||
if len(goArg) > 0 {
|
||||
if len(goArg) > 0 && goArg != "run" {
|
||||
return control(s, goArg)
|
||||
}
|
||||
|
||||
@@ -102,6 +99,7 @@ func control(s service.Service, goArg string) (int, string) {
|
||||
}
|
||||
return 0, "Tunnel Service Already Running."
|
||||
} else if status == service.StatusUnknown {
|
||||
s.Uninstall()
|
||||
s.Install()
|
||||
status, serr = s.Status()
|
||||
if dolog {
|
||||
@@ -112,6 +110,7 @@ func control(s service.Service, goArg string) (int, string) {
|
||||
err = s.Start()
|
||||
}
|
||||
case "install":
|
||||
s.Uninstall()
|
||||
err = s.Install()
|
||||
status, serr = s.Status()
|
||||
if dolog {
|
||||
|
||||
@@ -21,6 +21,7 @@ const (
|
||||
func StartWebServer(Port int, TLS bool) {
|
||||
http.HandleFunc("/start", startHandler)
|
||||
http.HandleFunc("/stop", StopHandler)
|
||||
http.HandleFunc("/status", StatusHandler)
|
||||
http.HandleFunc("/exit", ExitHandler)
|
||||
server := &http.Server{
|
||||
Addr: "127.0.0.1:" + fmt.Sprintf("%d", Port),
|
||||
@@ -85,6 +86,8 @@ func startHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
http.Error(w, fmt.Sprintf("Ok"), http.StatusOK)
|
||||
}
|
||||
func StatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
func StopHandler(w http.ResponseWriter, r *http.Request) {
|
||||
err := global.StopServiceC()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user