mirror of
https://github.com/Alexey71/opera-proxy.git
synced 2026-05-13 14:11:00 +00:00
resolver: more liberal factory
This commit is contained in:
@@ -16,8 +16,8 @@ func FromURL(u string) (*net.Resolver, error) {
|
|||||||
}
|
}
|
||||||
host := parsed.Hostname()
|
host := parsed.Hostname()
|
||||||
port := parsed.Port()
|
port := parsed.Port()
|
||||||
switch strings.ToLower(parsed.Scheme) {
|
switch scheme := strings.ToLower(parsed.Scheme); scheme {
|
||||||
case "", "dns":
|
case "", "udp", "dns":
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "53"
|
port = "53"
|
||||||
}
|
}
|
||||||
@@ -27,12 +27,20 @@ func FromURL(u string) (*net.Resolver, error) {
|
|||||||
port = "53"
|
port = "53"
|
||||||
}
|
}
|
||||||
return NewTCPResolver(net.JoinHostPort(host, port)), nil
|
return NewTCPResolver(net.JoinHostPort(host, port)), nil
|
||||||
case "http", "https":
|
case "http", "https", "doh":
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "443"
|
if scheme == "http" {
|
||||||
|
port = "80"
|
||||||
|
} else {
|
||||||
|
port = "443"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if scheme == "doh" {
|
||||||
|
parsed.Scheme = "https"
|
||||||
|
u = parsed.String()
|
||||||
}
|
}
|
||||||
return dns.NewDoHResolver(u, dns.DoHAddresses(net.JoinHostPort(host, port)))
|
return dns.NewDoHResolver(u, dns.DoHAddresses(net.JoinHostPort(host, port)))
|
||||||
case "tls":
|
case "tls", "dot":
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "853"
|
port = "853"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user