[GH-ISSUE #3850] frpc的HTTP代理能使用,socks5代理无法使用,socks5报错0x03或0x04 #3060

Closed
opened 2026-05-05 13:58:46 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @AdiEcho on GitHub (Dec 15, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3850

Bug Description

先说一下我的部署情况
frps 是双栈网络环境机器,frpc 部分双栈部分仅v4,frpc同时部署http代理和socks5代理

在几台机器上的http代理正常通网,但是socks5不通,使用socks5的时候报错0x03: Network unreachable或0x04: Host unreachable
这个现象在几台机器上必现,其他机器socks5和http代理均可用
在log中没有有用的信息,所以发到issue中看看有没有大佬知道是啥情况

frpc Version

0.53.0

frps Version

0.53.0

System Architecture

linux/amd64

Configurations

serverAddr = ****
serverPort =  ****
auth.token =  ****
[[proxies]]
name = "http_proxy"
type = "tcp"
remotePort = 11111
transport.useEncryption = true
transport.useCompression = true
[proxies.plugin]
type = "http_proxy"

[[proxies]]
name = "socks5_proxy"
type = "tcp"
remotePort = 11112
transport.useEncryption = true
transport.useCompression = true
[proxies.plugin]
type = "socks5"

Logs

2023/12/15 12:38:29 [D] [proxy_wrapper.go:260] [e116d9673a3b7c36] [socks5_proxy] start a new work connection, localAddr: **** remoteAddr: ****
2023/12/15 12:38:29 [T] [proxy.go:144] [e116d9673a3b7c36] [socks5_proxy] handle tcp work connection, useEncryption: true, useCompression: true
2023/12/15 12:38:29 [D] [proxy.go:192] [e116d9673a3b7c36] [socks5_proxy] handle by plugin: socks5
2023/12/15 12:38:30 [D] [proxy.go:194] [e116d9673a3b7c36] [socks5_proxy] handle by plugin finished
2023/12/15 12:38:30 [D] [proxy_wrapper.go:260] [e116d9673a3b7c36] [http_proxy] start a new work connection, localAddr: **** remoteAddr: ****
2023/12/15 12:38:30 [T] [proxy.go:144] [e116d9673a3b7c36] [http_proxy] handle tcp work connection, useEncryption: true, useCompression: true
2023/12/15 12:38:30 [D] [proxy.go:192] [e116d9673a3b7c36] [http_proxy] handle by plugin: http_proxy
2023/12/15 12:38:32 [D] [proxy.go:194] [e116d9673a3b7c36] [http_proxy] handle by plugin finished

Steps to reproduce

正常部署

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @AdiEcho on GitHub (Dec 15, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3850 ### Bug Description 先说一下我的部署情况 frps 是双栈网络环境机器,frpc 部分双栈部分仅v4,frpc同时部署http代理和socks5代理 在几台机器上的http代理正常通网,但是socks5不通,使用socks5的时候报错0x03: Network unreachable或0x04: Host unreachable 这个现象在几台机器上必现,其他机器socks5和http代理均可用 在log中没有有用的信息,所以发到issue中看看有没有大佬知道是啥情况 ### frpc Version 0.53.0 ### frps Version 0.53.0 ### System Architecture linux/amd64 ### Configurations ``` serverAddr = **** serverPort = **** auth.token = **** [[proxies]] name = "http_proxy" type = "tcp" remotePort = 11111 transport.useEncryption = true transport.useCompression = true [proxies.plugin] type = "http_proxy" [[proxies]] name = "socks5_proxy" type = "tcp" remotePort = 11112 transport.useEncryption = true transport.useCompression = true [proxies.plugin] type = "socks5" ``` ### Logs ``` 2023/12/15 12:38:29 [D] [proxy_wrapper.go:260] [e116d9673a3b7c36] [socks5_proxy] start a new work connection, localAddr: **** remoteAddr: **** 2023/12/15 12:38:29 [T] [proxy.go:144] [e116d9673a3b7c36] [socks5_proxy] handle tcp work connection, useEncryption: true, useCompression: true 2023/12/15 12:38:29 [D] [proxy.go:192] [e116d9673a3b7c36] [socks5_proxy] handle by plugin: socks5 2023/12/15 12:38:30 [D] [proxy.go:194] [e116d9673a3b7c36] [socks5_proxy] handle by plugin finished 2023/12/15 12:38:30 [D] [proxy_wrapper.go:260] [e116d9673a3b7c36] [http_proxy] start a new work connection, localAddr: **** remoteAddr: **** 2023/12/15 12:38:30 [T] [proxy.go:144] [e116d9673a3b7c36] [http_proxy] handle tcp work connection, useEncryption: true, useCompression: true 2023/12/15 12:38:30 [D] [proxy.go:192] [e116d9673a3b7c36] [http_proxy] handle by plugin: http_proxy 2023/12/15 12:38:32 [D] [proxy.go:194] [e116d9673a3b7c36] [http_proxy] handle by plugin finished ``` ### Steps to reproduce 正常部署 ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [X] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [X] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@AdiEcho commented on GitHub (Dec 15, 2023):

经测试
访问目标为ip地址时,问题机器部署的socks5代理和http代理使用均正常
访问目标为域名地址时,仅http代理工作正常

应用方面使用doh实现解决了这个问题,但对其出现的原因还是不理解

<!-- gh-comment-id:1858354076 --> @AdiEcho commented on GitHub (Dec 15, 2023): 经测试 访问目标为ip地址时,问题机器部署的socks5代理和http代理使用均正常 访问目标为域名地址时,仅http代理工作正常 应用方面使用doh实现解决了这个问题,但对其出现的原因还是不理解
Author
Owner

@xqzr commented on GitHub (Dec 15, 2023):

IP 协议版本🤔
比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接

<!-- gh-comment-id:1858440622 --> @xqzr commented on GitHub (Dec 15, 2023): IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接
Author
Owner

@xqzr commented on GitHub (Dec 15, 2023):

socks5 代理 收到域名 时有可能,在本地解析 (结果可能被污染)
http 代理 收到域名 时不会在 本地解析,而是 传递给 frpc 解析

<!-- gh-comment-id:1858444178 --> @xqzr commented on GitHub (Dec 15, 2023): socks5 代理 收到域名 时有可能,在本地解析 ~~(结果可能被污染)~~ http 代理 收到域名 时不会在 本地解析,而是 传递给 frpc 解析
Author
Owner

@AdiEcho commented on GitHub (Dec 15, 2023):

IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接

太对了哥,就是这个原因

刚刚找了 纯v4/v6/双栈 的网站测试了一下
socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错
http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host

感谢老哥的解答

PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接

<!-- gh-comment-id:1858466773 --> @AdiEcho commented on GitHub (Dec 15, 2023): > IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接 太对了哥,就是这个原因 刚刚找了 纯v4/v6/双栈 的网站测试了一下 socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错 http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host 感谢老哥的解答 PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接
Author
Owner

@xqzr commented on GitHub (Dec 15, 2023):

IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接

刚刚找了 纯v4/v6/双栈 的网站测试了一下 socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错 http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host

PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接

frpc 这边有 IPv6 能力吗?如果没有 socks5 客户端(浏览器)把 IPv6 地址 传递给 socks5 服务端(frpc),而 frpc 这边网络 没有 IPv6 能力,就出错了

<!-- gh-comment-id:1858521746 --> @xqzr commented on GitHub (Dec 15, 2023): > > IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接 > > 刚刚找了 纯v4/v6/双栈 的网站测试了一下 socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错 http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host > > PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接 frpc 这边有 IPv6 能力吗?如果没有 socks5 客户端(浏览器)把 IPv6 地址 传递给 socks5 服务端(frpc),而 frpc 这边网络 没有 IPv6 能力,就出错了
Author
Owner

@AdiEcho commented on GitHub (Dec 16, 2023):

IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接

刚刚找了 纯v4/v6/双栈 的网站测试了一下 socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错 http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host
PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接

frpc 这边有 IPv6 能力吗?如果没有 socks5 客户端(浏览器)把 IPv6 地址 传递给 socks5 服务端(frpc),而 frpc 这边网络 没有 IPv6 能力,就出错了

出问题的frpc都没有v6地址
确实是socks5客户端的问题,客户端是双栈环境,通过限制仅v4连接也同样解决了这个问题了

顺便贴一下相关的python代码给有需要的朋友

import socket
old_getaddrinfo = socket.getaddrinfo


def new_getaddrinfo(*args, **kwargs):
    responses = old_getaddrinfo(*args, **kwargs)
    return [response for response in responses if response[0] == socket.AF_INET]


socket.getaddrinfo = new_getaddrinfo
<!-- gh-comment-id:1858752143 --> @AdiEcho commented on GitHub (Dec 16, 2023): > > > IP 协议版本🤔 比如 frpc 没有 IPv6,但域名解析 得到 IPv6 地址,并且 使用它连接 > > > > > > 刚刚找了 纯v4/v6/双栈 的网站测试了一下 socks5 只能连接 纯v4 网站,纯v6/双栈 网站都无法使用,如issue报错 http 能连接 纯v4/双栈 网站,纯v6 则报错 dial tcp: lookup **** on 127.0.0.1:53: no such host > > PS: 其实还是有点不明白,为什么会解析到v6地址,这样的话socks5也太脆弱了,双栈网站都无法连接 > > frpc 这边有 IPv6 能力吗?如果没有 socks5 客户端(浏览器)把 IPv6 地址 传递给 socks5 服务端(frpc),而 frpc 这边网络 没有 IPv6 能力,就出错了 出问题的frpc都没有v6地址 确实是socks5客户端的问题,客户端是双栈环境,通过限制仅v4连接也同样解决了这个问题了 顺便贴一下相关的python代码给有需要的朋友 ``` import socket old_getaddrinfo = socket.getaddrinfo def new_getaddrinfo(*args, **kwargs): responses = old_getaddrinfo(*args, **kwargs) return [response for response in responses if response[0] == socket.AF_INET] socket.getaddrinfo = new_getaddrinfo ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3060
No description provided.