E-MailRelay
gsocks.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 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 ///
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. Returns true if fully sent.
48 
49  bool read( G::ReadWrite & ) ;
50  ///< Reads the response. Returns true if fully received
51  ///< and positive. Throws if the response is negative.
52 
53 private:
54  Socks( const Socks & ) ;
55  void operator=( const Socks & ) ;
56  static std::string buildPdu( const std::string & , unsigned int ) ;
57 
58 private:
59  size_t m_request_offset ;
60  std::string m_request ;
61  std::string m_response ;
62 } ;
63 
64 #endif
An abstract interface for reading and writing from a non-blocking i/o channel.
Definition: greadwrite.h:49
Network classes.
Definition: gaddress.h:29
bool send(G::ReadWrite &)
Sends the connect-request pdu. Returns true if fully sent.
Definition: gsocks.cpp:63
bool read(G::ReadWrite &)
Reads the response.
Definition: gsocks.cpp:89
Implements the socks4a proxy connection protocol.
Definition: gsocks.h:38
Socks(const Location &)
Constructor.
Definition: gsocks.cpp:25
A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie.
Definition: glocation.h:50