Mercurial > hg > nnchat
comparison main.c @ 638:bda973fa2b3b
Add proxy disable/enable setting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Jun 2014 09:33:05 +0300 |
parents | 6273c4ea6e51 |
children | 02e1307e2a62 |
comparison
equal
deleted
inserted
replaced
637:8c6b8cd42f62 | 638:bda973fa2b3b |
---|---|
76 *optLogExtension = ".log", | 76 *optLogExtension = ".log", |
77 *optSite = "NN", | 77 *optSite = "NN", |
78 *optNickSepStr = NULL; | 78 *optNickSepStr = NULL; |
79 char optNickSep; | 79 char optNickSep; |
80 BOOL optDaemon = FALSE, | 80 BOOL optDaemon = FALSE, |
81 optProxyEnable = FALSE, | |
81 setIgnoreMode = FALSE, | 82 setIgnoreMode = FALSE, |
82 optDebug = FALSE, | 83 optDebug = FALSE, |
83 optLogEnable = FALSE, | 84 optLogEnable = FALSE, |
84 optLogDaily = FALSE, | 85 optLogDaily = FALSE, |
85 optOnlyFriendPrv = FALSE; | 86 optOnlyFriendPrv = FALSE; |
140 "\n" | 141 "\n" |
141 "Supported proxy types are SOCKS 4/4A and SOCKS 5.\n" | 142 "Supported proxy types are SOCKS 4/4A and SOCKS 5.\n" |
142 "(Only user/pass auth and no auth supported, no GSSAPI!)\n" | 143 "(Only user/pass auth and no auth supported, no GSSAPI!)\n" |
143 "These can be set with the -P option as follows:\n" | 144 "These can be set with the -P option as follows:\n" |
144 "\n" | 145 "\n" |
146 " -P disable (to disable proxy use)\n" | |
145 " -P <type>://[<userid>[:passwd]@]<host>[:<port>]\n" | 147 " -P <type>://[<userid>[:passwd]@]<host>[:<port>]\n" |
146 " -P socks4://localhost:9000\n" | 148 " -P socks4://localhost:9000\n" |
147 " -P socks5://foobar:pass@localhost\n" | 149 " -P socks5://foobar:pass@localhost\n" |
148 "\n" | 150 "\n" |
149 "Type can be socks4, socks4a or socks5. Only socks5\n" | 151 "Type can be socks4, socks4a or socks5. Only socks5\n" |
191 BOOL ret = FALSE; | 193 BOOL ret = FALSE; |
192 char *proto = NULL, *rest = NULL, *host = NULL, | 194 char *proto = NULL, *rest = NULL, *host = NULL, |
193 *auth = NULL, *port = NULL; | 195 *auth = NULL, *port = NULL; |
194 size_t len; | 196 size_t len; |
195 | 197 |
198 optProxyEnable = FALSE; | |
199 | |
200 // Handle disable case | |
201 if (strncasecmp(uri, "disab", 5) == 0) | |
202 return TRUE; | |
203 | |
204 // Split the URI | |
196 if (!argSplitStr(uri, "://", &proto, &rest)) | 205 if (!argSplitStr(uri, "://", &proto, &rest)) |
197 { | 206 { |
198 THERR("Malformed proxy URI, should be <type>://[<userid>[:passwd]@]<host>[:<port>]\n"); | 207 THERR("Malformed proxy URI, should be <type>://[<userid>[:passwd]@]<host>[:<port>]\n"); |
199 goto out; | 208 goto out; |
200 } | 209 } |
253 optProxyUserID != NULL && optProxyPassword != NULL) | 262 optProxyUserID != NULL && optProxyPassword != NULL) |
254 optProxyAuthType = TH_PROXY_AUTH_USER; | 263 optProxyAuthType = TH_PROXY_AUTH_USER; |
255 else | 264 else |
256 optProxyAuthType = TH_PROXY_AUTH_NONE; | 265 optProxyAuthType = TH_PROXY_AUTH_NONE; |
257 | 266 |
267 optProxyEnable = TRUE; | |
258 ret = TRUE; | 268 ret = TRUE; |
259 | 269 |
260 out: | 270 out: |
261 th_free(proto); | 271 th_free(proto); |
262 th_free(rest); | 272 th_free(rest); |
2033 th_cfg_add_comment(&tmpcfg, "Default port to connect"); | 2043 th_cfg_add_comment(&tmpcfg, "Default port to connect"); |
2034 th_cfg_add_int(&tmpcfg, "port", &optPort, optPort); | 2044 th_cfg_add_int(&tmpcfg, "port", &optPort, optPort); |
2035 th_cfg_add_section(&cfg, "server", tmpcfg); | 2045 th_cfg_add_section(&cfg, "server", tmpcfg); |
2036 | 2046 |
2037 tmpcfg = NULL; | 2047 tmpcfg = NULL; |
2048 th_cfg_add_comment(&tmpcfg, "Enable proxy"); | |
2049 th_cfg_add_bool(&tmpcfg, "enable", &optProxyEnable, optProxyEnable); | |
2038 th_cfg_add_comment(&tmpcfg, "Proxy URI (see comandline help for more information)"); | 2050 th_cfg_add_comment(&tmpcfg, "Proxy URI (see comandline help for more information)"); |
2039 th_cfg_add_string(&tmpcfg, "uri", &setProxyURI, NULL); | 2051 th_cfg_add_string(&tmpcfg, "uri", &setProxyURI, NULL); |
2040 th_cfg_add_section(&cfg, "proxy", tmpcfg); | 2052 th_cfg_add_section(&cfg, "proxy", tmpcfg); |
2041 | 2053 |
2042 | 2054 |
2225 } | 2237 } |
2226 | 2238 |
2227 editState.conn = conn; | 2239 editState.conn = conn; |
2228 | 2240 |
2229 // Are we using a proxy? | 2241 // Are we using a proxy? |
2230 if (optProxyType != TH_PROXY_NONE && optProxyServer != NULL) | 2242 if (optProxyEnable && optProxyType != TH_PROXY_NONE && optProxyServer != NULL) |
2231 { | 2243 { |
2232 if (optProxyUserID == NULL) | 2244 if (optProxyUserID == NULL) |
2233 optProxyUserID = "James Bond"; | 2245 optProxyUserID = "James Bond"; |
2234 | 2246 |
2235 if (th_conn_set_proxy(conn, optProxyType, optProxyPort, optProxyServer, optProxyAuthType) != THERR_OK || | 2247 if (th_conn_set_proxy(conn, optProxyType, optProxyPort, optProxyServer, optProxyAuthType) != THERR_OK || |