Code Monkey home page Code Monkey logo

nps's Introduction

NPS

README|中文文档

说明

由于nps已经有二年多的时间没有更新了,存留了不少bug和未完善的功能。

此版本基于 nps 0.26.10的基础上二次开发而来。

DockerHubNPS NPC

交流群

聊天灌水QQ群:619833483

特价云服务器

国内BGP,游戏开服,2核 2G 15M上行 25元/月,专属连接,首月5折

捐赠

image

更新日志

  • 2024-06-01 v0.26.19

    • golang 版本升级到 1.22.
    • 增加自动https,自动将http 重定向(301)到 https.
    • 客户端命令行方式启动支持多个隧道ID,使用逗号拼接,示例:npc -server=xxx:8024 -vkey=ytkpyr0er676m0r7,iwnbjfbvygvzyzzt .
    • 移除 nps.conf 参数 https_just_proxy , 调整 https 处理逻辑,如果上传了 https 证书,则由nps负责SSL (此方式可以获取真实IP), 否则走端口转发模式(使用本地证书,nps 获取不到真实IP), 如下图所示。
      image
  • 2024-02-27 v0.26.18
    新增:nps.conf 新增 tls_bridge_port=8025 参数,当 tls_enable=true 时,nps 会监听8025端口,作为 tls 的连接端口。
    客户端可以选择连接 tls 端口或者非 tls 端口: npc.exe -server=xxx:8024 -vkey=xxxnpc.exe -server=xxx:8025 -vkey=xxx -tls_enable=true

  • 2024-01-31 v0.26.17
    说明:考虑到 npc 历史版本客户端众多,版本号不同旧版本客户端无法连接,为了兼容,仓库版本号将继续沿用 0.26.xx

  • 2024-01-02 v0.27.01 (已作废,功能移动到v0.26.17 版本)
    新增:tls 流量加密,(客户端忽略证书校验,谨慎使用,客户端与服务端需要同时开启,或同时关闭),使用方式:
    服务端:nps.conf tls_enable=true;
    客户端:npc.conf tls_enable=true 或者 npc.exe -server=xxx -vkey=xxx -tls_enable=true

  • 2023-06-01 v0.26.16
    修复:https 流量不统计 Bug 修复。
    新增:新增全局黑名单IP,用于防止被肉鸡扫描端口或被恶意攻击。
    新增:新增客户端上次在线时间。

  • 2023-02-24 v0.26.15
    修复:更新程序 url 更改到当前仓库中
    修复:nps 在外部路径启动时找不到配置文件
    新增:增加 nps 启动参数,-conf_path=D:\test\nps,可用于加载指定nps配置文件和web文件目录。
    window 使用示例:
    直接启动:nps.exe -conf_path=D:\test\nps
    安装:nps.exe install -conf_path=D:\test\nps
    安装启动:nps.exe start

    linux 使用示例:
    直接启动:./nps -conf_path=/app/nps
    安装:./nps install -conf_path=/app/nps
    安装启动:nps start -conf_path=/app/nps

  • 2022-12-30 v0.26.14
    修复:API 鉴权漏洞修复

  • 2022-12-19
    修复:某些场景下丢包导致服务端意外退出
    优化:新增隧道时,不指定服务端口时,将自动生成端口号
    优化:API返回ID, /client/add/, /index/addhost/,/index/add/
    优化:域名解析、隧道页面,增加[唯一验证密钥],方便搜查

  • 2022-10-30
    新增:在管理面板中新增客户端时,可以配置多个黑名单IP,用于防止被肉鸡扫描端口或被恶意攻击。
    优化:0.26.12 版本还原了注册系统功能,使用方式和以前一样。无论是否注册了系统服务,直接执行 nps 时只会读取当前目录下的配置文件。

  • 2022-10-27
    新增:在管理面板登录时开启验证码校验,开启方式:nps.conf open_captcha=true,感谢 @dongFangTuring 提供的PR

  • 2022-10-24:
    修复:HTTP协议支持WebSocket(稳定性待测试)

  • 2022-10-21:
    修复:HTTP协议下实时统计流量,能够精准的限制住流量(上下行对等)
    优化:删除HTTP隧道时,客户端已用流量不再清空

  • 2022-10-19:
    BUG:在TCP协议下,流量统计有问题,只有当连接断开时才会统计流量。例如,限制客户端流量20m,当传输100m的文件时,也能传输成功。
    修复:TCP协议下实时统计流量,能够精准的限制住流量(上下行对等)
    优化:删除TCP隧道时,客户端已用流量不再清空 image

  • 2022-09-14:
    修改NPS工作目录为当前可执行文件目录(即配置文件和nps可执行文件放在同一目录下,直接执行nps文件即可),去除注册系统服务,启动、停止、升级等命令

