Browse Source

update ip format

Ewan Chou 11 years ago
parent
commit
7aa889407c
3 changed files with 7 additions and 5 deletions
  1. 2 2
      .travis.yml
  2. 1 1
      dns/test.example.com.json
  3. 4 2
      targeting.go

+ 2 - 2
.travis.yml

@@ -6,8 +6,8 @@ before_install:
   - sudo apt-get install libgeoip-dev bzr
   - sudo apt-get install libgeoip-dev bzr
 install:
 install:
   - mkdir -p $TRAVIS_BUILD_DIR/db
   - mkdir -p $TRAVIS_BUILD_DIR/db
-  - wget -qO- http://geodns.bitnames.com/geoip/GeoLiteCity.dat.gz | gzip -cd > $TRAVIS_BUILD_DIR/db/GeoIPCity.dat
-  - wget -qO- http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz | gzip -cd > $TRAVIS_BUILD_DIR/db/GeoIPASNum.dat
+  - curl -s http://geodns.bitnames.com/geoip/GeoLiteCity.dat.gz | gzip -cd > $TRAVIS_BUILD_DIR/db/GeoIPCity.dat
+  - curl -s http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz | gzip -cd > $TRAVIS_BUILD_DIR/db/GeoIPASNum.dat
   - go get github.com/abh/dns
   - go get github.com/abh/dns
   - go get github.com/abh/geoip
   - go get github.com/abh/geoip
   - go get launchpad.net/gocheck
   - go get launchpad.net/gocheck

+ 1 - 1
dns/test.example.com.json

@@ -34,7 +34,7 @@
     },
     },
     "bar.no": { "a": [] },
     "bar.no": { "a": [] },
     "bar.as15169": { "a": [ ["192.168.1.4" ] ] },
     "bar.as15169": { "a": [ ["192.168.1.4" ] ] },
-    "bar.1.0.0.255": { "a": [ ["192.168.1.3" ] ] },
+    "bar.[1.0.0.255]": { "a": [ ["192.168.1.3" ] ] },
     "0": {
     "0": {
       "a": [ [ "192.168.0.1", 10 ] ]
       "a": [ [ "192.168.0.1", 10 ] ]
     },
     },

+ 4 - 2
targeting.go

@@ -38,9 +38,11 @@ func (t TargetOptions) GetTargets(ip net.IP) ([]string, int) {
 
 
 	if t&TargetIP > 0 {
 	if t&TargetIP > 0 {
 		ipStr := ip.String()
 		ipStr := ip.String()
-		targets = append(targets, ipStr)
+		targets = append(targets, "["+ipStr+"]")
 		dotIndex := strings.LastIndex(ipStr, ".")
 		dotIndex := strings.LastIndex(ipStr, ".")
-		targets = append(targets, ipStr[:dotIndex]+".0")
+		if dotIndex > 0 {
+			targets = append(targets, "["+ipStr[:dotIndex]+".0]")
+		}
 	}
 	}
 
 
 	if t&TargetASN > 0 && len(asn) > 0 {
 	if t&TargetASN > 0 && len(asn) > 0 {