2
* socks.h - SOCKS5 TCP proxy client/server
3
* Copyright (C) 2003 Justin Karneges
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include"bytestream.h"
31
class SocksClient : public ByteStream
35
enum Error { ErrConnectionRefused = ErrCustom, ErrHostNotFound, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth };
36
enum Method { AuthNone=0x0001, AuthUsername=0x0002 };
37
SocksClient(QObject *parent=0);
38
SocksClient(int, QObject *parent=0);
41
bool isIncoming() const;
44
void setAuth(const QString &user, const QString &pass="");
45
void connectToHost(const QString &proxyHost, int proxyPort, const QString &host, int port);
48
void chooseMethod(int);
50
void requestGrant(bool);
55
void write(const QByteArray &);
56
QByteArray read(int bytes=0);
57
int bytesAvailable() const;
58
int bytesToWrite() const;
60
QHostAddress peerAddress() const;
61
Q_UINT16 peerPort() const;
68
void incomingMethods(int);
69
void incomingAuth(const QString &user, const QString &pass);
70
void incomingRequest(const QString &host, int port);
73
void sock_connected();
74
void sock_connectionClosed();
75
void sock_delayedCloseFinished();
76
void sock_readyRead();
77
void sock_bytesWritten(int);
86
void reset(bool clear=false);
88
void processOutgoing(const QByteArray &);
89
void processIncoming(const QByteArray &);
90
void continueIncoming();
91
void writeData(const QByteArray &a);
94
class SocksServer : public QObject
98
SocksServer(QObject *parent=0);
101
bool isActive() const;
102
bool listen(Q_UINT16 port);
105
QHostAddress address() const;
106
SocksClient *takeIncoming();
109
void incomingReady();
112
void connectionReady(int);
113
void connectionError();