Removed proxy_enabled option in favor of proxy_type.

This commit is contained in:
Håvard Pettersson 2015-01-04 14:56:05 +01:00
parent 30677fdd7a
commit dde3ce9512
4 changed files with 35 additions and 12 deletions

View File

@ -45,7 +45,7 @@ char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] =
"max_friend_requests", "max_friend_requests",
"proxy_address", "proxy_address",
"proxy_port", "proxy_port",
"proxy", "proxy_type",
"udp", "udp",
"ipv6", "ipv6",
}; };
@ -57,7 +57,7 @@ char *twc_profile_option_defaults[TWC_PROFILE_NUM_OPTIONS] =
"100", "100",
NULL, NULL,
NULL, NULL,
"off", "none",
"on", "on",
"on", "on",
}; };
@ -231,16 +231,17 @@ twc_config_init_option(struct t_config_section *section,
type = "string"; type = "string";
description = "proxy address"; description = "proxy address";
break; break;
case TWC_PROFILE_OPTION_PROXY_ENABLED:
type = "boolean";
description = "use a proxy for communicating with the Tox "
"network; requries profile reload to take effect";
break;
case TWC_PROFILE_OPTION_PROXY_PORT: case TWC_PROFILE_OPTION_PROXY_PORT:
type = "integer"; type = "integer";
description = "proxy port"; description = "proxy port";
min = 0; max = UINT16_MAX; min = 0; max = UINT16_MAX;
break; break;
case TWC_PROFILE_OPTION_PROXY_TYPE:
type = "integer";
description = "proxy type; requires profile reload to take effect";
string_values = "none|socks5|http";
min = 0; max = 0;
break;
case TWC_PROFILE_OPTION_SAVEFILE: case TWC_PROFILE_OPTION_SAVEFILE:
type = "string"; type = "string";
description = "path to Tox data file (\"%h\" will be replaced by " description = "path to Tox data file (\"%h\" will be replaced by "

View File

@ -25,6 +25,13 @@ struct t_twc_profile;
extern struct t_config_option *twc_config_friend_request_message; extern struct t_config_option *twc_config_friend_request_message;
extern struct t_config_option *twc_config_short_id_size; extern struct t_config_option *twc_config_short_id_size;
enum t_twc_proxy
{
TWC_PROXY_NONE = 0,
TWC_PROXY_SOCKS5,
TWC_PROXY_HTTP
};
void void
twc_config_init(); twc_config_init();

View File

@ -218,8 +218,22 @@ twc_profile_load(struct t_twc_profile *profile)
// create Tox options object // create Tox options object
Tox_Options options; Tox_Options options;
options.proxy_enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_PROXY_ENABLED); char *proxy_type;
switch (TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_TYPE))
{
case TWC_PROXY_NONE:
options.proxy_type = TOX_PROXY_NONE;
break;
case TWC_PROXY_SOCKS5:
options.proxy_type = TOX_PROXY_SOCKS5;
proxy_type = "SOCKS5";
break;
case TWC_PROXY_HTTP:
options.proxy_type = TOX_PROXY_HTTP;
proxy_type = "HTTP";
break;
}
const char *proxy_address = const char *proxy_address =
TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS); TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS);
@ -233,7 +247,7 @@ twc_profile_load(struct t_twc_profile *profile)
options.ipv6enabled = options.ipv6enabled =
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_IPV6); TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_IPV6);
if (options.proxy_enabled) if (options.proxy_type != TOX_PROXY_NONE)
{ {
if (!options.proxy_address || !options.proxy_port) if (!options.proxy_address || !options.proxy_port)
{ {
@ -246,8 +260,9 @@ twc_profile_load(struct t_twc_profile *profile)
else else
{ {
weechat_printf(profile->buffer, weechat_printf(profile->buffer,
"%susing proxy %s:%d", "%susing %s proxy %s:%d",
weechat_prefix("network"), weechat_prefix("network"),
proxy_type,
options.proxy_address, options.proxy_port); options.proxy_address, options.proxy_port);
} }
} }

View File

@ -33,7 +33,7 @@ enum t_twc_profile_option
TWC_PROFILE_OPTION_MAX_FRIEND_REQUESTS, TWC_PROFILE_OPTION_MAX_FRIEND_REQUESTS,
TWC_PROFILE_OPTION_PROXY_ADDRESS, TWC_PROFILE_OPTION_PROXY_ADDRESS,
TWC_PROFILE_OPTION_PROXY_PORT, TWC_PROFILE_OPTION_PROXY_PORT,
TWC_PROFILE_OPTION_PROXY_ENABLED, TWC_PROFILE_OPTION_PROXY_TYPE,
TWC_PROFILE_OPTION_UDP, TWC_PROFILE_OPTION_UDP,
TWC_PROFILE_OPTION_IPV6, TWC_PROFILE_OPTION_IPV6,