Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele committed Jul 4, 2024
1 parent 1bcb5a5 commit 6764fd2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/file/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,10 @@ var (
IPv6HasBracketPattern = regexp.MustCompile(`\[\S+\]$`)
)

func isIPv6(hostname string) bool {
// hasIPv6Format checks if the hostname is in ipv6 format.
// This is a best effort check, it doesn't guarantee that the hostname is a valid ipv6 address,
// but it checks if the hostname has more than 2 colons.
func hasIPv6Format(hostname string) bool {
parts := strings.Split(hostname, ":")
return len(parts) > 2
}
Expand Down Expand Up @@ -1140,7 +1143,7 @@ func (b *stateBuilder) ingestTargets(targets []kong.Target) error {
for _, t := range targets {
t := t

if t.Target != nil && isIPv6(*t.Target) {
if t.Target != nil && hasIPv6Format(*t.Target) {
normalizedTarget, err := normalizeIPv6(*t.Target)
if err != nil {
return err
Expand Down

0 comments on commit 6764fd2

Please sign in to comment.