Implementation of Parent Proxy routing. More...
#include "libts.h"
#include "P_EventSystem.h"
#include "ParentSelection.h"
#include "ControlMatcher.h"
#include "Main.h"
#include "Error.h"
#include "ProxyConfig.h"
#include "HTTP.h"
#include "HttpTransact.h"
Go to the source code of this file.
Defines | |
#define | PARENT_RegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc |
#define | PARENT_ReadConfigInteger REC_ReadConfigInteger |
#define | PARENT_ReadConfigStringAlloc REC_ReadConfigStringAlloc |
#define | TEST_FAIL(str) |
#define | T(x) ink_strlcat(tbl,x, sizeof(tbl)); |
#define | REBUILD params->ParentTable = new P_table("", "ParentSelection Unit Test Table", &http_dest_tags, ALLOW_HOST_TABLE | ALLOW_REGEX_TABLE | ALLOW_URL_TABLE | ALLOW_IP_TABLE | DONT_BUILD_TABLE); params->ParentTable->BuildTableFromString(tbl); |
#define | REINIT delete request; delete result; request = new HttpRequestData(); result = new ParentResult(); if (!result || !request) { (void)printf("Allocation failed\n"); return; } |
#define | ST(x) printf ("*** TEST %d *** STARTING ***\n", x); |
#define | RE(x, y) if (x) { printf("*** TEST %d *** PASSED ***\n", y); passes ++; } else { printf("*** TEST %d *** FAILED *** FAILED *** FAILED ***\n", y); fails++; } |
#define | FP params->findParent(request, result); |
#define | TEST_IP4_ADDR "209.131.62.14" |
#define | TEST_IP6_ADDR "BEEF:DEAD:ABBA:CAFE:1337:1E1F:5EED:C0FF" |
Typedefs | |
typedef ControlMatcher < ParentRecord, ParentResult > | P_table |
Enumerations | |
enum | ParentCB_t { PARENT_FILE_CB, PARENT_DEFAULT_CB, PARENT_RETRY_CB, PARENT_ENABLE_CB, PARENT_THRESHOLD_CB, PARENT_DNS_ONLY_CB } |
Functions | |
ParentRecord * | createDefaultParent (char *val) |
static int | setup_socks_servers (ParentRecord *rec_arr, int len) |
void | request_to_data (HttpRequestData *req, sockaddr const *srcip, sockaddr const *dstip, const char *str) |
EXCLUSIVE_REGRESSION_TEST() | PARENTSELECTION (RegressionTest *, int, int *pstatus) |
int | verify (ParentResult *r, ParentResultType e, const char *h, int p) |
void | br (HttpRequestData *h, const char *os_hostname, sockaddr const *dest_ip) |
void | show_result (ParentResult *p) |
Variables | |
static const char | modulePrefix [] = "[ParentSelection]" |
static ConfigUpdateHandler < ParentConfig > * | parentConfigUpdate = NULL |
static const char * | file_var = "proxy.config.http.parent_proxy.file" |
static const char * | default_var = "proxy.config.http.parent_proxies" |
static const char * | retry_var = "proxy.config.http.parent_proxy.retry_time" |
static const char * | enable_var = "proxy.config.http.parent_proxy_routing_enable" |
static const char * | threshold_var = "proxy.config.http.parent_proxy.fail_threshold" |
static const char * | dns_parent_only_var = "proxy.config.http.no_dns_just_forward_to_parent" |
static const char * | ParentResultStr [] |
static const char * | ParentRRStr [] |
ParentRecord *const | extApiRecord = (ParentRecord *) 0xeeeeffff |
static Ptr< ProxyMutex > | socks_server_reconfig_mutex |
static int | passes |
static int | fails |
Implementation of Parent Proxy routing.
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 ParentSelection.cc.
#define FP params->findParent(request, result); |
Referenced by PARENTSELECTION().
#define PARENT_ReadConfigInteger REC_ReadConfigInteger |
Definition at line 34 of file ParentSelection.cc.
Referenced by SocksServerConfig::reconfigure(), and ParentConfig::reconfigure().
#define PARENT_ReadConfigStringAlloc REC_ReadConfigStringAlloc |
Definition at line 35 of file ParentSelection.cc.
Referenced by SocksServerConfig::reconfigure(), and ParentConfig::reconfigure().
#define PARENT_RegisterConfigUpdateFunc REC_RegisterConfigUpdateFunc |
Definition at line 33 of file ParentSelection.cc.
#define RE | ( | x, | ||
y | ||||
) | if (x) { printf("*** TEST %d *** PASSED ***\n", y); passes ++; } else { printf("*** TEST %d *** FAILED *** FAILED *** FAILED ***\n", y); fails++; } |
Referenced by PARENTSELECTION().
#define REBUILD params->ParentTable = new P_table("", "ParentSelection Unit Test Table", &http_dest_tags, ALLOW_HOST_TABLE | ALLOW_REGEX_TABLE | ALLOW_URL_TABLE | ALLOW_IP_TABLE | DONT_BUILD_TABLE); params->ParentTable->BuildTableFromString(tbl); |
Referenced by PARENTSELECTION().
#define REINIT delete request; delete result; request = new HttpRequestData(); result = new ParentResult(); if (!result || !request) { (void)printf("Allocation failed\n"); return; } |
Referenced by PARENTSELECTION().
#define ST | ( | x | ) | printf ("*** TEST %d *** STARTING ***\n", x); |
Referenced by PARENTSELECTION().
#define T | ( | x | ) | ink_strlcat(tbl,x, sizeof(tbl)); |
Referenced by Trie< T >::Clear(), DynArray< T >::defvalue(), CacheArray< T >::detach(), DynArray< T >::detach(), ts::dynamic_ptr_cast(), IntrusiveDList< RBNode,&RBNode::_next,&RBNode::_prev >::getHead(), IntrusiveDList< RBNode,&RBNode::_next,&RBNode::_prev >::getTail(), max(), min(), CacheArray< T >::operator T *(), DynArray< T >::operator T *(), CacheArray< T >::operator()(), DynArray< T >::operator()(), Ptr< NetAcceptAction >::operator*(), NonAtomicPtr< T >::operator*(), Ptr< NetAcceptAction >::operator->(), NonAtomicPtr< T >::operator->(), Ptr< T >::operator=(), NonAtomicPtr< T >::operator=(), CacheArray< T >::operator[](), DynArray< T >::operator[](), PARENTSELECTION(), Trie< T >::Print(), ts::ptr_cast(), CacheArray< T >::resize(), ts::Rv< R >::result(), IntrusiveDList< RBNode,&RBNode::_next,&RBNode::_prev >::takeHead(), IntrusiveDList< RBNode,&RBNode::_next,&RBNode::_prev >::takeTail(), and Ptr< NetAcceptAction >::to_ptr().
#define TEST_FAIL | ( | str | ) |
{ \
printf("%d: %s\n", test_id,str);\
err= REGRESSION_TEST_FAILED;\
}
Definition at line 1096 of file ParentSelection.cc.
#define TEST_IP4_ADDR "209.131.62.14" |
Referenced by PARENTSELECTION().
#define TEST_IP6_ADDR "BEEF:DEAD:ABBA:CAFE:1337:1E1F:5EED:C0FF" |
Referenced by PARENTSELECTION().
typedef ControlMatcher<ParentRecord, ParentResult> P_table |
Definition at line 37 of file ParentSelection.cc.
enum ParentCB_t |
PARENT_FILE_CB | |
PARENT_DEFAULT_CB | |
PARENT_RETRY_CB | |
PARENT_ENABLE_CB | |
PARENT_THRESHOLD_CB | |
PARENT_DNS_ONLY_CB |
Definition at line 67 of file ParentSelection.cc.
void br | ( | HttpRequestData * | h, | |
const char * | os_hostname, | |||
sockaddr const * | dest_ip | |||
) |
Definition at line 1352 of file ParentSelection.cc.
References HttpRequestData::api_info, ats_ip_copy(), ats_strdup, HTTPHdr::create(), HttpRequestData::dest_ip, HttpRequestData::hdr, HttpRequestData::hostname_str, HTTP_TYPE_REQUEST, HttpRequestData::incoming_port, IpEndpoint::sa, HttpRequestData::src_ip, and HttpRequestData::xact_start.
Referenced by PARENTSELECTION().
ParentRecord* createDefaultParent | ( | char * | val | ) |
Definition at line 969 of file ParentSelection.cc.
References ParentRecord::DefaultInit().
Referenced by SocksServerConfig::reconfigure(), and ParentConfig::reconfigure().
EXCLUSIVE_REGRESSION_TEST() PARENTSELECTION | ( | RegressionTest * | , | |
int | , | |||
int * | pstatus | |||
) |
Definition at line 1125 of file ParentSelection.cc.
References ats_ip_pton(), br(), fails, ParentConfigParams::FailThreshold, FP, HttpRequestData::hdr, ink_assert, ParentConfigParams::markParentDown(), PARENT_DIRECT, PARENT_SPECIFIED, ParentConfigParams::ParentEnable, ParentConfigParams::ParentRetryTime, passes, RE, REBUILD, REGRESSION_TEST_PASSED, REINIT, ST, ParentConfig::startup(), T, TEST_IP4_ADDR, TEST_IP6_ADDR, HTTPHdr::url_set(), and verify().
void request_to_data | ( | HttpRequestData * | req, | |
sockaddr const * | srcip, | |||
sockaddr const * | dstip, | |||
const char * | str | |||
) |
Definition at line 1102 of file ParentSelection.cc.
References ats_ip_copy(), HttpRequestData::dest_ip, HttpRequestData::hdr, http_parser_clear(), http_parser_init(), HTTPHdr::parse_req(), IpEndpoint::sa, and HttpRequestData::src_ip.
static int setup_socks_servers | ( | ParentRecord * | rec_arr, | |
int | len | |||
) | [static] |
Definition at line 1004 of file ParentSelection.cc.
References ats_ip_getbestaddrinfo(), ats_ip_ntop(), ats_is_ip6(), ParentRecord::go_direct, ParentRecord::num_parents, ParentRecord::parents, and Warning.
Referenced by SocksServerConfig::reconfigure().
void show_result | ( | ParentResult * | p | ) |
Definition at line 1367 of file ParentSelection.cc.
References ParentResult::hostname, PARENT_DIRECT, PARENT_FAIL, PARENT_SPECIFIED, PARENT_UNDEFINED, ParentResult::port, and ParentResult::r.
Referenced by verify().
int verify | ( | ParentResult * | r, | |
ParentResultType | e, | |||
const char * | h, | |||
int | p | |||
) |
Definition at line 1343 of file ParentSelection.cc.
References ParentResult::hostname, is_debug_tag_set, ParentResult::port, ParentResult::r, and show_result().
Referenced by PARENTSELECTION().
const char* default_var = "proxy.config.http.parent_proxies" [static] |
Definition at line 45 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().
const char* dns_parent_only_var = "proxy.config.http.no_dns_just_forward_to_parent" [static] |
Definition at line 49 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().
const char* enable_var = "proxy.config.http.parent_proxy_routing_enable" [static] |
Definition at line 47 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().
ParentRecord* const extApiRecord = (ParentRecord *) 0xeeeeffff |
Definition at line 78 of file ParentSelection.cc.
int fails [static] |
Definition at line 1122 of file ParentSelection.cc.
Referenced by PARENTSELECTION().
const char* file_var = "proxy.config.http.parent_proxy.file" [static] |
Definition at line 44 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().
const char modulePrefix[] = "[ParentSelection]" [static] |
Definition at line 40 of file ParentSelection.cc.
Referenced by ParentRecord::DefaultInit(), ParentRecord::Init(), and ParentConfig::reconfigure().
ConfigUpdateHandler<ParentConfig>* parentConfigUpdate = NULL [static] |
Definition at line 41 of file ParentSelection.cc.
Referenced by ParentConfig::startup().
const char* ParentResultStr[] [static] |
{ "Parent_Undefined", "Parent_Direct", "Parent_Specified", "Parent_Failed" }
Definition at line 51 of file ParentSelection.cc.
Referenced by ParentConfigParams::findParent(), and ParentConfigParams::nextParent().
const char* ParentRRStr[] [static] |
{ "false", "strict", "true" }
Definition at line 58 of file ParentSelection.cc.
Referenced by ParentRecord::Print().
int passes [static] |
Definition at line 1121 of file ParentSelection.cc.
Referenced by PARENTSELECTION().
const char* retry_var = "proxy.config.http.parent_proxy.retry_time" [static] |
Definition at line 46 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().
Ptr<ProxyMutex> socks_server_reconfig_mutex [static] |
Definition at line 991 of file ParentSelection.cc.
const char* threshold_var = "proxy.config.http.parent_proxy.fail_threshold" [static] |
Definition at line 48 of file ParentSelection.cc.
Referenced by ParentConfig::reconfigure(), and ParentConfig::startup().