File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,12 @@ func (c Cdoh) Write(b []byte) (n int, err error) {
157157// ResolverDoh returns a DoH resolver. For further information, see https://datatracker.ietf.org/doc/html/rfc8484.
158158func ResolverDoh (addr string ) * net.Resolver {
159159 urls := doa .Try (url .Parse (addr ))
160- urls .Host = doa .Try (net .LookupHost (urls .Hostname ()))[0 ]
160+ host := doa .Try (net .LookupHost (urls .Hostname ()))[0 ]
161+ port := urls .Port ()
162+ urls .Host = host
163+ if port != "" {
164+ urls .Host = host + ":" + port
165+ }
161166 return & net.Resolver {
162167 PreferGo : true ,
163168 Dial : func (ctx context.Context , network , address string ) (net.Conn , error ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212const (
1313 DazeServerListenOn = "127.0.0.1:28080"
1414 CurlDest = "https://www.zhihu.com"
15+ HostLookup = "google.com"
1516)
1617
1718func TestLocaleHTTP (t * testing.T ) {
@@ -64,23 +65,23 @@ func TestLocaleSocks5(t *testing.T) {
6465
6566func TestResolverDns (t * testing.T ) {
6667 dns := ResolverDns ("1.1.1.1:53" )
67- _ , err := dns .LookupHost (context .Background (), "google.com" )
68+ _ , err := dns .LookupHost (context .Background (), HostLookup )
6869 if err != nil {
6970 t .FailNow ()
7071 }
7172}
7273
7374func TestResolverDot (t * testing.T ) {
7475 dot := ResolverDot ("1.1.1.1:853" )
75- _ , err := dot .LookupHost (context .Background (), "google.com" )
76+ _ , err := dot .LookupHost (context .Background (), HostLookup )
7677 if err != nil {
7778 t .FailNow ()
7879 }
7980}
8081
8182func TestResolverDoh (t * testing.T ) {
8283 doh := ResolverDoh ("https://1.1.1.1/dns-query" )
83- _ , err := doh .LookupHost (context .Background (), "google.com" )
84+ _ , err := doh .LookupHost (context .Background (), HostLookup )
8485 if err != nil {
8586 t .FailNow ()
8687 }
You can’t perform that action at this time.
0 commit comments