X-Git-Url: https://git.openstreetmap.org/dns.git/blobdiff_plain/629b0194771e9f99bc46b537b545adf0c0f258e9..e7069a230493f268a6e047aecaaa5afa32adab9b:/bin/mkgeo diff --git a/bin/mkgeo b/bin/mkgeo index 76316b0..77b44d9 100755 --- a/bin/mkgeo +++ b/bin/mkgeo @@ -230,10 +230,13 @@ foreach my $origin (sort { $a->{name} cmp $b->{name} } values %$origins) $clon = $clon + 360; } - $zonefile->print("# $origin->{name}\n"); - $zonefile->print("C\L$origin->{code}\E.${zone}:$cluster->{name}.${zone}:600\n"); + if (!defined($gdnsname)) + { + $zonefile->print("# $origin->{name}\n"); + $zonefile->print("C\L$origin->{code}\E.${zone}:$cluster->{name}.${zone}:600\n"); - $jszonefile->print(" CNAME(\"\L$origin->{code}\E.${jszone}\", \"$cluster->{name}.${zone}.\", TTL(\"10m\")),\n"); + $jszonefile->print(" CNAME(\"\L$origin->{code}\E.${jszone}\", \"$cluster->{name}.${zone}.\", TTL(\"10m\")),\n"); + } push @json, { type => "Feature", @@ -251,21 +254,25 @@ foreach my $origin (sort { $a->{name} cmp $b->{name} } values %$origins) $targetorigins->{$cluster->{name}}->{bandwidth} += $origin->{bandwidth}; } -# Header for default records -$zonefile->print("# Unknown origins\n"); - -# Output default records for IPs that can't be mapped to a country -foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters) +# Skip default records if we don't need them +if (!defined($gdnsname)) { - my $name = $cluster->{name}; + # Header for default records + $zonefile->print("# Unknown origins\n"); - if (my $default = $cluster->{default}) - { - output_server($zonefile, $jszonefile, "${default}.${zone}", "${default}.${jszone}", $cluster); - } - elsif (exists($cluster->{default})) + # Output default records for IPs that can't be mapped to a country + foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters) { - output_server($zonefile, $jszonefile, "${zone}", "${jszone}", $cluster); + my $name = $cluster->{name}; + + if (my $default = $cluster->{default}) + { + output_server($zonefile, $jszonefile, "${default}.${zone}", "${default}.${jszone}", $cluster); + } + elsif (exists($cluster->{default})) + { + output_server($zonefile, $jszonefile, "${zone}", "${jszone}", $cluster); + } } } @@ -544,7 +551,7 @@ sub output_server { my $ipv6 = $server->{ipv6}; - $ipv6 =~ s/([0-9a-f]{4})(?=.)/\1:/ig; + $ipv6 =~ s/([0-9a-f]{4})(?=.)/$1:/ig; $zonefile->printf("3${name}:$server->{ipv6}:600\n", $index + 1); $jszonefile->printf(" AAAA(\"${jsname}\", \"${ipv6}\", TTL(\"10m\")),\n", $index + 1);