33 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DOMAIN_LAWYER_H_
34 #define NET_INSTAWEB_REWRITER_PUBLIC_DOMAIN_LAWYER_H_
43 namespace net_instaweb {
94 const StringPiece& resource_url,
95 GoogleString* mapped_domain_name,
96 GoogleUrl* resolved_request,
97 MessageHandler* handler)
const;
107 const GoogleUrl& domain_to_check)
const;
133 bool MapOrigin(
const StringPiece& in, GoogleString* out,
134 GoogleString* host_header,
bool* is_proxy)
const;
135 bool MapOriginUrl(
const GoogleUrl& gurl, GoogleString* out,
136 GoogleString* host_header,
bool* is_proxy)
const;
146 bool AddDomain(
const StringPiece& domain_name, MessageHandler* handler);
150 bool AddKnownDomain(
const StringPiece& domain_name, MessageHandler* handler);
163 const StringPiece& comma_separated_from_domains,
164 MessageHandler* handler);
172 const StringPiece& from_domain_name,
173 MessageHandler* handler);
192 const StringPiece& comma_separated_from_domains,
193 const StringPiece& host_header,
194 MessageHandler* handler);
221 const StringPiece& origin_domain,
222 const StringPiece& to_domain_name,
223 MessageHandler* handler);
231 const StringPiece& from_domain_name,
232 MessageHandler* handler);
237 bool AddShard(
const StringPiece& to_domain,
238 const StringPiece& comma_separated_shards,
239 MessageHandler* handler);
250 bool ShardDomain(
const StringPiece& domain_name, uint32 hash,
251 GoogleString* sharded_domain)
const;
260 bool empty()
const {
return domain_map_.empty(); }
282 const StringPiece& domain2)
const;
287 const GoogleUrl& domain_name,
288 ConstStringStarVector* from_domains)
const;
299 GoogleString
ToString(StringPiece line_prefix)
const;
306 friend class DomainLawyerTest;
308 typedef bool (Domain::*SetDomainFn)(Domain* domain, MessageHandler* handler);
310 static GoogleString NormalizeDomainName(
const StringPiece& domain_name);
312 static bool IsSchemeSafeToMapTo(
const StringPiece& domain_name,
313 bool allow_https_scheme);
315 bool MapDomainHelper(
316 const StringPiece& to_domain_name,
317 const StringPiece& comma_separated_from_domains,
318 const StringPiece& host_header,
319 SetDomainFn set_domain_fn,
320 bool allow_wildcards,
321 bool allow_map_to_https,
323 MessageHandler* handler);
325 bool MapUrlHelper(
const Domain& from_domain,
326 const Domain& to_domain,
327 const GoogleUrl& gurl,
328 GoogleUrl* mapped_gurl)
const;
330 bool DomainNameToTwoProtocols(
const StringPiece& domain_name,
331 GoogleString* http_url,
332 GoogleString* https_url);
334 bool TwoProtocolDomainHelper(
335 const StringPiece& to_domain_name,
336 const StringPiece& from_domain_name,
337 SetDomainFn set_domain_fn,
339 MessageHandler* handler);
341 Domain* AddDomainHelper(
const StringPiece& domain_name,
342 bool warn_on_duplicate,
345 MessageHandler* handler);
346 Domain* CloneAndAdd(
const Domain* src);
348 Domain* FindDomain(
const GoogleUrl& gurl)
const;
352 typedef std::map<GoogleString, Domain*> DomainMap;
353 DomainMap domain_map_;
354 typedef std::vector<Domain*> DomainVector;
355 DomainVector wildcarded_domains_;
356 bool can_rewrite_domains_;
359 bool authorize_all_domains_;
bool AddShard(const StringPiece &to_domain, const StringPiece &comma_separated_shards, MessageHandler *handler)
GoogleString Signature() const
bool AddProxyDomainMapping(const StringPiece &proxy_domain, const StringPiece &origin_domain, const StringPiece &to_domain_name, MessageHandler *handler)
bool can_rewrite_domains() const
Definition: domain_lawyer.h:274
bool MapOrigin(const StringPiece &in, GoogleString *out, GoogleString *host_header, bool *is_proxy) const
int num_wildcarded_domains() const
Visible for testing.
Definition: domain_lawyer.h:277
bool AddRewriteDomainMapping(const StringPiece &to_domain, const StringPiece &comma_separated_from_domains, MessageHandler *handler)
bool WillDomainChange(const GoogleUrl &url) const
bool AddDomain(const StringPiece &domain_name, MessageHandler *handler)
bool IsProxyMapped(const GoogleUrl &url) const
Determines whether a URL's domain was proxy-mapped from a different origin.
void Merge(const DomainLawyer &src)
GoogleString ToString() const
Version that's easier to call from debugger.
Definition: domain_lawyer.h:302
bool IsOriginKnown(const GoogleUrl &domain_to_check) const
bool ShardDomain(const StringPiece &domain_name, uint32 hash, GoogleString *sharded_domain) const
bool AddOriginDomainMapping(const StringPiece &to_domain, const StringPiece &comma_separated_from_domains, const StringPiece &host_header, MessageHandler *handler)
void FindDomainsRewrittenTo(const GoogleUrl &domain_name, ConstStringStarVector *from_domains) const
Definition: domain_lawyer.h:47
bool MapRequestToDomain(const GoogleUrl &original_request, const StringPiece &resource_url, GoogleString *mapped_domain_name, GoogleUrl *resolved_request, MessageHandler *handler) const
bool AddTwoProtocolOriginDomainMapping(const StringPiece &to_domain_name, const StringPiece &from_domain_name, MessageHandler *handler)
bool IsDomainAuthorized(const GoogleUrl &original_request, const GoogleUrl &domain_to_check) const
bool AddTwoProtocolRewriteDomainMapping(const StringPiece &to_domain_name, const StringPiece &from_domain_name, MessageHandler *handler)
bool DoDomainsServeSameContent(const StringPiece &domain1, const StringPiece &domain2) const
bool AddKnownDomain(const StringPiece &domain_name, MessageHandler *handler)