chg: Change name of service to HiddifyService

This commit is contained in:
Hiddify
2024-02-03 15:55:59 +01:00
parent e53c65fa18
commit fd782bf7e8
6 changed files with 22 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import (
"crypto/tls"
"fmt"
"net/http"
"os"
"strconv"
"github.com/hiddify/libcore/global"
@@ -20,6 +21,7 @@ const (
func StartWebServer(Port int, TLS bool) {
http.HandleFunc("/start", startHandler)
http.HandleFunc("/stop", StopHandler)
http.HandleFunc("/exit", ExitHandler)
server := &http.Server{
Addr: "127.0.0.1:" + fmt.Sprintf("%d", Port),
}
@@ -91,6 +93,11 @@ func StopHandler(w http.ResponseWriter, r *http.Request) {
}
http.Error(w, fmt.Sprintf("Ok"), http.StatusOK)
}
func ExitHandler(w http.ResponseWriter, r *http.Request) {
global.StopServiceC()
os.Exit(0)
http.Error(w, fmt.Sprintf("Ok"), http.StatusOK)
}
func GetStack(stack string) global.Stack {
switch stack {