]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
bbc27441 AJ |
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 | ||
582c2af2 | 9 | #include "squid.h" |
2d46f579 | 10 | |
c302ddb5 CT |
11 | #if USE_ADAPTATION |
12 | #include "acl/AdaptationService.h" | |
13 | #include "acl/AdaptationServiceData.h" | |
14 | #endif | |
6f58d7d7 | 15 | #include "acl/AllOf.h" |
75d47340 CT |
16 | #include "acl/AnnotateClient.h" |
17 | #include "acl/AnnotateTransaction.h" | |
18 | #include "acl/AnnotationData.h" | |
6f58d7d7 | 19 | #include "acl/AnyOf.h" |
32d002cb | 20 | #if USE_SQUID_EUI |
2d46f579 | 21 | #include "acl/Arp.h" |
a98c2da5 | 22 | #include "acl/Eui64.h" |
2d46f579 | 23 | #endif |
5d65362c | 24 | #if USE_OPENSSL |
8693472e CT |
25 | #include "acl/AtStep.h" |
26 | #include "acl/AtStepData.h" | |
5d65362c | 27 | #endif |
2d46f579 | 28 | #include "acl/Asn.h" |
2d46f579 | 29 | #include "acl/Checklist.h" |
88df846b | 30 | #include "acl/ConnectionsEncrypted.h" |
2d46f579 AR |
31 | #include "acl/Data.h" |
32 | #include "acl/DestinationAsn.h" | |
33 | #include "acl/DestinationDomain.h" | |
34 | #include "acl/DestinationIp.h" | |
35 | #include "acl/DomainData.h" | |
2f1431ea | 36 | #if USE_AUTH |
2d46f579 | 37 | #include "acl/ExtUser.h" |
2f1431ea | 38 | #endif |
2d46f579 | 39 | #include "acl/FilledChecklist.h" |
4eac3407 | 40 | #include "acl/forward.h" |
2d46f579 | 41 | #include "acl/Gadgets.h" |
5ec4cffe EB |
42 | #include "acl/HasComponent.h" |
43 | #include "acl/HasComponentData.h" | |
bbaf2685 | 44 | #include "acl/HierCode.h" |
602d9612 | 45 | #include "acl/HierCodeData.h" |
2d46f579 AR |
46 | #include "acl/HttpHeaderData.h" |
47 | #include "acl/HttpRepHeader.h" | |
48 | #include "acl/HttpReqHeader.h" | |
49 | #include "acl/HttpStatus.h" | |
2d46f579 AR |
50 | #include "acl/IntRange.h" |
51 | #include "acl/Ip.h" | |
1e40905d AJ |
52 | #include "acl/LocalIp.h" |
53 | #include "acl/LocalPort.h" | |
2d46f579 | 54 | #include "acl/MaxConnection.h" |
2d46f579 | 55 | #include "acl/Method.h" |
602d9612 | 56 | #include "acl/MethodData.h" |
2d46f579 | 57 | #include "acl/MyPortName.h" |
39baccc8 CT |
58 | #include "acl/Note.h" |
59 | #include "acl/NoteData.h" | |
2d46f579 | 60 | #include "acl/PeerName.h" |
2d46f579 | 61 | #include "acl/Protocol.h" |
602d9612 | 62 | #include "acl/ProtocolData.h" |
cb1b906f | 63 | #include "acl/Random.h" |
2d46f579 AR |
64 | #include "acl/RegexData.h" |
65 | #include "acl/ReplyHeaderStrategy.h" | |
66 | #include "acl/ReplyMimeType.h" | |
67 | #include "acl/RequestHeaderStrategy.h" | |
68 | #include "acl/RequestMimeType.h" | |
69 | #include "acl/SourceAsn.h" | |
70 | #include "acl/SourceDomain.h" | |
71 | #include "acl/SourceIp.h" | |
3248e962 CT |
72 | #include "acl/SquidError.h" |
73 | #include "acl/SquidErrorData.h" | |
cb4f4424 | 74 | #if USE_OPENSSL |
2d46f579 | 75 | #include "acl/Certificate.h" |
602d9612 | 76 | #include "acl/CertificateData.h" |
69f69080 | 77 | #include "acl/ServerName.h" |
602d9612 A |
78 | #include "acl/SslError.h" |
79 | #include "acl/SslErrorData.h" | |
2d46f579 AR |
80 | #endif |
81 | #include "acl/Strategised.h" | |
82 | #include "acl/Strategy.h" | |
83 | #include "acl/StringData.h" | |
cb4f4424 | 84 | #if USE_OPENSSL |
00352183 AR |
85 | #include "acl/ServerCertificate.h" |
86 | #endif | |
bb5e7a79 | 87 | #include "acl/Tag.h" |
2d46f579 | 88 | #include "acl/Time.h" |
602d9612 | 89 | #include "acl/TimeData.h" |
5ceaee75 | 90 | #include "acl/TransactionInitiator.h" |
2d46f579 | 91 | #include "acl/Url.h" |
9d35fe37 | 92 | #include "acl/UrlLogin.h" |
2d46f579 AR |
93 | #include "acl/UrlPath.h" |
94 | #include "acl/UrlPort.h" | |
95 | #include "acl/UserData.h" | |
2f1431ea | 96 | #if USE_AUTH |
abca32cf | 97 | #include "auth/AclMaxUserIp.h" |
602d9612 | 98 | #include "auth/AclProxyAuth.h" |
2f1431ea | 99 | #endif |
e2b74520 | 100 | #include "base/RegexPattern.h" |
4eac3407 | 101 | #include "ExternalACL.h" |
4daaf3cb AJ |
102 | #if USE_IDENT |
103 | #include "ident/AclIdent.h" | |
104 | #endif | |
4eac3407 CT |
105 | #if SQUID_SNMP |
106 | #include "snmp_core.h" | |
2f1431ea | 107 | #endif |
5d65362c | 108 | |
4eac3407 CT |
109 | // Not in src/acl/ because some of the ACLs it registers are not in src/acl/. |
110 | void | |
111 | Acl::Init() | |
112 | { | |
113 | /* the registration order does not matter */ | |
114 | ||
115 | // The explicit return type (ACL*) for lambdas is needed because the type | |
116 | // of the return expression inside lambda is not ACL* but AclFoo* while | |
117 | // Acl::Maker is defined to return ACL*. | |
118 | ||
119 | RegisterMaker("all-of", [](TypeName)->ACL* { return new Acl::AllOf; }); // XXX: Add name parameter to ctor | |
120 | RegisterMaker("any-of", [](TypeName)->ACL* { return new Acl::AnyOf; }); // XXX: Add name parameter to ctor | |
121 | RegisterMaker("random", [](TypeName name)->ACL* { return new ACLRandom(name); }); | |
122 | RegisterMaker("time", [](TypeName name)->ACL* { return new ACLStrategised<time_t>(new ACLTimeData, new ACLTimeStrategy, name); }); | |
123 | RegisterMaker("src_as", [](TypeName name)->ACL* { return new ACLStrategised<Ip::Address>(new ACLASN, new ACLSourceASNStrategy, name); }); | |
124 | RegisterMaker("dst_as", [](TypeName name)->ACL* { return new ACLStrategised<Ip::Address>(new ACLASN, new ACLDestinationASNStrategy, name); }); | |
125 | RegisterMaker("browser", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLRequestHeaderStrategy<Http::HdrType::USER_AGENT>, name); }); | |
126 | RegisterMaker("dstdomain", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLDomainData, new ACLDestinationDomainStrategy, name); }); | |
127 | RegisterMaker("dstdom_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLDestinationDomainStrategy , name); }); | |
128 | RegisterMaker("dst", [](TypeName)->ACL* { return new ACLDestinationIP; }); // XXX: Add name parameter to ctor | |
129 | RegisterMaker("hier_code", [](TypeName name)->ACL* { return new ACLStrategised<hier_code>(new ACLHierCodeData, new ACLHierCodeStrategy, name); }); | |
130 | RegisterMaker("rep_header", [](TypeName name)->ACL* { return new ACLStrategised<HttpHeader*>(new ACLHTTPHeaderData, new ACLHTTPRepHeaderStrategy, name); }); | |
131 | RegisterMaker("req_header", [](TypeName name)->ACL* { return new ACLStrategised<HttpHeader*>(new ACLHTTPHeaderData, new ACLHTTPReqHeaderStrategy, name); }); | |
132 | RegisterMaker("http_status", [](TypeName name)->ACL* { return new ACLHTTPStatus(name); }); | |
133 | RegisterMaker("maxconn", [](TypeName name)->ACL* { return new ACLMaxConnection(name); }); | |
134 | RegisterMaker("method", [](TypeName name)->ACL* { return new ACLStrategised<HttpRequestMethod>(new ACLMethodData, new ACLMethodStrategy, name); }); | |
135 | RegisterMaker("localip", [](TypeName)->ACL* { return new ACLLocalIP; }); // XXX: Add name parameter to ctor | |
136 | RegisterMaker("localport", [](TypeName name)->ACL* { return new ACLStrategised<int>(new ACLIntRange, new ACLLocalPortStrategy, name); }); | |
137 | RegisterMaker("myportname", [](TypeName name)->ACL* { return new ACLStrategised<const char *>(new ACLStringData, new ACLMyPortNameStrategy, name); }); | |
138 | RegisterMaker("peername", [](TypeName name)->ACL* { return new ACLStrategised<const char *>(new ACLStringData, new ACLPeerNameStrategy, name); }); | |
139 | RegisterMaker("peername_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLPeerNameStrategy, name); }); | |
140 | RegisterMaker("proto", [](TypeName name)->ACL* { return new ACLStrategised<AnyP::ProtocolType>(new ACLProtocolData, new ACLProtocolStrategy, name); }); | |
141 | RegisterMaker("referer_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLRequestHeaderStrategy<Http::HdrType::REFERER>, name); }); | |
142 | RegisterMaker("rep_mime_type", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLReplyHeaderStrategy<Http::HdrType::CONTENT_TYPE>, name); }); | |
143 | RegisterMaker("req_mime_type", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLRequestHeaderStrategy<Http::HdrType::CONTENT_TYPE>, name); }); | |
144 | RegisterMaker("srcdomain", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLDomainData, new ACLSourceDomainStrategy, name); }); | |
145 | RegisterMaker("srcdom_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLSourceDomainStrategy, name); }); | |
146 | RegisterMaker("src", [](TypeName)->ACL* { return new ACLSourceIP; }); // XXX: Add name parameter to ctor | |
147 | RegisterMaker("url_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLUrlStrategy, name); }); | |
148 | RegisterMaker("urllogin", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLUrlLoginStrategy, name); }); | |
149 | RegisterMaker("urlpath_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLUrlPathStrategy, name); }); | |
150 | RegisterMaker("port", [](TypeName name)->ACL* { return new ACLStrategised<int>(new ACLIntRange, new ACLUrlPortStrategy, name); }); | |
151 | RegisterMaker("external", [](TypeName name)->ACL* { return new ACLExternal(name); }); | |
152 | RegisterMaker("squid_error", [](TypeName name)->ACL* { return new ACLStrategised<err_type>(new ACLSquidErrorData, new ACLSquidErrorStrategy, name); }); | |
153 | RegisterMaker("connections_encrypted", [](TypeName name)->ACL* { return new Acl::ConnectionsEncrypted(name); }); | |
154 | RegisterMaker("tag", [](TypeName name)->ACL* { return new ACLStrategised<const char *>(new ACLStringData, new ACLTagStrategy, name); }); | |
155 | RegisterMaker("note", [](TypeName name)->ACL* { return new ACLStrategised<NotePairs::Entry*>(new ACLNoteData, new ACLNoteStrategy, name); }); | |
156 | RegisterMaker("annotate_client", [](TypeName name)->ACL* { return new ACLStrategised<NotePairs::Entry*>(new ACLAnnotationData, new ACLAnnotateClientStrategy, name); }); | |
157 | RegisterMaker("annotate_transaction", [](TypeName name)->ACL* { return new ACLStrategised<NotePairs::Entry*>(new ACLAnnotationData, new ACLAnnotateTransactionStrategy, name); }); | |
158 | RegisterMaker("has", [](TypeName name)->ACL* {return new ACLStrategised<ACLChecklist *>(new ACLHasComponentData, new ACLHasComponentStrategy, name); }); | |
5ceaee75 | 159 | RegisterMaker("transaction_initiator", [](TypeName name)->ACL* {return new TransactionInitiator(name);}); |
69f69080 | 160 | |
4eac3407 CT |
161 | #if USE_OPENSSL |
162 | RegisterMaker("ssl_error", [](TypeName name)->ACL* { return new ACLStrategised<const Security::CertErrors *>(new ACLSslErrorData, new ACLSslErrorStrategy, name); }); | |
163 | RegisterMaker("user_cert", [](TypeName name)->ACL* { return new ACLStrategised<X509*>(new ACLCertificateData(Ssl::GetX509UserAttribute, "*"), new ACLCertificateStrategy, name); }); | |
164 | RegisterMaker("ca_cert", [](TypeName name)->ACL* { return new ACLStrategised<X509*>(new ACLCertificateData(Ssl::GetX509CAAttribute, "*"), new ACLCertificateStrategy, name); }); | |
165 | RegisterMaker("server_cert_fingerprint", [](TypeName name)->ACL* { return new ACLStrategised<X509*>(new ACLCertificateData(Ssl::GetX509Fingerprint, "-sha1", true), new ACLServerCertificateStrategy, name); }); | |
166 | RegisterMaker("at_step", [](TypeName name)->ACL* { return new ACLStrategised<Ssl::BumpStep>(new ACLAtStepData, new ACLAtStepStrategy, name); }); | |
167 | RegisterMaker("ssl::server_name", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLServerNameData, new ACLServerNameStrategy, name); }); | |
168 | RegisterMaker("ssl::server_name_regex", [](TypeName name)->ACL* { return new ACLStrategised<char const *>(new ACLRegexData, new ACLServerNameStrategy, name); }); | |
2d46f579 AR |
169 | #endif |
170 | ||
32d002cb | 171 | #if USE_SQUID_EUI |
4eac3407 CT |
172 | RegisterMaker("arp", [](TypeName name)->ACL* { return new ACLARP(name); }); |
173 | RegisterMaker("eui64", [](TypeName name)->ACL* { return new ACLEui64(name); }); | |
2d46f579 AR |
174 | #endif |
175 | ||
ee326f02 | 176 | #if USE_IDENT |
4eac3407 CT |
177 | RegisterMaker("ident", [](TypeName name)->ACL* { return new ACLIdent(new ACLUserData, name); }); |
178 | RegisterMaker("ident_regex", [](TypeName name)->ACL* { return new ACLIdent(new ACLRegexData, name); }); | |
2d46f579 AR |
179 | #endif |
180 | ||
2f1431ea | 181 | #if USE_AUTH |
4eac3407 CT |
182 | RegisterMaker("ext_user", [](TypeName name)->ACL* { return new ACLExtUser(new ACLUserData, name); }); |
183 | RegisterMaker("ext_user_regex", [](TypeName name)->ACL* { return new ACLExtUser(new ACLRegexData, name); }); | |
184 | RegisterMaker("proxy_auth", [](TypeName name)->ACL* { return new ACLProxyAuth(new ACLUserData, name); }); | |
185 | RegisterMaker("proxy_auth_regex", [](TypeName name)->ACL* { return new ACLProxyAuth(new ACLRegexData, name); }); | |
186 | RegisterMaker("max_user_ip", [](TypeName name)->ACL* { return new ACLMaxUserIP(name); }); | |
2f1431ea | 187 | #endif |
bb5e7a79 | 188 | |
c302ddb5 | 189 | #if USE_ADAPTATION |
4eac3407 | 190 | RegisterMaker("adaptation_service", [](TypeName name)->ACL* { return new ACLStrategised<const char *>(new ACLAdaptationServiceData, new ACLAdaptationServiceStrategy, name); }); |
c302ddb5 | 191 | #endif |
f53969cc | 192 | |
4eac3407 CT |
193 | #if SQUID_SNMP |
194 | RegisterMaker("snmp_community", [](TypeName name)->ACL* { return new ACLStrategised<const char *>(new ACLStringData, new ACLSNMPCommunityStrategy, name); }); | |
195 | #endif | |
196 | } | |
5ec4cffe | 197 |