Expose client behind NAT to internet by using a public reverse-proxy (with access to the internet)

huangapple go评论80阅读模式
英文:

Expose client behind NAT to internet by using a public reverse-proxy (with access to the internet)

问题

我想了解通过公共服务器将NAT后面的客户端暴露出来的理论,例如将客户端用作代理(最好是SOCKS5)。找到一个现成的解决方案会很理想,但理论也足够好。

我想指出我的意思。NAT后面的客户端不直接侦听TCP。它只是打开到公共服务器的TCP连接,该服务器应该将客户端暴露出来。NAT后面的客户端上的SOCKS5代理不直接暴露,因此拨号的TCP连接应该以某种方式表现得像TCP侦听器。

如果NAT后面的客户端连接到公共服务器,其他用户如何连接,我应该如何转发请求?

我认为基本上这是TeamViewer使用的相同技术:

“在建立会话时,TeamViewer确定最佳连接类型。在通过我们的主服务器进行握手后,70%的情况下建立直接的UDP或TCP连接(即使在标准网关、NAT和防火墙后面)。其余的连接通过我们高度冗余的路由器网络通过TCP或https隧道路由。您无需打开任何端口即可使用TeamViewer。”

但具体是如何实现的呢?

英文:

I want to understand the theory of exposing clients behind NATs via a public server, for example to use the client as a proxy (preferably SOCKS5). It would be ideal to find a ready solution but theory would good enough.

To point out what I mean. The client behind the NAT does not directly listen on TCP. It just opens up a TCP connection to the public server which should expose the client. The SOCKS5 proxy on client behind NAT is not directly exposed so the dialed TCP connection should somehow behave like a TCP listener.

If a client behind NAT connects to a public server, how do other users connect and how should I forward the requests?

I think basically it's the same technique that TeamViewer is using:

"When establishing a session, TeamViewer determines the optimal type of connection. After the handshake through our master servers, a direct connection via UDP or TCP is established in 70% of all cases (even behind standard gateways, NATs and firewalls). The rest of the connections are routed through our highly redundant router network via TCP or https tunneling. You do not have to open any ports in order to work with TeamViewer."

But how exactly?

答案1

得分: 1

总结一下,对于使用golang编写的代理服务器,你需要:

  1. 创建一个服务器,监听带有一些参数的请求。
  2. 当接收到请求时,它将向所需的地址发出请求。
  3. 然后将响应返回给原始客户端在私有网络中。
英文:

To summarize, for a proxy server in golang, you have to

  1. Create a server that listens to requests with some parameters.
  2. When a request is received, it will make the request to the desired address.
  3. Then it will return the response to the original client in the private network.

huangapple
  • 本文由 发表于 2021年12月15日 05:59:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/70356041.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定