- char *p = socks_proxy;
- fwd->gateway_host = strdup(socks_proxy);
-
- if ((*fwd->gateway_host == '[')
- && (NULL != (p = strchr(fwd->gateway_host, ']'))))
- {
- *p++ = '\0';
- memmove(fwd->gateway_host, fwd->gateway_host + 1,
- (size_t)(p - fwd->gateway_host));
- if (*p == ':')
- {
- fwd->gateway_port = (int)strtol(++p, NULL, 0);
- }
- }
- else if (NULL != (p = strchr(fwd->gateway_host, ':')))
- {
- *p++ = '\0';
- fwd->gateway_port = (int)strtol(p, 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);