diff --git a/src/twc-config.c b/src/twc-config.c index ddc3507..a620180 100644 --- a/src/twc-config.c +++ b/src/twc-config.c @@ -45,7 +45,7 @@ char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] = "max_friend_requests", "proxy_address", "proxy_port", - "proxy", + "proxy_type", "udp", "ipv6", }; @@ -57,7 +57,7 @@ char *twc_profile_option_defaults[TWC_PROFILE_NUM_OPTIONS] = "100", NULL, NULL, - "off", + "none", "on", "on", }; @@ -231,16 +231,17 @@ twc_config_init_option(struct t_config_section *section, type = "string"; description = "proxy address"; 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: type = "integer"; description = "proxy port"; min = 0; max = UINT16_MAX; 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: type = "string"; description = "path to Tox data file (\"%h\" will be replaced by " diff --git a/src/twc-config.h b/src/twc-config.h index 79fd8e2..6ff17c3 100644 --- a/src/twc-config.h +++ b/src/twc-config.h @@ -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_short_id_size; +enum t_twc_proxy +{ + TWC_PROXY_NONE = 0, + TWC_PROXY_SOCKS5, + TWC_PROXY_HTTP +}; + void twc_config_init(); diff --git a/src/twc-profile.c b/src/twc-profile.c index 2110384..831eda6 100644 --- a/src/twc-profile.c +++ b/src/twc-profile.c @@ -218,8 +218,22 @@ twc_profile_load(struct t_twc_profile *profile) // create Tox options object 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 = TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS); @@ -233,7 +247,7 @@ twc_profile_load(struct t_twc_profile *profile) options.ipv6enabled = 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) { @@ -246,8 +260,9 @@ twc_profile_load(struct t_twc_profile *profile) else { weechat_printf(profile->buffer, - "%susing proxy %s:%d", + "%susing %s proxy %s:%d", weechat_prefix("network"), + proxy_type, options.proxy_address, options.proxy_port); } } diff --git a/src/twc-profile.h b/src/twc-profile.h index 4c3ff4a..258cab9 100644 --- a/src/twc-profile.h +++ b/src/twc-profile.h @@ -33,7 +33,7 @@ enum t_twc_profile_option TWC_PROFILE_OPTION_MAX_FRIEND_REQUESTS, TWC_PROFILE_OPTION_PROXY_ADDRESS, TWC_PROFILE_OPTION_PROXY_PORT, - TWC_PROFILE_OPTION_PROXY_ENABLED, + TWC_PROFILE_OPTION_PROXY_TYPE, TWC_PROFILE_OPTION_UDP, TWC_PROFILE_OPTION_IPV6,