aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Mirrors
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MGA/Mirrors')
-rw-r--r--lib/MGA/Mirrors/Controller/Graph.pm8
-rw-r--r--lib/MGA/Mirrors/DB.pm10
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/MGA/Mirrors/Controller/Graph.pm b/lib/MGA/Mirrors/Controller/Graph.pm
index 5ca93cf..a2b6ad6 100644
--- a/lib/MGA/Mirrors/Controller/Graph.pm
+++ b/lib/MGA/Mirrors/Controller/Graph.pm
@@ -42,10 +42,16 @@ sub index :Path :Args(0) {
$graph->add_node($_, shape => 'box', cluster => $node{$_}{country});
}
}
- $graph->add_edge($from, $to);
+ # Minimum bandwidth of both nodes
+ my $bandwidth = ($node{$from}{bandwidth} < $node{$to}{bandwidth}) ? $node{$from}{bandwidth} : $node{$to}{bandwidth};
+ $bandwidth = 1 if (!$bandwidth);
+ my $thickness = log($bandwidth) / log(3) - 16; # Scale line thickness from bandwidth
+ $thickness = ($thickness < 1) ? 1 : $thickness;
+ $graph->add_edge($from => $to, penwidth => $thickness);
}
}
$c->stash->{graphviz}->{graph} = $graph;
+ $c->stash->{graphviz}->{format} = "svg";
}
sub end : Private {
diff --git a/lib/MGA/Mirrors/DB.pm b/lib/MGA/Mirrors/DB.pm
index 2e54847..1f59614 100644
--- a/lib/MGA/Mirrors/DB.pm
+++ b/lib/MGA/Mirrors/DB.pm
@@ -10,6 +10,8 @@ use DBI;
use File::Temp qw(tempfile);
use Net::DNS;
+my $timeout = 10; # timeout connecting to remote servers
+
sub configfile { '/etc/mga-mirrors.ini' }
sub new {
@@ -284,13 +286,11 @@ sub check_distributions {
sub _check_url {
my ($self, $furi) = @_;
- my ($fh, $filename) = tempfile();
- close($fh);
my $cmd =
- $furi->scheme =~ /^http|ftp$/ ? "wget -q --no-check-certificate -nv -t 1 -T 4 -O $filename " . $furi->as_string :
- $furi->scheme eq 'rsync' ? "rsync --timeout 4 -q " . $furi->as_string . " $filename" : '';
+ $furi->scheme =~ /^http|ftp$/ ? "wget -q --no-check-certificate -nv -t 1 -T $timeout -O /dev/null " . $furi->as_string :
+ $furi->scheme eq 'rsync' ? "rsync --dry-run --timeout $timeout -q " . $furi->as_string . " /dev/null 2>/dev/null" : '';
my $ok = (system($cmd) == 0);
- unlink($filename);
+ #print STDERR "Result of \"$cmd\" was " . ($ok ? "ok" : "failure") . "\n";
return $ok
}