IP version supported by Tinyproxy
- ipv4 : ignore IPv6 addresses in DNS response - ipv6 : ignore IPv4 addresses in DNS response - any : accept both IPv4 and IPv6 addresses in DNS response
This commit is contained in:
parent
3764b85514
commit
d3c0bf7a55
@ -321,5 +321,11 @@ ViaProxyName "tinyproxy"
|
|||||||
#
|
#
|
||||||
#ReverseBaseURL "http://localhost:8888/"
|
#ReverseBaseURL "http://localhost:8888/"
|
||||||
|
|
||||||
|
#
|
||||||
|
# IP version supported by Tinyproxy
|
||||||
|
# ipv4 : ignore IPv6 addresses in DNS response
|
||||||
|
# ipv6 : ignore IPv4 addresses in DNS response
|
||||||
|
# any : accept both IPv4 and IPv6 addresses in DNS response
|
||||||
|
#
|
||||||
|
IPversion any
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ config_directive_find (register const char *str, register size_t len)
|
|||||||
{"logfile", CD_logfile},
|
{"logfile", CD_logfile},
|
||||||
{"basicauth", CD_basicauth},
|
{"basicauth", CD_basicauth},
|
||||||
{"addheader", CD_addheader},
|
{"addheader", CD_addheader},
|
||||||
{"maxrequestsperchild", CD_maxrequestsperchild}
|
{"maxrequestsperchild", CD_maxrequestsperchild},
|
||||||
|
{"ipversion", CD_ipversion},
|
||||||
};
|
};
|
||||||
|
|
||||||
for(i=0;i<sizeof(wordlist)/sizeof(wordlist[0]);++i) {
|
for(i=0;i<sizeof(wordlist)/sizeof(wordlist[0]);++i) {
|
||||||
|
@ -58,5 +58,6 @@ reversemagic, CD_reversemagic
|
|||||||
reversepath, CD_reversepath
|
reversepath, CD_reversepath
|
||||||
upstream, CD_upstream
|
upstream, CD_upstream
|
||||||
loglevel, CD_loglevel
|
loglevel, CD_loglevel
|
||||||
|
ipversion, CD_ipversion
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ CD_reversemagic,
|
|||||||
CD_reversepath,
|
CD_reversepath,
|
||||||
CD_upstream,
|
CD_upstream,
|
||||||
CD_loglevel,
|
CD_loglevel,
|
||||||
|
CD_ipversion
|
||||||
};
|
};
|
||||||
|
|
||||||
struct config_directive_entry { const char* name; enum config_directive value; };
|
struct config_directive_entry { const char* name; enum config_directive value; };
|
||||||
|
33
src/conf.c
33
src/conf.c
@ -161,6 +161,8 @@ static HANDLE_FUNC (handle_viaproxyname);
|
|||||||
static HANDLE_FUNC (handle_disableviaheader);
|
static HANDLE_FUNC (handle_disableviaheader);
|
||||||
static HANDLE_FUNC (handle_xtinyproxy);
|
static HANDLE_FUNC (handle_xtinyproxy);
|
||||||
|
|
||||||
|
static HANDLE_FUNC (handle_ipversion);
|
||||||
|
|
||||||
#ifdef UPSTREAM_SUPPORT
|
#ifdef UPSTREAM_SUPPORT
|
||||||
static HANDLE_FUNC (handle_upstream);
|
static HANDLE_FUNC (handle_upstream);
|
||||||
#endif
|
#endif
|
||||||
@ -254,7 +256,8 @@ struct {
|
|||||||
#endif
|
#endif
|
||||||
/* loglevel */
|
/* loglevel */
|
||||||
STDCONF (loglevel, "(critical|error|warning|notice|connect|info)",
|
STDCONF (loglevel, "(critical|error|warning|notice|connect|info)",
|
||||||
handle_loglevel)
|
handle_loglevel),
|
||||||
|
STDCONF (ipversion, "(ipv4|ipv6|any)", handle_ipversion)
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned int ndirectives = sizeof (directives) / sizeof (directives[0]);
|
const unsigned int ndirectives = sizeof (directives) / sizeof (directives[0]);
|
||||||
@ -932,6 +935,34 @@ static HANDLE_FUNC (handle_loglevel)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ip_version_s {
|
||||||
|
const char *string;
|
||||||
|
enum ip_version_e ipversion;
|
||||||
|
};
|
||||||
|
static struct ip_version_s ip_version[] = {
|
||||||
|
{"ipv4", IPv4_Only},
|
||||||
|
{"ipv6", IPv6_Only},
|
||||||
|
{"any", IP_Any}
|
||||||
|
};
|
||||||
|
static HANDLE_FUNC (handle_ipversion)
|
||||||
|
{
|
||||||
|
static const unsigned int nips =
|
||||||
|
sizeof (ip_version) / sizeof (ip_version[0]);
|
||||||
|
unsigned int i;
|
||||||
|
char *arg = get_string_arg (line, &match[2]);
|
||||||
|
for (i = 0; i != nips; ++i) {
|
||||||
|
if (!strcasecmp (arg, ip_version[i].string)) {
|
||||||
|
conf->ipversion = ip_version[i].ipversion;
|
||||||
|
safefree (arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safefree (arg);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static HANDLE_FUNC (handle_basicauth)
|
static HANDLE_FUNC (handle_basicauth)
|
||||||
{
|
{
|
||||||
char *user, *pass;
|
char *user, *pass;
|
||||||
|
@ -34,6 +34,12 @@ typedef struct {
|
|||||||
char *value;
|
char *value;
|
||||||
} http_header_t;
|
} http_header_t;
|
||||||
|
|
||||||
|
enum ip_version_e {
|
||||||
|
IPv4_Only = 0,
|
||||||
|
IPv6_Only,
|
||||||
|
IP_Any
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hold all the configuration time information.
|
* Hold all the configuration time information.
|
||||||
*/
|
*/
|
||||||
@ -68,6 +74,7 @@ struct config_s {
|
|||||||
unsigned int idletimeout;
|
unsigned int idletimeout;
|
||||||
sblist *bind_addrs;
|
sblist *bind_addrs;
|
||||||
unsigned int bindsame;
|
unsigned int bindsame;
|
||||||
|
enum ip_version_e ipversion;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The configured name to use in the HTTP "Via" header field.
|
* The configured name to use in the HTTP "Via" header field.
|
||||||
|
@ -146,7 +146,14 @@ int opensock (const char *host, int port, const char *bind_to)
|
|||||||
"opensock: opening connection to %s:%d", host, port);
|
"opensock: opening connection to %s:%d", host, port);
|
||||||
|
|
||||||
memset (&hints, 0, sizeof (struct addrinfo));
|
memset (&hints, 0, sizeof (struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC;
|
log_message(LOG_INFO, "opensock: ipversion: %d", config->ipversion);
|
||||||
|
if (config->ipversion == IPv4_Only) {
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
} else if (config->ipversion == IPv6_Only) {
|
||||||
|
hints.ai_family = AF_INET6;
|
||||||
|
} else {
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
}
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
snprintf (portstr, sizeof (portstr), "%d", port);
|
snprintf (portstr, sizeof (portstr), "%d", port);
|
||||||
|
Loading…
Reference in New Issue
Block a user