|
|
|
@ -246,6 +246,9 @@ namespace proxy
@@ -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
@@ -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
@@ -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
@@ -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"); |
|
|
|
|