Skip to content
Browse files

Add a per-continent index

There are still some cases where there's no site in the user's
continent for the given archive type.
  • Loading branch information...
1 parent c8e29b1 commit 062e6d8c7b0c04983b5664a1cdec9efef72fc34e @rgeissert committed Jan 16, 2012
Showing with 18 additions and 1 deletion.
  1. +13 −0 redir.pl
  2. +5 −1 update.pl
View
13 redir.pl
@@ -132,6 +132,19 @@
}
}
+print "X-Continent: ".$r->continent_code."\r\n";
+# match by continent
+if ($host eq '') {
+ foreach my $match (keys %{$rdb->{'continent'}{$r->continent_code}}) {
+ my $mirror = $db->{'all'}{$match};
+
+ next unless fullfils_request($rdb, $match, $arch, $ipv6);
+
+ $host = $mirror->{'site'}.$mirror->{$mirror_type.'-http'};
+ last;
+ }
+}
+
# something went awry, we don't know how to handle this user, we failed
# let's make another attempt:
if ($host eq '' && $mirror_type eq 'archive') {
View
6 update.pl
@@ -91,7 +91,7 @@
$db{$mirror_type} = shared_clone({
'country' => {}, 'ipv6' => {}, 'arch' => {},
- 'all' => {}, 'AS' => {}
+ 'all' => {}, 'AS' => {}, 'continent' => {}
});
$semaphore{$mirror_type} = Thread::Semaphore->new();
}
@@ -290,6 +290,7 @@ ($)
}
my $country = ($r && $r->country_code) || 'A1';
my ($listed_country) = split /\s+/, $entry->{'country'};
+ my $continent = $r->continent_code || 'XX';
# A1: Anonymous proxies
# A2: Satellite providers
@@ -355,11 +356,14 @@ ($)
unless (exists ($db{$type}{'AS'}{$as}));
$db{$type}{'country'}{$country} = shared_clone({})
unless (exists ($db{$type}{'country'}{$country}));
+ $db{$type}{'continent'}{$continent} = shared_clone({})
+ unless (exists ($db{$type}{'continent'}{$continent}));
$db{$type}{'all'}{$id} = undef;
$db{$type}{'ipv6'}{$id} = undef
if (defined ($entry->{'ipv6'}) && $entry->{'ipv6'} eq 'yes');
$db{$type}{'country'}{$country}{$id} = undef;
+ $db{$type}{'continent'}{$continent}{$id} = undef;
push @{$db{$type}{'AS'}{$as}}, $id;
foreach my $arch (keys %archs) {

0 comments on commit 062e6d8

Please sign in to comment.
Something went wrong with that request. Please try again.