简体   繁体   English

通过使用公共反向代理(可以访问 Internet)将 NAT 后面的客户端公开到 Internet

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

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).我想了解通过公共服务器在 NAT 后面公开客户端的理论,例如将客户端用作代理(最好是 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. NAT 后面的客户端不直接监听 TCP。 It just opens up a TCP connection to the public server which should expose the client.它只是打开了一个到应该公开客户端的公共服务器的 TCP 连接。 The SOCKS5 proxy on client behind NAT is not directly exposed so the dialed TCP connection should somehow behave like a TCP listener. NAT 后面的客户端上的 SOCKS5 代理没有直接暴露,因此拨打的 TCP 连接应该以某种方式表现得像 TCP 监听器。

If a client behind NAT connects to a public server, how do other users connect and how should I forward the requests?如果 NAT 后面的客户端连接到公共服务器,其他用户如何连接,我应该如何转发请求?

I think basically it's the same technique that TeamViewer is using:我认为基本上它与 TeamViewer 使用的技术相同:

"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." "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 “

But how exactly?但具体如何?

To summarize, for a proxy server in golang, you have to总而言之,对于 golang 中的代理服务器,您必须

  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.然后它将响应返回给私有网络中的原始客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM