Remap configuration file parsing. More...
#include "RemapConfig.h"
#include "UrlRewrite.h"
#include "ReverseProxy.h"
#include "I_Layout.h"
#include "HTTP.h"
#include "libts.h"
#include "ink_cap.h"
Go to the source code of this file.
Data Structures | |
struct | remap_directive |
Defines | |
#define | modulePrefix "[ReverseProxy]" |
Functions | |
static bool | remap_parse_config_bti (const char *path, BUILD_TABLE_INFO *bti) |
static int | UrlWhack (char *toWhack, int *origLength) |
Returns the length of the URL. | |
static void | clear_xstr_array (char *v[], size_t vsize) |
Cleanup *char[] array - each item in array must be allocated via ats_malloc or similar "x..." function. | |
static const char * | process_filter_opt (url_mapping *mp, const BUILD_TABLE_INFO *bti, char *errStrBuf, int errStrBufSize) |
static bool | is_inkeylist (const char *key,...) |
static const char * | parse_define_directive (const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
static const char * | parse_delete_directive (const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
static const char * | parse_activate_directive (const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
static const char * | parse_deactivate_directive (const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
static const char * | parse_include_directive (const char *directive, BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
const char * | remap_parse_directive (BUILD_TABLE_INFO *bti, char *errbuf, size_t errbufsize) |
const char * | remap_validate_filter_args (acl_filter_rule **rule_pp, const char **argv, int argc, char *errStrBuf, size_t errStrBufSize) |
unsigned long | remap_check_option (const char **argv, int argc, unsigned long findmode, int *_ret_idx, const char **argptr) |
int | remap_load_plugin (const char **argv, int argc, url_mapping *mp, char *errbuf, int errbufsize, int jump_to_argc, int *plugin_found_at) |
static bool | process_regex_mapping_config (const char *from_host_lower, url_mapping *new_mapping, UrlRewrite::RegexMapping *reg_map) |
will process the regex mapping configuration and create objects in output argument reg_map. | |
bool | remap_parse_config (const char *path, UrlRewrite *rewrite) |
Variables | |
static const remap_directive | directives [] |
Remap configuration file parsing.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file RemapConfig.cc.
#define modulePrefix "[ReverseProxy]" |
Definition at line 32 of file RemapConfig.cc.
Referenced by remap_parse_config_bti().
static void clear_xstr_array | ( | char * | v[], | |
size_t | vsize | |||
) | [static] |
Cleanup *char[] array - each item in array must be allocated via ats_malloc or similar "x..." function.
Definition at line 68 of file RemapConfig.cc.
References ats_free_null().
Referenced by BUILD_TABLE_INFO::reset().
static bool is_inkeylist | ( | const char * | key, | |
... | ||||
) | [static] |
Definition at line 123 of file RemapConfig.cc.
References unlikely.
Referenced by remap_validate_filter_args().
static const char* parse_activate_directive | ( | const char * | directive, | |
BUILD_TABLE_INFO * | bti, | |||
char * | errbuf, | |||
size_t | errbufsize | |||
) | [static] |
Definition at line 195 of file RemapConfig.cc.
References Debug, acl_filter_rule::find_byname(), BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, acl_filter_rule::requeue_in_active_list(), and BUILD_TABLE_INFO::rules_list.
static const char* parse_deactivate_directive | ( | const char * | directive, | |
BUILD_TABLE_INFO * | bti, | |||
char * | errbuf, | |||
size_t | errbufsize | |||
) | [static] |
Definition at line 216 of file RemapConfig.cc.
References Debug, acl_filter_rule::find_byname(), BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, acl_filter_rule::requeue_in_passive_list(), and BUILD_TABLE_INFO::rules_list.
static const char* parse_define_directive | ( | const char * | directive, | |
BUILD_TABLE_INFO * | bti, | |||
char * | errbuf, | |||
size_t | errbufsize | |||
) | [static] |
Definition at line 148 of file RemapConfig.cc.
References acl_filter_rule::add_argv(), BUILD_TABLE_INFO::argc, BUILD_TABLE_INFO::argv, Debug, acl_filter_rule::find_byname(), BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, remap_validate_filter_args(), and BUILD_TABLE_INFO::rules_list.
static const char* parse_delete_directive | ( | const char * | directive, | |
BUILD_TABLE_INFO * | bti, | |||
char * | errbuf, | |||
size_t | errbufsize | |||
) | [static] |
Definition at line 182 of file RemapConfig.cc.
References Debug, acl_filter_rule::delete_byname(), BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, and BUILD_TABLE_INFO::rules_list.
static const char* parse_include_directive | ( | const char * | directive, | |
BUILD_TABLE_INFO * | bti, | |||
char * | errbuf, | |||
size_t | errbufsize | |||
) | [static] |
Definition at line 237 of file RemapConfig.cc.
References Debug, Layout::get(), ink_file_is_directory(), BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, Layout::relative_to(), remap_parse_config_bti(), BUILD_TABLE_INFO::rewrite, and BUILD_TABLE_INFO::rules_list.
static const char* process_filter_opt | ( | url_mapping * | mp, | |
const BUILD_TABLE_INFO * | bti, | |||
char * | errStrBuf, | |||
int | errStrBufSize | |||
) | [static] |
Definition at line 96 of file RemapConfig.cc.
References acl_filter_rule::active_queue_flag, BUILD_TABLE_INFO::argc, acl_filter_rule::argc, BUILD_TABLE_INFO::argv, acl_filter_rule::argv, Debug, url_mapping::filter, acl_filter_rule::filter_name, acl_filter_rule::next, BUILD_TABLE_INFO::remap_optflg, REMAP_OPTFLG_ALL_FILTERS, remap_validate_filter_args(), BUILD_TABLE_INFO::rules_list, and unlikely.
Referenced by remap_parse_config_bti().
static bool process_regex_mapping_config | ( | const char * | from_host_lower, | |
url_mapping * | new_mapping, | |||
UrlRewrite::RegexMapping * | reg_map | |||
) | [static] |
will process the regex mapping configuration and create objects in output argument reg_map.
It assumes existing data in reg_map is inconsequential and will be perfunctorily null-ed;
Definition at line 762 of file RemapConfig.cc.
References ats_free(), ats_malloc(), URL::host_get(), UrlRewrite::MAX_REGEX_SUBS, memcpy, UrlRewrite::RegexMapping::n_substitutions, UrlRewrite::RegexMapping::re, UrlRewrite::RegexMapping::re_extra, UrlRewrite::RegexMapping::substitution_ids, UrlRewrite::RegexMapping::substitution_markers, UrlRewrite::RegexMapping::to_url_host_template, UrlRewrite::RegexMapping::to_url_host_template_len, url_mapping::toUrl, UrlRewrite::RegexMapping::url_map, and Warning.
Referenced by remap_parse_config_bti().
unsigned long remap_check_option | ( | const char ** | argv, | |
int | argc, | |||
unsigned long | findmode, | |||
int * | _ret_idx, | |||
const char ** | argptr | |||
) |
Definition at line 488 of file RemapConfig.cc.
References REMAP_OPTFLG_ACTION, REMAP_OPTFLG_MAP_ID, REMAP_OPTFLG_MAP_WITH_REFERER, REMAP_OPTFLG_METHOD, REMAP_OPTFLG_PLUGIN, REMAP_OPTFLG_PPARAM, and REMAP_OPTFLG_SRC_IP.
Referenced by remap_load_plugin(), remap_parse_config_bti(), and remap_validate_filter_args().
int remap_load_plugin | ( | const char ** | argv, | |
int | argc, | |||
url_mapping * | mp, | |||
char * | errbuf, | |||
int | errbufsize, | |||
int | jump_to_argc, | |||
int * | plugin_found_at | |||
) |
Definition at line 559 of file RemapConfig.cc.
References url_mapping::add_plugin(), remap_plugin_info::add_to_list(), ats_free(), ats_strdup, countof, Debug, remap_plugin_info::find_by_path(), url_mapping::fromURL, ink_assert, PATH_NAME_MAX, REC_ReadConfigInteger, remap_check_option(), REMAP_OPTFLG_PLUGIN, remap_pi_list, _tsremap_api_info::size, URL::string_get(), url_mapping::toUrl, TS_SUCCESS, TSPluginDirGet(), TSREMAP_FUNCNAME_DELETE_INSTANCE, TSREMAP_FUNCNAME_DO_REMAP, TSREMAP_FUNCNAME_DONE, TSREMAP_FUNCNAME_INIT, TSREMAP_FUNCNAME_NEW_INSTANCE, TSREMAP_FUNCNAME_OS_RESPONSE, _tsremap_api_info::tsremap_version, unlikely, and Warning.
Referenced by remap_parse_config_bti().
bool remap_parse_config | ( | const char * | path, | |
UrlRewrite * | rewrite | |||
) |
Definition at line 1260 of file RemapConfig.cc.
References remap_parse_config_bti(), and BUILD_TABLE_INFO::rewrite.
Referenced by UrlRewrite::BuildTable().
static bool remap_parse_config_bti | ( | const char * | path, | |
BUILD_TABLE_INFO * | bti | |||
) | [static] |
Definition at line 852 of file RemapConfig.cc.
References referer_info::any, BUILD_TABLE_INFO::argc, BUILD_TABLE_INFO::argv, ats_free_null(), ats_ip_ntop(), ats_is_ip(), ats_is_ip_any(), ats_malloc(), ats_strdup, BUILD_TABLE_MAX_ARGS, URL::copy(), URL::create(), Debug, url_mapping::default_redirect_url, url_mapping::filter_redirect_url, FORWARD_MAP, FORWARD_MAP_REFERER, FORWARD_MAP_WITH_RECV_PORT, url_mapping::fromURL, URL::host_get(), URL::host_set(), Tokenizer::Initialize(), UrlRewrite::InsertForwardMapping(), UrlRewrite::InsertMapping(), isascii, LowerCaseStr(), url_mapping::map_id, memcpy, modulePrefix, referer_info::negative, url_mapping::negative_referer, referer_info::next, url_mapping::optional_referer, BUILD_TABLE_INFO::paramc, BUILD_TABLE_INFO::paramv, PARSE_DONE, redirect_tag_str::parse_format_redirect_url(), URL::parse_no_path_component_breakdown(), process_filter_opt(), process_regex_mapping_config(), readIntoBuffer(), url_mapping::redir_chunk_list, url_mapping::referer_list, remap_check_option(), remap_load_plugin(), BUILD_TABLE_INFO::remap_optflg, REMAP_OPTFLG_MAP_ID, REMAP_OPTFLG_MAP_WITH_REFERER, REMAP_OPTFLG_PLUGIN, remap_parse_directive(), BUILD_TABLE_INFO::reset(), BUILD_TABLE_INFO::rewrite, URL::scheme_get(), URL::scheme_set(), SHARE_TOKS, SignalError, url_mapping::tag, tokLine(), url_mapping::toUrl, url_mapping::unique, unlikely, URL_LEN_HTTP, URL_SCHEME_FILE, URL_SCHEME_HTTP, URL_SCHEME_HTTPS, URL_SCHEME_TUNNEL, URL_SCHEME_WS, URL_SCHEME_WSS, UrlWhack(), Warning, and url_mapping::wildcard_from_scheme.
Referenced by parse_include_directive(), and remap_parse_config().
const char* remap_parse_directive | ( | BUILD_TABLE_INFO * | bti, | |
char * | errbuf, | |||
size_t | errbufsize | |||
) |
Definition at line 316 of file RemapConfig.cc.
References countof, Debug, BUILD_TABLE_INFO::paramv, remap_directive::parser, and unlikely.
Referenced by remap_parse_config_bti().
const char* remap_validate_filter_args | ( | acl_filter_rule ** | rule_pp, | |
const char ** | argv, | |||
int | argc, | |||
char * | errStrBuf, | |||
size_t | errStrBufSize | |||
) |
Definition at line 338 of file RemapConfig.cc.
References ACL_FILTER_MAX_SRC_IP, acl_filter_rule::allow_flag, Debug, src_ip_info_t::end, ExtractIpRange(), HTTP_WKSIDX_CONNECT, HTTP_WKSIDX_DELETE, HTTP_WKSIDX_GET, HTTP_WKSIDX_HEAD, HTTP_WKSIDX_ICP_QUERY, HTTP_WKSIDX_OPTIONS, HTTP_WKSIDX_POST, HTTP_WKSIDX_PURGE, HTTP_WKSIDX_PUSH, HTTP_WKSIDX_PUT, HTTP_WKSIDX_TRACE, ink_strlcpy(), src_ip_info_t::invert, is_debug_tag_set, is_inkeylist(), acl_filter_rule::method_restriction_enabled, acl_filter_rule::nonstandard_methods, acl_filter_rule::print(), remap_check_option(), REMAP_OPTFLG_ACTION, REMAP_OPTFLG_INVERT, REMAP_OPTFLG_METHOD, REMAP_OPTFLG_SRC_IP, src_ip_info_t::reset(), IpEndpoint::sa, acl_filter_rule::src_ip_array, acl_filter_rule::src_ip_cnt, acl_filter_rule::src_ip_valid, acl_filter_rule::standard_method_lookup, src_ip_info_t::start, and unlikely.
Referenced by parse_define_directive(), and process_filter_opt().
static int UrlWhack | ( | char * | toWhack, | |
int * | origLength | |||
) | [static] |
Returns the length of the URL.
Will replace the terminator with a '/' if this is a full URL and there are no '/' in it after the the host. This ensures that class URL parses the URL correctly.
Definition at line 45 of file RemapConfig.cc.
Referenced by remap_parse_config_bti().
const remap_directive directives[] [static] |
{ { ".definefilter", parse_define_directive}, { ".deffilter", parse_define_directive}, { ".defflt", parse_define_directive}, { ".deletefilter", parse_delete_directive}, { ".delfilter", parse_delete_directive}, { ".delflt", parse_delete_directive}, { ".usefilter", parse_activate_directive}, { ".activefilter", parse_activate_directive}, { ".activatefilter", parse_activate_directive}, { ".useflt", parse_activate_directive}, { ".unusefilter", parse_deactivate_directive}, { ".deactivatefilter", parse_deactivate_directive}, { ".unactivefilter", parse_deactivate_directive}, { ".deuseflt", parse_deactivate_directive}, { ".unuseflt", parse_deactivate_directive}, { ".include", parse_include_directive }, }
Definition at line 291 of file RemapConfig.cc.