tpws: deny connections to 0.0.0.0

This commit is contained in:
bol-van 2022-04-21 13:41:43 +03:00
parent dd1ba8218d
commit a15de18b33
13 changed files with 4 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -155,8 +155,9 @@ bool saconvmapped(struct sockaddr_storage *a)
bool is_localnet(const struct sockaddr *a)
{
return a->sa_family==AF_INET && *(char*)&((struct sockaddr_in *)a)->sin_addr.s_addr==127 ||
a->sa_family==AF_INET6 && saismapped((struct sockaddr_in6 *)a) && ((struct sockaddr_in6 *)a)->sin6_addr.s6_addr[12]==127;
// 0.0.0.0, ::ffff:0.0.0.0 = localhost in linux
return a->sa_family==AF_INET && (*(char*)&((struct sockaddr_in *)a)->sin_addr.s_addr==127 || !((struct sockaddr_in *)a)->sin_addr.s_addr) ||
a->sa_family==AF_INET6 && saismapped((struct sockaddr_in6 *)a) && (((struct sockaddr_in6 *)a)->sin6_addr.s6_addr[12]==127 || !*(uint32_t*)(((struct sockaddr_in6 *)a)->sin6_addr.s6_addr+12));
}
bool is_linklocal(const struct sockaddr_in6 *a)
{

View File

@ -842,7 +842,7 @@ static bool handle_proxy_mode(tproxy_conn_t *conn, struct tailhead *conn_list)
}
if (params.debug>=2)
{
printf("socks5 hostname resolved to : \n");
printf("socks5 hostname resolved to :\n");
print_addrinfo(ai);
}
memcpy(&ss,ai->ai_addr,ai->ai_addrlen);