SourceDomain.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
28 void
30 {
31  fqdncache_nbgethostbyaddr(Filled(checklist)->src_addr, LookupDone, checklist);
32 }
33 
34 void
35 SourceDomainLookup::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 
43 int
45 {
46  const char *fqdn = NULL;
48 
49  if (fqdn) {
50  return data->match(fqdn);
51  } else if (!checklist->sourceDomainChecked()) {
52  /* FIXME: 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 
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:607
virtual bool match(M)=0
static SourceDomainLookup instance_
Definition: SourceDomain.h:32
Ip::Address src_addr
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
void fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH *handler, void *handlerData)
Definition: fqdncache.cc:413
encapsulates DNS lookup results
Definition: LookupDetails.h:20
static void LookupDone(const char *, const Dns::LookupDetails &, void *)
Definition: SourceDomain.cc:35
void const char HLPCB void * data
Definition: stub_helper.cc:16
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
bool goAsync(AsyncState *)
Definition: Checklist.cc:115
virtual void checkForAsync(ACLChecklist *) const
Definition: SourceDomain.cc:29
#define FQDN_LOOKUP_IF_MISS
Definition: defines.h:48
const char * AclMatchedName
Definition: Acl.cc:30
const char * fqdncache_gethostbyaddr(const Ip::Address &addr, int flags)
Definition: fqdncache.cc:480
static SourceDomainLookup * Instance()
Definition: SourceDomain.cc:23
HttpRequest * request
void resumeNonBlockingCheck(AsyncState *state)
Definition: Checklist.cc:262
bool sourceDomainChecked() const
#define NULL
Definition: types.h:166
virtual int match(ACLData< MatchType > *&, ACLFilledChecklist *) override
Definition: SourceDomain.cc:44

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors