]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
try to stop using wget, let's see if WWW::Mechanize stops the leak
authortabris <redacted>
Sun, 26 Feb 2012 21:58:57 +0000 (21:58 +0000)
committertabris <redacted>
Sun, 26 Feb 2012 21:58:57 +0000 (21:58 +0000)
git-svn-id: http://svn.tabris.net/repos/srsv@3582 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.4.3/SrSv/TOR.pm

index 773bc82803c67e5d0fc1aff2c3bd8edb0344c997..a6c46b57d04f0554f5e21288a95e3e3d82dda064 100644 (file)
@@ -31,17 +31,23 @@ BEGIN { our @EXPORT = qw( getTorRouters ); }
 
 sub openURI($) {
        my ($URI) = @_;
-       my $fh;
+       my $data;
        if($URI =~ s/^file:\/\///i) {
                use IO::File;
-               $fh = IO::File->new($URI, 'r') or die;
+               my $fh = IO::File->new($URI, 'r') or die;
+               return $fh;
        } else {
        # assume HTTP/FTP URI
-               use IO::Pipe;
-               $fh = IO::Pipe->new();
+=cut           use IO::Pipe;
+               my $fh = IO::Pipe->new();
                $fh->reader(qq(wget -q -O - $URI)) or die;
+=cut
+               use WWW::Mechanize;
+               my $mech = WWW::Mechanize->new();
+               $mech->get($URI) or die $!;
+               my $content = $mech->content;
+               return $content;
        }
-       return $fh;
 }
 
 our %TOR_cmdhash;
@@ -58,7 +64,7 @@ BEGIN {
 sub parseTorRouterList($) {
        my ($fh) = @_;
        our (%currentRouter, @routerList);
-       foreach my $l (<$fh>) {
+       foreach my $l (ref($fh) ? <$fh> : split($/, $fh)) {
                my ($tok, undef) = split(' ', $l, 2);
                #print "$l";
                chomp $l;