FlowerWrong / tun2socks

Redirect tun flow to socks 5 in golang, support tcp and udp.
425 stars 107 forks source link

请教一个问题 #54

Closed android0276 closed 5 years ago

android0276 commented 5 years ago

应用程序 -> tun -> Tun2sock -> 代理服务 -> 目标服务器 假如请求的域名是abc.com,abc.com 在 tun 这里会做DNS解析 想问下在代理服务器那里还会进行DNS再次查询请求吗

FlowerWrong commented 5 years ago

你用的是哪种模式在跑? https://github.com/FlowerWrong/tun2socks/wiki#dns-mode

FlowerWrong commented 5 years ago

我用fake-mode,在darwin下设置etc/hosts是好用的。可以正常访问。

FlowerWrong commented 5 years ago

如果发现不行,重启你的浏览器试试,可能是dns缓存。

android0276 commented 5 years ago

没有用fake-mode,用的纯路由那种

android0276 commented 5 years ago

我用 Curl 调试过,确实不行

android0276 commented 5 years ago

我发现我的经过 Tunsock 到远程代理服务器后重新解析DNS了

android0276 commented 5 years ago

你走 fake-mode 的话,如果设置etc/hosts, 请求的时候将直接是IP,你的规则并不会代理这个,他会走直连

android0276 commented 5 years ago

大神再分析下

FlowerWrong commented 5 years ago

不会吧,你dig看下dns对不对。后续走代理或者直连都没问题。

android0276 commented 5 years ago

DNS 对的没有问题

FlowerWrong commented 5 years ago

curl -i -v https://ourbits.club/torrents.php 我这里还真没复现。

android0276 commented 5 years ago

你确认你的这个请求被代理了吗

FlowerWrong commented 5 years ago

我明儿用你那种模式试试。

android0276 commented 5 years ago

好吧...tun2sock 转发TCP流量,代理服务器不会再解析DNS吧

FlowerWrong commented 5 years ago

我试了下,还是可以的。终端查询dns的时候用dscacheutil -q host -a name ourbits.club

tun2sock 转发TCP流量,代理服务器不会再解析DNS吧

socks5代理支持三种,ipv4、ipv6和域名,如果是域名,那么肯定需要在代理服务器上解析,ip则不用。 https://zh.wikipedia.org/wiki/SOCKS#SOCKS5

这里应该还是/etc/hosts有没有起效的问题。我是darwin。

FlowerWrong commented 5 years ago

😢 我的route table https://github.com/FlowerWrong/ip2socks/blob/master/scripts/darwin_setup_utun.sh

android0276 commented 5 years ago

我觉得这个问题是个比较深的问题...

android0276 commented 5 years ago

大神还需要我提供哪些信息,我这边都可以提供,只求帮忙解决这个问题,这个感觉是我的技术盲区,谢谢哈

FlowerWrong commented 5 years ago

我这里还是ok的。这个和走不走代理没有关系。都是ip访问,这里是dns出的问题。

sudo route -n add -host 51.15.167.112 -interface utun1
Password:
add host 51.15.167.112: gateway utun1
 ~  curl -i -v https://ourbits.club/torrents.php
*   Trying 51.15.167.112...
* TCP_NODELAY set
* Connected to ourbits.club (51.15.167.112) port 443 (#0)
* ALPN, offering http/1.1
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: ourbits.club
* Server certificate: Let's Encrypt Authority X3
* Server certificate: DST Root CA X3
> GET /torrents.php HTTP/1.1
> Host: ourbits.club
> User-Agent: curl/7.63.0
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
HTTP/1.1 302 Moved Temporarily
< Server: nginx
Server: nginx
< Date: Fri, 25 Jan 2019 03:41:42 GMT
Date: Fri, 25 Jan 2019 03:41:42 GMT
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Connection: keep-alive
Connection: keep-alive
< Location: /login.php?returnto=torrents.php
Location: /login.php?returnto=torrents.php
< Expires: Fri, 25 Jan 2019 15:41:42 GMT
Expires: Fri, 25 Jan 2019 15:41:42 GMT
< Cache-Control: max-age=43200
Cache-Control: max-age=43200
< X-Cache: MISS
X-Cache: MISS

<
* Connection #0 to host ourbits.club left intact
FlowerWrong commented 5 years ago

我没法复现,无法确定具体问题在哪里。

FlowerWrong commented 5 years ago

你试试 curl --http1.1 -i -v https://ourbits.club/torrents.php 我本地没有http2环境

android0276 commented 5 years ago

还需要提供其他数据供你分析吗

FlowerWrong commented 5 years ago

😭 这就很尴尬了。 你ssh到服务器上试试,改/etc/hosts,然后curl,我这里试了hk的服务器ok的。 如果你的也没问题,那么再看看ss日志,是不是代理的时候用的域名而不是ip地址。

android0276 commented 5 years ago

话说我想不通。。Vmess是在本地弄个socks5 SSR也是弄个socks5,为啥Vmess可以,SSR死活都不行

FlowerWrong commented 5 years ago

我用的官方ss,你熟悉代码可以跟踪一下,多打打log。 我觉得不是什么大问题。

android0276 commented 5 years ago

好吧,这个问题我不纠结了,我感觉是不是ssr 强制做了 tcp dns 重解析