All Projects → oyyd → nysocks

oyyd / nysocks

Licence: BSD-3-Clause license
Nysocks binds kcp and libuv to provide an aggressive tcp tunnel in nodejs.

Programming Languages

C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to nysocks

gost
GO Simple Tunnel - a simple tunnel written in golang
Stars: ✭ 8,395 (+10662.82%)
Mutual labels:  tunnel, socks5, kcp
fuso
一款体积小, 快速, 稳定, 高效, 轻量的内网穿透, 端口转发工具 支持多连接,级联代理,传输加密 (A small volume, fast, stable, efficient, and lightweight intranet penetration, port forwarding tool supports multiple connections, cascading proxy, and transmission encryption)
Stars: ✭ 1,132 (+1351.28%)
Mutual labels:  tunnel, socks5, kcp
Stowaway
👻Stowaway -- Multi-hop Proxy Tool for pentesters
Stars: ✭ 500 (+541.03%)
Mutual labels:  tunnel, socks5
Awslambdaproxy
An AWS Lambda powered HTTP/SOCKS web proxy
Stars: ✭ 571 (+632.05%)
Mutual labels:  tunnel, socks5
V2ray Core
A platform for building proxies to bypass network restrictions.
Stars: ✭ 13,438 (+17128.21%)
Mutual labels:  tunnel, socks5
Openiothub
💖A free IoT (Internet of Things) platform and private cloud. [一个免费的物联网和私有云平台,支持内网穿透]
Stars: ✭ 371 (+375.64%)
Mutual labels:  tunnel, socks5
Exodus
network proxy and tunnel (VPN)
Stars: ✭ 432 (+453.85%)
Mutual labels:  tunnel, socks5
ap-kcp
用于穿透恶劣网络环境的高性能可靠传输协议,基于 KCP 优化和修改,使用 Rust 实现
Stars: ✭ 121 (+55.13%)
Mutual labels:  tunnel, kcp
Pingtunnel
ping tunnel is a tool that advertises tcp/udp/socks5 traffic as icmp traffic for forwarding.
Stars: ✭ 1,904 (+2341.03%)
Mutual labels:  tunnel, socks5
Glider
glider is a forward proxy with multiple protocols support, and also a dns/dhcp server with ipset management features(like dnsmasq).
Stars: ✭ 1,710 (+2092.31%)
Mutual labels:  tunnel, socks5
Tun2socks
tun2socks - powered by gVisor TCP/IP stack
Stars: ✭ 123 (+57.69%)
Mutual labels:  tunnel, socks5
Nps
一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
Stars: ✭ 19,537 (+24947.44%)
Mutual labels:  tunnel, socks5
Kcp
⚡ KCP - A Fast and Reliable ARQ Protocol
Stars: ✭ 10,473 (+13326.92%)
Mutual labels:  tunnel, kcp
libuvpp
minimal change of libuv for p2p networking
Stars: ✭ 22 (-71.79%)
Mutual labels:  kcp, libuv
Xray Core
Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
Stars: ✭ 6,908 (+8756.41%)
Mutual labels:  tunnel, socks5
Python Proxy
HTTP/HTTP2/HTTP3/Socks4/Socks5/Shadowsocks/ShadowsocksR/SSH/Redirect/Pf TCP/UDP asynchronous tunnel proxy implemented in Python 3 asyncio.
Stars: ✭ 692 (+787.18%)
Mutual labels:  tunnel, socks5
mieru
見える是一款 socks5 网络代理(科学上网)工具。Mieru is a socks5 proxy to bypass censorship.
Stars: ✭ 63 (-19.23%)
Mutual labels:  tunnel, socks5
gost
GO Simple Tunnel - a simple tunnel written in golang
Stars: ✭ 154 (+97.44%)
Mutual labels:  tunnel, kcp
Venom
Venom - A Multi-hop Proxy for Penetration Testers
Stars: ✭ 1,228 (+1474.36%)
Mutual labels:  tunnel, socks5
Kcptun
A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。KCPプロトコルに基づく安全なトンネル。KCP 프로토콜을 기반으로 하는 보안 터널입니다。
Stars: ✭ 12,714 (+16200%)
Mutual labels:  tunnel, kcp

nysocks

npm-version travis-ci

English

Nysocks是nodejs上利用libuvkcp实现的代理工具。

  • 特性
    • 通过kcp,它在经常发生丢包的网络环境下也能有较好的表现。
    • 支持SOCKS5SS协议。
    • 加密传输数据。

对Linode上Tokyo 2, JP机房的测试(经常会发生10%的丢包):

一般ss代理:

nysocks“fast2”模式:

工作方式

你需要一台可以连接到的服务器来代理网络请求。

对于SOCKS协议

work-socks

对于SS协议

work-ss

目前支持ss协议的客户端较较多,因此你可以直接在服务器上同时启动一个ss协议的client和server来支持这些设备。但直接连接服务器上的client会没办法发挥kcp的优势。

protocol(unstable):

NOTE: 在nysocks v2.0.0中协议发生了改变,请确保客户端和服务器的版本都在该版本之上.

+-------+-----+-----+---------+---------+--------+------------+
|  kcp  | ver | cmd |  nonce  | mux.cmd | mux.id | mux.length |
+-------+-----+-----+---------+---------+--------+------------+
|  24   |  1  |  1  |    8    |    1    |    2   |     4      |
+-------+-----+-----+---------+---------+--------+------------+

