Initial: initial commit
This commit is contained in:
50
core/src/main/golang/main.go
Normal file
50
core/src/main/golang/main.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -llog
|
||||
|
||||
#include "bridge.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"cfa/config"
|
||||
"cfa/core"
|
||||
"cfa/tunnel"
|
||||
|
||||
"github.com/Dreamacro/clash/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
panic("Stub!")
|
||||
}
|
||||
|
||||
//export coreInit
|
||||
func coreInit(home, versionName C.c_string, sdkVersion C.int) {
|
||||
h := C.GoString(home)
|
||||
v := C.GoString(versionName)
|
||||
s := int(sdkVersion)
|
||||
|
||||
core.Init(h, v, s)
|
||||
|
||||
reset()
|
||||
}
|
||||
|
||||
//export reset
|
||||
func reset() {
|
||||
config.LoadDefault()
|
||||
tunnel.ResetStatistic()
|
||||
|
||||
runtime.GC()
|
||||
}
|
||||
|
||||
//export forceGc
|
||||
func forceGc() {
|
||||
go func() {
|
||||
log.Infoln("[APP] request force GC")
|
||||
|
||||
runtime.GC()
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user