Skip to content

Latest commit

 

History

History
66 lines (52 loc) · 2.27 KB

README.zh-CN.md

File metadata and controls

66 lines (52 loc) · 2.27 KB

cppnat

cppnat 是一个NAT内网穿透工具,用来帮助你暴露你的内网的服务到公网上。

编译 (推荐)

  1. 初始化 thirt_party/ 下的git子模块。
  2. 使用CMake来生成项目文件。CMakeLists.txt在这个仓库的根目录中。

Linux

mkdir build ; cd build ; cmake .. ; make 

如果编译一切顺利,编译会输出 serverclient 在这个仓库的 bin/ 文件夹里。
默认的 server.jsonclient.json 也在里面,修改他们来满足你的需要。

Windows

mkdir build & cd build && cmake .. 

打开 cppnat.sln,然后使用 Visual Studio 来编译 cppnat .
编译成功的话,Visual Studio 会输出 server.execlient.exeRelease/或者Debug/.里,取决于你使用什么模式编译。
server.jsonclient.json 也会被拷贝过去修改他们来满足你的需要。

编译 (弃用)

  1. 初始化 thirt_party/ 下的git子模块。
  2. linux系统下执行 build_server.shbuild_client.sh 需要至少g++ 10.
    Windows需要Visual Studio,执行build_server.batbuild_client.bat.
  3. 如果编译顺利,编译会输出 serverclient 在这个仓库的 bin/ 文件夹里。
    默认的 server.jsonclient.json 也在里面,修改他们来满足你的需要。

执行

bin/server.jsonbin/client.json 模板配置文件在在这个仓库的 bin/ 文件夹里。修改他们来满足你的需要。

配置

服务端

bin/server 一般部署在有公网的服务器上。每个TCP请求都会被重定向到cppnat客户端。

server.json

{
    "bind_ip": "127.0.0.1",
    "bind_port": 54432
}

配置文件里配置公网服务器需要绑定的ip和端口

客户端

bin/client一般部署在没有公网ip但能正常连接互联网的服务器上,通常是经过了网络地址转换。

client.json

{
    "server_ip": "127.0.0.1",
    "server_port": 54432,
    "proxy_ip": "127.0.0.1",
    "proxy_port": 33123
}

配置 server_ipserver_port 来指定cppnat的ip和端口 配置 proxy_ipproxy_port 来指定需要代理的内网TCP服务

项目

该项目由Visual Studio Code编写,可以用Visual Studio Code直接打开。