diff --git a/cli/cli.go b/cli/cli.go index 159b6d3..4a61b7d 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" flag "github.com/stefansundin/go-zflag" ) diff --git a/cli/dig.go b/cli/dig.go index 00ee8a6..35ba5fe 100644 --- a/cli/dig.go +++ b/cli/dig.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" ) // ParseDig parses commands from the popular DNS tool dig. diff --git a/cli/dig_test.go b/cli/dig_test.go index 5293bb2..7073dbf 100644 --- a/cli/dig_test.go +++ b/cli/dig_test.go @@ -6,7 +6,7 @@ import ( "testing" "git.froth.zone/sam/awl/cli" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "gotest.tools/v3/assert" ) diff --git a/cli/misc.go b/cli/misc.go index 85228fd..3011cd6 100644 --- a/cli/misc.go +++ b/cli/misc.go @@ -8,7 +8,7 @@ import ( "strings" "git.froth.zone/sam/awl/conf" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "golang.org/x/net/idna" ) diff --git a/cli/misc_test.go b/cli/misc_test.go index 286e0e3..3176cd3 100644 --- a/cli/misc_test.go +++ b/cli/misc_test.go @@ -7,7 +7,7 @@ import ( "testing" "git.froth.zone/sam/awl/cli" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) diff --git a/doc/wiki b/doc/wiki index 6f3070f..0fba1fb 160000 --- a/doc/wiki +++ b/doc/wiki @@ -1 +1 @@ -Subproject commit 6f3070f5933d0cc48bc8bb5290a1d0cc1825cd75 +Subproject commit 0fba1fbe4b12e8c88514b3f7d98be3e75a5a034d diff --git a/main.go b/main.go index 641deac..494e786 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,8 @@ import ( "strings" "git.froth.zone/sam/awl/cli" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/query" + "git.froth.zone/sam/awl/pkg/util" ) var version = "DEV" diff --git a/logawl/docs.go b/pkg/logawl/docs.go similarity index 100% rename from logawl/docs.go rename to pkg/logawl/docs.go diff --git a/logawl/logawl.go b/pkg/logawl/logawl.go similarity index 100% rename from logawl/logawl.go rename to pkg/logawl/logawl.go diff --git a/logawl/logger.go b/pkg/logawl/logger.go similarity index 100% rename from logawl/logger.go rename to pkg/logawl/logger.go diff --git a/logawl/logging_test.go b/pkg/logawl/logging_test.go similarity index 98% rename from logawl/logging_test.go rename to pkg/logawl/logging_test.go index 24f001c..6d0bdd3 100644 --- a/logawl/logging_test.go +++ b/pkg/logawl/logging_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "git.froth.zone/sam/awl/logawl" + "git.froth.zone/sam/awl/pkg/logawl" "gotest.tools/v3/assert" ) diff --git a/query/docs.go b/pkg/query/docs.go similarity index 100% rename from query/docs.go rename to pkg/query/docs.go diff --git a/query/print.go b/pkg/query/print.go similarity index 99% rename from query/print.go rename to pkg/query/print.go index c026343..800fe56 100644 --- a/query/print.go +++ b/pkg/query/print.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "golang.org/x/net/idna" "gopkg.in/yaml.v3" diff --git a/query/print_test.go b/pkg/query/print_test.go similarity index 98% rename from query/print_test.go rename to pkg/query/print_test.go index 4eade9b..d80a2f2 100644 --- a/query/print_test.go +++ b/pkg/query/print_test.go @@ -5,8 +5,8 @@ package query_test import ( "testing" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/query" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) diff --git a/query/query.go b/pkg/query/query.go similarity index 98% rename from query/query.go rename to pkg/query/query.go index 1b8dcaf..729db25 100644 --- a/query/query.go +++ b/pkg/query/query.go @@ -8,17 +8,13 @@ import ( "strings" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/resolvers" + "git.froth.zone/sam/awl/pkg/util" "github.com/dchest/uniuri" "github.com/miekg/dns" "golang.org/x/net/idna" ) -const ( - tcp = "tcp" - udp = "udp" -) - // ToString turns the response into something that looks a lot like dig // // Much of this is taken from https://github.com/miekg/dns/blob/master/msg.go#L900 @@ -336,7 +332,7 @@ func CreateQuery(opts util.Options) (util.Response, error) { } } - resolver, err := LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) if err != nil { return util.Response{}, err } diff --git a/query/query_test.go b/pkg/query/query_test.go similarity index 97% rename from query/query_test.go rename to pkg/query/query_test.go index 7c76d34..fce2cf3 100644 --- a/query/query_test.go +++ b/pkg/query/query_test.go @@ -5,8 +5,8 @@ package query_test import ( "testing" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/query" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) diff --git a/query/struct.go b/pkg/query/struct.go similarity index 100% rename from query/struct.go rename to pkg/query/struct.go diff --git a/query/DNSCrypt.go b/pkg/resolvers/DNSCrypt.go similarity index 95% rename from query/DNSCrypt.go rename to pkg/resolvers/DNSCrypt.go index 53afc3d..18927ef 100644 --- a/query/DNSCrypt.go +++ b/pkg/resolvers/DNSCrypt.go @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause -package query +package resolvers import ( "fmt" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/ameshkov/dnscrypt/v2" "github.com/miekg/dns" ) diff --git a/query/DNSCrypt_test.go b/pkg/resolvers/DNSCrypt_test.go similarity index 94% rename from query/DNSCrypt_test.go rename to pkg/resolvers/DNSCrypt_test.go index 37df392..763dde0 100644 --- a/query/DNSCrypt_test.go +++ b/pkg/resolvers/DNSCrypt_test.go @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause -package query_test +package resolvers_test import ( "testing" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/query" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) diff --git a/query/HTTPS.go b/pkg/resolvers/HTTPS.go similarity index 97% rename from query/HTTPS.go rename to pkg/resolvers/HTTPS.go index 0c56002..d090a18 100644 --- a/query/HTTPS.go +++ b/pkg/resolvers/HTTPS.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause -package query +package resolvers import ( "bytes" @@ -9,7 +9,7 @@ import ( "net/http" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" ) diff --git a/query/HTTPS_test.go b/pkg/resolvers/HTTPS_test.go similarity index 90% rename from query/HTTPS_test.go rename to pkg/resolvers/HTTPS_test.go index b844847..533c12d 100644 --- a/query/HTTPS_test.go +++ b/pkg/resolvers/HTTPS_test.go @@ -1,12 +1,12 @@ // SPDX-License-Identifier: BSD-3-Clause -package query_test +package resolvers_test import ( "testing" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/resolvers" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) @@ -26,7 +26,7 @@ func TestResolveHTTPS(t *testing.T) { }, } // testCase := util.Request{Server: "https://dns9.quad9.net/dns-query", Type: dns.TypeA, Name: "git.froth.zone."} - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) @@ -49,7 +49,7 @@ func Test2ResolveHTTPS(t *testing.T) { var err error testCase := util.Request{Type: dns.TypeA, Name: "git.froth.zone"} - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) @@ -77,7 +77,7 @@ func Test3ResolveHTTPS(t *testing.T) { // testCase.Name = fmt.Sprintf("%s.", testCase.Name) // } - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) @@ -103,7 +103,7 @@ func Test404ResolveHTTPS(t *testing.T) { }, } // testCase := util.Request{Server: "https://dns9.quad9.net/dns-query", Type: dns.TypeA, Name: "git.froth.zone."} - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) diff --git a/query/QUIC.go b/pkg/resolvers/QUIC.go similarity index 97% rename from query/QUIC.go rename to pkg/resolvers/QUIC.go index 9191fdd..94df961 100644 --- a/query/QUIC.go +++ b/pkg/resolvers/QUIC.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause -package query +package resolvers import ( "crypto/tls" @@ -8,7 +8,7 @@ import ( "io" "time" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/lucas-clemente/quic-go" "github.com/miekg/dns" ) diff --git a/query/QUIC_test.go b/pkg/resolvers/QUIC_test.go similarity index 89% rename from query/QUIC_test.go rename to pkg/resolvers/QUIC_test.go index 6d83199..0bfe025 100644 --- a/query/QUIC_test.go +++ b/pkg/resolvers/QUIC_test.go @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause -package query_test +package resolvers_test import ( "fmt" @@ -10,8 +10,8 @@ import ( "testing" "time" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/resolvers" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) @@ -35,7 +35,7 @@ func TestQuic(t *testing.T) { for i := range testCases { switch i { case 0: - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) // if the domain is not canonical, make it canonical if !strings.HasSuffix(testCase.Name, ".") { @@ -50,7 +50,7 @@ func TestQuic(t *testing.T) { assert.ErrorContains(t, err, "fully qualified") assert.Equal(t, res, util.Response{}) case 1: - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) testCase2.Server = net.JoinHostPort(testCase2.Server, strconv.Itoa(opts.Request.Port)) @@ -79,7 +79,7 @@ func TestInvalidQuic(t *testing.T) { Logger: util.InitLogger(0), Request: util.Request{Server: "example.com", Port: 853, Type: dns.TypeA, Name: "git.froth.zone", Timeout: 10 * time.Millisecond}, } - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) diff --git a/query/general.go b/pkg/resolvers/general.go similarity index 96% rename from query/general.go rename to pkg/resolvers/general.go index 8e0973b..907e6d3 100644 --- a/query/general.go +++ b/pkg/resolvers/general.go @@ -1,13 +1,13 @@ // SPDX-License-Identifier: BSD-3-Clause -package query +package resolvers import ( "crypto/tls" "fmt" "net" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" ) diff --git a/query/general_test.go b/pkg/resolvers/general_test.go similarity index 89% rename from query/general_test.go rename to pkg/resolvers/general_test.go index fe06c12..c4379bb 100644 --- a/query/general_test.go +++ b/pkg/resolvers/general_test.go @@ -1,13 +1,14 @@ // SPDX-License-Identifier: BSD-3-Clause -package query_test +package resolvers_test import ( "testing" "time" - "git.froth.zone/sam/awl/query" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/query" + "git.froth.zone/sam/awl/pkg/resolvers" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" ) @@ -26,7 +27,7 @@ func TestResolve(t *testing.T) { Retries: 0, }, } - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) @@ -49,7 +50,7 @@ func TestTruncate(t *testing.T) { Name: "limit.txt.example.", }, } - resolver, err := query.LoadResolver(opts) + resolver, err := resolvers.LoadResolver(opts) assert.NilError(t, err) msg := new(dns.Msg) diff --git a/query/resolver.go b/pkg/resolvers/resolver.go similarity index 93% rename from query/resolver.go rename to pkg/resolvers/resolver.go index 049522e..a600f20 100644 --- a/query/resolver.go +++ b/pkg/resolvers/resolver.go @@ -1,16 +1,21 @@ // SPDX-License-Identifier: BSD-3-Clause -package query +package resolvers import ( "net" "strconv" "strings" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" ) +const ( + tcp = "tcp" + udp = "udp" +) + // Resolver is the main resolver interface. type Resolver interface { LookUp(*dns.Msg) (util.Response, error) diff --git a/util/docs.go b/pkg/util/docs.go similarity index 100% rename from util/docs.go rename to pkg/util/docs.go diff --git a/util/logger.go b/pkg/util/logger.go similarity index 84% rename from util/logger.go rename to pkg/util/logger.go index 8e5a32c..a09ae11 100644 --- a/util/logger.go +++ b/pkg/util/logger.go @@ -2,7 +2,7 @@ package util -import "git.froth.zone/sam/awl/logawl" +import "git.froth.zone/sam/awl/pkg/logawl" // InitLogger initializes the logawl instance. func InitLogger(verbosity int) (log *logawl.Logger) { diff --git a/util/logger_test.go b/pkg/util/logger_test.go similarity index 77% rename from util/logger_test.go rename to pkg/util/logger_test.go index 938dc05..2e07862 100644 --- a/util/logger_test.go +++ b/pkg/util/logger_test.go @@ -5,8 +5,8 @@ package util_test import ( "testing" - "git.froth.zone/sam/awl/logawl" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/logawl" + "git.froth.zone/sam/awl/pkg/util" "gotest.tools/v3/assert" ) diff --git a/util/options.go b/pkg/util/options.go similarity index 99% rename from util/options.go rename to pkg/util/options.go index 139a558..9ae3a1f 100644 --- a/util/options.go +++ b/pkg/util/options.go @@ -6,7 +6,7 @@ import ( "fmt" "net" - "git.froth.zone/sam/awl/logawl" + "git.froth.zone/sam/awl/pkg/logawl" "github.com/miekg/dns" ) diff --git a/util/options_test.go b/pkg/util/options_test.go similarity index 94% rename from util/options_test.go rename to pkg/util/options_test.go index 741e7c2..1e28e95 100644 --- a/util/options_test.go +++ b/pkg/util/options_test.go @@ -5,7 +5,7 @@ package util_test import ( "testing" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "gotest.tools/v3/assert" ) diff --git a/util/query.go b/pkg/util/query.go similarity index 100% rename from util/query.go rename to pkg/util/query.go diff --git a/util/reverseDNS.go b/pkg/util/reverseDNS.go similarity index 90% rename from util/reverseDNS.go rename to pkg/util/reverseDNS.go index 1d6c7fc..391bd7e 100644 --- a/util/reverseDNS.go +++ b/pkg/util/reverseDNS.go @@ -13,8 +13,8 @@ type errReverseDNS struct { addr string } -func (e *errReverseDNS) Error() string { - return fmt.Sprintf("reverseDNS: invalid value %s given", e.addr) +func (errDNS *errReverseDNS) Error() string { + return fmt.Sprintf("reverseDNS: invalid value %s given", errDNS.addr) } // ReverseDNS is given an IP or phone number and returns a canonical string to be queried. diff --git a/util/reverseDNS_test.go b/pkg/util/reverseDNS_test.go similarity index 97% rename from util/reverseDNS_test.go rename to pkg/util/reverseDNS_test.go index 5a77748..4725b4d 100644 --- a/util/reverseDNS_test.go +++ b/pkg/util/reverseDNS_test.go @@ -5,7 +5,7 @@ package util_test import ( "testing" - "git.froth.zone/sam/awl/util" + "git.froth.zone/sam/awl/pkg/util" "github.com/miekg/dns" "gotest.tools/v3/assert" )