Added script to create archlinux vserver/chroot environment
[mirrors/Programs.git] / perl / gnutella / gnutella.pl
... / ...
CommitLineData
1#!/usr/bin/env perl
2use strict;
3use warnings;
4use IO::Socket::INET;
5use LWP::Simple;
6
7our $g_client = 'petella';
8our $g_client_version = '0.1';
9$g_client = 'LimeWire';
10$g_client_version = '5.1.2';
11our %g_cache;
12
13#my $sock = IO::Socket::INET->new(PeerAddr => 'localhost', PeerPort => '80');
14#my $sock = IO::Socket::INET->new('localhost:80');
15#print $sock "GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n";
16#while(<$sock>) { print $_; STDOUT->flush; } $sock->close;
17
18my $gwc_url = 'http://gwc.lame.net/gwcii.php';
19foreach( split(/\n/, get($gwc_url."?client=$g_client&version=$g_client_version&hostfile=1")) ) {
20 my($ip, $port) = split(/:/, $_);
21 $ip =~ s/[^0-9\.]//;
22 $port =~ s/[^0-9]//;
23 $g_cache{$ip}=$port;
24}
25
26while (my($ip, $port) = each(%g_cache)){
27 print "connecting to gnutella:$ip:$port\n";
28 #my $sock = IO::Socket::INET->new('10.127.85.96:35301');
29 my $sock = IO::Socket::INET->new(PeerAddr => $ip, PeerPort => $port);
30 print $sock "GNUTELLA CONNECT/0.6\r\n".
31 "User-Agent: $g_client/$g_client_version\r\n".
32 "X-Ultrapeer: False\r\n".
33 "X-Query-Routing: 0.1\r\n\r\n";
34 while(<$sock>) {
35 print $_;
36 STDOUT->flush;
37 }
38 $sock->close;
39}
40
41
42
This page took 0.080109 seconds and 4 git commands to generate.