- proxy.address = proxy_host;
- proxy_af = Ustrchr(proxy_host, ':') ? AF_INET6 : AF_INET;
-
- if ((fd = smtp_sock_connect(&proxy, proxy_af, sob.port,
- interface, tb, sob.timeout)) < 0)
- continue;
-
- /* Do the socks protocol stuff */
- /* Send method-selection */
- state = US"method select";
- HDEBUG(D_transport|D_acl|D_v) debug_printf(" SOCKS>> 05 01 %02x\n", sob.auth_type);
- buf[0] = 5; buf[1] = 1; buf[2] = sob.auth_type;
- if (send(fd, buf, 3, 0) < 0)
- goto snd_err;
-
- /* expect method response */
- if ( !fd_ready(fd, tmo-time(NULL))
- || read(fd, buf, 2) != 2
- )
- goto rcv_err;
- HDEBUG(D_transport|D_acl|D_v)
- debug_printf(" SOCKS<< %02x %02x\n", buf[0], buf[1]);
- if ( buf[0] != 5
- || socks_auth(fd, buf[1], &sob, tmo) != OK
- )
- goto proxy_err;
+ proxy.address = proxy.name = sob->proxy_host;
+ proxy_af = Ustrchr(sob->proxy_host, ':') ? AF_INET6 : AF_INET;
+
+ /*XXX we trust that the method-select command is idempotent */
+ if ((fd = smtp_sock_connect(&proxy, proxy_af, sob->port,
+ interface, tb, sob->timeout, &early_data)) >= 0)
+ {
+ proxy_local_address = string_copy(proxy.address);
+ proxy_local_port = sob->port;
+ break;
+ }
+
+ log_write(0, LOG_MAIN, "%s: %s", __FUNCTION__, strerror(errno));
+ sob->is_failed = TRUE;
+ }