diff options
-rw-r--r-- | src/conf.c | 8 | ||||
-rw-r--r-- | src/reqs.c | 10 | ||||
-rw-r--r-- | src/upstream.c | 9 | ||||
-rw-r--r-- | src/upstream.h | 8 |
4 files changed, 21 insertions, 14 deletions
@@ -1137,17 +1137,17 @@ static int _handle_upstream(struct config_s* conf, const char* line, static HANDLE_FUNC (handle_upstream) { - return _handle_upstream(conf, line, match, HTTP_TYPE); + return _handle_upstream(conf, line, match, PT_HTTP); } static HANDLE_FUNC (handle_upstream4) { - return _handle_upstream(conf, line, match, SOCKS4_TYPE); + return _handle_upstream(conf, line, match, PT_SOCKS4); } static HANDLE_FUNC (handle_upstream5) { - return _handle_upstream(conf, line, match, SOCKS5_TYPE); + return _handle_upstream(conf, line, match, PT_SOCKS5); } static HANDLE_FUNC (handle_upstream_no) @@ -1158,7 +1158,7 @@ static HANDLE_FUNC (handle_upstream_no) if (!domain) return -1; - upstream_add (NULL, 0, domain, 0, 0, HTTP_TYPE, &conf->upstream_list); + upstream_add (NULL, 0, domain, 0, 0, PT_HTTP, &conf->upstream_list); safefree (domain); return 0; @@ -62,7 +62,7 @@ #ifdef UPSTREAM_SUPPORT # define UPSTREAM_CONFIGURED() (config.upstream_list != NULL) # define UPSTREAM_HOST(host) upstream_get(host, config.upstream_list) -# define UPSTREAM_IS_HTTP(conn) (conn->upstream_proxy != NULL && conn->upstream_proxy->type == HTTP_TYPE) +# define UPSTREAM_IS_HTTP(conn) (conn->upstream_proxy != NULL && conn->upstream_proxy->type == PT_HTTP) #else # define UPSTREAM_CONFIGURED() (0) # define UPSTREAM_HOST(host) (NULL) @@ -271,7 +271,7 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request) request->method, request->path, request->host, portbuff); } else if (connptr->upstream_proxy && - connptr->upstream_proxy->type == HTTP_TYPE && + connptr->upstream_proxy->type == PT_HTTP && connptr->upstream_proxy->ua.authstr) { return write_message (connptr->server_fd, "%s %s HTTP/1.0\r\n" @@ -1292,7 +1292,7 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request) "Established connection to %s proxy \"%s\" using file descriptor %d.", proxy_type_name(cur_upstream->type), cur_upstream->host, connptr->server_fd); - if (cur_upstream->type == SOCKS4_TYPE) { + if (cur_upstream->type == PT_SOCKS4) { buff[0] = 4; /* socks version */ buff[1] = 1; /* connect command */ @@ -1308,7 +1308,7 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request) if (buff[0]!=0 || buff[1]!=90) return -1; - } else if (cur_upstream->type == SOCKS5_TYPE) { + } else if (cur_upstream->type == PT_SOCKS5) { /* init */ buff[0] = 5; /* socks version */ @@ -1404,7 +1404,7 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request) return -1; } - if (cur_upstream->type != HTTP_TYPE) + if (cur_upstream->type != PT_HTTP) return connect_to_upstream_proxy(connptr, request); log_message (LOG_CONN, diff --git a/src/upstream.c b/src/upstream.c index 03a6b8e..0c6b14e 100644 --- a/src/upstream.c +++ b/src/upstream.c @@ -35,9 +35,10 @@ const char * proxy_type_name(proxy_type type) { switch(type) { - case HTTP_TYPE: return "http"; - case SOCKS4_TYPE: return "socks4"; - case SOCKS5_TYPE: return "socks5"; + case PT_NONE: return "none"; + case PT_HTTP: return "http"; + case PT_SOCKS4: return "socks4"; + case PT_SOCKS5: return "socks5"; default: return "unknown"; } } @@ -63,7 +64,7 @@ static struct upstream *upstream_build (const char *host, int port, const char * up->host = up->domain = up->ua.user = up->pass = NULL; up->ip = up->mask = 0; if (user) { - if (type == HTTP_TYPE) { + if (type == PT_HTTP) { char b[BASE64ENC_BYTES((256+2)-1) + 1]; ssize_t ret; ret = basicauth_string(user, pass, b, sizeof b); diff --git a/src/upstream.h b/src/upstream.h index 9b664c8..c112784 100644 --- a/src/upstream.h +++ b/src/upstream.h @@ -31,7 +31,13 @@ * Even if upstream support is not compiled into tinyproxy, this * structure still needs to be defined. */ -typedef enum {HTTP_TYPE, SOCKS4_TYPE, SOCKS5_TYPE} proxy_type; +typedef enum proxy_type { + PT_NONE = 0, + PT_HTTP, + PT_SOCKS4, + PT_SOCKS5 +} proxy_type; + struct upstream { struct upstream *next; char *domain; /* optional */ |