diff -Naur stunnel-4.18/src/client.c stunnel-4.18-extra-logging/src/client.c --- stunnel-4.18/src/client.c 2006-08-23 11:35:32.000000000 +0200 +++ stunnel-4.18-extra-logging/src/client.c 2006-10-05 10:20:03.672581056 +0200 @@ -928,6 +928,18 @@ } #endif +void connect_log_source(int s) { + struct sockaddr_in cliaddr; + socklen_t cliaddrlen = sizeof(struct sockaddr_in); + + memset(&cliaddr, 0, sizeof(cliaddr)); + if (getsockname(s, (struct sockaddr *) &cliaddr, &cliaddrlen)) { + sockerror("getsockname() error"); + } else { + s_log(LOG_NOTICE,"connected to backend from %s:%d", inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); + } +} + static int connect_remote(CLI *c) { /* connect to remote host */ SOCKADDR_UNION bind_addr, addr; SOCKADDR_LIST resolved_list, *address_list; @@ -975,6 +987,7 @@ if(!connect(c->fd, &addr.sa, addr_len(addr))) { fd=c->fd; c->fd=-1; + connect_log_source(fd); return fd; /* no error -> success (should not be possible) */ } error=get_last_socket_error(); @@ -989,6 +1002,7 @@ longjmp(c->err, 1); fd=c->fd; c->fd=-1; + connect_log_source(fd); return fd; /* success! */ } longjmp(c->err, 1);