@@ -39,9 +39,12 @@ func (t TargetOptions) GetTargets(ip net.IP) ([]string, int) {
if t&TargetIP > 0 {
ipStr := ip.String()
targets = append(targets, "["+ipStr+"]")
- dotIndex := strings.LastIndex(ipStr, ".")
- if dotIndex > 0 {
- targets = append(targets, "["+ipStr[:dotIndex]+".0]")
+ ip4 := ip.To4()
+ if ip4 != nil {
+ if ip4[3] != 0 {
+ ip4[3] = 0
+ targets = append(targets, "["+ip4.String()+"]")
+ }
}
@@ -34,8 +34,8 @@ func (s *TargetingSuite) TestTargetParse(c *C) {
str = tgt.String()
c.Check(str, Equals, "@ continent country asn")
-func (s *TargetingSuite) TestGetTargets(c *C) {
+func (s *TargetingSuite) TestGetTargets(c *C) {
ip := net.ParseIP("207.171.1.1")
geoIP.setupGeoIPCity()