Coder Social home page Coder Social logo

nkn-tunnel's Introduction

NKN Tunnel

GitHub license Go Report Card Build Status PRs Welcome

nkn

Tunnel any TCP applications through NKN client or Tuna. A few advantages:

  • Network agnostic: Neither sender nor receiver needs to have public IP address or port forwarding. NKN tunnel only establish outbound (websocket) connections, so Internet access is all they need on both side.
  • Top level security: All data are end to end authenticated and encrypted. No one else in the world except sender and receiver can see or modify the content of the data. The same public key is used for both routing and encryption, eliminating the possibility of man in the middle attack.
  • Decent performance: By aggregating multiple overlay paths concurrently, one can get ~100ms end to end latency and 10+mbps end to end throughput between international devices using the default NKN client mode, or much lower latency and higher throughput using Tuna mode.
  • Everything is open source and decentralized. The default NKN client mode is free (If you are curious, node relay traffic for clients for free to earn mining rewards in NKN blockchain), while Tuna mode requires listener to pay NKN token directly to Tuna service providers.

A diagram of the default NKN client mode:

                                 A - ... - X
                               /             \
Alice <--> TCP <--> NKN client - B - ... - Y - NKN client <--> TCP <--> Bob
                               \             /
                                 C - ... - Z

A diagram of the Tuna mode:

                                      A
                                    /   \
Alice <--> TCP <--> NKN Tuna client - B - NKN Tuna client <--> TCP <--> Bob
                                    \   /
                                      C

Build

go build -o nkn-tunnel bin/main.go

Basic Usage

"Server" side:

./nkn-tunnel -to 127.0.0.1:8080 -s <seed>

and you will see an output like Listening at xxx where xxx is the server listening address.

"Client" side:

./nkn-tunnel -from 127.0.0.1:8081 -to <server-listening-address>

Now any TCP connection to client port 8081 will be forwarded to server port 8080.

Tuna Mode

Add -tuna on both side of the tunnel to use Tuna mode, which has much better performance but requires listener to pay NKN token directly to Tuna service providers.

Turn on UDP under Tuna Mode

When using Tuna mode, add -udp to turn on UDP communication on both side to support UDP communication.

Contributing

Can I submit a bug, suggestion or feature request?

Yes. Please open an issue for that.

Can I contribute patches?

Yes, we appreciate your help! To make contributions, please fork the repo, push your changes to the forked repo with signed-off commits, and open a pull request here.

Please sign off your commit. This means adding a line "Signed-off-by: Name " at the end of each commit, indicating that you wrote the code and have the right to pass it on as an open source patch. This can be done automatically by adding -s when committing:

git commit -s

Community

nkn-tunnel's People

Contributors

billfort avatar bufrr avatar dependabot[bot] avatar iheron avatar yilunzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nkn-tunnel's Issues

2020/08/12 22:03:16 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

启动的时候报错。
能从dth网络获取种子地址吗?能缓存一下以前连过的节点吗?
不然很不稳定啊。

❯ ./nkn-tunnel -from nkn -to 127.0.0.1:22
2020/08/12 22:03:10 Seed: c6d1afe7d7eab9f1c72c68f0dde2970a096a438dc3f4f8482e70a20f2fa807fa
2020/08/12 22:03:16.093490 [ERROR] GID 11, POST request: Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw
aiting headers)

2020/08/12 22:03:16 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2020/08/12 22:03:16 Retry in 1000 ms...
2020/08/12 22:03:16.106078 [ERROR] GID 13, POST request: Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw
aiting headers)

2020/08/12 22:03:16 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2020/08/12 22:03:16 Retry in 1000 ms...
2020/08/12 22:03:16.109304 [ERROR] GID 10, POST request: Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw
aiting headers)

2020/08/12 22:03:16 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2020/08/12 22:03:16 Retry in 1000 ms...
2020/08/12 22:03:16.113133 [ERROR] GID 12, POST request: Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw
aiting headers)

2020/08/12 22:03:16 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2020/08/12 22:03:16 Retry in 1000 ms...
2020/08/12 22:03:18 Listening at ab5c2d464999e80121bd3ebfd787532d4c083b109eecd2da76cb622a4b143193



2020/08/12 22:04:02 websocket: close 1006 (abnormal closure): unexpected EOF
2020/08/12 22:04:02 Reconnect in 1000 ms...
2020/08/12 22:04:08.789706 [ERROR] GID 21, POST request: Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while aw
aiting headers)

2020/08/12 22:04:08 Post http://seed.nkn.org:30003: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2020/08/12 22:04:08 Retry in 1000 ms...

upgrade a release version?

i found the release and codes mybe old,the dependencies of it are old too,i wish the team can update to a newer version

Tuna mode and Usage

Seems that there is no reference of how to generate seed and pubkey at all?

If you don't provide a seed, it's automatically generated.

Now I know the server listening address is what it pops up after by -v, "listening at xxxxx"
If I would like to use tuna mode, where to purchase or add token to this address?

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.