Fiz whitespaces

This commit is contained in:
Markus Moeller 2020-01-12 19:14:38 +00:00
parent a9edc77d0c
commit 585882edd2
11 changed files with 205 additions and 218 deletions

View File

@ -259,7 +259,6 @@ struct {
{
BEGIN "(upstream)" WS "(none)" WS STR END, handle_upstream_no, NULL
},
{
BEGIN "(upstream)" WS "(http|socks4|socks5)" WS
"(" USERNAME /*username*/ ":" PASSWORD /*password*/ "@" ")?"
@ -388,6 +387,7 @@ static int check_match (struct config_s *conf, const char *line,
unsigned int i;
assert (ndirectives > 0);
for (i = 0; i != ndirectives; ++i) {
assert (directives[i].cre);
if (!regexec

View File

@ -486,6 +486,7 @@ BAD_REQUEST_ERROR:
}
#endif
/*
* Check to see if they're requesting the stat host
*/
@ -1299,8 +1300,7 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
log_message(LOG_CONN,
"Established connection to %s proxy \"%s\" using file descriptor %d.",
proxy_type_name (cur_upstream->type), cur_upstream->host,
connptr->server_fd);
proxy_type_name (cur_upstream->type), cur_upstream->host, connptr->server_fd);
if (cur_upstream->type == PT_SOCKS4) {
@ -1313,22 +1313,17 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
buff[8] = 0; /* user */
if (9 != safe_write(connptr->server_fd, buff, 9))
return -1;
if (8 != safe_read (connptr->server_fd, buff, 8))
return -1;
if (buff[0]!=0 || buff[1]!=90)
return -1;
} else if (cur_upstream->type == PT_SOCKS5) {
/* init */
int n_methods = ulen ? 2 : 1;
buff[0] = 5; /* socks version */
buff[1] = n_methods; /* number of methods */
buff[2] = 0; /* no auth method */
if (ulen)
buff[3] = 2; /* auth method -> username / password */
if (2 + n_methods !=
safe_write (connptr->server_fd, buff, 2 + n_methods))
if (ulen) buff[3] = 2; /* auth method -> username / password */
if (2 + n_methods != safe_write(connptr->server_fd, buff, 2 + n_methods))
return -1;
if (2 != safe_read(connptr->server_fd, buff, 2))
return -1;
@ -1351,8 +1346,7 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
memcpy(cur, cur_upstream->pass, c);
cur += c;
if ((cur - out) !=
safe_write (connptr->server_fd, out, cur - out))
if ((cur - out) != safe_write(connptr->server_fd, out, cur - out))
return -1;
if (2 != safe_read(connptr->server_fd, in, 2))
@ -1380,19 +1374,14 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
if (buff[0] != 5 || buff[1] != 0)
return -1;
switch (buff[3]) {
case 1:
len = 4;
break; /* ip v4 */
case 4:
len = 16;
break; /* ip v6 */
case 1: len = 4; break; /* ip v4 */
case 4: len = 16; break; /* ip v6 */
case 3: /* domainname */
if (1 != safe_read(connptr->server_fd, buff, 1))
return -1;
len = buff[0]; /* max = 255 */
break;
default:
return -1;
default: return -1;
}
if (2 + len != safe_read(connptr->server_fd, buff, 2 + len))
return -1;
@ -1406,6 +1395,7 @@ connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
return establish_http_connection (connptr, request);
}
/*
* Establish a connection to the upstream proxy server.
*/
@ -1563,6 +1553,7 @@ get_request_entity (struct conn_s *connptr)
return ret;
}
/*
* This is the main drive for each connection. As you can tell, for the
* first few steps we are using a blocking socket. If you remember the

View File

@ -144,19 +144,15 @@ static char *get_hostip (int *lookup_err, char *host, in_addr_t ip,
return safestrdup (hostip);
}
const char *proxy_type_name (proxy_type type)
const char *
proxy_type_name (proxy_type type)
{
switch (type) {
case PT_NONE:
return "none";
case PT_HTTP:
return "http";
case PT_SOCKS4:
return "socks4";
case PT_SOCKS5:
return "socks5";
default:
return "unknown";
case PT_NONE: return "none";
case PT_HTTP: return "http";
case PT_SOCKS4: return "socks4";
case PT_SOCKS5: return "socks5";
default: return "unknown";
}
}