Skip to content

Commit

Permalink
raw string for regex and dead code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarazzutti committed Jun 10, 2024
1 parent d0911ac commit 51eaa30
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 0 additions & 20 deletions app/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,6 @@ func (resolver *resolver) resolveRecu(host string, qtypes []string) (*string, er
return nil, fmt.Errorf("no host found: %s", host)
}

func (resolver *resolver) resolveRecuZ(host string, qtypes []string) (*string, error) {

cnames := make(map[string]struct{})
for _, qtype := range qtypes {
for _, rr := range resolver.dnsResolver.Resolve(host, qtype) {
if rr.Type == qtype {
return &rr.Value, nil
} else if rr.Type == "CNAME" {
cnames[rr.Value] = struct{}{}
}
}
}

for cname := range cnames { // todo will leave athe first one
return resolver.resolveRecu(cname, qtypes)
}

return nil, fmt.Errorf("no host found: %s", host)
}

type BackendResolver interface {
Resolve(host string, qtype []uint16) (*dns.Msg, error)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (runner *runner) loadRest() error {
}

func splitPair(str string) (string, string, error) {
r := regexp.MustCompile("^([^:]+):\\s?(.*)$")
r := regexp.MustCompile(`^([^:]+):\\s?(.*)$`)
e := r.FindStringSubmatch(str)
if len(e) == 3 {
return e[1], e[2], nil
Expand All @@ -233,7 +233,6 @@ func splitPair(str string) (string, string, error) {
}

func runAndError(config *app.Config, xp *extraConfig, appLogic func(config *app.Config, consoleLogger app.ConsoleLogger) (app.HTTPPing, error)) func(cmd *cobra.Command, args []string) error {

return func(cmd *cobra.Command, args []string) error {
r := runner{appLogic: appLogic, config: config, xp: xp, cmd: cmd, args: args}
return r.run()
Expand Down

0 comments on commit 51eaa30

Please sign in to comment.