Giter Site home page Giter Site logo

alpsmonaco / cppnat Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 2.0 14.76 MB

cppnat is a NAT reverse proxy tool (aslo known as a hole punching tool) helps you expose your private IP and port and bind them onto a server with public IP,access your private service anywhere.

License: MIT License

C++ 91.63% Batchfile 2.14% Shell 2.08% CMake 4.15%
cpp cpp17 hole-punching nat nat-hole-punching nat-traversal proxy reverse-proxy asio easy-to-use

cppnat's Introduction

cppnat

writen in cpp,cppnat is a NAT reverse proxy tool (aslo known as a hole punching tool) helps you expose your private IP and port and bind them onto a server with public IP,access your private service anywhere.

README | 中文文档

build (recommended)

  1. Init git submodules in thirt_party/.
  2. Use CMake to generate platform project file.CmakeLists.txt file is in the root path of this repository.

Linux

mkdir build ; cd build ; cmake .. ; make 

If the compile is successful,you will have both server and client in the bin/ directory of this repository.
The default server.json and client.json are also included in the bin/ directory,change them to satisfy you needs.

Windows

mkdir build & cd build && cmake .. 

Open cppnat.sln and compile cppnat using Visual Studio.
You will have server.exe and client.exe in Visual Studio build output directory,
could be Release/ or Debug/ depends on which mode you choose to compile.
Also server.json and client.json will be copied to the directory,
change them to satisfy you needs.

build (deprecated)

  1. Init git submodules in thirt_party/.
  2. run build_server.sh and build_client.sh on linux os, requires at least g++ 10.
    For Windows system with MSVC compiler cl.exe has installed,run build_server.bat and build_client.bat.
  3. If the compile is successful,you will have server and client in the bin/ directory.
    The default server.json and client.json are also included in the bin/ directory,change them to satisfy you needs.

run

There are bin/server.json and bin/client.json template config file in the bin/ directory.Simply change them to satisfy you needs.

config

server

bin/server is typically dispatched on a server with public ip.Every TCP connection to the ip and the port you have configured will be redirected to nat client.

server.json

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

There are only two keys in the config json file indicates on which ip and which port the nat server should bind.

client

bin/client is typically dispatched on a computer without a public ip but able to connect to the Internet with NAT.
A client helps you expose you service such as ssh or rdp to the Internet that you could access it anywhere.

client.json

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

configure server_ip and server_port to a nat server's binded ip and binded port.
configure proxy_ip and proxy_port to you local private service.

Now you could access you private service anywhere based on asio,this library performs well under high concurrency as well.

Project

This library is written with Visual Studio Code,you could open this project of root path and launch it directly.

cppnat's People

Contributors

alpsmonaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wahello sabixr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.