SourceDomain.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
21
24{
25 return &instance_;
26}
27
28void
30{
31 fqdncache_nbgethostbyaddr(Filled(checklist)->src_addr, LookupDone, checklist);
32}
33
34void
35SourceDomainLookup::LookupDone(const char *, const Dns::LookupDetails &details, void *data)
36{
37 ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
38 checklist->markSourceDomainChecked();
39 checklist->request->recordLookup(details);
41}
42
43int
45{
46 const auto checklist = Filled(ch);
47
48 const char *fqdn = nullptr;
49 fqdn = fqdncache_gethostbyaddr(checklist->src_addr, FQDN_LOOKUP_IF_MISS);
50
51 if (fqdn) {
52 return data->match(fqdn);
53 } else if (!checklist->sourceDomainChecked()) {
54 // TODO: Using AclMatchedName here is not OO correct. Should find a way to the current acl
55 debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->src_addr << "'");
56 if (checklist->goAsync(SourceDomainLookup::Instance()))
57 return -1;
58 // else fall through to "none" match, hiding the lookup failure (XXX)
59 }
60
61 return data->match("none");
62}
63
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
void resumeNonBlockingCheck(AsyncState *state)
Definition: Checklist.cc:261
HttpRequest::Pointer request
int match(ACLChecklist *) override
Matches the actual data in checklist against this ACL.
Definition: SourceDomain.cc:44
encapsulates DNS lookup results
Definition: LookupDetails.h:23
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:580
static void LookupDone(const char *, const Dns::LookupDetails &, void *)
Definition: SourceDomain.cc:35
void checkForAsync(ACLChecklist *) const override
Definition: SourceDomain.cc:29
static SourceDomainLookup * Instance()
Definition: SourceDomain.cc:23
static SourceDomainLookup instance_
Definition: SourceDomain.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
#define FQDN_LOOKUP_IF_MISS
Definition: defines.h:34
const char * AclMatchedName
Definition: Acl.cc:29
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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors