changeset 638:bda973fa2b3b

Add proxy disable/enable setting.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Jun 2014 09:33:05 +0300
parents 8c6b8cd42f62
children 02e1307e2a62
files main.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Sun Jun 22 06:25:32 2014 +0300
+++ b/main.c	Wed Jun 25 09:33:05 2014 +0300
@@ -78,6 +78,7 @@
         *optNickSepStr = NULL;
 char    optNickSep;
 BOOL    optDaemon = FALSE,
+        optProxyEnable = FALSE,
         setIgnoreMode = FALSE,
         optDebug = FALSE,
         optLogEnable = FALSE,
@@ -142,6 +143,7 @@
     "(Only user/pass auth and no auth supported, no GSSAPI!)\n"
     "These can be set with the -P option as follows:\n"
     "\n"
+    " -P disable  (to disable proxy use)\n"
     " -P <type>://[<userid>[:passwd]@]<host>[:<port>]\n"
     " -P socks4://localhost:9000\n"
     " -P socks5://foobar:pass@localhost\n"
@@ -193,6 +195,13 @@
          *auth = NULL, *port = NULL;
     size_t len;
 
+    optProxyEnable = FALSE;
+
+    // Handle disable case
+    if (strncasecmp(uri, "disab", 5) == 0)
+        return TRUE;
+
+    // Split the URI
     if (!argSplitStr(uri, "://", &proto, &rest))
     {
         THERR("Malformed proxy URI, should be <type>://[<userid>[:passwd]@]<host>[:<port>]\n");
@@ -255,6 +264,7 @@
     else
         optProxyAuthType = TH_PROXY_AUTH_NONE;
 
+    optProxyEnable = TRUE;
     ret = TRUE;
 
 out:
@@ -2035,6 +2045,8 @@
     th_cfg_add_section(&cfg, "server", tmpcfg);
 
     tmpcfg = NULL;
+    th_cfg_add_comment(&tmpcfg, "Enable proxy");
+    th_cfg_add_bool(&tmpcfg, "enable", &optProxyEnable, optProxyEnable);
     th_cfg_add_comment(&tmpcfg, "Proxy URI (see comandline help for more information)");
     th_cfg_add_string(&tmpcfg, "uri", &setProxyURI, NULL);
     th_cfg_add_section(&cfg, "proxy", tmpcfg);
@@ -2227,7 +2239,7 @@
     editState.conn = conn;
 
     // Are we using a proxy?
-    if (optProxyType != TH_PROXY_NONE && optProxyServer != NULL)
+    if (optProxyEnable && optProxyType != TH_PROXY_NONE && optProxyServer != NULL)
     {
         if (optProxyUserID == NULL)
             optProxyUserID = "James Bond";