]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/SourceDomain.cc
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 28 Access Control */
12 #include "acl/Checklist.h"
13 #include "acl/DomainData.h"
14 #include "acl/FilledChecklist.h"
15 #include "acl/RegexData.h"
16 #include "acl/SourceDomain.h"
17 #include "fqdncache.h"
18 #include "HttpRequest.h"
20 SourceDomainLookup
SourceDomainLookup::instance_
;
23 SourceDomainLookup::Instance()
29 SourceDomainLookup::checkForAsync(ACLChecklist
*checklist
) const
31 fqdncache_nbgethostbyaddr(Filled(checklist
)->src_addr
, LookupDone
, checklist
);
35 SourceDomainLookup::LookupDone(const char *, const Dns::LookupDetails
&details
, void *data
)
37 ACLFilledChecklist
*checklist
= Filled((ACLChecklist
*)data
);
38 checklist
->markSourceDomainChecked();
39 checklist
->request
->recordLookup(details
);
40 checklist
->resumeNonBlockingCheck(SourceDomainLookup::Instance());
44 ACLSourceDomainStrategy::match (ACLData
<MatchType
> * &data
, ACLFilledChecklist
*checklist
)
46 const char *fqdn
= nullptr;
47 fqdn
= fqdncache_gethostbyaddr(checklist
->src_addr
, FQDN_LOOKUP_IF_MISS
);
50 return data
->match(fqdn
);
51 } else if (!checklist
->sourceDomainChecked()) {
52 // TODO: Using AclMatchedName here is not OO correct. Should find a way to the current acl
53 debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName
<< "' ACL for '" << checklist
->src_addr
<< "'");
54 if (checklist
->goAsync(SourceDomainLookup::Instance()))
56 // else fall through to "none" match, hiding the lookup failure (XXX)
59 return data
->match("none");