Skip to content

Commit db05821

Browse files
committed
check the online IP format
1 parent 6a10250 commit db05821

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/lib/ip_helper.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ func (helper *IPHelper) getIPOnline() string {
228228
log.Error(fmt.Sprintf("request:%v failed to get online IP", reqURL))
229229
continue
230230
}
231+
232+
if isIPv4(onlineIP) {
233+
if strings.ToUpper(helper.configuration.IPType) != utils.IPV4 {
234+
log.Warnf("The online IP (%s) from %s is not IPV6, will skip it.", onlineIP, reqURL)
235+
continue
236+
}
237+
} else {
238+
if strings.ToUpper(helper.configuration.IPType) != utils.IPV6 {
239+
log.Warnf("The online IP (%s) from %s is not IPV4, will skip it.", onlineIP, reqURL)
240+
continue
241+
}
242+
}
243+
231244
log.Debugf("Get ip success by: %s, online IP: %s", reqURL, onlineIP)
232245

233246
err = response.Body.Close()

0 commit comments

Comments
 (0)