#include <UrlRewrite.h>
Data Structures | |
struct | MappingsStore |
struct | RegexMapping |
Public Types | |
typedef Queue< RegexMapping > | RegexMappingList |
Public Member Functions | |
UrlRewrite () | |
~UrlRewrite () | |
int | BuildTable (const char *path) |
Reads the configuration file and creates a new hash table. | |
mapping_type | Remap_redirect (HTTPHdr *request_header, URL *redirect_url) |
Determines if a redirect is to occur and if so, figures out what the redirect is. | |
bool | ReverseMap (HTTPHdr *response_header) |
void | SetReverseFlag (int flag) |
Sets the reverse proxy flag. | |
void | Print () |
Debugging Method. | |
bool | is_valid () const |
void | PerformACLFiltering (HttpTransact::State *s, url_mapping *mapping) |
Perform fast ACL filtering. | |
url_mapping * | SetupPacMapping () |
Allocaites via new, and setups the default mapping to the PAC generator port which is used to serve the PAC (proxy autoconfig) file. | |
url_mapping * | SetupBackdoorMapping () |
Allocaites via new, and adds a mapping like this map /ink/rh http://{backdoor}/ink/rh. | |
void | PrintStore (MappingsStore &store) |
Debugging method. | |
void | DestroyStore (MappingsStore &store) |
bool | InsertForwardMapping (mapping_type maptype, url_mapping *mapping, const char *src_host) |
bool | InsertMapping (mapping_type maptype, url_mapping *new_mapping, RegexMapping *reg_map, const char *src_host, bool is_cur_mapping_regex) |
bool | TableInsert (InkHashTable *h_table, url_mapping *mapping, const char *src_host) |
Inserts arg mapping in h_table with key src_host chaining the mapping of existing entries bound to src_host if necessary. | |
bool | forwardMappingLookup (URL *request_url, int request_port, const char *request_host, int request_host_len, UrlMappingContainer &mapping_container) |
bool | reverseMappingLookup (URL *request_url, int request_port, const char *request_host, int request_host_len, UrlMappingContainer &mapping_container) |
bool | permanentRedirectLookup (URL *request_url, int request_port, const char *request_host, int request_host_len, UrlMappingContainer &mapping_container) |
bool | temporaryRedirectLookup (URL *request_url, int request_port, const char *request_host, int request_host_len, UrlMappingContainer &mapping_container) |
bool | forwardMappingWithRecvPortLookup (URL *request_url, int recv_port, const char *request_host, int request_host_len, UrlMappingContainer &mapping_container) |
Data Fields | |
MappingsStore | forward_mappings |
MappingsStore | reverse_mappings |
MappingsStore | permanent_redirects |
MappingsStore | temporary_redirects |
MappingsStore | forward_mappings_with_recv_port |
int | nohost_rules |
int | reverse_proxy |
int | backdoor_enabled |
int | mgmt_autoconf_port |
int | default_to_pac |
int | default_to_pac_port |
char * | ts_name |
char * | http_default_redirect_url |
int | num_rules_forward |
int | num_rules_reverse |
int | num_rules_redirect_permanent |
int | num_rules_redirect_temporary |
int | num_rules_forward_with_recv_port |
Static Public Attributes | |
static const int | MAX_REGEX_SUBS = 10 |
Definition at line 52 of file UrlRewrite.h.
Definition at line 92 of file UrlRewrite.h.
UrlRewrite::UrlRewrite | ( | ) |
Definition at line 55 of file UrlRewrite.cc.
References ats_free(), ats_strdup, backdoor_enabled, BuildTable(), default_to_pac, default_to_pac_port, forward_mappings, forward_mappings_with_recv_port, Layout::get(), UrlRewrite::MappingsStore::hash_lookup, http_default_redirect_url, is_debug_tag_set, mgmt_autoconf_port, modulePrefix, permanent_redirects, Print(), REC_ReadConfigInteger, REC_ReadConfigStringAlloc, Layout::relative_to(), reverse_mappings, reverse_proxy, temporary_redirects, ts_name, url_remap_mode, and Warning.
UrlRewrite::~UrlRewrite | ( | ) |
Definition at line 114 of file UrlRewrite.cc.
References ats_free(), DestroyStore(), forward_mappings, forward_mappings_with_recv_port, http_default_redirect_url, permanent_redirects, reverse_mappings, temporary_redirects, and ts_name.
int UrlRewrite::BuildTable | ( | const char * | path | ) |
Reads the configuration file and creates a new hash table.
Definition at line 672 of file UrlRewrite.cc.
References backdoor_enabled, default_to_pac, UrlRewrite::MappingsStore::empty(), forward_mappings, forward_mappings_with_recv_port, UrlRewrite::MappingsStore::hash_lookup, ink_assert, ink_hash_table_create(), ink_hash_table_destroy(), ink_hash_table_isbound(), InkHashTableKeyType_String, nohost_rules, num_rules_forward, num_rules_forward_with_recv_port, num_rules_redirect_permanent, num_rules_redirect_temporary, num_rules_reverse, permanent_redirects, remap_parse_config(), reverse_mappings, SetupBackdoorMapping(), SetupPacMapping(), TableInsert(), temporary_redirects, unlikely, and Warning.
Referenced by UrlRewrite().
void UrlRewrite::DestroyStore | ( | MappingsStore & | store | ) | [inline] |
Definition at line 106 of file UrlRewrite.h.
References UrlRewrite::MappingsStore::hash_lookup, and UrlRewrite::MappingsStore::regex_list.
Referenced by ~UrlRewrite().
bool UrlRewrite::forwardMappingLookup | ( | URL * | request_url, | |
int | request_port, | |||
const char * | request_host, | |||
int | request_host_len, | |||
UrlMappingContainer & | mapping_container | |||
) | [inline] |
Definition at line 124 of file UrlRewrite.h.
References forward_mappings.
Referenced by RemapProcessor::setup_for_remap().
bool UrlRewrite::forwardMappingWithRecvPortLookup | ( | URL * | request_url, | |
int | recv_port, | |||
const char * | request_host, | |||
int | request_host_len, | |||
UrlMappingContainer & | mapping_container | |||
) | [inline] |
Definition at line 148 of file UrlRewrite.h.
References forward_mappings_with_recv_port.
Referenced by RemapProcessor::setup_for_remap().
bool UrlRewrite::InsertForwardMapping | ( | mapping_type | maptype, | |
url_mapping * | mapping, | |||
const char * | src_host | |||
) |
Definition at line 637 of file UrlRewrite.cc.
References FORWARD_MAP, FORWARD_MAP_REFERER, FORWARD_MAP_WITH_RECV_PORT, forward_mappings, forward_mappings_with_recv_port, UrlRewrite::MappingsStore::hash_lookup, num_rules_forward, num_rules_forward_with_recv_port, SetHomePageRedirectFlag(), TableInsert(), and url_mapping::toUrl.
Referenced by remap_parse_config_bti().
bool UrlRewrite::InsertMapping | ( | mapping_type | maptype, | |
url_mapping * | new_mapping, | |||
RegexMapping * | reg_map, | |||
const char * | src_host, | |||
bool | is_cur_mapping_regex | |||
) |
Definition at line 594 of file UrlRewrite.cc.
References FORWARD_MAP, FORWARD_MAP_REFERER, FORWARD_MAP_WITH_RECV_PORT, forward_mappings, forward_mappings_with_recv_port, url_mapping::homePageRedirect, num_rules_forward, num_rules_forward_with_recv_port, num_rules_redirect_permanent, num_rules_redirect_temporary, num_rules_reverse, PERMANENT_REDIRECT, permanent_redirects, REVERSE_MAP, reverse_mappings, SetHomePageRedirectFlag(), TEMPORARY_REDIRECT, temporary_redirects, and url_mapping::toUrl.
Referenced by remap_parse_config_bti().
bool UrlRewrite::is_valid | ( | ) | const [inline] |
Definition at line 63 of file UrlRewrite.h.
Referenced by init_reverse_proxy(), and reloadUrlRewrite().
void UrlRewrite::PerformACLFiltering | ( | HttpTransact::State * | s, | |
url_mapping * | map | |||
) |
Perform fast ACL filtering.
Definition at line 420 of file UrlRewrite.cc.
References HttpTransact::State::acl_filtering_performed, ats_is_ip(), HttpTransact::State::client_connection_enabled, HttpTransact::State::client_info, Debug, url_mapping::filter, HttpTransact::State::hdr_info, HTTP_WKSIDX_CONNECT, ink_release_assert, acl_filter_rule::next, and unlikely.
Referenced by RemapProcessor::finish_remap().
bool UrlRewrite::permanentRedirectLookup | ( | URL * | request_url, | |
int | request_port, | |||
const char * | request_host, | |||
int | request_host_len, | |||
UrlMappingContainer & | mapping_container | |||
) | [inline] |
Definition at line 136 of file UrlRewrite.h.
References permanent_redirects.
Referenced by Remap_redirect().
void UrlRewrite::Print | ( | ) |
Debugging Method.
Definition at line 212 of file UrlRewrite.cc.
References forward_mappings, forward_mappings_with_recv_port, http_default_redirect_url, num_rules_forward, num_rules_forward_with_recv_port, num_rules_redirect_permanent, num_rules_redirect_temporary, num_rules_reverse, permanent_redirects, PrintStore(), reverse_mappings, reverse_proxy, and temporary_redirects.
Referenced by SetReverseFlag(), and UrlRewrite().
void UrlRewrite::PrintStore | ( | MappingsStore & | store | ) |
Debugging method.
Definition at line 240 of file UrlRewrite.cc.
References Queue< C, L >::empty(), forl_LL, UrlRewrite::MappingsStore::hash_lookup, ink_hash_table_entry_value(), ink_hash_table_iterator_first(), ink_hash_table_iterator_next(), UrlMappingPathIndex::Print(), and UrlRewrite::MappingsStore::regex_list.
Referenced by Print().
mapping_type UrlRewrite::Remap_redirect | ( | HTTPHdr * | request_header, | |
URL * | redirect_url | |||
) |
Determines if a redirect is to occur and if so, figures out what the redirect is.
This was plaguiarized from UrlRewrite::Remap. redirect_url ought to point to the new, mapped URL when the function exits.
Definition at line 481 of file UrlRewrite.cc.
References URL::copy(), URL::create(), Debug, URL::host_get(), ink_assert, ink_atoi(), HdrHeapSDKHandle::m_heap, MIME_FIELD_HOST, MIME_LEN_HOST, NONE, num_rules_redirect_permanent, num_rules_redirect_temporary, PERMANENT_REDIRECT, permanentRedirectLookup(), URL::port_get(), reverse_proxy, TEMPORARY_REDIRECT, temporaryRedirectLookup(), HTTPHdr::url_get(), url_rewrite_remap_request(), URL::valid(), and MIMEHdr::value_get().
Referenced by request_url_remap_redirect().
bool UrlRewrite::ReverseMap | ( | HTTPHdr * | response_header | ) |
Definition at line 365 of file UrlRewrite.cc.
References URL::create(), HdrHeapSDKHandle::destroy(), UrlRewrite::MappingsStore::empty(), URL::host_get(), ink_assert, HdrHeapSDKHandle::m_heap, MIME_FIELD_CONTENT_LOCATION, MIME_FIELD_LOCATION, MIME_LEN_CONTENT_LOCATION, MIME_LEN_LOCATION, num_rules_reverse, URL::parse(), URL::port_get(), reverse_mappings, reverseMappingLookup(), URL::string_get_ref(), unlikely, url_rewrite_remap_request(), MIMEHdr::value_get(), and MIMEHdr::value_set().
Referenced by response_url_remap().
bool UrlRewrite::reverseMappingLookup | ( | URL * | request_url, | |
int | request_port, | |||
const char * | request_host, | |||
int | request_host_len, | |||
UrlMappingContainer & | mapping_container | |||
) | [inline] |
Definition at line 130 of file UrlRewrite.h.
References reverse_mappings.
Referenced by ReverseMap().
void UrlRewrite::SetReverseFlag | ( | int | flag | ) |
Sets the reverse proxy flag.
Definition at line 129 of file UrlRewrite.cc.
References is_debug_tag_set, Print(), and reverse_proxy.
Referenced by url_rewrite_CB().
url_mapping * UrlRewrite::SetupBackdoorMapping | ( | ) |
Allocaites via new, and adds a mapping like this map /ink/rh http://{backdoor}/ink/rh.
These {backdoor} things are then rewritten in a request-hdr hook. (In the future it might make sense to move the rewriting into HttpSM directly.)
Definition at line 174 of file UrlRewrite.cc.
References URL::create(), url_mapping::fromURL, URL::parse(), URL::scheme_set(), url_mapping::toUrl, URL_LEN_HTTP, and URL_SCHEME_HTTP.
Referenced by BuildTable().
url_mapping * UrlRewrite::SetupPacMapping | ( | ) |
Allocaites via new, and setups the default mapping to the PAC generator port which is used to serve the PAC (proxy autoconfig) file.
Definition at line 142 of file UrlRewrite.cc.
References URL::create(), default_to_pac_port, url_mapping::fromURL, mgmt_autoconf_port, URL::parse(), URL::port_set(), and url_mapping::toUrl.
Referenced by BuildTable().
bool UrlRewrite::TableInsert | ( | InkHashTable * | h_table, | |
url_mapping * | mapping, | |||
const char * | src_host | |||
) |
Inserts arg mapping in h_table with key src_host chaining the mapping of existing entries bound to src_host if necessary.
Definition at line 760 of file UrlRewrite.cc.
References ink_hash_table_insert(), ink_hash_table_lookup(), and Warning.
Referenced by BuildTable(), and InsertForwardMapping().
bool UrlRewrite::temporaryRedirectLookup | ( | URL * | request_url, | |
int | request_port, | |||
const char * | request_host, | |||
int | request_host_len, | |||
UrlMappingContainer & | mapping_container | |||
) | [inline] |
Definition at line 142 of file UrlRewrite.h.
References temporary_redirects.
Referenced by Remap_redirect().
Definition at line 157 of file UrlRewrite.h.
Referenced by BuildTable(), and UrlRewrite().
Definition at line 161 of file UrlRewrite.h.
Referenced by BuildTable(), and UrlRewrite().
Definition at line 162 of file UrlRewrite.h.
Referenced by SetupPacMapping(), and UrlRewrite().
Definition at line 118 of file UrlRewrite.h.
Referenced by BuildTable(), forwardMappingLookup(), InsertForwardMapping(), InsertMapping(), Print(), RemapProcessor::setup_for_remap(), UrlRewrite(), and ~UrlRewrite().
Definition at line 122 of file UrlRewrite.h.
Referenced by BuildTable(), forwardMappingWithRecvPortLookup(), InsertForwardMapping(), InsertMapping(), Print(), RemapProcessor::setup_for_remap(), UrlRewrite(), and ~UrlRewrite().
Definition at line 166 of file UrlRewrite.h.
Referenced by RemapProcessor::finish_remap(), Print(), UrlRewrite(), and ~UrlRewrite().
const int UrlRewrite::MAX_REGEX_SUBS = 10 [static] |
Definition at line 66 of file UrlRewrite.h.
Referenced by process_regex_mapping_config().
Definition at line 160 of file UrlRewrite.h.
Referenced by SetupPacMapping(), and UrlRewrite().
Definition at line 155 of file UrlRewrite.h.
Referenced by BuildTable(), and RemapProcessor::setup_for_remap().
Definition at line 167 of file UrlRewrite.h.
Referenced by BuildTable(), InsertForwardMapping(), InsertMapping(), Print(), and RemapProcessor::setup_for_remap().
Definition at line 171 of file UrlRewrite.h.
Referenced by BuildTable(), InsertForwardMapping(), InsertMapping(), Print(), and RemapProcessor::setup_for_remap().
Definition at line 169 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), Print(), and Remap_redirect().
Definition at line 170 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), Print(), and Remap_redirect().
Definition at line 168 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), Print(), and ReverseMap().
Definition at line 120 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), permanentRedirectLookup(), Print(), UrlRewrite(), and ~UrlRewrite().
Definition at line 119 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), Print(), ReverseMap(), reverseMappingLookup(), UrlRewrite(), and ~UrlRewrite().
Definition at line 156 of file UrlRewrite.h.
Referenced by Print(), Remap_redirect(), SetReverseFlag(), RemapProcessor::setup_for_remap(), and UrlRewrite().
Definition at line 121 of file UrlRewrite.h.
Referenced by BuildTable(), InsertMapping(), Print(), temporaryRedirectLookup(), UrlRewrite(), and ~UrlRewrite().
char* UrlRewrite::ts_name |
Definition at line 164 of file UrlRewrite.h.
Referenced by UrlRewrite(), and ~UrlRewrite().