ehang-io / nps

一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
https://ehang.io/nps/documents
GNU General Public License v3.0
30.47k stars 5.5k forks source link

Out of Range Error and multiple problems when use NPS with RDP using UDP. 使用UDP的远程桌面时出现越界错误等多个问题 #953

Open panda361 opened 2 years ago

panda361 commented 2 years ago

当使用NPS代理远程桌面协议时,远程桌面经常无法使用UDP协议进行通信,这极大地降低了使用体验。 后来发现如果把NPS的加密关掉后,偶尔可以实现使用UDP的连接。但是在使用过程中遇到了如下问题。 当RDP内容变化较大时,会产生很多UDP包,频发NPC与NPS之间连接断开。 也产生过如下的越界问题。 When using NPS to proxy RDP, MSTSC often cannot communicate using the UDP protocol, which greatly reduces the user experience. I discovered that if the encryption of NPS is turned off, connections using UDP can occasionally be realized. However, the following problems were encountered during use. When the RDP content changes greatly, a lot of UDP packets will be generated, and the connection between NPC and NPS will be disconnected frequently. The following out of range error have also occurred.

2021/12/13 18:58:00.029 [D] [udp.go:49]  New udp connection,client 3,remote address ******:62377
panic: runtime error: slice bounds out of range [75:71]

goroutine 19236 [running]:
ehang.io/nps-mux.(*sendWindow).WriteTo(0xc000812fc0, 0x2007a1103, 0xa54560, 0xc000677558, 0x47, 0x0, 0x0)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:554 +0x2f2
ehang.io/nps-mux.(*sendWindow).WriteFull(0xc000812fc0, 0xc0007a1100, 0x47, 0x688, 0xc000000002, 0x40a37f, 0xc000010000, 0xaa0b00)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:608 +0x8e
ehang.io/nps-mux.(*conn).Write(0xc0006563c0, 0xc0007a1100, 0x47, 0x688, 0xc000677638, 0x40b905, 0xaa0b00)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:63 +0x8e
ehang.io/nps/lib/rate.(*rateConn).Write(0xc00089cf60, 0xc0007a1100, 0x47, 0x688, 0xc00089cf60, 0x1, 0xc000024688)
        /home/runner/work/nps/nps/lib/rate/conn.go:28 +0x55
ehang.io/nps/server/proxy.(*UdpModeServer).process(0xc0001100e0, 0xc0004dbd10, 0xc0007a1100, 0x47, 0x688)
        /home/runner/work/nps/nps/server/proxy/udp.go:59 +0x8e3
created by ehang.io/nps/server/proxy.(*UdpModeServer).Start
        /home/runner/work/nps/nps/server/proxy/udp.go:50 +0x2cc
panic: runtime error: slice bounds out of range [75:71]

goroutine 19237 [running]:
ehang.io/nps-mux.(*sendWindow).WriteTo(0xc000812fc0, 0x2007a1803, 0xa54560, 0xc0004d0d58, 0x4b, 0x0, 0x0)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:554 +0x2f2
ehang.io/nps-mux.(*sendWindow).WriteFull(0xc000812fc0, 0xc0007a1800, 0x4b, 0x688, 0xc000000002, 0x40a37f, 0xc000010000, 0xaa0b00)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:608 +0x8e
ehang.io/nps-mux.(*conn).Write(0xc0006563c0, 0xc0007a1800, 0x4b, 0x688, 0xc000672638, 0x40b905, 0xaa0b00)
        /home/runner/go/pkg/mod/ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992/conn.go:63 +0x8e
ehang.io/nps/lib/rate.(*rateConn).Write(0xc00089cf60, 0xc0007a1800, 0x4b, 0x688, 0xc00089cf60, 0xc00026d001, 0x15)
        /home/runner/work/nps/nps/lib/rate/conn.go:28 +0x55
ehang.io/nps/server/proxy.(*UdpModeServer).process(0xc0001100e0, 0xc0004dbd40, 0xc0007a1800, 0x4b, 0x688)
        /home/runner/work/nps/nps/server/proxy/udp.go:59 +0x8e3
created by ehang.io/nps/server/proxy.(*UdpModeServer).Start
        /home/runner/work/nps/nps/server/proxy/udp.go:50 +0x2cc

想知道,NPS的加密/压缩对反代的内容会产生什么样子的影响吗。 如何能实现更可靠的UDP传输 感谢~ I wonder how NPS encryption/compression will impact on content? How to achieve more reliable UDP transmission Thanks~

Xm798 commented 2 years ago

遇到了同样的问题,RDP开启UDP时nps服务端会频繁崩溃,需要手动重启服务端以恢复正常访问。