mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-25 10:32:18 -05:00
When transparent, make sure both connections use the same address family
This commit is contained in:
parent
dedb3672d7
commit
7d23a55236
13
common.c
13
common.c
@ -139,11 +139,22 @@ int bind_peer(int fd, int fd_from)
|
|||||||
* of new file descriptor. */
|
* of new file descriptor. */
|
||||||
int connect_addr(struct connection *cnx, int fd_from)
|
int connect_addr(struct connection *cnx, int fd_from)
|
||||||
{
|
{
|
||||||
struct addrinfo *a;
|
struct addrinfo *a, from;
|
||||||
|
struct sockaddr_storage ss;
|
||||||
char buf[NI_MAXHOST];
|
char buf[NI_MAXHOST];
|
||||||
int fd, res;
|
int fd, res;
|
||||||
|
|
||||||
|
memset(&from, 0, sizeof(from));
|
||||||
|
from.ai_addr = (struct sockaddr*)&ss;
|
||||||
|
from.ai_addrlen = sizeof(ss);
|
||||||
|
|
||||||
|
res = getpeername(fd_from, from.ai_addr, &from.ai_addrlen);
|
||||||
|
CHECK_RES_RETURN(res, "getpeername");
|
||||||
|
|
||||||
for (a = cnx->proto->saddr; a; a = a->ai_next) {
|
for (a = cnx->proto->saddr; a; a = a->ai_next) {
|
||||||
|
/* When transparent, make sure both connections use the same address family */
|
||||||
|
if (transparent && a->ai_family != from.ai_addr->sa_family)
|
||||||
|
continue;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "connecting to %s family %d len %d\n",
|
fprintf(stderr, "connecting to %s family %d len %d\n",
|
||||||
sprintaddr(buf, sizeof(buf), a),
|
sprintaddr(buf, sizeof(buf), a),
|
||||||
|
Loading…
Reference in New Issue
Block a user