|
|
@ -246,6 +246,9 @@ namespace proxy |
|
|
|
size = 7 + addr.dns.size; |
|
|
|
size = 7 + addr.dns.size; |
|
|
|
m_response[4] = addr.dns.size; |
|
|
|
m_response[4] = addr.dns.size; |
|
|
|
memcpy(m_response + 5, addr.dns.value, 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; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
htobe16buf(m_response + size - 2, port); //Port
|
|
|
|
htobe16buf(m_response + size - 2, port); //Port
|
|
|
@ -291,15 +294,13 @@ namespace proxy |
|
|
|
if (m_authchosen == AUTH_UNACCEPTABLE) |
|
|
|
if (m_authchosen == AUTH_UNACCEPTABLE) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint(eLogWarning, "SOCKS: v5 authentication negotiation failed"); |
|
|
|
LogPrint(eLogWarning, "SOCKS: v5 authentication negotiation failed"); |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed, |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed, shared_from_this(), std::placeholders::_1)); |
|
|
|
shared_from_this(), std::placeholders::_1)); |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint(eLogDebug, "SOCKS: v5 choosing authentication method: ", m_authchosen); |
|
|
|
LogPrint(eLogDebug, "SOCKS: v5 choosing authentication method: ", m_authchosen); |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse, |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse, shared_from_this(), std::placeholders::_1)); |
|
|
|
shared_from_this(), std::placeholders::_1)); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -343,8 +344,7 @@ namespace proxy |
|
|
|
response = GenerateSOCKS5Response(SOCKS5_OK, ADDR_DNS, ad, m_stream->GetRecvStreamID()); |
|
|
|
response = GenerateSOCKS5Response(SOCKS5_OK, ADDR_DNS, ad, m_stream->GetRecvStreamID()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksDone, |
|
|
|
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksDone, shared_from_this(), std::placeholders::_1)); |
|
|
|
shared_from_this(), std::placeholders::_1)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SOCKSHandler::EnterState(SOCKSHandler::state nstate, uint8_t parseleft) { |
|
|
|
void SOCKSHandler::EnterState(SOCKSHandler::state nstate, uint8_t parseleft) { |
|
|
@ -735,8 +735,7 @@ namespace proxy |
|
|
|
LogPrint(eLogInfo, "SOCKS: negotiating with upstream proxy"); |
|
|
|
LogPrint(eLogInfo, "SOCKS: negotiating with upstream proxy"); |
|
|
|
EnterState(UPSTREAM_HANDSHAKE); |
|
|
|
EnterState(UPSTREAM_HANDSHAKE); |
|
|
|
if (m_upstreamSock) { |
|
|
|
if (m_upstreamSock) { |
|
|
|
boost::asio::write(*m_upstreamSock, |
|
|
|
boost::asio::write(*m_upstreamSock, GenerateUpstreamRequest()); |
|
|
|
GenerateUpstreamRequest()); |
|
|
|
|
|
|
|
AsyncUpstreamSockRead(); |
|
|
|
AsyncUpstreamSockRead(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
LogPrint(eLogError, "SOCKS: no upstream socket to send handshake to"); |
|
|
|
LogPrint(eLogError, "SOCKS: no upstream socket to send handshake to"); |
|
|
|