mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
[SOCKS] wrap DNS type requests response as IPv4 (fixes netcat usage, closes #1336)
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
627d8cfe69
commit
7133a07f38
1 changed files with 34 additions and 35 deletions
|
@ -246,6 +246,9 @@ namespace proxy
|
|||
size = 7 + addr.dns.size;
|
||||
m_response[4] = addr.dns.size;
|
||||
memcpy(m_response + 5, addr.dns.value, addr.dns.size);
|
||||
// replace type to IPv4 for support socks5 clients
|
||||
// without domain name resolving support (like netcat)
|
||||
m_response[3] = ADDR_IPV4;
|
||||
break;
|
||||
}
|
||||
htobe16buf(m_response + size - 2, port); //Port
|
||||
|
@ -291,15 +294,13 @@ namespace proxy
|
|||
if (m_authchosen == AUTH_UNACCEPTABLE)
|
||||
{
|
||||
LogPrint(eLogWarning, "SOCKS: v5 authentication negotiation failed");
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed,
|
||||
shared_from_this(), std::placeholders::_1));
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed, shared_from_this(), std::placeholders::_1));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint(eLogDebug, "SOCKS: v5 choosing authentication method: ", m_authchosen);
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse,
|
||||
shared_from_this(), std::placeholders::_1));
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse, shared_from_this(), std::placeholders::_1));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -343,8 +344,7 @@ namespace proxy
|
|||
response = GenerateSOCKS5Response(SOCKS5_OK, ADDR_DNS, ad, m_stream->GetRecvStreamID());
|
||||
break;
|
||||
}
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksDone,
|
||||
shared_from_this(), std::placeholders::_1));
|
||||
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksDone, shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
void SOCKSHandler::EnterState(SOCKSHandler::state nstate, uint8_t parseleft) {
|
||||
|
@ -735,8 +735,7 @@ namespace proxy
|
|||
LogPrint(eLogInfo, "SOCKS: negotiating with upstream proxy");
|
||||
EnterState(UPSTREAM_HANDSHAKE);
|
||||
if (m_upstreamSock) {
|
||||
boost::asio::write(*m_upstreamSock,
|
||||
GenerateUpstreamRequest());
|
||||
boost::asio::write(*m_upstreamSock, GenerateUpstreamRequest());
|
||||
AsyncUpstreamSockRead();
|
||||
} else {
|
||||
LogPrint(eLogError, "SOCKS: no upstream socket to send handshake to");
|
||||
|
|
Loading…
Add table
Reference in a new issue