]> git.openstreetmap.org Git - dns.git/blobdiff - bin/mkgeo
Drop unused A records for clustered CDN nodes
[dns.git] / bin / mkgeo
index 400fff7cdc4dc24cde40c076f42086e2952fd8e7..ce0ff2f10c6a19db32408eaf168aad252f0616ca 100755 (executable)
--- a/bin/mkgeo
+++ b/bin/mkgeo
@@ -205,7 +205,7 @@ my @json;
 
 # Open output files
 my $zonefile = IO::File->new("> include/${zone}.js") || die "$!";
-my $jsonfile = IO::File->new("> json/${zone}.json") || die "$!";
+my $jsonfile = IO::File->new("> json/${zone}.openstreetmap.org.json") || die "$!";
 
 # Output headers
 $zonefile->print("var \U${zone}\E_RECORDS = [\n");
@@ -273,12 +273,14 @@ foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters)
 {
     my $name = $cluster->{name};
 
-    output_server($zonefile, "${name}.${zone}", $cluster);
-
     if (@{$cluster->{servers}} > 1)
     {
         output_server($zonefile, "${name}-%02d.${zone}", $cluster);
     }
+    else
+    {
+        output_server($zonefile, "${name}.${zone}", $cluster);
+    }
 }
 
 # Output the GeoJSON text
@@ -348,7 +350,7 @@ if (defined($gdnsname))
                     my $number = sprintf("%02d", $index + 1);
                     my $bandwidth = $server->{bandwidth};
 
-                    $gdnsweightedfile->print("  ${name}-${number} = [ ${name}-${number}.${zone}., ${bandwidth} ]\n");
+                    $gdnsweightedfile->print("  ${name}-${number} = [ ${name}-${number}.${zone}.openstreetmap.org., ${bandwidth} ]\n");
                 }
             }
 
@@ -358,7 +360,7 @@ if (defined($gdnsname))
         }
         else
         {
-            $gdnsresourcefile->print("    ${name} => ${name}.${zone}.\n");
+            $gdnsresourcefile->print("    ${name} => ${name}.${zone}.openstreetmap.org.\n");
         }
     }
 
@@ -534,11 +536,7 @@ sub output_server
 
             if ($server->{ipv6})
             {
-                my $ipv6 = $server->{ipv6};
-
-                $ipv6 =~ s/([0-9a-f]{4})(?=.)/$1:/ig;
-
-                $zonefile->printf("  AAAA(\"${name}\", \"${ipv6}\", TTL(\"10m\")),\n", $index + 1);
+                $zonefile->printf("  AAAA(\"${name}\", \"$server->{ipv6}\", TTL(\"10m\")),\n", $index + 1);
             }
         }
     }