gpt4 book ai didi

proxy - 通过 Dante socks5 代理服务器的 Telegram 调用不起作用

转载 作者:行者123 更新时间:2023-12-04 07:16:07 31 4
gpt4 key购买 nike

我已将 Ubuntu 16.04 上的 Dante 1.4 配置为 Telegram 的 socks5 代理。

聊天正常,但语音通话不正常,“连接”失败。

为了代理 Telegram 语音流量,我需要配置什么特别的东西吗?

我正在使用单个非特权(> 1024)TCP/UDP端口+登录名+密码进行连接。

谢谢!

UPD:当我试图调用某人时,那是一段日志:

Apr 15 23:05:38 (1523736338.510915) danted[22977]: info: pass(1): udp/udpassociate [: username%USER@0.0.0.0.0 192.168.1.30.36562

Apr 15 23:08:33 (1523736513.020190) danted[22989]: info: pass(1): udp/udpassociate [: username%USER@0.0.0.0.0 192.168.1.30.49065

我可以在目标设备上接听电话,但连接正在循环并在 30 秒后出现错误。

最佳答案

使用 socks 代理 UDP 比看起来要复杂一些,所以让我们从头开始。
Telegram 电话use UDP with socks . socks 5 RFC1928为中继 UDP 定义了以下序列:

  • 客户端实例化一个 TCP socks5 连接。
  • 客户发送 UDP ASSOCIATE请求,包含客户端的源地址和端口,将用于向 socks5 服务器发送 UDP 数据报。它们可能是零(在 Telegram 中它们是)(第 4 节)。
  • Socks5 服务器为这个 TCP socks5 连接绑定(bind)一个随机的 UDP 端口来中继数据报,并发送一个 UDP ASSOCIATE响应,包含客户端应发送要中继的数据报的地址和端口(第 6 节)。
  • 要发送数据报,客户端必须向有效负载添加一个 header ,其中包含目标地址和端口,服务器应在其中中继该数据报(第 7 节)。
  • 服务器将保持 UDP 端口绑定(bind),直到 TCP socks5 连接终止。

  • 如您所见,仅打开一个 TCP 端口是不够的。要使 UDP 正常工作,客户端必须可以访问自动绑定(bind)的 UDP 端口。 NAT 和防火墙可能会使情况更加复杂。
    使用 Dante 进行 UDP 中继配置
  • Telegram 调用是点对点的,所以 udpassociate命令应该被允许 0/0 :
     socks pass {
    from: 0.0.0.0/0
    to: 0.0.0.0/0
    # udp.portrange: 40000-45000
    command: udpassociate
    log: error connect disconnect
    }
  • udpreply (这是实际的中继,上面的第 4 步)也应该允许每个人使用:
     socks pass {
    from: 0.0.0.0/0
    to: 0.0.0.0/0
    command: udpreply
    log: error connect disconnect
    }
  • 如果您的 socks5 服务器位于防火墙后面,请打开一系列 UDP 端口(例如 40000-45000 )并添加 udp.portrange: 40000-45000udpassociate 的行 block (请参阅第一点中注释掉的示例)。然后 Dante 将仅绑定(bind)该范围内的 UDP 端口。
  • 如果你的 socks5 服务器在 NAT 之后,那么在响应 UDP ASSOCIATE 中返回的目标地址请求将是本地 IP,而不是外部 IP。客户端不太可能访问该本地 IP,因此发送的数据报将被静默丢弃。
    不幸的是,Dante 使用 TCP 连接的目标地址作为客户端发送 UDP 数据报的地址(见 the comment in the source code)。 NAT 将这个地址从外部地址转换为本地地址,因此 Dante 认为客户端可以使用该目标地址到达代理的假设被打破。
    一个不涉及修补 Dante 的可能解决方案是使用 iptables 将目标地址从本地更改为外部地址(假设它是已知的并且不会更改):
     # 203.0.113.12 – the external IP
    # 1080/tcp - Dante TCP port
    # 40000:45000 – Dante UDP portrange
    iptables -t nat -A PREROUTING -p tcp --dport 1080 -j DNAT --to-destination 203.0.113.12
    iptables -t nat -A PREROUTING -p udp --dport 40000:45000 -j DNAT --to-destination 203.0.113.12

    # If external address is not added to any network device on that
    # machine, then add it to the loopback interface, so the kernel
    # would know where to route the DNATed packets:
    ip addr add 203.0.113.12/32 dev lo
  • 关于proxy - 通过 Dante socks5 代理服务器的 Telegram 调用不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49855516/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com