mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
Clean up SOCKS a bit
This commit is contained in:
parent
c9576dcdbe
commit
17ccaab792
11
SOCKS.cpp
11
SOCKS.cpp
@ -4,17 +4,12 @@
|
||||
#include "Destination.h"
|
||||
#include "ClientContext.h"
|
||||
#include "I2PEndian.h"
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
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;
|
||||
|
23
SOCKS.h
23
SOCKS.h
@ -1,33 +1,20 @@
|
||||
#ifndef SOCKS4A_H__
|
||||
#define SOCKS4A_H__
|
||||
#ifndef SOCKS_H__
|
||||
#define SOCKS_H__
|
||||
|
||||
#include <climits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/asio.hpp>
|
||||
#include "Identity.h"
|
||||
#include "Streaming.h"
|
||||
#include "I2PTunnel.h"
|
||||
|
||||
#ifdef MAC_OSX
|
||||
/*
|
||||
* - MAXHOSTNAMELEN from <sys/param.h>
|
||||
* 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 <netdb.h>
|
||||
* on Solaris 10, Cygwin, BeOS,
|
||||
* - 256 on mingw.
|
||||
*
|
||||
* */
|
||||
#include <sys/param.h>
|
||||
#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(); }
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user