new: add tunnel service

This commit is contained in:
Hiddify
2024-01-29 21:55:01 +01:00
parent 25d5b8a1c5
commit 5fa28220b4
28 changed files with 364 additions and 231 deletions

33
admin_service_cmd/main.go Normal file
View File

@@ -0,0 +1,33 @@
package main
/*
#cgo LDFLAGS: bin/libcore.dll
#include <stdlib.h>
#include <stdint.h>
// Import the function from the DLL
extern void AdminServiceStart(char *arg);
*/
import "C"
import (
"os"
)
func main() {
args := os.Args
// Check if there is at least one command-line argument
if len(args) < 2 {
println("Usage: hiddify-service.exe empty/start/stop/uninstall/install")
// os.Exit(1)
args = append(args, "")
}
// fmt.Printf("os.Args: %+v", args)
os.Chdir(os.Args[0])
// Convert the Go string to a C string
arg := C.CString(args[1])
// defer C.free(unsafe.Pointer(arg))
// Call AdminServiceStart with the C string
C.AdminServiceStart(arg)
}