nps's People

Contributors

arugal avatar avengexyz avatar caiych avatar callantaylor avatar clh021 avatar cnlh avatar dalerkd avatar deltaxraydelta avatar dongfangturing avatar evangwt avatar exfly avatar ffdfgdfg avatar hanxi avatar hellodword avatar hzgjq avatar jireh012 avatar kekxv avatar lesteryou avatar libotony avatar lpxxn avatar mrdotdotdot avatar snowie2000 avatar thelittlefox avatar waysup avatar wuhanstudio avatar wyaode avatar xiexiao avatar yisier avatar yzy613 avatar zouri 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nps's Issues

NPS如何安装?报错当前连接验证错误

2022/10/28 10:57:21.590 [I] [bridge.go:198] Current client connection validation error, close this client: 122.96.144.253:60106
2022/10/28 10:57:21.949 [I] [bridge.go:198] Current client connection validation error, close this client: 218.2.107.245:12045
2022/10/28 10:57:26.692 [I] [bridge.go:198] Current client connection validation error, close this client: 122.96.144.253:60109
2022/10/28 10:57:27.047 [I] [bridge.go:198] Current client connection validation error, close this client: 218.2.107.245:28158

image

请问有docker的npc吗?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Basic 认证用户名 这个干嘛用的?

文档里面没找到这个设置的具体说明?
我刚开始以为是 http代理的用户名和密码认证
但是 实践的时候发现
加了 Basic 认证用户名 和密码 就会提示 ssl:default [远程计算机拒绝网络连接。]
而且log里面没找到相关的内容.
希望能够得到解答,谢谢

web Basic 认证

希望能改进一下Basic 认证功能,主要是在编辑客户端开启了Basic 认证功能,底下所有Web都进行了认证加密,这点很不方便,有些站点须要加密认证,有些不要,能不能在新增WEB页面里添加Basic 认证功能,这样可以有选择

命令:nps start和nps的问题

不知道哪里出现的问题
当我直接试用nps start的时候,一切正常(web后台和内网穿透均正常)
但是我试用nps命令启动的时候,web后台正常,但是内网穿透有问题
这是截图:
https://s1.ax1x.com/2022/11/22/z1G64x.png

以下是我的配置文件

appname = nps
#Boot mode(dev|pro)
runmode = pro

##bridge
# 底层通信协议,默认tcp,可选用kcp
bridge_type=tcp
# 底层通信端口,默认8024,如已被占用请指定其他端口
bridge_port=7000
bridge_ip=0.0.0.0

# 当客户端以配置文件模式启动时会用到的验证密钥,可自行设置,本教程不会使用到
public_vkey=

#Traffic data persistence interval(minute)
#Ignorance means no persistence
flow_store_interval=1

# log level LevelEmergency->0  LevelAlert->1 LevelCritical->2 LevelError->3 LevelWarning->4 LevelNotice->5 LevelInformational->6 LevelDebug->7
log_level=6
log_path=nps.log

#Whether to restrict IP access, true or false or ignore
#ip_limit=true

#p2p
#p2p_ip=127.0.0.1
#p2p_port=6000

#web
web_host=nps.xxx*****.cn
web_username=*8*****
web_password=**********5
web_port = 8001
web_ip=0.0.0.0
web_base_url=
web_open_ssl=true
web_cert_file=/root/conf/server.pem
web_key_file=/root/conf/server.key
# if web under proxy use sub path. like http://host/nps need this.
#web_base_url=/nps

#Web API unauthenticated IP address(the len of auth_crypt_key must be 16)
#Remove comments if needed
#auth_key=test
auth_crypt_key =1234567812345678

#allow_ports=9001-9009,10001,11000-12000

#Web management multi-user login
allow_user_login=false
allow_user_register=false
allow_user_change_username=false

#extension
#流量限制
allow_flow_limit=true
#带宽限制
allow_rate_limit=true
#客户端最大隧道数限制
allow_tunnel_num_limit=true
allow_local_proxy=false
#客户端最大连接数
allow_connection_num_limit=true
#每个隧道监听不同的服务端端口
allow_multi_ip=true
system_info_display=true

#获取用户真实ip
http_add_origin_header=true

#cache
http_cache=false
http_cache_length=100

#get origin ip
http_add_origin_header=false

#pprof debug options
#pprof_ip=0.0.0.0
#pprof_port=9999

#client disconnect timeout
disconnect_timeout=60

#管理面板开启验证码校验
open_captcha=true

请问怎么使用?

