Skip to content

Commit

Permalink
intra: m refactor bootstrap reinit
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Jan 18, 2024
1 parent b487438 commit 9ba2610
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions intra/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ func (b *bootstrap) reinit(trtype, ippOrUrl, ipcsv string) error {
return dnsx.ErrNotDefaultTransport
}

// note: plain ip4 address is a valid url; ex: 1.2.3.4
if parsed, err := url.Parse(ippOrUrl); err == nil { // ippOrUrl is a url?
if trtype != dnsx.DOH {
log.E("dns: default: reinit: url %s; %s != %s", ippOrUrl, trtype, dnsx.DOH)
if trtype == dnsx.DOH {
// note: plain ip4 address is a valid url; ex: 1.2.3.4
if parsed, err := url.Parse(ippOrUrl); err != nil { // ippOrUrl is a url?
log.E("dns: default: reinit: not %s url %s", trtype, ippOrUrl)
return dnsx.ErrNotDefaultTransport
} else {
b.url = ippOrUrl
b.hostname = parsed.Hostname()
b.ipports = ipcsv // may be empty
b.typ = dnsx.DOH
}
b.url = ippOrUrl
b.hostname = parsed.Hostname()
b.ipports = ipcsv // may be empty
b.typ = dnsx.DOH
} else { // ippOrUrl is an ipport?
if trtype != dnsx.DNS53 {
log.E("dns: default: reinit: ipport %s; %s != %s", ippOrUrl, trtype, dnsx.DNS53)
Expand Down

0 comments on commit 9ba2610

Please sign in to comment.