コード例 #1
0
ファイル: neighbors.c プロジェクト: CoolerVoid/squid
peer_t
neighborType(const peer * p, const request_t * request)
{
    const struct _domain_type *d = NULL;
    for (d = p->typelist; d; d = d->next) {
	if (0 == matchDomainName(request->host, d->domain))
	    if (d->type != PEER_NONE)
		return d->type;
    }
#if PEER_MULTICAST_SIBLINGS
    if (p->type == PEER_MULTICAST)
	if (p->options.mcast_siblings)
	    return PEER_SIBLING;
#endif
    return p->type;
}
コード例 #2
0
ファイル: neighbors.c プロジェクト: CoolerVoid/squid
/*
 * peerAllowedToUse
 *
 * this function figures out if it is appropriate to fetch REQUEST
 * from PEER.
 */
int
peerAllowedToUse(const peer * p, request_t * request)
{
    const struct _domain_ping *d = NULL;
    int do_ping = 1;
    assert(request != NULL);
    if (neighborType(p, request) == PEER_SIBLING) {
#if PEER_MULTICAST_SIBLINGS
	if (p->type == PEER_MULTICAST && p->options.mcast_siblings &&
	    (request->flags.nocache || request->flags.refresh || request->flags.loopdetect || request->flags.need_validation))
	    debug(15, 2) ("peerAllowedToUse(%s, %s) : multicast-siblings optimization match\n",
		p->name, request->host);
#endif
	if (request->flags.nocache)
	    return 0;
	if (request->flags.refresh)
	    return 0;
	if (request->flags.loopdetect)
	    return 0;
	if (request->flags.need_validation)
	    return 0;
    }
    if (p->peer_domain == NULL && p->access == NULL)
	return do_ping;
    do_ping = 0;
    for (d = p->peer_domain; d; d = d->next) {
	if (0 == matchDomainName(request->host, d->domain)) {
	    do_ping = d->do_ping;
	    break;
	}
	do_ping = !d->do_ping;
    }
    if (p->peer_domain && 0 == do_ping)
	return do_ping;
    if (p->access == NULL)
	return do_ping;
    return aclCheckFastRequest(p->access, request);
}
コード例 #3
0
ファイル: url.c プロジェクト: cristdai/squid2
void
urlInitialize(void)
{
    debug(23, 5) ("urlInitialize: Initializing...\n");
    assert(sizeof(ProtocolStr) == (PROTO_MAX + 1) * sizeof(char *));
    memset(&null_request_flags, '\0', sizeof(null_request_flags));
    /*
     * These test that our matchDomainName() function works the
     * way we expect it to.
     */
    assert(0 == matchDomainName("foo.com", "foo.com"));
    assert(0 == matchDomainName(".foo.com", "foo.com"));
    assert(0 == matchDomainName("foo.com", ".foo.com"));
    assert(0 == matchDomainName(".foo.com", ".foo.com"));
    assert(0 == matchDomainName("x.foo.com", ".foo.com"));
    assert(0 != matchDomainName("x.foo.com", "foo.com"));
    assert(0 != matchDomainName("foo.com", "x.foo.com"));
    assert(0 != matchDomainName("bar.com", "foo.com"));
    assert(0 != matchDomainName(".bar.com", "foo.com"));
    assert(0 != matchDomainName(".bar.com", ".foo.com"));
    assert(0 != matchDomainName("bar.com", ".foo.com"));
    assert(0 < matchDomainName("zzz.com", "foo.com"));
    assert(0 > matchDomainName("aaa.com", "foo.com"));
    assert(0 == matchDomainName("FOO.com", "foo.COM"));
    assert(0 < matchDomainName("bfoo.com", "afoo.com"));
    assert(0 > matchDomainName("afoo.com", "bfoo.com"));
    assert(0 < matchDomainName("x-foo.com", ".foo.com"));
    /* more cases? */
}