tpws: check for sock4a protocol

This commit is contained in:
bol-van 2022-04-21 09:42:06 +03:00
parent bdfeb96a81
commit dd1ba8218d
12 changed files with 10 additions and 4 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

@ -756,6 +756,12 @@ static bool handle_proxy_mode(tproxy_conn_t *conn, struct tailhead *conn_list)
socks4_send_rep(conn->fd, S4_REP_FAILED);
return false;
}
if (m->ip==htonl(1)) // special ip 0.0.0.1
{
VPRINT("socks4a protocol not supported")
socks4_send_rep(conn->fd, S4_REP_FAILED);
return false;
}
ss.ss_family = AF_INET;
((struct sockaddr_in*)&ss)->sin_port = m->port;
((struct sockaddr_in*)&ss)->sin_addr.s_addr = m->ip;
@ -810,14 +816,14 @@ static bool handle_proxy_mode(tproxy_conn_t *conn, struct tailhead *conn_list)
if (params.no_resolve)
{
DBGPRINT("socks5 hostname resolving disabled")
VPRINT("socks5 hostname resolving disabled")
socks5_send_rep(conn->fd,S5_REP_NOT_ALLOWED_BY_RULESET);
return false;
}
port=S5_PORT_FROM_DD(m,rd);
if (!port)
{
DBGPRINT("socks5 no port is given")
VPRINT("socks5 no port is given")
socks5_send_rep(conn->fd,S5_REP_HOST_UNREACHABLE);
return false;
}
@ -830,7 +836,7 @@ static bool handle_proxy_mode(tproxy_conn_t *conn, struct tailhead *conn_list)
r=getaddrinfo(sdom,sport,&hints,&ai);
if (r)
{
DBGPRINT("socks5 getaddrinfo error %d",r)
VPRINT("socks5 getaddrinfo error %d",r)
socks5_send_rep(conn->fd,S5_REP_HOST_UNREACHABLE);
return false;
}