Improve(fakeip): use lru cache to avoid outdate

This commit is contained in:
Dreamacro
2019-07-26 19:09:13 +08:00
parent 1702e7ddb4
commit 271ed2b9c1
9 changed files with 386 additions and 67 deletions

View File

@ -157,6 +157,10 @@ func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error) {
// IPToHost return fake-ip or redir-host mapping host
func (r *Resolver) IPToHost(ip net.IP) (string, bool) {
if r.fakeip {
return r.pool.LookBack(ip)
}
cache := r.cache.Get(ip.String())
if cache == nil {
return "", false