Magic telegram connection which couldn't be routed
After one of the Telegram updates, I noticed connections to the address 5.28.195.2 in the client log files. In my routing rules, Telegram is supposed to work through a proxy. Therefore, I decided to set up routing for the address 5.28.195.2.
I used the following rule:
{
"ip": [
"5.28.195.2"
],
"outboundTag": "proxy"
}
After that, I checked the log file again and found that the connection still goes through direct.
Then I decided to test the simplest variant: I route all traffic through the proxy, except for connections to this server.
Client config
{
"log": {
"loglevel": "debug",
"dnsLog": true
},
"dns": {
"servers": [
"https://1.1.1.1/dns-query"
],
"disableFallback": true
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"ip": [
"5.28.195.2"
],
"outboundTag": "direct"
}
]
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"userLevel": 8
},
"sniffing": {
"destOverride": [
"http",
"tls",
"quic"
],
"enabled": true,
"routeOnly": false
},
"tag": "socks"
}
],
"outbounds": [
{
...
"tag": "proxy"
},
{
"protocol": "freedom",
"streamSettings": {
"sockopt": {
"domainStrategy": "UseIP"
}
},
"tag": "direct"
}
]
}
And again, it doesn't work! The connection to the server goes through the proxy.
Telegram connection log
01-06 02:11:12.135 I/GoLog (21695): [Info] [318232503] proxy/vless/outbound: tunneling request to tcp:www.google.com:443 via 4.3.2.1:8443
01-06 02:11:12.135 I/GoLog (21695): [Info] [318232503] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:12.135 I/GoLog (21695): from tcp:127.0.0.1:40350 accepted tcp:5.28.195.2:443 [socks >> proxy]
01-06 02:11:12.135 I/GoLog (21695): [Info] [318232503] app/dispatcher: default route for tcp:www.google.com:443
01-06 02:11:12.135 I/GoLog (21695): [Info] [318232503] app/dispatcher: sniffed domain: www.google.com
01-06 02:11:12.134 I/GoLog (21695): [Info] [318232503] proxy/socks: TCP Connect request to tcp:5.28.195.2:443
01-06 02:11:11.331 I/GoLog (21695): [Info] [287329464] proxy/vless/outbound: tunneling request to tcp:firebaselogging.googleapis.com:443 via 4.3.2.1:8443
01-06 02:11:11.331 I/GoLog (21695): from 127.0.0.1:40346 accepted //firebaselogging.googleapis.com:443 [socks >> proxy]
01-06 02:11:11.331 I/GoLog (21695): [Info] [287329464] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:11.331 I/GoLog (21695): [Info] [287329464] app/dispatcher: default route for tcp:firebaselogging.googleapis.com:443
01-06 02:11:11.331 I/GoLog (21695): [Info] [287329464] app/dispatcher: sniffed domain: firebaselogging.googleapis.com
01-06 02:11:11.330 I/GoLog (21695): [Info] [287329464] proxy/http: request to Method [CONNECT] Host [firebaselogging.googleapis.com:443] with URL [//firebaselogging.googleapis.com:443]
01-06 02:11:11.330 I/GoLog (21695): [Debug] [287329464] proxy/socks: Not Socks request, try to parse as HTTP request
01-06 02:11:08.869 I/GoLog (21695): [Info] [2550867050] proxy/vless/outbound: tunneling request to tcp:www.google.com:443 via 4.3.2.1:8443
01-06 02:11:08.869 I/GoLog (21695): [Info] [2550867050] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:08.869 I/GoLog (21695): from tcp:127.0.0.1:40344 accepted tcp:5.28.195.2:443 [socks >> proxy]
01-06 02:11:08.868 I/GoLog (21695): [Info] [2550867050] app/dispatcher: default route for tcp:www.google.com:443
01-06 02:11:08.868 I/GoLog (21695): [Info] [2550867050] app/dispatcher: sniffed domain: www.google.com
01-06 02:11:08.868 I/GoLog (21695): [Info] [2550867050] proxy/socks: TCP Connect request to tcp:5.28.195.2:443
01-06 02:11:05.651 I/GoLog (21695): [Info] [328262724] proxy/vless/outbound: tunneling request to tcp:www.google.com:443 via 4.3.2.1:8443
01-06 02:11:05.651 I/GoLog (21695): [Info] [328262724] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:05.650 I/GoLog (21695): from tcp:127.0.0.1:57872 accepted tcp:5.28.195.2:443 [socks >> proxy]
01-06 02:11:05.650 I/GoLog (21695): [Info] [328262724] app/dispatcher: default route for tcp:www.google.com:443
01-06 02:11:05.650 I/GoLog (21695): [Info] [328262724] app/dispatcher: sniffed domain: www.google.com
01-06 02:11:05.650 I/GoLog (21695): [Info] [328262724] proxy/socks: TCP Connect request to tcp:5.28.195.2:443
01-06 02:11:02.531 I/GoLog (21695): [Info] [3212975889] proxy/vless/outbound: tunneling request to tcp:www.google.com:443 via 4.3.2.1:8443
01-06 02:11:02.531 I/GoLog (21695): from tcp:127.0.0.1:57860 accepted tcp:5.28.195.2:443 [socks >> proxy]
01-06 02:11:02.531 I/GoLog (21695): [Info] [3476398634] proxy/vless/outbound: tunneling request to tcp:[2001:67c:4e8:f002::a]:443 via 4.3.2.1:8443
01-06 02:11:02.531 I/GoLog (21695): [Info] [3212975889] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:02.531 I/GoLog (21695): [Info] [3212975889] app/dispatcher: default route for tcp:www.google.com:443
01-06 02:11:02.531 I/GoLog (21695): [Info] [3212975889] app/dispatcher: sniffed domain: www.google.com
01-06 02:11:02.531 I/GoLog (21695): [Info] [3476398634] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:02.530 I/GoLog (21695): from tcp:127.0.0.1:57846 accepted tcp:[2001:67c:4e8:f002::a]:443 [socks >> proxy]
01-06 02:11:02.530 I/GoLog (21695): [Info] [3476398634] app/dispatcher: default route for tcp:[2001:67c:4e8:f002::a]:443
01-06 02:11:02.530 I/GoLog (21695): [Info] [3212975889] proxy/socks: TCP Connect request to tcp:5.28.195.2:443
01-06 02:11:02.530 I/GoLog (21695): [Info] [3476398634] proxy/socks: TCP Connect request to tcp:[2001:67c:4e8:f002::a]:443
01-06 02:11:01.492 I/GoLog (21695): [Debug] [3510570180] proxy/socks: writing back UDP response with 128 bytes
01-06 02:11:01.394 I/GoLog (21695): [Debug] [3075516791] proxy/socks: writing back UDP response with 128 bytes
01-06 02:11:01.344 I/GoLog (21695): [Info] [3510570180] proxy/vless/outbound: tunneling request to udp:8.8.8.8:53 via 4.3.2.1:8443
01-06 02:11:01.271 I/GoLog (21695): [Debug] [3510570180] transport/internet: dialing to tcp:4.3.2.1:8443
01-06 02:11:01.271 I/GoLog (21695): [Info] [3510570180] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:01.271 I/GoLog (21695): from udp:127.0.0.1:43329 accepted udp:8.8.8.8:53 [socks >> proxy]
01-06 02:11:01.271 I/GoLog (21695): [Info] [3510570180] app/dispatcher: default route for udp:8.8.8.8:53
01-06 02:11:01.271 I/GoLog (21695): [Info] [3510570180] transport/internet/udp: establishing new connection for udp:8.8.8.8:53
01-06 02:11:01.271 I/GoLog (21695): [Debug] [3510570180] transport/internet/udp: dispatch request to: udp:8.8.8.8:53
01-06 02:11:01.271 I/GoLog (21695): [Debug] [3510570180] proxy/socks: send packet to udp:8.8.8.8:53 with 46 bytes
01-06 02:11:01.271 I/GoLog (21695): [Info] [3510570180] proxy/socks: client UDP connection from udp:127.0.0.1:43329
01-06 02:11:01.270 I/GoLog (21695): [Info] [3075516791] proxy/vless/outbound: tunneling request to udp:8.8.8.8:53 via 4.3.2.1:8443
01-06 02:11:01.270 I/GoLog (21695): [Info] [3075516791] transport/internet/splithttp: XHTTP is dialing to tcp:4.3.2.1:8443, mode stream-one, HTTP version 2, host easy.sausage.com
01-06 02:11:01.270 I/GoLog (21695): from udp:127.0.0.1:41541 accepted udp:8.8.8.8:53 [socks >> proxy]
01-06 02:11:01.270 I/GoLog (21695): [Info] [3075516791] app/dispatcher: default route for udp:8.8.8.8:53
01-06 02:11:01.270 I/GoLog (21695): [Info] [3075516791] transport/internet/udp: establishing new connection for udp:8.8.8.8:53
01-06 02:11:01.270 I/GoLog (21695): [Debug] [3075516791] transport/internet/udp: dispatch request to: udp:8.8.8.8:53
01-06 02:11:01.270 I/GoLog (21695): [Debug] [3075516791] proxy/socks: send packet to udp:8.8.8.8:53 with 46 bytes
01-06 02:11:01.270 I/GoLog (21695): [Info] [3075516791] proxy/socks: client UDP connection from udp:127.0.0.1:41541
--------- beginning of main
Then I launched telnet and connected to the server on port 443. And you know what I saw in the logs? A direct connection!
Telnet connection log
01-06 00:43:00.682 I/GoLog (12733): [Info] [2263401831] proxy/freedom: connection opened to tcp:5.28.195.2:443, local endpoint 192.168.1.80:51888, remote endpoint 5.28.195.2:443
01-06 00:43:00.561 I/GoLog (12733): from tcp:127.0.0.1:54510 accepted tcp:5.28.195.2:443 [socks -> direct]
01-06 00:43:00.561 I/GoLog (12733): [Debug] [2263401831] transport/internet: dialing to tcp:5.28.195.2:443
01-06 00:43:00.561 I/GoLog (12733): [Info] [2263401831] transport/internet/tcp: dialing TCP to tcp:5.28.195.2:443
01-06 00:43:00.561 I/GoLog (12733): [Info] [2263401831] app/dispatcher: taking detour [direct] for [tcp:5.28.195.2:443]
01-06 00:43:00.360 I/GoLog (12733): [Info] [2263401831] proxy/socks: TCP Connect request to tcp:5.28.195.2:443
So, when I manually establish a connection via telnet or a browser to this address, the routing rule works. When Telegram establishes the connection, the rule does not work.
Why, how does it do that?? How can I fix this?
X-ray version: 25.12.8
P.S. Logs for telegram connection looks simple. No any information about connection. Strange.
未提供完整日志
未提供完整日志
Ok, log file is extended
很明显telegram学tor发假sni被xray嗅探到然后错误路由了
Damn, now I see. It's always trying to hide behind Google. After adding "domain:google.com" in the routing rules, access to 5.28.195.2 becomes correct (as planned). Main question: is it possible to dragon with that without adding Google in routing? It's not good for me.
Damn, now I see. It's always trying to hide behind Google. After adding "domain:google.com" in the routing rules, access to 5.28.195.2 becomes correct (as planned). Main question: is it possible to dragon with that without adding Google in routing? It's not good for me.
Just use SniffingObject.domainsExcluded