feat: add support for tcp, dot
This commit is contained in:
parent
8bcd940685
commit
0aa3b36b35
6 changed files with 48 additions and 22 deletions
18
cmd/cli.go
18
cmd/cli.go
|
@ -67,18 +67,28 @@ func main() {
|
|||
Destination: hub.QueryFlags.QClasses,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "udp",
|
||||
Usage: "Use the DNS protocol over UDP",
|
||||
Name: "udp",
|
||||
Usage: "Use the DNS protocol over UDP",
|
||||
Aliases: []string{"U"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "tcp",
|
||||
Usage: "Use the DNS protocol over TCP",
|
||||
Name: "tcp",
|
||||
Usage: "Use the DNS protocol over TCP",
|
||||
Aliases: []string{"T"},
|
||||
Destination: &hub.QueryFlags.UseTCP,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "https",
|
||||
Usage: "Use the DNS-over-HTTPS protocol",
|
||||
Aliases: []string{"H"},
|
||||
Destination: &hub.QueryFlags.IsDOH,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "tls",
|
||||
Usage: "Use the DNS-over-TLS",
|
||||
Aliases: []string{"S"},
|
||||
Destination: &hub.QueryFlags.IsDOT,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ipv6",
|
||||
Aliases: []string{"6"},
|
||||
|
|
|
@ -25,7 +25,7 @@ type QueryFlags struct {
|
|||
IsDOH bool
|
||||
IsDOT bool
|
||||
IsUDP bool
|
||||
IsTLS bool
|
||||
UseTCP bool
|
||||
UseIPv4 bool
|
||||
UseIPv6 bool
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import (
|
|||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// loadResolver checks
|
||||
// loadResolver checks for various flags and initialises
|
||||
// the correct resolver based on the config.
|
||||
func (hub *Hub) loadResolver(c *cli.Context) error {
|
||||
// check if DOH flag is set.
|
||||
if hub.QueryFlags.IsDOH {
|
||||
|
@ -18,11 +19,6 @@ func (hub *Hub) loadResolver(c *cli.Context) error {
|
|||
hub.Resolver = rslvr
|
||||
return nil
|
||||
}
|
||||
// check if DOT flag is set.
|
||||
|
||||
// check if TCP flag is set.
|
||||
|
||||
// fallback to good ol UDP.
|
||||
if len(hub.QueryFlags.Nameservers.Value()) == 0 {
|
||||
if runtime.GOOS == "windows" {
|
||||
// TODO: Add a method for reading system default nameserver in windows.
|
||||
|
@ -38,6 +34,8 @@ func (hub *Hub) loadResolver(c *cli.Context) error {
|
|||
rslvr, err := resolvers.NewClassicResolver(hub.QueryFlags.Nameservers.Value(), resolvers.ClassicResolverOpts{
|
||||
UseIPv4: hub.QueryFlags.UseIPv4,
|
||||
UseIPv6: hub.QueryFlags.UseIPv6,
|
||||
UseTLS: hub.QueryFlags.IsDOT,
|
||||
UseTCP: hub.QueryFlags.UseTCP,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue