]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/send-announce.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / send-announce.cc
index 085203d523d4509c1e124f6f0ccbd70cc8d52de3..d7312984740f03771926bdc6786b282e5460fa04 100644 (file)
@@ -1,50 +1,31 @@
-
 /*
- * $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-2018 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;
@@ -58,28 +39,28 @@ start_announce(void *datanotused)
 }
 
 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(),
@@ -106,14 +87,18 @@ send_announce(const ipcache_addrs *ia, const DnsLookupDetails &, void *junk)
             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));
+    }
 }
+