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,
163 const StringPiece& comma_separated_from_domains,
172 const StringPiece& from_domain_name,
195 const StringPiece& comma_separated_from_domains,
196 const StringPiece& host_header,
224 const StringPiece& origin_domain,
225 const StringPiece& to_domain_name,
235 const StringPiece& from_domain_name,
236 const StringPiece& host_header,
242 bool AddShard(
const StringPiece& to_domain,
243 const StringPiece& comma_separated_shards,
255 bool ShardDomain(
const StringPiece& domain_name, uint32 hash,
265 bool empty()
const {
return domain_map_.empty() && proxy_suffix_.empty(); }
283 return can_rewrite_domains_ || !proxy_suffix_.empty();
292 const StringPiece& domain2)
const;
298 ConstStringStarVector* from_domains)
const;
323 const GoogleString& proxy_suffix()
const {
return proxy_suffix_; }
352 friend class DomainLawyerTest;
354 typedef bool (Domain::*SetDomainFn)(Domain* domain,
MessageHandler* handler);
356 static GoogleString NormalizeDomainName(
const StringPiece& domain_name);
358 static bool IsSchemeSafeToMapTo(
const StringPiece& domain_name,
359 bool allow_https_scheme);
361 bool MapDomainHelper(
362 const StringPiece& to_domain_name,
363 const StringPiece& comma_separated_from_domains,
364 const StringPiece& host_header,
365 SetDomainFn set_domain_fn,
366 bool allow_wildcards,
367 bool allow_map_to_https,
371 bool MapUrlHelper(
const Domain& from_domain,
372 const Domain& to_domain,
376 bool DomainNameToTwoProtocols(
const StringPiece& domain_name,
380 bool TwoProtocolDomainHelper(
381 const StringPiece& to_domain_name,
382 const StringPiece& from_domain_name,
383 const StringPiece& host_header,
384 SetDomainFn set_domain_fn,
388 Domain* AddDomainHelper(
const StringPiece& domain_name,
389 bool warn_on_duplicate,
393 Domain* CloneAndAdd(
const Domain* src);
395 Domain* FindDomain(
const GoogleUrl& gurl)
const;
399 typedef std::map<GoogleString, Domain*> DomainMap;
400 DomainMap domain_map_;
401 typedef std::vector<Domain*> DomainVector;
402 DomainVector wildcarded_domains_;
404 bool can_rewrite_domains_;
407 bool authorize_all_domains_;
class GoogleUrl
Definition: google_url.h:58
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:282
bool AddProxySuffix(const GoogleUrl &base_url, GoogleString *href) const
bool MapOrigin(const StringPiece &in, GoogleString *out, GoogleString *host_header, bool *is_proxy) const
bool StripProxySuffix(const GoogleUrl &gurl, GoogleString *url, GoogleString *host) const
int num_wildcarded_domains() const
Visible for testing.
Definition: domain_lawyer.h:287
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:348
bool IsOriginKnown(const GoogleUrl &domain_to_check) const
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
bool ShardDomain(const StringPiece &domain_name, uint32 hash, GoogleString *sharded_domain) const
void set_proxy_suffix(const GoogleString &suffix)
Definition: domain_lawyer.h:322
bool AddOriginDomainMapping(const StringPiece &to_domain, const StringPiece &comma_separated_from_domains, const StringPiece &host_header, MessageHandler *handler)
bool AddTwoProtocolOriginDomainMapping(const StringPiece &to_domain_name, const StringPiece &from_domain_name, 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 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)
Definition: message_handler.h:39
bool DoDomainsServeSameContent(const StringPiece &domain1, const StringPiece &domain2) const
bool AddKnownDomain(const StringPiece &domain_name, MessageHandler *handler)