E-MailRelay
gsocks.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 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
30namespace GNet
31{
32 class Socks ;
33}
34
35//| \class GNet::Socks
36/// Implements the SOCKS4a proxy connection protocol.
37///
39{
40public:
41 G_EXCEPTION( SocksError , tx("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
58private:
59 std::size_t m_request_offset {0U} ;
60 std::string m_request ;
61 std::string m_response ;
62} ;
63
64#endif
A class that represents the remote target for out-going client connections.
Definition: glocation.h:70
Implements the SOCKS4a proxy connection protocol.
Definition: gsocks.h:39
bool send(G::ReadWrite &)
Sends the connect-request pdu using the given file descriptor.
Definition: gsocks.cpp:64
bool read(G::ReadWrite &)
Reads the response using the given file descriptor.
Definition: gsocks.cpp:90
Socks(const Location &)
Constructor.
Definition: gsocks.cpp:27
static std::string buildPdu(const std::string &far_host, unsigned int far_port)
Builds a SOCKS4a connect request pdu.
Definition: gsocks.cpp:39
An abstract interface for reading and writing from a non-blocking i/o channel.
Definition: greadwrite.h:50
Network classes.
Definition: gdef.h:1243
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Definition: ggettext.h:84