我是小白一个,请问一下你更新的nps怎么使用?我需要websocket功能,我没找到安装包什么的?👍

改完存储位置后映射访问报错,改动在PR中

2022/11/01 15:06:02 worker with func exits from a panic: runtime error: invalid memory address or nil pointer dereference

2022/11/01 15:06:02 worker with func exits from panic: goroutine 72 [running]:

github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1.1(0xc00030a2a0)

/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:58 +0x165

panic(0xa66500, 0xf62ce0)

/usr/local/go/src/runtime/panic.go:969 +0x1b9

ehang.io/nps/lib/file.(*Flow).Add(0x0, 0x8000, 0x8000)

/go/src/ehang.io/nps/lib/file/obj.go:21 +0x33

ehang.io/nps/lib/goroutine.CopyBuffer(0x7efe6aebe858, 0xc000348020, 0xbd9960, 0xc000316050, 0x0, 0x0, 0xc0003043f0, 0xd, 0x0, 0x0)

/go/src/ehang.io/nps/lib/goroutine/pool.go:81 +0x2db

ehang.io/nps/lib/goroutine.copyConnGroup(0xad7d00, 0xc00031f630)

/go/src/ehang.io/nps/lib/goroutine/pool.go:114 +0x15d

github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1(0xc00030a2a0)

/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:68 +0xb0

created by github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run

/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:48 +0x4c

NPC -Docker - 遇到了内核提示0.26.0,但是我装了0.26.14

Server : 服务端版本 0.26.14
Clent: 0.26.14

Clent Docer Bug Info:
2023/01/12 16:25:26.568 [I] [npc.go:231] the version of client is 0.26.14, the core version of client is 0.26.0
2023/01/12 16:25:26.569 [I] [control.go:97] Loading configuration file conf/npc.conf successfully
2023/01/12 16:25:27.648 [E] [control.go:235] The client does not match the server version. The current core version of the client is 0.26.0
panic: runtime error: invalid memory address or nil pointer dereference
[

P2P模式不是真实的点对点,依然需要服务端转发,并且受服务器带宽限制,希望修复

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Opening '...'
  2. Click on '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots or logs
Add screenshots or logs to help explain your problem.

Server (please complete the following information):

  • OS: [e.g. Centos, Windows]
  • ARCH: [e.g. Amd64, Arm]
  • Tunnel [e.g. TCP, HTTP]
  • Version [e.g. 0.24.0]

Client (please complete the following information):

  • OS: [e.g. Centos, Windows]
  • ARCH: [e.g. Amd64, Arm]
  • Tunnel [e.g. TCP, HTTP]
  • Version [e.g. 0.24.0]

Additional context
Add any other context about the problem here.

android 服务端和客户端支持

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

可以考虑一下出npc安卓版吗,如果可以的话,能不能加上p2p连接功能

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

websocket报错

2022/10/31 01:12:28 worker with func exits from a panic: runtime error: invalid memory address or nil pointer dereference
2022/10/31 01:12:28 worker with func exits from panic: goroutine 240 [running]:
github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1.1(0xc000202a80)
/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:58 +0x165
panic(0xa66500, 0xf62ce0)
/usr/local/go/src/runtime/panic.go:969 +0x1b9
ehang.io/nps/lib/file.(*Flow).Add(0x0, 0x81, 0x81)
/go/src/ehang.io/nps/lib/file/obj.go:21 +0x33
ehang.io/nps/lib/goroutine.CopyBuffer(0x7f714146f008, 0xc00000d4a0, 0xbd9920, 0xc0000a00c0, 0x0, 0x0, 0xc0000a2670, 0xe, 0x0, 0x0)
/go/src/ehang.io/nps/lib/goroutine/pool.go:81 +0x2db
ehang.io/nps/lib/goroutine.copyConnGroup(0xad7d00, 0xc0002930e0)
/go/src/ehang.io/nps/lib/goroutine/pool.go:114 +0x15d
github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run.func1(0xc000202a80)
/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:68 +0xb0
created by github.com/panjf2000/ants/v2.(*goWorkerWithFunc).run
/go/pkg/mod/github.com/panjf2000/ants/[email protected]/worker_func.go:48 +0x4c

在外部路径启动时会找不到配置文件

执行文件路径:/mnt/mmcblk0p1/app/nps/nps
配置文件路径:/mnt/mmcblk0p1/app/nps/conf/nps.conf

在其他目录启动输入 /mnt/mmcblk0p1/app/nps/nps
会提示
2023/01/12 11:38:47 load config file error the target config file: conf/nps.conf don't exist

是否能添加一个 用于查询 流量统计数据的API

我的想通过调取API的方式来统计流量(因为我有好几个服务器需要统计 所以我想自己写一个脚本 进行流量分析 毕竟我不可能一个一个的进后台)

(希望得到各位支持 谢谢谢谢🙏)

校园网拦截npc客户端的连接

连接后客户端提示:
[46f73f7a2b954e16b7c8e375d9355b77](client.go:63] The connection server failed and will be reconnected in five seconds, error read tcp 10.2.28.8:40784->101.2.188.54:8080: wsarecv: An existing connection was forcibly closed by the remote host.)

