Squid Web Cache master
Loading...
Searching...
No Matches
SourceDomain.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 28 Access Control */
10
11#include "squid.h"
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"
19
20static void LookupDone(const char *, const Dns::LookupDetails &, void *data);
21
22static void
24{
25 fqdncache_nbgethostbyaddr(checklist.src_addr, LookupDone, &checklist);
26}
27
28static void
29LookupDone(const char *, const Dns::LookupDetails &details, void *data)
30{
31 ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
32 checklist->markSourceDomainChecked();
33 if (checklist->request)
34 checklist->request->recordLookup(details);
35 else
36 debugs(28, 3, "no request to recordLookup()");
37
38 checklist->resumeNonBlockingCheck();
39}
40
41int
43{
44 const auto checklist = Filled(ch);
45
46 const char *fqdn = nullptr;
47 fqdn = fqdncache_gethostbyaddr(checklist->src_addr, FQDN_LOOKUP_IF_MISS);
48
49 if (fqdn) {
50 return data->match(fqdn);
51 } else if (!checklist->sourceDomainChecked()) {
52 debugs(28, 3, "aclMatchAcl: Can't yet compare '" << name << "' ACL for '" << checklist->src_addr << "'");
53 if (checklist->goAsync(StartLookup, *this))
54 return -1;
55 // else fall through to "none" match, hiding the lookup failure (XXX)
56 }
57
58 return data->match("none");
59}
60
static void StartLookup(ACLFilledChecklist &cl, const Acl::Node &)
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
static void StartLookup(ACLFilledChecklist &checklist, const Acl::Node &)
static void LookupDone(const char *, const Dns::LookupDetails &, void *data)
void resumeNonBlockingCheck()
Definition Checklist.cc:230
HttpRequest::Pointer request
SBuf name
Definition Node.h:81
int match(ACLChecklist *) override
Matches the actual data in checklist against this Acl::Node.
encapsulates DNS lookup results
void recordLookup(const Dns::LookupDetails &detail)
#define debugs(SECTION, LEVEL, CONTENT)
Definition Stream.h:192
#define FQDN_LOOKUP_IF_MISS
Definition defines.h:34
const char * fqdncache_gethostbyaddr(const Ip::Address &addr, int flags)
Definition fqdncache.cc:481
void fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH *handler, void *handlerData)
Definition fqdncache.cc:414