From fd782bf7e88407634f8169cf4d05bbfc16280a67 Mon Sep 17 00:00:00 2001 From: Hiddify Date: Sat, 3 Feb 2024 15:55:59 +0100 Subject: [PATCH] chg: Change name of service to HiddifyService --- .github/workflows/release.yml | 2 +- Makefile | 3 ++- admin_service/cmd/admin_service.manifest | 2 +- admin_service/cmd/main.go | 2 +- admin_service/web.go | 7 +++++++ build_windows.bat | 11 ++++++++++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88ef4e3..cd5a6ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: rm -f /*.h rm ./hiddify-libcore*sources* ||echo "no source" rm ./hiddify-libcore-macos-a*.dylib || echo "no macos arm and amd" - files=$(ls | grep -E '^(libcore\.(dll|so|dylib|aar)|Libcore.xcframework|hiddify-service(\.exe)?)$') + files=$(ls | grep -E '^(libcore\.(dll|so|dylib|aar)|Libcore.xcframework|HiddifyService(\.exe)?)$') echo tar -czvf hiddify-core-${{ matrix.job.target }}.tar.gz $files tar -czvf hiddify-core-${{ matrix.job.target }}.tar.gz $files diff --git a/Makefile b/Makefile index c3761d3..faafbef 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PRODUCT_NAME=libcore BASENAME=$(PRODUCT_NAME) BINDIR=bin LIBNAME=$(PRODUCT_NAME) -SRVNAME=hiddify-service +SRVNAME=HiddifyService BRANCH=$(shell git branch --show-current) VERSION=$(shell git describe --tags || echo "unknown version") @@ -35,6 +35,7 @@ ios: lib_install windows-amd64: + curl http://localhost:18020/exit || echo "exited" env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc $(GOBUILDLIB) -o $(BINDIR)/$(LIBNAME).dll ./custom go get github.com/akavel/rsrc go install github.com/akavel/rsrc diff --git a/admin_service/cmd/admin_service.manifest b/admin_service/cmd/admin_service.manifest index 514190c..fd7d880 100644 --- a/admin_service/cmd/admin_service.manifest +++ b/admin_service/cmd/admin_service.manifest @@ -3,7 +3,7 @@ Hiddify Tunnel Service diff --git a/admin_service/cmd/main.go b/admin_service/cmd/main.go index 09e0048..3a086df 100644 --- a/admin_service/cmd/main.go +++ b/admin_service/cmd/main.go @@ -20,7 +20,7 @@ import ( func main() { args := os.Args if len(args) < 2 { - fmt.Println("Usage: hiddify-service.exe empty/start/stop/uninstall/install") + fmt.Println("Usage: HiddifyService.exe empty/start/stop/uninstall/install") args = append(args, "") } diff --git a/admin_service/web.go b/admin_service/web.go index dcce7e6..e14317d 100644 --- a/admin_service/web.go +++ b/admin_service/web.go @@ -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 { diff --git a/build_windows.bat b/build_windows.bat index b4d76ed..26e5258 100644 --- a/build_windows.bat +++ b/build_windows.bat @@ -3,7 +3,16 @@ set GOOS=windows set GOARCH=amd64 set CC=x86_64-w64-mingw32-gcc set CGO_ENABLED=1 +curl http://localhost:18020/exit || echo "Exited" +del bin\libcore.dll bin\HiddifyService.exe +set CGO_LDFLAGS= go build -trimpath -tags with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc -ldflags="-w -s" -buildmode=c-shared -o bin/libcore.dll ./custom +go get github.com/akavel/rsrc +go install github.com/akavel/rsrc rsrc -manifest admin_service\cmd\admin_service.manifest -ico ..\assets\images\tray_icon_connected.ico -o admin_service\cmd\admin_service.syso -go build -o bin/hiddify-service.exe ./admin_service/cmd/ + +copy bin\libcore.dll . +set CGO_LDFLAGS="libcore.dll" +go build -o bin/HiddifyService.exe ./admin_service/cmd/ +del libcore.dll