+/* *************************************************************************
+ * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
+ * *************************************************************************/
+ case hash_forward_socks4:
+ vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
+
+ if (vec_count != 3)
+ {
+ log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
+ "forward-socks4 directive in configuration file.");
+ string_append(&config->proxy_args,
+ "<br>\nWARNING: Wrong number of parameters for "
+ "forward-socks4 directive in configuration file.");
+ continue;
+ }
+
+ /* allocate a new node */
+ cur_fwd = zalloc(sizeof(*cur_fwd));
+ if (cur_fwd == NULL)
+ {
+ log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
+ continue;
+ }
+
+ cur_fwd->type = SOCKS_4;
+
+ /* Save the URL pattern */
+ if (create_url_spec(cur_fwd->url, vec[0]))
+ {
+ log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
+ "directive in configuration file.");
+ string_append(&config->proxy_args,
+ "<br>\nWARNING: Bad URL specifier for "
+ "forward-socks4 directive in configuration file.");
+ continue;
+ }
+
+ /* Parse the SOCKS proxy host[:port] */
+ p = vec[1];
+
+ if (strcmp(p, ".") != 0)
+ {
+ cur_fwd->gateway_host = strdup(p);
+
+ if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
+ {
+ *p++ = '\0';
+ cur_fwd->gateway_port = atoi(p);
+ }
+ if (cur_fwd->gateway_port <= 0)
+ {
+ cur_fwd->gateway_port = 1080;
+ }
+ }
+
+ /* Parse the parent HTTP proxy host[:port] */
+ p = vec[2];
+
+ if (strcmp(p, ".") != 0)
+ {
+ cur_fwd->forward_host = strdup(p);
+
+ if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
+ {
+ *p++ = '\0';
+ cur_fwd->forward_port = atoi(p);
+ }
+
+ if (cur_fwd->forward_port <= 0)
+ {
+ cur_fwd->forward_port = 8000;
+ }
+ }
+
+ /* Add to list. */
+ cur_fwd->next = config->forward;
+ config->forward = cur_fwd;
+
+ continue;
+
+/* *************************************************************************
+ * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
+ * *************************************************************************/
+ case hash_forward_socks4a:
+ vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
+
+ if (vec_count != 3)
+ {
+ log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
+ "forward-socks4a directive in configuration file.");
+ string_append(&config->proxy_args,
+ "<br>\nWARNING: Wrong number of parameters for "
+ "forward-socks4a directive in configuration file.");
+ continue;
+ }
+
+ /* allocate a new node */
+ cur_fwd = zalloc(sizeof(*cur_fwd));
+ if (cur_fwd == NULL)
+ {
+ log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
+ /* Never get here - LOG_LEVEL_FATAL causes program exit */
+ continue;
+ }
+
+ cur_fwd->type = SOCKS_4A;
+
+ /* Save the URL pattern */
+ if (create_url_spec(cur_fwd->url, vec[0]))
+ {
+ log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
+ "directive in configuration file.");
+ string_append(&config->proxy_args,
+ "<br>\nWARNING: Bad URL specifier for "
+ "forward-socks4a directive in configuration file.");
+ continue;
+ }
+
+ /* Parse the SOCKS proxy host[:port] */
+ p = vec[1];
+
+ cur_fwd->gateway_host = strdup(p);
+
+ if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
+ {
+ *p++ = '\0';
+ cur_fwd->gateway_port = atoi(p);
+ }
+ if (cur_fwd->gateway_port <= 0)
+ {
+ cur_fwd->gateway_port = 1080;
+ }
+
+ /* Parse the parent HTTP proxy host[:port] */
+ p = vec[2];
+
+ if (strcmp(p, ".") != 0)
+ {
+ cur_fwd->forward_host = strdup(p);
+
+ if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
+ {
+ *p++ = '\0';
+ cur_fwd->forward_port = atoi(p);
+ }
+
+ if (cur_fwd->forward_port <= 0)
+ {
+ cur_fwd->forward_port = 8000;
+ }
+ }
+
+ /* Add to list. */
+ cur_fwd->next = config->forward;
+ config->forward = cur_fwd;
+