inbounds协议(HTTP)与outbounds协议(Trojan/Vmess)不同是否可行
如题,想给一些只支持http_proxy的程序用上机场提供的trojan协议的节点,机场clash.yaml中某个节点的信息(隐去一些密钥细节)如下
-
name: "节点1\t"
type: trojan
server: relay-**-**.*****.com
port: '22***'
password: 1a****-****-****-a467-2b******8d6c
sni: **-**.telk*****.com
注意到是一个开启了sni选项的trojan节点,查阅手册后填写对应outbounds项如下:
{
"type": "trojan",
"tag": "trojan-out-node1",
"server": "relay-**-**.*****.com",
"server_port": 22***,
"password": "1a****-****-****-a467-2b******8d6c",
"tls": {
"enabled": true,
"server_name": "**-**.telk*****.com",
"insecure": true,
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
}
}
其中,insecure、disable_sni、utls等field都排列组合增删过,添加与否不影响下面日志的报错出现。 sing-box日志如下,目测请求进入正常,dns查询正常,但每次都疑似直接收到目标服务器的rst直接connection reset by peer
+0800 2024-12-18 10:12:06 INFO inbound/http[**]: tcp server started at 0.0.0.0:38752
+0800 2024-12-18 10:12:06 INFO sing-box started (0.00s)
+0800 2024-12-18 10:12:21 INFO [2264161095 0ms] inbound/http[**]: inbound connection from ******:20494
+0800 2024-12-18 10:12:21 INFO [2264161095 1ms] inbound/http[**]: [**] inbound connection to *.com:443
+0800 2024-12-18 10:12:21 DEBUG [2264161095 1ms] router: match[0] inbound=** => trojan-out-node1
+0800 2024-12-18 10:12:21 INFO [2264161095 1ms] outbound/trojan[trojan-out-node1]: outbound multiplex connection to x.com:443
+0800 2024-12-18 10:12:21 DEBUG [2264161095 1ms] dns: lookup domain relay-**-**.*****.com
+0800 2024-12-18 10:12:21 DEBUG [2264161095 1ms] outbound/direct[direct]: outbound packet connection to 114.114.114.114:53
+0800 2024-12-18 10:12:21 DEBUG [2264161095 20ms] dns: exchanged relay-**-**.*****.com NOERROR 34
+0800 2024-12-18 10:12:21 DEBUG [2264161095 21ms] dns: exchanged relay-**-**.*****.com A relay-**-**.*****.com. 34 IN A 183.***.***.***
+0800 2024-12-18 10:12:21 DEBUG [2264161095 21ms] dns: exchanged relay-**-**.*****.comNOERROR 34
+0800 2024-12-18 10:12:21 DEBUG [2264161095 21ms] dns: exchanged relay-**-**.*****.com CNAME relay-**-**.*****.com. 34 IN CNAME relay-**-**-sub.*****.com.
+0800 2024-12-18 10:12:21 DEBUG [2264161095 21ms] dns: lookup succeed for relay-**-**.*****.com: 183.**.**.**
+0800 2024-12-18 10:12:21 DEBUG [2264161095 234ms] inbound/http[**]: connection closed: process connection from 106.11.200.64:20494: upload: raw read: connection reset by peer | download: context canceled
随后我又在outbounds里添加了一个Vmess协议,也是同样的问题:请求进入正常、路由正常、dns查询正常,请求目标服务器IP connection被重置。Vmess协议在clash.yaml中配置如下
- { name: 🇭🇰, type: vmess, server: ***.*********.**, port: ****, uuid: , alterId: 0, cipher: auto, udp: true }
在sing-box中配置如下
{
"type": "vmess",
"tag": "vmess-out",
"server": "***.*********.**",
"server_port": ****,
"uuid": "",
"security": ""
},
怀疑是服务器安全组规则导致的连接失败?服务器已开发inbounds里定义的监听端口的任意源ip入权限,出权限没有任何限制。 又或者是我这样的http-trojan/Vmess协议链无法实现?
看了下机场给的配置信息
name: "节点1\t"
type: trojan
server: relay-**-**.*****.com
port: '22***'
password: 1a****-****-****-a467-2b******8d6c
sni: **-**.telk*****.com
对应的要求就是地址,端口,密码,外加 SNI。
我看了个sing-box的配置文件,换过来
{
"type": "trojan",
"server": "", 地址
"server_port": 443, 端口
"password": "", 密码
"tls": {
"enabled": true,
"server_name": "", SNI
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
}
}
最小化原则 ,就这些参数,应该是够了,对应得上。你配置中给了 "insecure": true, 这个应该是不要开它的。
日志中可疑的我觉得是这个
+0800 2024-12-18 10:12:21 INFO [2264161095 1ms] outbound/trojan[trojan-out-node1]: outbound multiplex connection to x.com:443
机场的服务端肯定不是sing-box core,吧,肯定不用开sig-box里面的mux。 multiplex 这英文又像是问题出在这儿。
但是你配置中你有不有写 https://github.com/chika0801/sing-box-examples/blob/main/Trojan/config_client.json#L24 mux true我不知道,你再排查一下了。
噢,是的,日志中的multiplex是之前看了您给的这个/Trojan/config_client里的例子,测试是否需要加上multiplex而生成的。 确实不需要加上该项,所以我粘上来的配置里没有该项。
insecure项去掉我也尝试过,(刚刚又试了一遍,确认去掉了insecure和multiplex,符合您给出的最小化原则),但是都出现一样的错误。
我倾向于认为配置本身没问题了,是我使用的aliyun cloud ecs的某些我未知的防火墙or其他OS组件导致的建连失败🤦
谢谢~有找明白我会来这条issue下repo
insecure项去掉我也尝试过,(刚刚又试了一遍,确认去掉了insecure和multiplex,符合您给出的最小化原则),但是都出现一样的错误。
你意思是服务端是机场提供的trojan配置,你客户端想用sing-box的出站来对接,你没成功。
然后你用clash的客户端配置成功连得通机场服务端是吧?
因为我觉得trojan配置本身没太多因素。要么你试试将客户端换成xray的trojan tcp tls这种配置连连看。
主要是服务端是机场,我也不用机场,不知道这些服务端有不有什么特别的。光看你发的内容,我就想不到其它可能原因了。只有看你自己再花时间研究不。
是的,您的理解完全正确:我想通过sing-box来取代clash去出站连接机场提供的trojan设置。
这个问题本周被部分解决了:我发现把我请求的代理的程序 和 sing-box服务 运行在同一台服务器上时,可以运行成功(侧面说明上面的配置应该没问题,就那么几个配置项
至于为什么需要在同一台机器上我还没弄明白,盲猜还是和防火墙出入规则有关(?
这条作为repo给有同样需求的人参考以及进一步研究。
另外,新年快乐。