From 49f641b9e471cef79240929ed84a6deceef2e7c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 9 Feb 2020 19:01:16 +0000 Subject: [PATCH] Don't output the (now unused) country CNAMEs for tile servers --- bin/mkgeo | 94 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/bin/mkgeo b/bin/mkgeo index 27876b8..d942ee0 100755 --- a/bin/mkgeo +++ b/bin/mkgeo @@ -212,60 +212,64 @@ my $jsonfile = IO::File->new("> json/${zone}.json") || die "$!"; # Output headers $jszonefile->print("var \U${jszone}\E_RECORDS = [\n"); -# Output details for each country -foreach my $origin (sort { $a->{name} cmp $b->{name} } values %$origins) +# Skip outputting server map if gdnsd is doing that +if (!defined($gdnsname)) { - my $cluster = $origin->{cluster}; - my $clon = $origin->{lon}; - my $clat = $origin->{lat}; - my $slon = $cluster->{lon}; - my $slat = $cluster->{lat}; - - if ($clon > 0 && $slon < 0 && 360 + $slon - $clon < $clon - $slon) - { - $slon = $slon + 360; - } - elsif ($slon > 0 && $clon < 0 && 360 + $clon - $slon < $slon - $clon) + # Output details for each country + foreach my $origin (sort { $a->{name} cmp $b->{name} } values %$origins) { - $clon = $clon + 360; - } + my $cluster = $origin->{cluster}; + my $clon = $origin->{lon}; + my $clat = $origin->{lat}; + my $slon = $cluster->{lon}; + my $slat = $cluster->{lat}; - $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"); - - push @json, { - type => "Feature", - geometry => { - type => "LineString", - coordinates => [ [ $clon, $clat ], [ $slon, $slat ] ] - }, - properties => { - origin => $origin->{name}, - server => $cluster->{name}, - colour => $cluster->{colour} + if ($clon > 0 && $slon < 0 && 360 + $slon - $clon < $clon - $slon) + { + $slon = $slon + 360; + } + elsif ($slon > 0 && $clon < 0 && 360 + $clon - $slon < $slon - $clon) + { + $clon = $clon + 360; } - }; - $targetorigins->{$cluster->{name}}->{bandwidth} += $origin->{bandwidth}; -} + $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"); + + push @json, { + type => "Feature", + geometry => { + type => "LineString", + coordinates => [ [ $clon, $clat ], [ $slon, $slat ] ] + }, + properties => { + origin => $origin->{name}, + server => $cluster->{name}, + colour => $cluster->{colour} + } + }; -# Header for default records -$zonefile->print("# Unknown origins\n"); + $targetorigins->{$cluster->{name}}->{bandwidth} += $origin->{bandwidth}; + } -# Output default records for IPs that can't be mapped to a country -foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters) -{ - 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); + } } } -- 2.39.5