E-MailRelay

gsocks.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gsocks.h
19///
20
21#ifndef G_NET_SOCKS_H
22#define G_NET_SOCKS_H
23
24#include "gdef.h"
25#include "greadwrite.h"
26#include "glocation.h"
27#include "gexception.h"
28#include <string>
29
30 namespace GNet
31{
32 class Socks ;
33}
34
35//| \class GNet::Socks
36/// Implements the SOCKS4a proxy connection protocol.
37///
38 class GNet::Socks
39{
40 public:
41 G_EXCEPTION( SocksError , "socks error" ) ;
42
43 explicit Socks( const Location & ) ;
44 ///< Constructor.
45
46 bool send( G::ReadWrite & ) ;
47 ///< Sends the connect-request pdu using the given
48 ///< file descriptor. Returns true if fully sent.
49
50 bool read( G::ReadWrite & ) ;
51 ///< Reads the response using the given file descriptor.
52 ///< Returns true if fully received and positive.
53 ///< Throws if the response is negative.
54
55 static std::string buildPdu( const std::string & far_host , unsigned int far_port ) ;
56 ///< Builds a SOCKS4a connect request pdu.
57
58 private:
59 std::size_t m_request_offset ;
60 std::string m_request ;
61 std::string m_response ;
62} ;
63
64#endif
GNet::Location
A class that represents the remote target for out-going client connections.
Definition: glocation.h:71
GNet::Socks
Implements the SOCKS4a proxy connection protocol.
Definition: gsocks.h:39
GNet::Socks::send
bool send(G::ReadWrite &)
Sends the connect-request pdu using the given file descriptor.
Definition: gsocks.cpp:66
GNet::Socks::read
bool read(G::ReadWrite &)
Reads the response using the given file descriptor.
Definition: gsocks.cpp:92
GNet::Socks::Socks
Socks(const Location &)
Constructor.
Definition: gsocks.cpp:27
GNet::Socks::buildPdu
static std::string buildPdu(const std::string &far_host, unsigned int far_port)
Builds a SOCKS4a connect request pdu.
Definition: gsocks.cpp:41
G::ReadWrite
An abstract interface for reading and writing from a non-blocking i/o channel.
Definition: greadwrite.h:50
gexception.h
glocation.h
greadwrite.h
GNet
Network classes.
Definition: gdef.h:1115