SourceDomain.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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 char *fqdn = nullptr;
48
49 if (fqdn) {
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()))
55 return -1;
56 // else fall through to "none" match, hiding the lookup failure (XXX)
57 }
58
59 return data->match("none");
60}
61
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
bool goAsync(AsyncState *)
Definition: Checklist.cc:114
void resumeNonBlockingCheck(AsyncState *state)
Definition: Checklist.cc:261
virtual bool match(M)=0
HttpRequest * request
Ip::Address src_addr
bool sourceDomainChecked() const
virtual int match(ACLData< MatchType > *&, ACLFilledChecklist *) override
Definition: SourceDomain.cc:44
encapsulates DNS lookup results
Definition: LookupDetails.h:21
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:583
static void LookupDone(const char *, const Dns::LookupDetails &, void *)
Definition: SourceDomain.cc:35
virtual void checkForAsync(ACLChecklist *) const
Definition: SourceDomain.cc:29
static SourceDomainLookup * Instance()
Definition: SourceDomain.cc:23
static SourceDomainLookup instance_
Definition: SourceDomain.h:32
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
#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