diff --git a/SOCKS.cpp b/SOCKS.cpp index e9c483c4..03b60f52 100644 --- a/SOCKS.cpp +++ b/SOCKS.cpp @@ -4,17 +4,12 @@ #include "Destination.h" #include "ClientContext.h" #include "I2PEndian.h" -#include #include -#include namespace i2p { namespace proxy { - const uint8_t socks_leaseset_timeout = 10; - const uint8_t socks_timeout = 60; - void SOCKSHandler::AsyncSockRead() { LogPrint(eLogDebug,"--- SOCKS async sock read"); @@ -129,10 +124,6 @@ namespace proxy } } - const size_t socks_hostname_size = 1024; - const size_t socks_ident_size = 1024; - const size_t destb32_len = 52; - std::size_t SOCKSHandler::HandleData(uint8_t *sock_buff, std::size_t len) { assert(len); // This should always be called with a least a byte left to parse @@ -228,7 +219,7 @@ namespace proxy m_need_more = false; return rv; } - if (m_destination.size() > HOST_NAME_MAX) { + if (m_destination.size() > max_socks_hostname_size) { LogPrint(eLogError,"--- SOCKS4a destination is too large "); SocksRequestFailed(); return 0; diff --git a/SOCKS.h b/SOCKS.h index e9b69f3b..e0cae1a4 100644 --- a/SOCKS.h +++ b/SOCKS.h @@ -1,33 +1,20 @@ -#ifndef SOCKS4A_H__ -#define SOCKS4A_H__ +#ifndef SOCKS_H__ +#define SOCKS_H__ -#include #include +#include #include #include "Identity.h" #include "Streaming.h" #include "I2PTunnel.h" -#ifdef MAC_OSX - /* - * - MAXHOSTNAMELEN from - * on MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, - * IRIX 6.5, OSF/1 5.1, Interix 3.5, Haiku, - * - MAXHOSTNAMELEN from - * on Solaris 10, Cygwin, BeOS, - * - 256 on mingw. - * - * */ -#include -#define HOST_NAME_MAX MAXHOSTNAMELEN -#endif - namespace i2p { namespace proxy { const size_t socks_buffer_size = 8192; + const size_t max_socks_hostname_size = 255; // Limit for socks5 and bad idea to traverse class SOCKSServer; class SOCKSHandler { @@ -128,7 +115,7 @@ namespace proxy SOCKSHandler(SOCKSServer * parent, boost::asio::ip::tcp::socket * sock) : m_parent(parent), m_sock(sock), m_stream(nullptr), m_state(GET_VERSION), m_authchosen(0xff), m_addrtype(0x01), m_error(0x01) - { AsyncSockRead(); m_destination.reserve(HOST_NAME_MAX+1); } + { AsyncSockRead(); m_destination.reserve(max_socks_hostname_size+1); } ~SOCKSHandler() { CloseSock(); CloseStream(); } };