mirror of
https://github.com/snail007/goproxy.git
synced 2026-04-27 00:15:51 +03:00
[GH-ISSUE #234] dns cache无效 #151
Labels
No labels
TODO
bug
duplicate
enhancement
good first issue
help wanted
helpful
invalid
need-confirm
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/goproxy#151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @momaer on GitHub (Mar 13, 2019).
Original GitHub issue: https://github.com/snail007/goproxy/issues/234
version: 7.2
vps:
./proxy http --daemon --forever --log="server.log" -t tcp -p :8080 -z password
本地:
./proxy dns -p :5454 -f dns-cache.dat -P $(dig @8.8.8.8 vps域名 +short):8080 -T tcp -S http -e 800 -Z password
dig @127.0.0.1 -p 5454 qq.com
发现没有 dns-cache.dat 这个文件生成.而且从本地 proxy命令的输出可以看到,每次都去dns 查询.
麻烦作者抽空看下哈,感谢!
@snail007 commented on GitHub (Mar 13, 2019):
我测试了,会缓存,但是缓存是在内存,1分钟以后才会写入文件
提供一下日志,多次访问同一个域名,有没有使用dns缓存会有提示.
@momaer commented on GitHub (Mar 13, 2019):
是的,我也发现要等一会才会有 cache file生成.
local日志:
2019/03/13 19:50:46 id: 16395 cache: MISS [(twitter.com. IN A)]
2019/03/13 19:50:46 id: 16395 resolve: [(twitter.com. IN A)] 8.8.8.8:53
2019/03/13 19:50:46 conn 127.0.0.1:44982 - 218.50.4.36:8080 connected [8.8.8.8:53]
2019/03/13 19:50:46 id: 16395 cache: CACHED [(twitter.com. IN A)] TTL 800
2019/03/13 19:50:46 conn 127.0.0.1:44982 - 218.50.4.36:8080 released [8.8.8.8:53]
2019/03/13 19:50:51 id: 24694 cache: MISS [(twitter.com. IN A)]
2019/03/13 19:50:51 id: 24694 resolve: [(twitter.com. IN A)] 8.8.8.8:53
2019/03/13 19:50:51 conn 127.0.0.1:45030 - 218.50.4.36:8080 connected [8.8.8.8:53]
2019/03/13 19:50:51 id: 24694 cache: CACHED [(twitter.com. IN A)] TTL 800
2019/03/13 19:50:51 conn 127.0.0.1:45030 - 218.50.4.36:8080 released [8.8.8.8:53]
2019/03/13 19:50:55 id: 27278 cache: MISS [(twitter.com. IN A)]
2019/03/13 19:50:55 id: 27278 resolve: [(twitter.com. IN A)] 8.8.8.8:53
2019/03/13 19:50:55 conn 127.0.0.1:45064 - 218.50.4.36:8080 connected [8.8.8.8:53]
2019/03/13 19:50:55 id: 27278 cache: CACHED [(twitter.com. IN A)] TTL 800
2019/03/13 19:50:55 conn 127.0.0.1:45064 - 218.50.4.36:8080 released [8.8.8.8:53]
➜ goproxy dig @127.0.0.1 -p 5555 twitter.com
; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> @127.0.0.1 -p 5555 twitter.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16395
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;twitter.com. IN A
;; ANSWER SECTION:
twitter.com. 1773 IN A 104.244.42.129
twitter.com. 1773 IN A 104.244.42.65
;; Query time: 329 msec
;; SERVER: 127.0.0.1#5555(127.0.0.1)
;; WHEN: Wed Mar 13 19:50:46 CST 2019
;; MSG SIZE rcvd: 94
➜ goproxy dig @127.0.0.1 -p 5555 twitter.com
; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> @127.0.0.1 -p 5555 twitter.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24694
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;twitter.com. IN A
;; ANSWER SECTION:
twitter.com. 1766 IN A 104.244.42.129
twitter.com. 1766 IN A 104.244.42.65
;; Query time: 231 msec
;; SERVER: 127.0.0.1#5555(127.0.0.1)
;; WHEN: Wed Mar 13 19:50:51 CST 2019
;; MSG SIZE rcvd: 94
➜ goproxy dig @127.0.0.1 -p 5555 twitter.com
; <<>> DiG 9.11.3-1ubuntu1.5-Ubuntu <<>> @127.0.0.1 -p 5555 twitter.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27278
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;twitter.com. IN A
;; ANSWER SECTION:
twitter.com. 675 IN A 104.244.42.193
twitter.com. 675 IN A 104.244.42.65
;; Query time: 229 msec
;; SERVER: 127.0.0.1#5555(127.0.0.1)
;; WHEN: Wed Mar 13 19:50:55 CST 2019
;; MSG SIZE rcvd: 94
从 dig response的 Query time来看,好像并未缓存.
@snail007 commented on GitHub (Mar 13, 2019):
缓存时间是依据域名的ttl缓存的,如果域名自己设置的ttl很小那就没有缓存,你可以强制指定ttl参数
@momaer commented on GitHub (Mar 13, 2019):
;; ANSWER SECTION:
twitter.com. 675 IN A 104.244.42.193
twitter.com. 675 IN A 104.244.42.65
这里的 675就是ttl呀.
怎么强制指定ttl? 我有用-e 800参数
@snail007 commented on GitHub (Mar 13, 2019):
我用nslookup -port=5353 www.baidu.com 127.0.0.1是没问题的,你试试看,dig如果每次查询的内容除了ID之外有变化就会导致每次缓存就不能命中。
另外我看你本地dns服务是5454端口,dig怎么使用了5555端口?
@momaer commented on GitHub (Mar 14, 2019):
我用 nslookup 发现是命中缓存了. 看来dig和nslookup是有区别的.
我本来监听的是 5454,后来又监听 了5555.
谢谢啦.