如何规避这样的问题。

tls加密

可以增加客户端和服务端连接使用tls加密这个功能吗

域名解析通道异常

使用域名解析映射内网服务时;
当浏览器已经打开过nps本身映射的页面后,再不重启浏览器的情况下,继续访问其他三级域名时,显示的内容只会是nps。
目前遇到过会出现类型情况的服务器页面有 nps本身页面、pfSecse管理页面、bitwarden密码管理页面。
当已经打开过上述页面后,只能重启浏览器才能打开映射的其他的域名。
image

客户端 ID 问题

遇到几个问题不知道是正常:

  • web操作,客户端暂停后原客户端ID被释放,但绑定的隧道的客户端ID确没有变动,如果隧道过多就需要一个一个手动去修改才能正常使用。
  • web操作暂停客户端后,状态和连接还是显示开放和在线,而暂停隧道界面却显示正常。

很想提供支持

很想提供支持,奈何我不会go,学了一点,但是也只限于刚刚会

多个客户端配置可以写在一个config文件内吗?

我的NAS上跑了不同的容器应用,有多个应用需要通过NPS以域名解析的方式穿透出内网。目前我是在NAS上跑了N个NPC容器来分别连接NPS实现不同的应用域名解析穿透,可以将这些写在一个NPC的config配置文件中,以实现只要启动一个NPC客户端,就可以完成所有的连接吗?
image
image

TCP隧道+nginx反代时如何获取真实IP

原因:使用nps将公网服务器的9000端口转发到内网的远程桌面。但是运行一段时间后就会发现有一个IP再不断的爆破这个900端口,参考大量的非法url 攻击的方式,想尝试在nps外面加nginx,在nginx里面使用allow和deny来对IP进行处理。我的配置目前如下,

stream{
    upstream windows{
        hash $remote_addr consistent;
        server 	127.0.0.1:9000 max_fails=3 fail_timeout=10s;
    }
    server{
        listen 8000;
        proxy_connect_timeout 20s;
        proxy_timeout 5m;
        proxy_pass windows;
    }
}

但是这样在npc客户端中显示的访问ip永远都是127.0.0.1,假如再次有非法IP爆破端口我无法知道他的真实ip。
问题:如果使用nginx的反代方式,如何知道爆破方的真实IP?
或者nps有什么方法可以限制或者允许指定IP吗?(因为使用的人较复杂,所以只通过一个IP或者一个IP cidr无法满足要求,需要支持多个IP cidr的设置)

一些需求

客户端导航:点开后左侧客户端列表,点开能够看到这个ID下面的所有tcp、域名解析等。客户端ID可以设置自动停用时间

一个域名对多个端口的问题,或者一个域名可以快速多条不同端口的穿透

客户端无法连接服务端,提示超时

服务端版本:v0.26.12.3
客户端版本:v0.26.12.3

操作:
在腾讯云服务器上安装服务端版本,开放了8424(桥接端口),9090(web端口)
在windows下直接使用npc.exe文件,不使用配置,执行以下命令
npc.exe -server=公网ip:8424 -vkey=uskbvdubfff08f02 -type=tcp
配置文件:
image

最后结果是这样的,超时,并且web界面未连接
image
宝塔端口放行
image
腾讯云端口放行
image

希望能得到大佬的解答,真心搞不懂,搞了大半个月了。

通过API 增加客户端没有返回ID

添加客户端接口 POST /client/add/

1、API 增加客户端没有返回ID(无法自动返回拿到ID,需要再查询所有ID,然后筛选出来刚新增的ID)
需求:
响应携带 ID
希望能提供自增长的客户端webAPI新增接口。每次可以返回跟原有ID不重复的ID.

2、域名解析列表获取接口,不能指定客户端ID下的域名列表。(仅通过搜索来筛选)

可以添加http重定向到https吗

域名解析只打开https的时候,希望通过https进行访问,可以添加http重定向https吗。nps管理页面也希望有重定向

WakeOnLan魔术桢

Is your feature request related to a problem? Please describe.
现有nps无法转发WOL魔术桢

Describe the solution you'd like
正常转发WOL魔术桢

Describe alternatives you've considered
None

Additional context
None

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.