new: add cli interface with basic webui

This commit is contained in:
Hiddify
2024-03-09 15:49:09 +01:00
parent f9e6f022c8
commit 3a82650759
27 changed files with 433 additions and 222 deletions

35
cli/bydll/clibydll.go Normal file
View File

@@ -0,0 +1,35 @@
package main
/*
#include <stdlib.h>
#include <stdint.h>
// Import the function from the DLL
char* parseCli(int argc, char** argv);
*/
import "C"
import (
"fmt"
"os"
"unsafe"
)
func main() {
args := os.Args
// Convert []string to []*C.char
var cArgs []*C.char
for _, arg := range args {
cArgs = append(cArgs, C.CString(arg))
}
defer func() {
for _, arg := range cArgs {
C.free(unsafe.Pointer(arg))
}
}()
// Call the C function
result := C.parseCli(C.int(len(cArgs)), (**C.char)(unsafe.Pointer(&cArgs[0])))
fmt.Println(C.GoString(result))
}

11
cli/main.go Normal file
View File

@@ -0,0 +1,11 @@
package main
import (
"os"
"github.com/hiddify/libcore/cmd"
)
func main() {
cmd.ParseCli(os.Args[1:])
}