if (-f "pingdom.yml")
{
- $cache = YAML::LoadFile("pingdom.yml");
+ $cache = YAML::LoadFile("pingdom.yml");
}
else
{
$server->{status} = $cache->{$server->{pingdom}} || "down";
}
}
+ else
+ {
+ $server->{status} = "down";
+ }
}
YAML::DumpFile("pingdom.yml", $cache);
my $jsonfile = IO::File->new("> json/${zone}.json") || die "$!";
# Output details for each country
-foreach my $origin (values %$origins)
+foreach my $origin (sort { $a->{name} cmp $b->{name} } values %$origins)
{
my $cluster = $origin->{cluster};
my $clon = $origin->{lon};
$zonefile->print("# Unknown origins\n");
# Output default records for IPs that can't be mapped to a country
-while (my($name,$cluster) = each %$clusters)
+foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters)
{
+ my $name = $cluster->{name};
+
if (my $default = $cluster->{default})
{
output_server($zonefile, "${default}.${zone}", $cluster);
$zonefile->print("# Servers\n");
# Output A records for each cluster
-while (my($name,$cluster) = each %$clusters)
+foreach my $cluster (sort { $a->{name} cmp $b->{name} } values %$clusters)
{
+ my $name = $cluster->{name};
+
output_server($zonefile, "${name}.${zone}", $cluster);
}
{
$match = "preferred";
}
- elsif ($cluster->{preferred} &&
- $cluster->{preferred}->{continents} &&
- grep { $_ eq $origin->{continent} } @{$cluster->{preferred}->{continents}})
- {
- $match = "preferred";
- }
elsif ($cluster->{allowed} &&
$cluster->{allowed}->{countries} &&
grep { $_ eq $origin->{country} } @{$cluster->{allowed}->{countries}})
{
$match = "allowed";
}
+ elsif ($cluster->{denied} &&
+ $cluster->{denied}->{countries} &&
+ grep { $_ eq $origin->{country} } @{$cluster->{denied}->{countries}})
+ {
+ $match = "denied";
+ }
+ elsif ($cluster->{preferred} &&
+ $cluster->{preferred}->{continents} &&
+ grep { $_ eq $origin->{continent} } @{$cluster->{preferred}->{continents}})
+ {
+ $match = "preferred";
+ }
elsif ($cluster->{allowed} &&
$cluster->{allowed}->{continents} &&
grep { $_ eq $origin->{continent} } @{$cluster->{allowed}->{continents}})
{
$match = "allowed";
}
- elsif ($cluster->{denied} &&
- $cluster->{denied}->{countries} &&
- grep { $_ eq $origin->{country} } @{$cluster->{preferred}->{countries}})
- {
- $match = "denied";
- }
elsif ($cluster->{denied} &&
$cluster->{denied}->{continents} &&
- grep { $_ eq $origin->{continent} } @{$cluster->{preferred}->{continents}})
+ grep { $_ eq $origin->{continent} } @{$cluster->{denied}->{continents}})
{
$match = "denied";
}
{
if ($server->{status} eq "up")
{
- $zonefile->print("+${name}:$server->{ipv4}:3600\n");
+ $zonefile->print("+${name}:$server->{ipv4}:600\n");
if ($server->{ipv6})
{
-# $zonefile->print("3${name}:$server->{ipv6}:3600\n");
+# $zonefile->print("3${name}:$server->{ipv6}:600\n");
}
}
}