forked from ehang-io/nps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
972 additions
and
946 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
![logo](logo.svg) | ||
|
||
# NPS <small>0.25.1</small> | ||
|
||
> 一款轻量级、高性能、功能强大的内网穿透代理服务器 | ||
- 支持tcp、udp流量转发 | ||
- 支持内网http代理、内网socks5代理、p2p | ||
- 简洁方便的WEB管理界面 | ||
- 服务端控制 | ||
|
||
|
||
[GitHub](https://github.com/cnlh/nps/) | ||
[开始使用](#docsify) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
* 入门 | ||
* [安装](install.md) | ||
* [使用示例](example.md) | ||
* 服务端 | ||
* [介绍](introduction.md) | ||
* [启动](start.md) | ||
* [配置文件](server_config.md) | ||
* [增强功能](nps_extend.md) | ||
|
||
* 客户端 | ||
|
||
* [基本使用](use.md) | ||
* [增强功能](npc_extend.md) | ||
|
||
* 扩展 | ||
|
||
* [功能](feature.md) | ||
* [说明](description.md) | ||
* [web api](api.md) | ||
|
||
* 其他 | ||
|
||
* [贡献](contribute.md) | ||
* [捐助](donate.md) | ||
* [致谢](thanks.md) | ||
* [交流](discuss.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# webAPI验证说明 | ||
- 采用auth_key的验证方式 | ||
- 在提交的每个请求后面附带两个参数,`auth_key` 和`timestamp` | ||
|
||
``` | ||
auth_key的生成方式为:md5(配置文件中的auth_key+当前时间戳) | ||
``` | ||
|
||
``` | ||
timestamp为当前时间戳 | ||
``` | ||
``` | ||
curl --request POST \ | ||
--url http://127.0.0.1:8080/client/list \ | ||
--data 'auth_key=2a0000d9229e7dbcf79dd0f5e04bb084×tamp=1553045344&start=0&limit=10' | ||
``` | ||
**注意:** 为保证安全,时间戳的有效范围为20秒内,所以每次提交请求必须重新生成。 | ||
|
||
# 获取服务端时间 | ||
由于服务端与api请求的客户端时间差异不能太大,所以提供了一个可以获取服务端时间的接口 | ||
|
||
``` | ||
POST /auth/gettime | ||
``` | ||
|
||
# 获取服务端authKey | ||
|
||
如果想获取authKey,服务端提供获取authKey的接口 | ||
|
||
``` | ||
POST /auth/getauthkey | ||
``` | ||
将返回加密后的authKey,采用aes cbc加密,请使用与服务端配置文件中cryptKey相同的密钥进行解密 | ||
|
||
**注意:** nps配置文件中`auth_crypt_key`需为16位 | ||
- 解密密钥长度128 | ||
- 偏移量与密钥相同 | ||
- 补码方式pkcs5padding | ||
- 解密串编码方式 十六进制 | ||
|
||
# 详细文档 | ||
- **此文档近期可能更新较慢,建议自行抓包** | ||
|
||
为方便第三方扩展,在web模式下可利用webAPI进行相关操作,详情见 | ||
[webAPI文档](https://github.com/cnlh/nps/wiki/webAPI%E6%96%87%E6%A1%A3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# 贡献 | ||
**欢迎参与到制作docker、图标、文档翻译等工作** | ||
- 如果遇到bug可以直接提交至dev分支 | ||
- 使用遇到问题可以通过issues反馈 | ||
- 项目处于开发阶段,还有很多待完善的地方,如果可以贡献代码,请提交 PR 至 dev 分支 | ||
- 如果有新的功能特性反馈,可以通过issues或者qq群反馈 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 获取用户真实ip | ||
|
||
在域名代理模式中,可以通过request请求 header 中的 X-Forwarded-For 和 X-Real-IP 来获取用户真实 IP。 | ||
|
||
**本代理前会在每一个http(s)请求中添加了这两个 header。** | ||
|
||
# 热更新支持 | ||
对于绝大多数配置,在web管理中的修改将实时使用,无需重启客户端或者服务端 | ||
|
||
# 客户端地址显示 | ||
在web管理中将显示客户端的连接地址 | ||
|
||
# 流量统计 | ||
可统计显示每个代理使用的流量,由于压缩和加密等原因,会和实际环境中的略有差异 | ||
|
||
# 当前客户端带宽 | ||
可统计每个客户端当前的带宽,可能和实际有一定差异,仅供参考。 | ||
|
||
# 客户端与服务端版本对比 | ||
为了程序正常运行,客户端与服务端的核心版本必须一致,否则将导致客户端无法成功连接致服务端。 | ||
|
||
# Linux系统限制 | ||
默认情况下linux对连接数量有限制,对于性能好的机器完全可以调整内核参数以处理更多的连接。 | ||
`tcp_max_syn_backlog` `somaxconn` | ||
酌情调整参数,增强网络性能 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 交流群 | ||
|
||
![二维码.jpeg](https://i.loli.net/2019/02/15/5c66c32a42074.jpeg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
如果您觉得nps对你有帮助,欢迎给予我们一定捐助,也是帮助nps更好的发展。 | ||
# 支付宝 | ||
![image](https://github.com/cnlh/nps/blob/master/image/donation_zfb.png?raw=true) | ||
# 微信 | ||
![image](https://github.com/cnlh/nps/blob/master/image/donation_wx.png?raw=true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# 统一准备工作(必做) | ||
- 开启服务端,假设公网服务器ip为1.1.1.1,配置文件中`bridge_port`为8284,配置文件中`web_port`为8080 | ||
- 访问1.1.1.1:8080 | ||
- 在客户端管理中创建一个客户端,记录下验证密钥 | ||
- 内网客户端运行(windows使用cmd运行加.exe) | ||
|
||
```shell | ||
./npc -server=1.1.1.1:8284 -vkey=客户端的密钥 | ||
``` | ||
**注意:运行服务端后,请确保能从客户端设备上正常访问配置文件中所配置的`bridge_port`端口,telnet,netcat这类的来检查** | ||
|
||
# 域名解析 | ||
|
||
**适用范围:** 小程序开发、微信公众号开发、产品演示 | ||
|
||
**假设场景:** | ||
- 有一个域名proxy.com,有一台公网机器ip为1.1.1.1 | ||
- 两个内网开发站点127.0.0.1:81,127.0.0.1:82 | ||
- 想通过(http|https://)a.proxy.com访问127.0.0.1:81,通过(http|https://)b.proxy.com访问127.0.0.1:82 | ||
|
||
**使用步骤** | ||
- 将*.proxy.com解析到公网服务器1.1.1.1 | ||
- 点击刚才创建的客户端的域名管理,添加两条规则规则:1、域名:`a.proxy.com`,内网目标:`127.0.0.1:81`,2、域名:`b.proxy.com`,内网目标:`127.0.0.1:82` | ||
|
||
现在访问(http|https://)`a.proxy.com`,`b.proxy.com`即可成功 | ||
|
||
**https:** 如需使用https请进行相关配置,详见 [使用https](#使用https) | ||
|
||
# tcp隧道 | ||
|
||
|
||
**适用范围:** ssh、远程桌面等tcp连接场景 | ||
|
||
**假设场景:** | ||
想通过访问公网服务器1.1.1.1的8001端口,连接内网机器10.1.50.101的22端口,实现ssh连接 | ||
|
||
**使用步骤** | ||
- 在刚才创建的客户端隧道管理中添加一条tcp隧道,填写监听的端口(8001)、内网目标ip和目标端口(10.1.50.101:22),保存。 | ||
- 访问公网服务器ip(1.1.1.1),填写的监听端口(8001),相当于访问内网ip(10.1.50.101):目标端口(22),例如:`ssh -p 8001 root@1.1.1.1` | ||
|
||
# udp隧道 | ||
|
||
**适用范围:** 内网dns解析等udp连接场景 | ||
|
||
**假设场景:** | ||
内网有一台dns(10.1.50.102:53),在非内网环境下想使用该dns,公网服务器为1.1.1.1 | ||
|
||
**使用步骤** | ||
- 在刚才创建的客户端的隧道管理中添加一条udp隧道,填写监听的端口(53)、内网目标ip和目标端口(10.1.50.102:53),保存。 | ||
- 修改需要使用的dns地址为1.1.1.1,则相当于使用10.1.50.102作为dns服务器 | ||
|
||
# socks5代理 | ||
|
||
|
||
**适用范围:** 在外网环境下如同使用vpn一样访问内网设备或者资源 | ||
|
||
**假设场景:** | ||
想将公网服务器1.1.1.1的8003端口作为socks5代理,达到访问内网任意设备或者资源的效果 | ||
|
||
**使用步骤** | ||
- 在刚才创建的客户端隧道管理中添加一条socks5代理,填写监听的端口(8003),保存。 | ||
- 在外网环境的本机配置socks5代理(例如使用proxifier进行全局代理),ip为公网服务器ip(1.1.1.1),端口为填写的监听端口(8003),即可畅享内网了 | ||
|
||
**注意** | ||
经过socks5代理,当收到socks5数据包时socket已经是accept状态。表现是扫描端口全open,建立连接后短时间关闭。若想同内网表现一致,建议远程连接一台设备。 | ||
|
||
# http正向代理 | ||
|
||
**适用范围:** 在外网环境下使用http正向代理访问内网站点 | ||
|
||
**假设场景:** | ||
想将公网服务器1.1.1.1的8004端口作为http代理,访问内网网站 | ||
|
||
**使用步骤** | ||
|
||
- 在刚才创建的客户端隧道管理中添加一条http代理,填写监听的端口(8004),保存。 | ||
- 在外网环境的本机配置http代理,ip为公网服务器ip(1.1.1.1),端口为填写的监听端口(8004),即可访问了 | ||
|
||
# 私密代理 | ||
|
||
**适用范围:** 无需占用多余的端口、安全性要求较高可以防止其他人连接的tcp服务,例如ssh。 | ||
|
||
**假设场景:** | ||
无需新增多的端口实现访问内网服务器10.1.50.2的22端口 | ||
|
||
**使用步骤** | ||
- 在刚才创建的客户端中添加一条私密代理,并设置唯一密钥secrettest和内网目标10.1.50.2:22 | ||
- 在需要连接ssh的机器上以执行命令 | ||
|
||
``` | ||
./npc -server=1.1.1.1:8284 -vkey=vkey -type=tcp -password=secrettest -local_type=secret | ||
``` | ||
如需指定本地端口可加参数`-local_port=xx`,默认为2000 | ||
|
||
**注意:** password为web管理上添加的唯一密钥,具体命令可查看web管理上的命令提示 | ||
|
||
假设10.1.50.2用户名为root,现在执行`ssh -p 2000 root@1.1.1.1`即可访问ssh | ||
|
||
|
||
# p2p服务 | ||
|
||
**适用范围:** 大流量传输场景,流量不经过公网服务器,但是由于p2p穿透和nat类型关系较大,不保证100%成功,支持大部分nat类型。[nat类型检测](#nat类型检测) | ||
|
||
**假设场景:** | ||
|
||
想通过访问使用端机器(访问端,也就是本机)的2000端口---->访问到内网机器 10.2.50.2的22端口 | ||
|
||
**使用步骤** | ||
- 在`nps.conf`中设置`p2p_ip`(nps服务器ip)和`p2p_port`(nps服务器udp端口) | ||
- 在刚才刚才创建的客户端中添加一条p2p代理,并设置唯一密钥p2pssh | ||
- 在使用端机器(本机)执行命令 | ||
|
||
``` | ||
./npc -server=1.1.1.1:8284 -vkey=123 -password=p2pssh -target=10.2.50.2:22 | ||
``` | ||
如需指定本地端口可加参数`-local_port=xx`,默认为2000 | ||
|
||
**注意:** password为web管理上添加的唯一密钥,具体命令可查看web管理上的命令提示 | ||
|
||
假设内网机器为10.2.50.2的ssh用户名为root,现在在本机上执行`ssh -p 2000 root@127.0.0.1`即可访问机器2的ssh,如果是网站在浏览器访问127.0.0.1:2000端口即可。 |
Oops, something went wrong.