Skip to content

Commit

Permalink
Add flags
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Oct 24, 2023
1 parent 0365795 commit c0bd568
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions x/examples/find-strategy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"log"
"net"
"os"
"strings"
"time"
"unicode"

Expand Down Expand Up @@ -232,7 +233,8 @@ func evaluateResponse(response *dns.Msg, requestDomain string) ([]net.IP, error)
func main() {
verboseFlag := flag.Bool("v", false, "Enable debug output")
// typeFlag := flag.String("type", "A", "The type of the query (A, AAAA, CNAME, NS or TXT).")
// resolverFlag := flag.String("resolver", "", "The address of the recursive DNS resolver to use in host:port format. If the port is missing, it's assumed to be 53")
resolversFlag := flag.String("resolvers", "8.8.8.8,2001:4860:4860::8888,1.1.1.1,9.9.9.9,9.9.9.9:9953,208.67.222.222,208.67.222.222:443", "The address of the recursive DNS resolver to use in host:port format. If the port is missing, it's assumed to be 53")
dotFlag := flag.String("dot", "dns.google,8.8.8.8,2001:4860:4860::8888,1.1.1.1,9.9.9.9,wikimedia-dns.org", "The address of the DNS-over-TLS resolvers to use in host:port format. If the port is missing, it's assumed to be 853")
transportFlag := flag.String("transport", "", "The transport for the connection to the recursive DNS resolver")
// tcpFlag := flag.Bool("tcp", false, "Force TCP when querying the DNS resolver")
domainFlag := flag.String("domain", "", "The test domain to find strategies")
Expand All @@ -259,12 +261,26 @@ func main() {
fingerprint(packetDialer, streamDialer, testDomain)

clients := []*dnsClient{}
for _, resolverAddr := range []string{"8.8.8.8:53", "[2001:4860:4860::8888]:53", "1.1.1.1:53", "9.9.9.9:53", "9.9.9.9:9953", "208.67.222.222:53", "208.67.222.222:443"} {
clients = append(clients, newUDPClient(packetDialer, resolverAddr))
clients = append(clients, newTCPClient(streamDialer, resolverAddr))
for _, resolverAddr := range strings.Split(*resolversFlag, ",") {
trimmedAddr := strings.TrimSpace(resolverAddr)
host, port, err := net.SplitHostPort(trimmedAddr)
if err != nil {
host = trimmedAddr
port = "53"
}
fullAddr := net.JoinHostPort(host, port)
clients = append(clients, newUDPClient(packetDialer, fullAddr))
clients = append(clients, newTCPClient(streamDialer, fullAddr))
}
for _, resolverAddr := range []string{"dns.google:853", "8.8.8.8:853", "[2001:4860:4860::8888]:853", "1.1.1.1:853", "9.9.9.9:853", "wikimedia-dns.org:853"} {
client, err := newTLSClient(streamDialer, resolverAddr)
for _, resolverAddr := range strings.Split(*dotFlag, ",") {
trimmedAddr := strings.TrimSpace(resolverAddr)
host, port, err := net.SplitHostPort(trimmedAddr)
if err != nil {
host = trimmedAddr
port = "853"
}
fullAddr := net.JoinHostPort(host, port)
client, err := newTLSClient(streamDialer, fullAddr)
if err != nil {
log.Fatalf("Failed to create TLS client: %v", err)
}
Expand Down Expand Up @@ -293,6 +309,7 @@ func main() {
}

// TODO:
// Add recursive resolver.
// Go over list of public resolvers, restricted to working categories.
// Prefer those that preserve case in the answer, and return public IPs.
// Also match against blocking fingerprint.
Expand Down

0 comments on commit c0bd568

Please sign in to comment.