Comments (4)
太棒了,我将尝试测试是否有bug,如果没有问题将尝试提交个pr让这个库能直接被go当作第三方库调用
from natmap.
明白你的意思。编译报错应该是由于没有拉取submodule,git clone需要带--recursive
参数。目前没有支持作为库调用,只能编译为可执行程序运行,ENABLE_STATIC=1
是静态链接成可执行文件。
from natmap.
谢谢你的指导,目前我初步尝试了下,似乎能正常运行。代码如下:
package main
/*
#cgo CFLAGS: -I../third-part/hev-task-system/include -I../third-part/hev-task-system/src/lib/rbtree
#cgo LDFLAGS: -L../third-part/hev-task-system/bin -lhev-task-system -lpthread
#include <stdlib.h>
#include "hev-main.h"
*/
import "C"
import (
"fmt"
"unsafe"
)
func main() {
// 参数数组
args := []string{"natmap", "-s", "turn.cloudflare.com", "-h", "qq.com", "-b", "8081"}
// 创建C风格的参数数组
argc := C.int(len(args))
argv := make([]*C.char, len(args))
for i, arg := range args {
argv[i] = C.CString(arg)
defer C.free(unsafe.Pointer(argv[i])) // 确保在函数结束时释放内存
}
// 调用C函数
ret := C.hev_main(argc, &argv[0])
if ret == 0 {
fmt.Println("调用C函数成功")
} else {
fmt.Println("调用C函数失败")
}
}
我修改了hev-main.h
里的函数名,不然编译会报错说有两个main
函数。
这个main.go
文件需要放到src
目录。
这是执行正常吗?
from natmap.
可以的,执行正常。
from natmap.
Related Issues (20)
- How about creating the docker image for NATMap?
- 问一个非常弱智的问题 HOT 5
- 在Android上执行时发生了错误 HOT 7
- Origin rule无法完成 HOT 4
- [Feature Request] iptables / nftables forwarding HOT 6
- How does stun - http work? HOT 1
- tcp和udp能否共存? HOT 7
- 添加docker支持 HOT 12
- ssh断开连接问题 HOT 4
- 网络变动后故障 HOT 3
- ddns via cloudflare HOT 1
- 希望能增加参数,不要错误日志,或者把日志写入文件。 HOT 3
- notification scripts can be run manually, but natmap cannot
- 在开启clash的服务器上,无法打洞 HOT 7
- 请求在wireguard安卓客户端增加TXT记录解析 HOT 7
- 是否可以增加个先行脚本参数呢 例如-e 带的脚本 HOT 12
- Does it support FreeBSD? HOT 6
- 如何判断打洞成功 HOT 4
- 作者能不能写一个更新日志 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from natmap.