]>
Commit | Line | Data |
---|---|---|
3841dd46 | 1 | /* |
262a0e14 | 2 | * $Id$ |
3841dd46 | 3 | * |
4 | * DEBUG: section 28 Access Control | |
5 | * AUTHOR: Duane Wessels | |
6 | * | |
7 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
8 | * ---------------------------------------------------------- | |
9 | * | |
10 | * Squid is the result of efforts by numerous individuals from | |
11 | * the Internet community; see the CONTRIBUTORS file for full | |
12 | * details. Many organizations have provided support for Squid's | |
13 | * development; see the SPONSORS file for full details. Squid is | |
14 | * Copyrighted (C) 2001 by the Regents of the University of | |
15 | * California; see the COPYRIGHT file for full details. Squid | |
16 | * incorporates software developed and/or copyrighted by other | |
17 | * sources; see the CREDITS file for full details. | |
18 | * | |
19 | * This program is free software; you can redistribute it and/or modify | |
20 | * it under the terms of the GNU General Public License as published by | |
21 | * the Free Software Foundation; either version 2 of the License, or | |
22 | * (at your option) any later version. | |
26ac0430 | 23 | * |
3841dd46 | 24 | * This program is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | * GNU General Public License for more details. | |
26ac0430 | 28 | * |
3841dd46 | 29 | * You should have received a copy of the GNU General Public License |
30 | * along with this program; if not, write to the Free Software | |
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
32 | * | |
33 | * | |
34 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
35 | */ | |
36 | ||
f7f3304a | 37 | #include "squid-old.h" |
c0941a6a AR |
38 | #include "acl/SourceDomain.h" |
39 | #include "acl/Checklist.h" | |
40 | #include "acl/RegexData.h" | |
41 | #include "acl/DomainData.h" | |
3ff65596 | 42 | #include "HttpRequest.h" |
3841dd46 | 43 | |
3841dd46 | 44 | SourceDomainLookup SourceDomainLookup::instance_; |
45 | ||
46 | SourceDomainLookup * | |
47 | SourceDomainLookup::Instance() | |
48 | { | |
49 | return &instance_; | |
50 | } | |
51 | ||
52 | void | |
077fe581 | 53 | SourceDomainLookup::checkForAsync(ACLChecklist *checklist) const |
3841dd46 | 54 | { |
55 | checklist->asyncInProgress(true); | |
c0941a6a | 56 | fqdncache_nbgethostbyaddr(Filled(checklist)->src_addr, LookupDone, checklist); |
3841dd46 | 57 | } |
58 | ||
59 | void | |
3ff65596 | 60 | SourceDomainLookup::LookupDone(const char *fqdn, const DnsLookupDetails &details, void *data) |
3841dd46 | 61 | { |
3ff65596 | 62 | ACLFilledChecklist *checklist = Filled((ACLChecklist*)data); |
3841dd46 | 63 | assert (checklist->asyncState() == SourceDomainLookup::Instance()); |
64 | ||
65 | checklist->asyncInProgress(false); | |
66 | checklist->changeState (ACLChecklist::NullState::Instance()); | |
3ff65596 AR |
67 | checklist->markSourceDomainChecked(); |
68 | checklist->request->recordLookup(details); | |
2efeb0b7 | 69 | checklist->matchNonBlocking(); |
3841dd46 | 70 | } |
71 | ||
3841dd46 | 72 | |
5dee515e | 73 | int |
c0941a6a | 74 | ACLSourceDomainStrategy::match (ACLData<MatchType> * &data, ACLFilledChecklist *checklist) |
3841dd46 | 75 | { |
5dee515e | 76 | const char *fqdn = NULL; |
77 | fqdn = fqdncache_gethostbyaddr(checklist->src_addr, FQDN_LOOKUP_IF_MISS); | |
62e76326 | 78 | |
5dee515e | 79 | if (fqdn) { |
62e76326 | 80 | return data->match(fqdn); |
5dee515e | 81 | } else if (!checklist->sourceDomainChecked()) { |
7660b45d | 82 | /* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */ |
cc192b50 | 83 | debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->src_addr << "'"); |
62e76326 | 84 | checklist->changeState(SourceDomainLookup::Instance()); |
85 | return 0; | |
5dee515e | 86 | } |
62e76326 | 87 | |
5dee515e | 88 | return data->match("none"); |
3841dd46 | 89 | } |
5dee515e | 90 | |
91 | ACLSourceDomainStrategy * | |
92 | ACLSourceDomainStrategy::Instance() | |
93 | { | |
94 | return &Instance_; | |
95 | } | |
96 | ||
97 | ACLSourceDomainStrategy ACLSourceDomainStrategy::Instance_; |