Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Sep 18, 2023
1 parent b87b418 commit 6ce7ed7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/private.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ func IsPublicAddr(a ma.Multiaddr) bool {
case ma.P_DNS, ma.P_DNS4, ma.P_DNS6, ma.P_DNSADDR:
dnsAddr := c.Value()
isPublic = true
if isSubDomain(dnsAddr, localHostDomain) {
if isSubdomain(dnsAddr, localHostDomain) {
isPublic = false
return false
}
for _, ud := range unResolvableDomains {
if isSubDomain(dnsAddr, ud) {
if isSubdomain(dnsAddr, ud) {
isPublic = false
return false
}

Check warning on line 124 in net/private.go

View check run for this annotation

Codecov / codecov/patch

net/private.go#L122-L124

Added lines #L122 - L124 were not covered by tests
}
for _, pd := range privateUseDomains {
if isSubDomain(dnsAddr, pd) {
if isSubdomain(dnsAddr, pd) {
isPublic = false
break
}
Expand All @@ -135,10 +135,10 @@ func IsPublicAddr(a ma.Multiaddr) bool {
return isPublic
}

// isSubDomain checks if child is sub domain of parent. It also returns true if child and parent are
// isSubdomain checks if child is sub domain of parent. It also returns true if child and parent are
// the same domain.
// Parent must have a "." prefix.
func isSubDomain(child, parent string) bool {
func isSubdomain(child, parent string) bool {
return strings.HasSuffix(child, parent) || child == parent[1:]
}

Expand All @@ -155,7 +155,7 @@ func IsPrivateAddr(a ma.Multiaddr) bool {
isPrivate = inAddrRange(net.IP(c.RawValue()), Private6)
case ma.P_DNS, ma.P_DNS4, ma.P_DNS6, ma.P_DNSADDR:
dnsAddr := c.Value()
if isSubDomain(dnsAddr, localHostDomain) {
if isSubdomain(dnsAddr, localHostDomain) {
isPrivate = true
}
// We don't check for privateUseDomains because private use domains can
Expand Down

0 comments on commit 6ce7ed7

Please sign in to comment.