Skip to content

Commit

Permalink
check the online IP format
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyYe committed Feb 28, 2024
1 parent 6a10250 commit db05821
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/lib/ip_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ func (helper *IPHelper) getIPOnline() string {
log.Error(fmt.Sprintf("request:%v failed to get online IP", reqURL))
continue
}

if isIPv4(onlineIP) {
if strings.ToUpper(helper.configuration.IPType) != utils.IPV4 {
log.Warnf("The online IP (%s) from %s is not IPV6, will skip it.", onlineIP, reqURL)
continue
}
} else {
if strings.ToUpper(helper.configuration.IPType) != utils.IPV6 {
log.Warnf("The online IP (%s) from %s is not IPV4, will skip it.", onlineIP, reqURL)
continue
}
}

log.Debugf("Get ip success by: %s, online IP: %s", reqURL, onlineIP)

err = response.Body.Close()
Expand Down

0 comments on commit db05821

Please sign in to comment.