Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

私密或P2P模式下穿透不成功 #515

Closed
TC3961 opened this issue Apr 19, 2020 · 3 comments
Closed

私密或P2P模式下穿透不成功 #515

TC3961 opened this issue Apr 19, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@TC3961
Copy link

TC3961 commented Apr 19, 2020

Describe the bug
之前一直用着v0.23.1版本的客户端,今天下载最新版本v0.26.6使用,奇怪的事情发生了。

先描述一下环境:

  • 1台公网机器,开放了3389端口作为nps工作端口,3390作为p2p工作端口,nps运行在docker中
  • 1台办公室Windows电脑,无配置模式运行npc,目标为办公室内网的一个web服务
  • 1台随身携带的Mac电脑,无配置模式运行npc,用于通过私密模式访问办公室内网的web服务

嗯,看上去没什么问题,p2p能否穿透不一定,但私密模式肯定是没问题的。

然后我就开始准备配置

  1. 公网机器运行nps的配置文件如下
appname = nps
#Boot mode(dev|pro)
runmode = dev

#HTTP(S) proxy port, no startup if empty
http_proxy_ip=0.0.0.0
http_proxy_port=8001
https_proxy_port=8002

##bridge
bridge_type=tcp
bridge_port=3389
bridge_ip=0.0.0.0

#p2p
p2p_ip=48.65.88.**
p2p_port=3390

#web
web_host=nps.****.com
web_username=admin
web_password=*********
web_port = 81

# 其他默认配置就不列出了 ...
  1. 在web管理后台添加了一个客户端,得到客户端命令
./npc -server=nps.****.com:3389 -vkey=ii5r6f1u3fk37odt -type=tcp

然后在办公室电脑运行了该命令,日志显示正常

$ ./npc -server=nps.****.com:3389 -vkey=ii5r6f1u3fk37odt -type=tcp
2020/04/19 14:46:15.856 [I] [npc.go:229]  the version of client is 0.26.6, the core version of client is 0.26.0
2020/04/19 14:46:15.979 [I] [client.go:67]  Successful connection with server nps.****.com:3389
  1. 在web管理后台为这个客户端添加一个私密隧道,目标端口为192.168.1.88:80,得到命令
./npc -server=nps.****.com:3389 -vkey=ii5r6f1u3fk37odt -type=tcp -password=3818b56dab01 -local_type=secret

然后我在我的Mac笔记本上运行了该命令,日志如下

./npc -server=nps.****.com:3389 -vkey=ii5r6f1u3fk37odt -type=tcp -password=3818b56dab01 -local_type=secret
2020/04/19 15:37:45.390 [I] [npc.go:229]  the version of client is 0.26.6, the core version of client is 0.26.0
2020/04/19 15:37:45.390 [I] [local.go:115]  successful start-up of local tcp monitoring, port 2000
2020/04/19 15:37:45.541 [I] [client.go:67]  Successful connection with server nps.****.com:3389
  1. 通过curl测试穿透是否成功
    我在Mac笔记本上运行了curl http://127.0.0.1:2000,但是响应的结果为
curl: (52) Empty reply from server

查看Mac笔记本上的日志,多了两行

2020/04/19 15:40:35.698 [D] [local.go:117]  new secret connection
2020/04/19 15:40:41.757 [W] [client.go:208]  connect to 192.168.1.88:80 error dial tcp 192.168.1.88:80: i/o timeout
  1. 我Ctrl+C结束Mac笔记本上的npc进程,web控制台上显示在线客户端为0
    我认为是Mac这边连接服务器后将办公室的npc挤下线了,
    还抢了对方的工作,
    在Mac笔记本当前局域网寻找我指定的web服务,
    当我在web控制台上修改隧道的目标端口为192.168.1.1:80时,
    我在Mac本机通过curl 127.0.0.1:2000确实访问到了当前局域网的路由器登录界面

  2. 可能是我配置上的疏忽,但是我使用旧版本(v0.23.1)是正常的,这可能不是一个BUG,但此时配置不通我特别郁闷,我已经反复尝试几个小时了,我很希望能使用新版本,希望大家可以帮忙找到问题所在,谢谢~

  3. 下面是我使用配置文件方式进行尝试的配置,依然无法成功
    办公室电脑npc.conf

server_addr=nps.****.com:3389
conn_type=tcp
vkey=ii5r6f1u3fk37odt
auto_reconnection=true
crypt=true
compress=true

[secret_web]
mode=secret
password=3818b56dab02
target_addr=192.168.1.88:80

Mac笔记本npc.conf

[common]
server_addr=nps.****.com:3389
conn_type=tcp
vkey=ii5r6f1u3fk37odt
auto_reconnection=true
crypt=true
compress=true

# 很奇怪,如果下面这个配置组名不为secret_web,会启动不成功
# 例如我起名为web_secret的时候,报错如下
# The server returned an error, which port or host may have been occupied or not allowed to open.  web_secret
[secret_web]
local_port=2000
password=3818b56dab02
@TC3961 TC3961 added the bug Something isn't working label Apr 19, 2020
@ghost
Copy link

ghost commented Apr 21, 2020

同样的问题。

@ffdfgdfg
Copy link
Contributor

96e7b02

@TC3961 TC3961 closed this as completed May 7, 2020
ffdfgdfg added a commit that referenced this issue May 7, 2020
kiririx pushed a commit to kiririx/nps that referenced this issue Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@TC3961 @ffdfgdfg and others