]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/AnnounceCache.pl
e48adabb16b1d1b442e3ee712b37c0c659453444
3 ## Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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.
12 $host = (shift || 'sd.cache.nlanr.net');
13 $port = (shift || '3131');
15 require "$ENV{'HARVEST_HOME'}/lib/socket.ph";
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);
23 chop($me=`uname -a|cut -f2 -d' '`);
24 $myip=(gethostbyname($me))[4];
26 die "socket: $!\n" unless
27 socket (SOCK
, &AF_INET
, &SOCK_DGRAM
, $proto);
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";