summaryrefslogtreecommitdiffhomepage
path: root/src/conf.c
diff options
context:
space:
mode:
authorGonzalo Tornaria <tornaria@math.utexas.edu>2016-12-20 21:30:43 +0000
committerrofl0r <rofl0r@users.noreply.github.com>2018-02-06 16:11:39 +0000
commit8906b0734e5c61016d9d4090507f010b2006292d (patch)
tree73eea974f5a292516e1ffd85ed44ddeae1b34764 /src/conf.c
parent116e59e93346ddbe08f56f8c7e8bd648690c0242 (diff)
add SOCKS upstream proxy support (socks4/socks5)
original patch submitted in 2006 to debian mailing list: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=392848%29#12 this version was rebased to git and updated by Russ Dill <russ.dill@gmail.com> in 2015 (the original patch used a different config file format). as discussed in #40. commit message by @rofl0r.
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/conf.c b/src/conf.c
index d568dfb..ca46930 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -160,6 +160,8 @@ static HANDLE_FUNC (handle_xtinyproxy);
#ifdef UPSTREAM_SUPPORT
static HANDLE_FUNC (handle_upstream);
+static HANDLE_FUNC (handle_upstream4);
+static HANDLE_FUNC (handle_upstream5);
static HANDLE_FUNC (handle_upstream_no);
#endif
@@ -257,6 +259,14 @@ struct {
BEGIN "(upstream)" WS "(" IP "|" ALNUM ")" ":" INT "(" WS STR
")?" END, handle_upstream, NULL
},
+ {
+ BEGIN "(upstream4)" WS "(" IP "|" ALNUM ")" ":" INT "(" WS STR
+ ")?" END, handle_upstream4, NULL
+ },
+ {
+ BEGIN "(upstream5)" WS "(" IP "|" ALNUM ")" ":" INT "(" WS STR
+ ")?" END, handle_upstream5, NULL
+ },
#endif
/* loglevel */
STDCONF ("loglevel", "(critical|error|warning|notice|connect|info)",
@@ -1066,7 +1076,8 @@ static HANDLE_FUNC (handle_reversepath)
#endif
#ifdef UPSTREAM_SUPPORT
-static HANDLE_FUNC (handle_upstream)
+static int _handle_upstream(struct config_s* conf, const char* line,
+ regmatch_t match[], proxy_type type)
{
char *ip;
int port;
@@ -1080,11 +1091,11 @@ static HANDLE_FUNC (handle_upstream)
if (match[10].rm_so != -1) {
domain = get_string_arg (line, &match[10]);
if (domain) {
- upstream_add (ip, port, domain, &conf->upstream_list);
+ upstream_add (ip, port, domain, type, &conf->upstream_list);
safefree (domain);
}
} else {
- upstream_add (ip, port, NULL, &conf->upstream_list);
+ upstream_add (ip, port, NULL, type, &conf->upstream_list);
}
safefree (ip);
@@ -1092,6 +1103,21 @@ static HANDLE_FUNC (handle_upstream)
return 0;
}
+static HANDLE_FUNC (handle_upstream)
+{
+ return _handle_upstream(conf, line, match, HTTP_TYPE);
+}
+
+static HANDLE_FUNC (handle_upstream4)
+{
+ return _handle_upstream(conf, line, match, SOCKS4_TYPE);
+}
+
+static HANDLE_FUNC (handle_upstream5)
+{
+ return _handle_upstream(conf, line, match, SOCKS5_TYPE);
+}
+
static HANDLE_FUNC (handle_upstream_no)
{
char *domain;
@@ -1100,7 +1126,7 @@ static HANDLE_FUNC (handle_upstream_no)
if (!domain)
return -1;
- upstream_add (NULL, 0, domain, &conf->upstream_list);
+ upstream_add (NULL, 0, domain, HTTP_TYPE, &conf->upstream_list);
safefree (domain);
return 0;