]>
Commit | Line | Data |
---|---|---|
090089c4 | 1 | #!/usr/local/bin/perl |
a151895d | 2 | # |
5b74111a | 3 | ## Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
a151895d AJ |
4 | ## |
5 | ## Squid software is distributed under GPLv2+ license and includes | |
6 | ## contributions from numerous individuals and organizations. | |
7 | ## Please see the COPYING and CONTRIBUTORS files for details. | |
8 | ## | |
090089c4 | 9 | |
10 | $|=1; | |
11 | ||
12 | $host = (shift || 'sd.cache.nlanr.net'); | |
13 | $port = (shift || '3131'); | |
14 | ||
15 | require "$ENV{'HARVEST_HOME'}/lib/socket.ph"; | |
16 | ||
17 | $sockaddr = 'S n a4 x8'; | |
18 | ($name, $aliases, $proto) = getprotobyname("udp"); | |
19 | ($fqdn, $aliases, $type, $len, $themaddr) = gethostbyname($host); | |
20 | $thissock = pack($sockaddr, &AF_INET, 0, "\0\0\0\0"); | |
21 | $them = pack($sockaddr, &AF_INET, $port, $themaddr); | |
22 | ||
23 | chop($me=`uname -a|cut -f2 -d' '`); | |
24 | $myip=(gethostbyname($me))[4]; | |
25 | ||
26 | die "socket: $!\n" unless | |
27 | socket (SOCK, &AF_INET, &SOCK_DGRAM, $proto); | |
28 | ||
29 | while (<>) { | |
30 | chop; | |
31 | $request_template = 'CCnx4x8x4a4a' . length; | |
32 | $request = pack($request_template, 1, 1, 24 + length, $myip, $_); | |
33 | die "send: $!\n" unless | |
34 | send(SOCK, $request, 0, $them); | |
35 | die "recv: $!\n" unless | |
36 | recv(SOCK, $reply, 1024, 0); | |
37 | ($type,$ver,$len,$payload) = unpack('CCnx4x8x4A', $reply); | |
38 | print $CODES[$type] . " $_\n"; | |
39 | } | |
40 |