github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/cmd/geph-client/dnshack.go (about) 1 package main 2 3 import ( 4 _ "unsafe" 5 6 log "github.com/sirupsen/logrus" 7 ) 8 9 // DNS hacks for Android and other systems without /etc/resolv.conf 10 11 // this only work before any Lookup call and net.dnsReadConfig() failed 12 //go:linkname defaultNS net.defaultNS 13 var defaultNS []string 14 15 func setDefaultNS2(addrs []string) { 16 defaultNS = addrs 17 } 18 19 func hackDNS() { 20 if bypassChinese { 21 log.Println("using 114.114.114.114 as hacked DNS because we want to bypass Chinese") 22 setDefaultNS2([]string{"114.114.114.114:53"}) 23 } else { 24 log.Println("hack DNS for lack of /etc/resolv.conf") 25 setDefaultNS2([]string{"74.82.42.42:53", "1.0.0.1:53", "8.8.8.8:53", "8.8.4.4:53"}) 26 } 27 }