--- tinyproxy-1.9.0/src/transparent-proxy.c 2017-05-05 14:07:12.242902301 +1000 +++ tinyproxy-1.9.0-p1/src/transparent-proxy.c 2017-05-05 16:23:12.707980943 +1000 @@ -32,6 +32,12 @@ #include "text.h" #include "conf.h" +# if defined(__linux__) +/* +// The only place SO_ORIGINAL_DST (80) is defined as addendum by Rusty R. +*/ +# include +# endif /* * Build a URL from parts. */ @@ -65,10 +71,14 @@ length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data); if (length <= 0) { struct sockaddr_in dest_addr; - +# if defined(__linux__) + length = sizeof (dest_addr); /* This is needed!! */ + if (getsockopt (connptr->client_fd, SOL_IP, SO_ORIGINAL_DST, (char *)&dest_addr, &length) < 0) { +# else if (getsockname (connptr->client_fd, (struct sockaddr *) &dest_addr, &length) < 0) { +# endif log_message (LOG_ERR, "process_request: cannot get destination IP for %d", connptr->client_fd);