123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package main
- import (
- "C"
- "github.com/astaxie/beego/logs"
- "github.com/cnlh/nps/client"
- "github.com/cnlh/nps/lib/common"
- "github.com/cnlh/nps/lib/version"
- )
- var cl *client.TRPClient
- //export StartClientByVerifyKey
- func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) int {
- logs.SetLogger("store")
- if cl != nil {
- cl.Close()
- }
- cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil)
- go func() {
- cl.Start()
- return
- }()
- return 1
- }
- //export GetClientStatus
- func GetClientStatus() int {
- return client.NowStatus
- }
- //export CloseClient
- func CloseClient() {
- if cl != nil {
- cl.Close()
- }
- }
- //export Version
- func Version() *C.char {
- return C.CString(version.VERSION)
- }
- //export Logs
- func Logs() *C.char {
- return C.CString(common.GetLogMsg())
- }
- func main() {
- // Need a main function to make CGO compile package as C shared library
- }
|