-
/*
- * $Id$
- *
- * DEBUG: section 27 Cache Announcer
- * AUTHOR: Duane Wessels
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 27 Cache Announcer */
+
#include "squid.h"
+#include "anyp/PortCfg.h"
#include "comm/Connection.h"
#include "event.h"
+#include "fd.h"
#include "fde.h"
+#include "fs_io.h"
+#include "globals.h"
#include "ICP.h"
#include "ipcache.h"
+#include "SquidConfig.h"
#include "SquidTime.h"
+#include "tools.h"
static IPH send_announce;
void
-start_announce(void *datanotused)
+start_announce(void *)
{
if (0 == Config.onoff.announce)
return;
}
static void
-send_announce(const ipcache_addrs *ia, const DnsLookupDetails &, void *junk)
+send_announce(const ipcache_addrs *ia, const Dns::LookupDetails &, void *)
{
LOCAL_ARRAY(char, tbuf, 256);
LOCAL_ARRAY(char, sndbuf, BUFSIZ);
char *host = Config.Announce.host;
char *file = NULL;
- u_short port = Config.Announce.port;
+ unsigned short port = Config.Announce.port;
int l;
int n;
int fd;
if (ia == NULL) {
- debugs(27, 1, "send_announce: Unknown host '" << host << "'");
+ debugs(27, DBG_IMPORTANT, "send_announce: Unknown host '" << host << "'");
return;
}
- debugs(27, 1, "Sending Announcement to " << host);
+ debugs(27, DBG_IMPORTANT, "Sending Announcement to " << host);
sndbuf[0] = '\0';
snprintf(tbuf, 256, "cache_version SQUID/%s\n", version_string);
strcat(sndbuf, tbuf);
- assert(Config.Sockaddr.http);
+ assert(HttpPortList != NULL);
snprintf(tbuf, 256, "Running on %s %d %d\n",
getMyHostname(),
getMyPort(),
sndbuf[l] = '\0';
file_close(fd);
} else {
- debugs(50, 1, "send_announce: " << file << ": " << xstrerror());
+ int xerrno = errno;
+ debugs(50, DBG_IMPORTANT, "send_announce: " << file << ": " << xstrerr(xerrno));
}
}
- Ip::Address S = ia->in_addrs[0];
- S.SetPort(port);
+ Ip::Address S = ia->current();
+ S.port(port);
assert(Comm::IsConnOpen(icpOutgoingConn));
- if (comm_udp_sendto(icpOutgoingConn->fd, S, sndbuf, strlen(sndbuf) + 1) < 0)
- debugs(27, 1, "ERROR: Failed to announce to " << S << " from " << icpOutgoingConn->local << ": " << xstrerror());
+ if (comm_udp_sendto(icpOutgoingConn->fd, S, sndbuf, strlen(sndbuf) + 1) < 0) {
+ int xerrno = errno;
+ debugs(27, DBG_IMPORTANT, "ERROR: Failed to announce to " << S << " from " << icpOutgoingConn->local << ": " << xstrerr(xerrno));
+ }
}
+