项目作者: Snawoot

项目描述 :
Yet another TCP-over-HTTP(S) tunnel
高级语言: Python
项目地址: git://github.com/Snawoot/chunk-nordic.git
创建时间: 2019-04-11T19:58:09Z
项目社区:https://github.com/Snawoot/chunk-nordic

开源协议:MIT License

下载


chunk-nordic

Build Status Coverage PyPI - Downloads PyPI PyPI - Status PyPI - License chunk-nordic

Yet another TCP-over-HTTP(S) tunnel.

Client component accepts TCP connections and forwards them to server component via pair of HTTP(S) connections in streaming mode (Content-Encoding: chunked). Server component forwards connections to target host and port (e.g. to VPN daemon).


:heart: :heart: :heart:

You can say thanks to the author by donations to these wallets:

  • ETH: 0xB71250010e8beC90C5f9ddF408251eBA9dD7320e
  • BTC:
    • Legacy: 1N89PRvG1CSsUk9sxKwBwudN6TjTPQ1N8a
    • Segwit: bc1qc0hcyxc000qf0ketv4r44ld7dlgmmu73rtlntw

Features

  • Multi-link full asynchronous operation.
  • Client support operation via proxy server (via HTTP_PROXY, HTTPS_PROXY environment variables and .netrc file).
  • Advanced TLS support:
    • Supports custom CAs for client and server.
    • Supports mutual TLS authentication between client and server with certificates.

For TLS reference see “TLS options” group in invokation synopsis.

Requirements

  • Python 3.5.3+
  • aiohttp

Installation

With basic Python event loop:

  1. pip3 install chunk-nordic

With high performance uvloop event loop:

  1. pip3 install chunk-nordic[uvloop]

If you prefer distribution via Docker image see Docker Example section below.

Also chunk-nordic is available on Snap Store:

Get it from the Snap Store

  1. sudo snap install chunk-nordic

Note that binaries installed by snap are named chunk-nordic.client and chunk-nordic.server.

Synopsis

Server:

  1. $ chunk-server --help
  2. usage: chunk-server [-h] [-u URI] [-v {debug,info,warn,error,fatal}]
  3. [--disable-uvloop] [-a BIND_ADDRESS] [-p BIND_PORT]
  4. [-w TIMEOUT] [-c CERT] [-k KEY] [-C CAFILE]
  5. dst_host dst_port
  6. Yet another TCP-over-HTTP(S) tunnel. Server-side component.
  7. positional arguments:
  8. dst_host target hostname
  9. dst_port target port
  10. optional arguments:
  11. -h, --help show this help message and exit
  12. -u URI, --uri URI path where connections served (default: /chunk-nordic)
  13. -v {debug,info,warn,error,fatal}, --verbosity {debug,info,warn,error,fatal}
  14. logging verbosity (default: info)
  15. --disable-uvloop do not use uvloop even if it is available (default:
  16. False)
  17. listen options:
  18. -a BIND_ADDRESS, --bind-address BIND_ADDRESS
  19. bind address (default: 127.0.0.1)
  20. -p BIND_PORT, --bind-port BIND_PORT
  21. bind port (default: 8080)
  22. timing options:
  23. -w TIMEOUT, --timeout TIMEOUT
  24. backend connect timeout (default: 4)
  25. TLS options:
  26. -c CERT, --cert CERT enable TLS and use certificate (default: None)
  27. -k KEY, --key KEY key for TLS certificate (default: None)
  28. -C CAFILE, --cafile CAFILE
  29. require client TLS auth using specified CA certs
  30. (default: None)

Client:

  1. $ chunk-client --help
  2. usage: chunk-client [-h] [-v {debug,info,warn,error,fatal}] [--disable-uvloop]
  3. [-a BIND_ADDRESS] [-p BIND_PORT] [-w TIMEOUT] [-c CERT]
  4. [-k KEY] [-C CAFILE] [--no-hostname-check]
  5. server_url
  6. Yet another TCP-over-HTTP(S) tunnel. Client-side component.
  7. positional arguments:
  8. server_url target hostname
  9. optional arguments:
  10. -h, --help show this help message and exit
  11. -v {debug,info,warn,error,fatal}, --verbosity {debug,info,warn,error,fatal}
  12. logging verbosity (default: info)
  13. --disable-uvloop do not use uvloop even if it is available (default:
  14. False)
  15. listen options:
  16. -a BIND_ADDRESS, --bind-address BIND_ADDRESS
  17. bind address (default: 127.0.0.1)
  18. -p BIND_PORT, --bind-port BIND_PORT
  19. bind port (default: 1940)
  20. timing options:
  21. -w TIMEOUT, --timeout TIMEOUT
  22. server connect timeout (default: 4)
  23. TLS options:
  24. -c CERT, --cert CERT use certificate for client TLS auth (default: None)
  25. -k KEY, --key KEY key for TLS certificate (default: None)
  26. -C CAFILE, --cafile CAFILE
  27. override default CA certs by set specified in file
  28. (default: None)
  29. --no-hostname-check do not check hostname in cert subject. This option is
  30. useful for private PKI and available only together
  31. with "--cafile" (default: False)

Example

Let’s assume we have OpenVPN instance on TCP port 1194 at server gate.example.com.

Server command:

  1. chunk-server 127.0.0.1 1194

Client command:

  1. chunk-client http://gate.example.com:8080/chunk-nordic

Fragment of client’s OpenVPN config:

  1. <connection>
  2. remote 127.0.0.1 1940 tcp
  3. </connection>

Docker Example

For environment same as in example above:

Server:

  1. docker run -dit \
  2. -p 8080:8080 \
  3. --restart unless-stopped \
  4. --name chunk-nordic-server yarmak/chunk-nordic \
  5. server 127.0.0.1 1194

Client:

  1. docker run -dit \
  2. -p 1940:1940 \
  3. --restart unless-stopped \
  4. --name chunk-nordic-server yarmak/chunk-nordic \
  5. client http://gate.example.com:8080/chunk-nordic