Add and use parse_forwarder_address() to reduce code duplication.
[privoxy.git] / filters.c
index 9758e1e..602bb0b 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -1,4 +1,4 @@
-const char filters_rcs[] = "$Id: filters.c,v 1.116 2009/04/17 11:34:34 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.118 2009/04/17 11:37:03 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/filters.c,v $
@@ -40,6 +40,12 @@ const char filters_rcs[] = "$Id: filters.c,v 1.116 2009/04/17 11:34:34 fabiankei
  *
  * Revisions   :
  *    $Log: filters.c,v $
+ *    Revision 1.118  2009/04/17 11:37:03  fabiankeil
+ *    Allow IPv6 addresses in forward-override{}.
+ *
+ *    Revision 1.117  2009/04/17 11:35:28  fabiankeil
+ *    Fix compiler warning.
+ *
  *    Revision 1.116  2009/04/17 11:34:34  fabiankeil
  *    Style cosmetics for the IPv6 code.
  *
@@ -2802,18 +2808,9 @@ const static struct forward_spec *get_forward_override_settings(struct client_st
       if (NULL != socks_proxy)
       {
          /* Parse the SOCKS proxy host[:port] */
-         fwd->gateway_host = strdup(socks_proxy);
-
-         if (NULL != (socks_proxy = strchr(fwd->gateway_host, ':')))
-         {
-            *socks_proxy++ = '\0';
-            fwd->gateway_port = (int)strtol(socks_proxy, NULL, 0);
-         }
-
-         if (fwd->gateway_port <= 0)
-         {
-            fwd->gateway_port = 1080;
-         }
+         fwd->gateway_port = 1080;
+         parse_forwarder_address(socks_proxy,
+            &fwd->gateway_host, &fwd->gateway_port);
 
          http_parent = vec[2];
       }
@@ -2829,18 +2826,9 @@ const static struct forward_spec *get_forward_override_settings(struct client_st
    /* Parse http forwarding settings */
    if (strcmp(http_parent, ".") != 0)
    {
-      fwd->forward_host = strdup(http_parent);
-
-      if (NULL != (http_parent = strchr(fwd->forward_host, ':')))
-      {
-         *http_parent++ = '\0';
-         fwd->forward_port = (int)strtol(http_parent, NULL, 0);
-      }
-
-      if (fwd->forward_port <= 0)
-      {
-         fwd->forward_port = 8000;
-      }
+      fwd->forward_port = 8000;
+      parse_forwarder_address(http_parent,
+         &fwd->forward_host, &fwd->forward_port);
    }
 
    assert (NULL != fwd);