diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2005-11-04 05:15:47 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2005-11-04 05:15:47 +0000 |
commit | 2f5118046d195875ee42530b5cf09898717663f9 (patch) | |
tree | afd97ef615aa3ab885a52b7ddb504595970e1a55 | |
parent | 72e173109255652683f15f7c881506d69bbfffe8 (diff) | |
download | tinyproxy-2f5118046d195875ee42530b5cf09898717663f9.tar.gz tinyproxy-2f5118046d195875ee42530b5cf09898717663f9.zip |
Added support for UPSTREAM directive.
Included the basic grammar and handler functions for the "upstream" and
"no upstream" directives. I still need to update the grammar to match
_all_ the possibilities documented in the tinyproxy.conf file, but at
least it now does as much as the old config parser.
Diffstat (limited to '')
-rw-r--r-- | src/conffile.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/src/conffile.c b/src/conffile.c index d57c09c..66e4600 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -1,4 +1,4 @@ -/* $Id: conffile.c,v 1.8 2005-11-04 01:31:41 rjkaes Exp $ +/* $Id: conffile.c,v 1.9 2005-11-04 05:15:47 rjkaes Exp $ * * Parses the configuration file and sets up the config_s structure for * use by the application. This file replaces the old grammar.y and @@ -124,11 +124,15 @@ static HANDLE_FUNC(handle_stathost); static HANDLE_FUNC(handle_syslog); static HANDLE_FUNC(handle_timeout); -//static HANDLE_FUNC(handle_upstream); static HANDLE_FUNC(handle_user); static HANDLE_FUNC(handle_viaproxyname); static HANDLE_FUNC(handle_xtinyproxy); +#ifdef UPSTREAM_SUPPORT +static HANDLE_FUNC(handle_upstream); +static HANDLE_FUNC(handle_upstream_no); +#endif + /* * This macro can be used to make standard directives in the form: * directive arguments [arguments ...] @@ -213,9 +217,11 @@ struct { STDCONF("reversepath", STR WS "(" STR ")?", handle_reversepath), #endif +#ifdef UPSTREAM_SUPPORT /* upstream is rather complicated */ -// { BEGIN "no" WS "upstream" WS STR END, handle_no_upstream }, -// { BEGIN "upstream" WS IP ":" INT "(" WS STR ")" END, handle_upstream }, + { BEGIN "(no" WS "upstream)" WS STR END, handle_upstream_no }, + { BEGIN "(upstream)" WS "(" IP "|" ALNUM ")" ":" INT "(" WS STR ")?" END, handle_upstream }, +#endif /* loglevel */ STDCONF("loglevel", "(critical|error|warning|notice|connect|info)", @@ -740,3 +746,45 @@ HANDLE_FUNC(handle_reversepath) return 0; } #endif + +#ifdef UPSTREAM_SUPPORT +static +HANDLE_FUNC(handle_upstream) +{ + char *ip; + int port; + char *domain; + + ip = get_string_arg(line, &match[2]); + if (!ip) return -1; + port = get_int_arg(line, &match[7]); + + if (match[9].rm_so != -1) { + domain = get_string_arg(line, &match[9]); + if (domain) { + upstream_add(ip, port, domain); + safefree(domain); + } + } else { + upstream_add(ip, port, NULL); + } + + safefree(ip); + + return 0; +} + +static +HANDLE_FUNC(handle_upstream_no) +{ + char *domain; + + domain = get_string_arg(line, &match[2]); + if (!domain) return -1; + + upstream_add(NULL, 0, domain); + safefree(domain); + + return 0; +} +#endif |