安装

node >= v6.x

请确保node-gyp可用

npm i nysocks -g

使用

1. 创建server

在你的服务器上,执行server命令:

nysocks server -p 20000 -k YOUR_PASSWORD -m fast

2 创建client

在你的客户端上,执行client命令连接到你的server上。之后client就可以对本地的其他应用提供代理服务了:

nysocks client -a YOUR_SERVER_HOST -p 20000 -k YOUR_PASSWORD -m fast

执行完上述命令后,当你的client显示SOCKS5 service is listening on 1080后,你就可以利用SOCKS5协议来进行代理了。nysocks的client同时会提供一个PAC(默认端口8090)文件服务来帮助你的应用确定哪些请求不需要转发。

SS协议client

你可以开启ss协议的client来代替SOCKS5协议:

nysocks client -a YOUR_SERVER_HOST -p 20000 -k YOUR_PASSWORD -m fast --client_protocol SS --ss_password YOUR_SS_PASSWORD --ss_method aes-128-cfb

关于nysocks中ss协议的实现,可以直接参考encryptsocks 中ssServer的实现。

3. 用config.json文件

类似与ss,你可以将配置数据储存在config.json文件中,像这里,以避免繁琐的命令行参数:

nysocks client -c config.json

4. 开启守护进程

在实际使用时,你可以利用-d选项让client和server运行在守护进程下,以便在发生问题以后自动重启:

nysocks client -d restart -c config.json

nysock使用pm2进行进程守护,你也可以通过nysocks命令行直接操作pm2,如查看正在运行的进程:

nysocks pm -- ls

清除所有的进程:

nysocks pm -- kill

5. 查看其他配置项

你可以直接在命令行工具上查看所有可用的配置项:

nysocks -h

可用配置

nysocks <command>

Commands:
  nysocks server  Start a tunnel server.
  nysocks client  Start a tunnel client.
  nysocks pm      Alias of PM2(process manager) CLI that you can use to check or
                  operate processes directly.

Options:
  --version                Show version number                         [boolean]
  --config, -c             The path of a json file that describe your
                           configuration.
  --daemon, -d             Run with a daemon(pm2): start, stop, restart.
  --daemon_status, -s      Show daemoned(pm2) processes status
  --mode, -m               Like kcptun: normal, fast, fast2, fast3.
  --password, -k           The passowrd/key for the encryption of transmissio.
  --socket_amount          The amount of connections to be created for each
                           client (default: 10)
  --server_addr, -a        The host of your server.
  --server_port, -p        The port of your server.
  --client_protocol, --cp  The protocol that will be used by clients: SS, SOCKS
                           (default: SOCKS)
  --socks_port             Specify the local port for SOCKS service (default:
                           1080)
  --ss_port                Specify the local port for ssServer service (default:
                           8083)
  --ss_password            Specify the key for the encryption of ss
  --ss_method              Specify the method of the encryption for ss (default:
                           aes-128-cfb)
  --log_path               The file path for logging. If not set, will log to
                           the console.
  --log_memory             Log memory info.
  --log_conn               Log connections info.
  --help                   Show help                                   [boolean]

config.json的例子:

{
  "serverAddr": "YOUR_SERVER_HOST",
  "serverPort": 20000,
  "socketAmount": 20,
  "password": "YOUR_PASSWORD",
  "kcp": {
    "sndwnd": 1024,
    "rcvwnd": 1024,
    "nodelay": 0,
    "interval": 30,
    "resend": 2,
    "nc": 1
  },
  "pac": {
    "pacServerPort": 8090
  },
  "clientProtocol": "SOCKS",
  "SOCKS": {
    "port": 1080
  },
  "SS": {
    "password": "YOUR_SS_PASSWORD",
    "method": "aes-128-cfb",
    "serverPort": 8083,
  }
}

如何利用SOCKS5服务

大多数操作系统本身支持直接利用SOCKS5进行代理:

osx-set-proxy

chrome扩展SwitchyOmega可以帮助你的浏览器进行代理。

利用ss服务

查看这些客户端。nysocks中的ss服务相当于一般ss工具中server提供的服务。

http/https代理

可以参考hpts和其他类似的工具,在SOCKS服务上支持http代理。

实现

通过node-addon(C/CPP)来实现(而非纯js)主要是因为:

  1. Node在v8.7.0版本之前不支持设置send/recv buffer的大小.
  2. 对于大量的数据传输而言,udp的收发非常频繁,并且我们需要不断修改buffer上的数据。直接在node上进行这类操作所造成的性能消耗对于网络代理工具而言是不可接受的,它会使整体的性能直接下降到不可用的程度。之前纯脚本的实现可以参考这里here

但addon在部署上相比node脚本而言显得十分困难,主要有以下几点:

  1. addon需要编译,编译本身对运行环境有较多要求。对于部分window环境来说,需要额外安装一些依赖。
  2. prebuild的形式要求开发人员具备在多环境下编译的能力,并能持续稳定跟上node版本的迭代,支持新的node版本(N-API/ABI可能会减轻这一问题)。
  3. 要在其他node环境上(如electron)上使用addon基本上都需要额外的支持。也更难使用在非Node的js运行环境上(RN,web, chrome-extension)。

传输加密

目前默认使用aes_256_cbc进行加密,不可配置。

已知问题

  • 不支持ipv6

参考

LICENSE

BSD

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].