# 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);
+ }
}
}
{
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);