Feature: move hosts to the top

This commit is contained in:
Dreamacro
2019-09-11 17:00:55 +08:00
parent 16e3090ee8
commit 96a4abf46c
6 changed files with 164 additions and 122 deletions

View File

@ -213,6 +213,13 @@ func (t *Tunnel) match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
defer t.configMux.RUnlock()
var resolved bool
if node := dns.DefaultHosts.Search(metadata.Host); node != nil {
ip := node.Data.(net.IP)
metadata.DstIP = &ip
resolved = true
}
for _, rule := range t.rules {
if !resolved && t.shouldResolveIP(rule, metadata) {
ip, err := t.resolveIP(metadata.Host)