Example #1
0
void
start_announce(void *datanotused)
{
    void *junk;
    if (0 == Config.onoff.announce)
	return;
    if (theOutIcpConnection < 0)
	return;
    cbdataAdd(junk = xmalloc(1), cbdataXfree, 0);
    ipcache_nbgethostbyname(Config.Announce.host, send_announce, junk);
    eventAdd("send_announce", start_announce, NULL, (double) Config.Announce.period, 1);
}
Example #2
0
void
netdbPingSite(const char *hostname)
{
#if USE_ICMP
    netdbEntry *n;
    generic_cbdata *h;
    if ((n = netdbLookupHost(hostname)) != NULL)
        if (n->next_ping_time > squid_curtime)
            return;
    h = cbdataAlloc(generic_cbdata);
    h->data = xstrdup(hostname);
    ipcache_nbgethostbyname(hostname, netdbSendPing, h);
#endif
}
Example #3
0
void
peerConnectSucceded(peer * p)
{
    if (!p->tcp_up) {
	debug(15, 2) ("TCP connection to %s (%s:%d) succeded\n", p->name, p->host, p->http_port);
	debug(15, 1) ("Detected REVIVED %s: %s\n",
	    neighborTypeStr(p), p->name);
	peerMonitorNow(p);
	p->stats.logged_state = PEER_ALIVE;
	peerClearRR();
	if (!p->n_addresses)
	    ipcache_nbgethostbyname(p->host, peerDNSConfigure, p);
    }
    p->tcp_up = p->connect_fail_limit;
}
Example #4
0
static void
peerRefreshDNS(void *data)
{
    peer *p = NULL;
    if (eventFind(peerRefreshDNS, NULL))
	eventDelete(peerRefreshDNS, NULL);
    if (!data && 0 == stat5minClientRequests()) {
	/* no recent client traffic, wait a bit */
	eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 180.0, 1);
	return;
    }
    for (p = Config.peers; p; p = p->next) {
	ipcache_nbgethostbyname(p->host, peerDNSConfigure, p);
    }
    /* Reconfigure the peers every hour */
    eventAddIsh("peerRefreshDNS", peerRefreshDNS, NULL, 3600.0, 1);
}
static int set_name_as_ip(FwdState *fwdState, char** name)
{
	const ipcache_addrs *addrs = NULL;
	ipcache_entry *i = NULL;
	if ((addrs = ipcacheCheckNumeric(*name)))
	{
		return 1;
	}
	i = ipcache_get(*name);
	if (NULL == i)
	{
		/* miss */
		return 0;
	}
	else if(i->flags.negcached == 1)
	{
		return 0;
	}
	else if (ipcacheExpiredEntry(i))
	{
		/* hit, but expired -- bummer */
		char *host=xstrdup(*name);
		*name = inet_ntoa(*(i->addrs.in_addrs));
		ipcache_nbgethostbyname(host, local_handler, NULL);
		//ipcacheRelease(i);
//		i = NULL;
		safe_free(host);
		return 0 ;
	}
	else
	{
		 *name = inet_ntoa(*(i->addrs.in_addrs));
	}
	debug(151,3)("mod_server_persist_connections-->set_name_as_ip: set name as %s\n ",*name);
	return 1 ;
}
Example #6
0
void
icpConnectionsOpen(void)
{
    u_short port;
    struct in_addr addr;
    struct sockaddr_in xaddr;
    int x;
    socklen_t len;
    wordlist *s;
    if (Config2.Accel.on && !Config.onoff.accel_with_proxy)
	return;
    if ((port = Config.Port.icp) <= 0)
	return;
    enter_suid();
    theInIcpConnection = comm_open(SOCK_DGRAM,
	0,
	Config.Addrs.udp_incoming,
	port,
	COMM_NONBLOCKING,
	"ICP Socket");
    leave_suid();
    if (theInIcpConnection < 0)
	fatal("Cannot open ICP Port");
    commSetSelect(theInIcpConnection,
	COMM_SELECT_READ,
	icpHandleUdp,
	NULL,
	0);
    for (s = Config.mcast_group_list; s; s = s->next)
	ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
    debug(12, 1) ("Accepting ICP messages at %s, port %d, FD %d.\n",
	inet_ntoa(Config.Addrs.udp_incoming),
	(int) port, theInIcpConnection);
    if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) {
	enter_suid();
	theOutIcpConnection = comm_open(SOCK_DGRAM,
	    0,
	    addr,
	    port,
	    COMM_NONBLOCKING,
	    "ICP Port");
	leave_suid();
	if (theOutIcpConnection < 0)
	    fatal("Cannot open Outgoing ICP Port");
	commSetSelect(theOutIcpConnection,
	    COMM_SELECT_READ,
	    icpHandleUdp,
	    NULL,
	    0);
	debug(12, 1) ("Outgoing ICP messages on port %d, FD %d.\n",
	    (int) port, theOutIcpConnection);
	fd_note(theOutIcpConnection, "Outgoing ICP socket");
	fd_note(theInIcpConnection, "Incoming ICP socket");
    } else {
	theOutIcpConnection = theInIcpConnection;
    }
    memset(&theOutICPAddr, '\0', sizeof(struct in_addr));
    len = sizeof(struct sockaddr_in);
    memset(&xaddr, '\0', len);
    x = getsockname(theOutIcpConnection,
	(struct sockaddr *) &xaddr, &len);
    if (x < 0)
	debug(50, 1) ("theOutIcpConnection FD %d: getsockname: %s\n",
	    theOutIcpConnection, xstrerror());
    else
	theOutICPAddr = xaddr.sin_addr;
}