You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zy...@apache.org on 2012/06/21 17:41:09 UTC
[2/3] git commit: TS-959 remove ae_ua filter
TS-959 remove ae_ua filter
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2549fa2d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2549fa2d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2549fa2d
Branch: refs/heads/master
Commit: 2549fa2dad0529d3dec547d313b257f88c2f010e
Parents: 425a9ee
Author: Zhao Yongming <mi...@gmail.com>
Authored: Tue Jun 5 12:08:53 2012 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Thu Jun 21 11:00:52 2012 +0800
----------------------------------------------------------------------
mgmt/RecordsConfig.cc | 7 -
proxy/Main.cc | 37 ------
proxy/config/ae_ua.config.default | 23 ----
proxy/http/HttpConfig.cc | 213 --------------------------------
4 files changed, 0 insertions(+), 280 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2549fa2d/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index d08f59a..e9e7ba3 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -506,13 +506,6 @@ RecordElement RecordsConfig[] = {
{RECT_CONFIG, "proxy.config.http.referer_default_redirect", RECD_STRING, "http://www.apache.org", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
- // ##########################################################
- // # HTTP Accept-Encoding filtering (depends on User-Agent) #
- // ##########################################################
- {RECT_CONFIG, "proxy.config.http.accept_encoding_filter_enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
- ,
- {RECT_CONFIG, "proxy.config.http.accept_encoding_filter.filename", RECD_STRING, "ae_ua.config", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
- ,
// ##############################
// # parent proxy configuration #
// ##############################
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2549fa2d/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 0dbbbd7..257fd13 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1109,40 +1109,6 @@ init_http_header()
http_init();
}
-// TODO: we should move this function out of the Main.cc
-static void
-init_http_aeua_filter(void)
-{
- char buf[2048], _cname[1024], *cname;
- int i, j;
-
- cname = &_cname[0];
- memset(buf, 0, sizeof(buf));
- memset(_cname, 0, sizeof(_cname));
-
- TS_ReadConfigString(_cname, "proxy.config.http.accept_encoding_filter.filename", (int) sizeof(_cname));
-
- if (_cname[0] && (j = strlen(_cname)) > 0) {
- while (j && (*cname == '/' || *cname == '\\')) {
- ++cname;
- --j;
- }
- ink_strlcpy(buf, system_config_directory, sizeof(buf));
- if ((i = strlen(buf)) >= 0) {
- if (!i || (buf[i - 1] != '/' && buf[i - 1] != '\\' && i < (int) sizeof(buf))) {
- ink_strlcat(buf, "/", sizeof(buf));
- ++i;
- }
- }
- if ((i + j + 1) < (int) sizeof(buf))
- ink_strlcat(buf, cname, sizeof(buf));
- }
-
- i = HttpConfig::init_aeua_filter(buf[0] ? buf : NULL);
-
- Debug("http_aeua", "[init_http_aeua_filter] - Total loaded %d REGEXP for Accept-Enconding/User-Agent filtering", i);
-}
-
struct AutoStopCont: public Continuation
{
int mainEvent(int event, Event * e)
@@ -1576,9 +1542,6 @@ main(int argc, char **argv)
init_http_header();
- // Init HTTP Accept-Encoding/User-Agent filter
- init_http_aeua_filter();
-
// Sanity checks
// if (!lock_process) check_for_root_uid();
check_fd_limit();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2549fa2d/proxy/config/ae_ua.config.default
----------------------------------------------------------------------
diff --git a/proxy/config/ae_ua.config.default b/proxy/config/ae_ua.config.default
deleted file mode 100644
index 6280f9f..0000000
--- a/proxy/config/ae_ua.config.default
+++ /dev/null
@@ -1,23 +0,0 @@
-# ---------------------------------------------------------------------------------------
-# Accept-Encoding/User-Agent filtering Configuration file.
-# This file can include an unlimited number of regular expressions or simple strings for
-# User-Agents headers filtering.
-# If the request User-Agent header matches the regular expression, Accep-Encoding header
-# will be verified/changed/removed in order to disable the acceptance of any compressed data.
-# Please keep in mind that Traffic Server has some predefined regular expressions
-# for well-known "bad" clients.
-# Traffic Server supports the following format for this file:
-# <string_type> <string>
-# where <string_type> can be:
-# .substring - check only lead substring in User-Agent header (case sensitive)
-# .string - the same as .substring
-# .substring_ncase - check only lead substring in User-Agent header (case insensitive)
-# .string_ncase - the same as .substring_ncase
-# .regexp - POSIX regular expression
-#
-# <string> - valid POSIX regular expression if ".regexp" string type was specified
-# or arbitrary ascii string for other string types
-# ---------------------------------------------------------------------------------------
-# For example:
-# .regexp Mozilla/4.[0-9].*
-# .string Mozilla/4.0
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2549fa2d/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 0667565..90db23f 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1646,219 +1646,6 @@ HttpConfig::release(HttpConfigParams * params)
configProcessor.release(m_id, params);
}
-/*
- Static Accept-Encoding/User-Agent filtering table
- The format of this table is compatible with ae_ua.config file
- */
-
-static char *static_aeua_filter_array[] = {
-// ".substring Mozilla/4.",
- NULL
-};
-
-static int
-read_string(FILE * fp, char *buf, int size)
-{
- int i, retsize = (-1);
- if (fp && --size > 0 && buf) {
- for (buf[(retsize = 0)] = 0; (i = fgetc(fp)) != EOF;) {
- if (i == '\n' || i == '\r')
- break;
- if ((i == ' ' || i == '\t') && !retsize)
- continue;
- if (retsize < size)
- buf[retsize++] = (char) i;
- }
- buf[retsize] = 0;
- if (i == EOF && !retsize)
- retsize = (-1); /* i == EOF && retsize == 0 */
- }
- return retsize;
-}
-
-static bool
-store_error_message(char *err_msg_buf, int err_msg_buf_size, const char *fmt, ...)
-{
- if (likely(err_msg_buf && err_msg_buf_size > 0)) {
- char buf[2048];
- va_list ap;
- va_start(ap, fmt);
- (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
- ink_strlcpy(err_msg_buf, buf, err_msg_buf_size);
- va_end(ap);
- }
- return false;
-}
-
-////////////////////////////////////////////////////////////////
-//
-// HttpConfig::init_aeua_filter()
-//
-// TODO: make aeua_filter more flex
-////////////////////////////////////////////////////////////////
-int
-HttpConfig::init_aeua_filter(char *config_fname)
-{
- char errmsgbuf[1024], line[2048], *c;
- HttpUserAgent_RegxEntry *ua, **uaa, *u;
- FILE *fp;
- int i, size;
- int retcount = 0;
-
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Config: \"%s\"", config_fname ? config_fname : "<NULL>");
-
- for (uaa = &HttpConfig::user_agent_list, i = 0; static_aeua_filter_array[i]; i++) {
- memset(errmsgbuf, 0, sizeof(errmsgbuf));
- ua = NEW(new HttpUserAgent_RegxEntry);
- if (!ua->create(static_aeua_filter_array[i], errmsgbuf, sizeof(errmsgbuf))) {
- ink_error("[HttpConfig::init_aeua_filter] - internal list - %s - %s",
- static_aeua_filter_array[i], errmsgbuf[0] ? errmsgbuf : "Unknown error");
- delete ua;
- ua = 0;
- } else {
- *uaa = ua;
- uaa = &(ua->next);
- retcount++;
- }
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Add \"%s\" filter - %s",
- static_aeua_filter_array[i], ua ? "Success" : "Error");
- }
- if (config_fname && config_fname[0]) {
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Opening config \"%s\"", config_fname);
- if ((fp = fopen(config_fname, "r")) != NULL) {
- while ((i = read_string(fp, line, (int) sizeof(line))) >= 0) {
- if (!i)
- continue;
- for (c = line; *c == ' ' || *c == '\t'; c++);
- if (*c == '#' || (size = strlen(c)) <= 0)
- continue;
- while (size > 0 && (c[size - 1] == ' ' || c[size - 1] == '\t' || c[size - 1] == '\n' || c[size - 1] == '\r'))
- c[--size] = 0;
- if (size <= 0)
- continue;
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - \"%s\"", c);
- for (u = HttpConfig::user_agent_list; u; u = u->next) {
- if (u->user_agent_str_size && u->user_agent_str && !strcmp(u->user_agent_str, c))
- break;
- }
- if (!u) {
- ua = NEW(new HttpUserAgent_RegxEntry);
- if (!ua->create(c, errmsgbuf, sizeof(errmsgbuf))) {
- ink_error("[HttpConfig::init_aeua_filter] - config list - %s - %s", c,
- errmsgbuf[0] ? errmsgbuf : "Unknown error");
- delete ua;
- ua = 0;
- } else {
- *uaa = ua;
- uaa = &(ua->next);
- retcount++;
- }
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Add \"%s\" filter - %s", c, ua ? "Success" : "Error");
- } else {
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Duplicate record \"%s\"", c);
- }
- }
- fclose(fp);
- } else {
- ink_error("[HttpConfig::init_aeua_filter] - Can't open \"%s\"", config_fname);
- }
- }
- Debug("http_aeua", "[HttpConfig::init_aeua_filter] - Added %d REGEXP filters", retcount);
- return retcount;
-}
-
-////////////////////////////////////////////////////////////////
-//
-// HttpUserAgent_RegxEntry::HttpUserAgent_RegxEntry()
-//
-////////////////////////////////////////////////////////////////
-HttpUserAgent_RegxEntry::HttpUserAgent_RegxEntry()
-{
- next = 0;
- user_agent_str_size = 0;
- user_agent_str = 0;
- regx_valid = false;
- stype = STRTYPE_UNKNOWN;
- memset(®x, 0, sizeof(regx));
-}
-
-////////////////////////////////////////////////////////////////
-//
-// HttpUserAgent_RegxEntry::~HttpUserAgent_RegxEntry()
-//
-////////////////////////////////////////////////////////////////
-HttpUserAgent_RegxEntry::~HttpUserAgent_RegxEntry()
-{
- (void) create(); /* just for clean up */
-}
-
-////////////////////////////////////////////////////////////////
-//
-// HttpUserAgent_RegxEntry::create()
-//
-////////////////////////////////////////////////////////////////
-bool
-HttpUserAgent_RegxEntry::create(char *_refexp_str, char *errmsgbuf, int errmsgbuf_size)
-{
- char *c, *refexp_str, refexp_str_buf[2048];
- bool retcode = false;
-
- user_agent_str = (char *)ats_free_null(user_agent_str);
- user_agent_str_size = 0;
- stype = STRTYPE_UNKNOWN;
- if (regx_valid) {
- pcre_free(regx);
- regx_valid = false;
- }
- if (errmsgbuf && errmsgbuf_size > 0)
- errmsgbuf[0] = 0;
-
-
- if (_refexp_str && *_refexp_str) {
- ink_strlcpy(refexp_str_buf, _refexp_str, sizeof(refexp_str_buf));
- refexp_str = refexp_str_buf;
-
- Debug("http_aeua", "[HttpUserAgent_RegxEntry::create] - \"%s\"", refexp_str);
- while (*refexp_str && (*refexp_str == ' ' || *refexp_str == '\t'))
- refexp_str++;
- if (*refexp_str == '.') {
- for (c = refexp_str; *refexp_str && *refexp_str != ' ' && *refexp_str != '\t'; refexp_str++);
- while (*refexp_str && (*refexp_str == ' ' || *refexp_str == '\t'))
- *refexp_str++ = 0;
- if (*refexp_str) {
- if (!strcasecmp(c, ".substring") || !strcasecmp(c, ".string"))
- stype = STRTYPE_SUBSTR_CASE;
- else if (!strcasecmp(c, ".substring_ncase") || !strcasecmp(c, ".string_ncase"))
- stype = STRTYPE_SUBSTR_NCASE;
- else if (!strcasecmp(c, ".regexp") || !strcasecmp(c, ".regex"))
- stype = STRTYPE_REGEXP;
- else
- return store_error_message(errmsgbuf, errmsgbuf_size, "Unknown string type \"%s\"", c);
- } else
- return store_error_message(errmsgbuf, errmsgbuf_size, "Empty string with \"%s\" string type", c);
- } else
- return store_error_message(errmsgbuf, errmsgbuf_size, "Incorrect string type - must start with '.'");
-
- user_agent_str = ats_strdup(refexp_str);
- retcode = true;
- if (stype == STRTYPE_REGEXP) {
- const char* error;
- int erroffset;
-
- regx = pcre_compile((const char *) user_agent_str, PCRE_CASELESS, &error, &erroffset, NULL);
- if (regx == NULL) {
- if (errmsgbuf && (errmsgbuf_size - 1) > 0)
- ink_strlcpy(errmsgbuf, error, errmsgbuf_size);
- user_agent_str = (char *)ats_free_null(user_agent_str);
- retcode = false;
- } else
- regx_valid = true;
- }
- user_agent_str_size = user_agent_str ? strlen(user_agent_str) : 0;
- }
- return retcode;
-}
-
////////////////////////////////////////////////////////////////
//
// HttpConfig::parse_ports_list()