Move code into a new function, to illustrate upcoming bugfix
This commit is contained in:
parent
0aad2f5b92
commit
42e421e7bb
@ -43,6 +43,35 @@ proxy_type_name(proxy_type type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse and process a netmask format (IP/mask), otherwise treat as a domain
|
||||||
|
*/
|
||||||
|
static void upstream_handle_site_spec(struct upstream *up, const char *domain)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
ptr = strchr (domain, '/');
|
||||||
|
if (ptr) {
|
||||||
|
struct in_addr addrstruct;
|
||||||
|
|
||||||
|
*ptr = '\0';
|
||||||
|
if (inet_aton (domain, &addrstruct) != 0) {
|
||||||
|
up->ip = ntohl (addrstruct.s_addr);
|
||||||
|
*ptr++ = '/';
|
||||||
|
|
||||||
|
if (strchr (ptr, '.')) {
|
||||||
|
if (inet_aton (ptr, &addrstruct) != 0)
|
||||||
|
up->mask =
|
||||||
|
ntohl (addrstruct.s_addr);
|
||||||
|
} else {
|
||||||
|
up->mask =
|
||||||
|
~((1 << (32 - atoi (ptr))) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
up->domain = safestrdup (domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Construct an upstream struct from input data.
|
* Construct an upstream struct from input data.
|
||||||
*/
|
*/
|
||||||
@ -50,7 +79,6 @@ static struct upstream *upstream_build (const char *host, int port, const char *
|
|||||||
const char *user, const char *pass,
|
const char *user, const char *pass,
|
||||||
proxy_type type)
|
proxy_type type)
|
||||||
{
|
{
|
||||||
char *ptr;
|
|
||||||
struct upstream *up;
|
struct upstream *up;
|
||||||
|
|
||||||
up = (struct upstream *) safemalloc (sizeof (struct upstream));
|
up = (struct upstream *) safemalloc (sizeof (struct upstream));
|
||||||
@ -99,27 +127,7 @@ static struct upstream *upstream_build (const char *host, int port, const char *
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = strchr (domain, '/');
|
upstream_handle_site_spec(up, domain);
|
||||||
if (ptr) {
|
|
||||||
struct in_addr addrstruct;
|
|
||||||
|
|
||||||
*ptr = '\0';
|
|
||||||
if (inet_aton (domain, &addrstruct) != 0) {
|
|
||||||
up->ip = ntohl (addrstruct.s_addr);
|
|
||||||
*ptr++ = '/';
|
|
||||||
|
|
||||||
if (strchr (ptr, '.')) {
|
|
||||||
if (inet_aton (ptr, &addrstruct) != 0)
|
|
||||||
up->mask =
|
|
||||||
ntohl (addrstruct.s_addr);
|
|
||||||
} else {
|
|
||||||
up->mask =
|
|
||||||
~((1 << (32 - atoi (ptr))) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
up->domain = safestrdup (domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_message (LOG_INFO, "Added no-upstream for %s", domain);
|
log_message (LOG_INFO, "Added no-upstream for %s", domain);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user