1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <strings.h>
#include "licq_constants.h"
// proxy types
#define PROXY_TYPE_HTTP 1
typedef enum ProxyError_et_
{
PROXY_ERROR_none,
PROXY_ERROR_errno,
PROXY_ERROR_h_errno,
PROXY_ERROR_internal
} ProxyError_et;
//=====ProxyServer==============================================================
class ProxyServer
{
public:
ProxyServer();
virtual ~ProxyServer();
int Descriptor() { return (m_nDescriptor); }
int Error();
char *ErrorStr(char *buf, int buflen);
struct sockaddr_in *ProxyAddr() { return (&m_sProxyAddr); };
bool SetProxyAddr(const char *_szProxyName, unsigned short _nProxyPort);
void SetProxyAuth(const char *_szProxyLogin, const char *_szProxyPasswd);
virtual bool InitProxy() = 0;
bool OpenConnection();
void CloseConnection();
virtual bool OpenProxyConnection(const char *_szRemoteName, unsigned short _nRemotePort) = 0;
static unsigned long GetIpByName(const char *_szHostName);
protected:
int m_nDescriptor;
ProxyError_et m_nErrorType;
struct sockaddr_in m_sProxyAddr;
char *m_szProxyLogin, *m_szProxyPasswd;
};
//=====HTTPProxyServer==========================================================
class HTTPProxyServer : public ProxyServer
{
public:
HTTPProxyServer() : ProxyServer() { }
virtual ~HTTPProxyServer();
// Abstract base class overload
virtual bool InitProxy()
{ return HTTPInitProxy(); }
virtual bool OpenProxyConnection(const char *_szRemoteName, unsigned short _nRemotePort)
{ return HTTPOpenProxyConnection(_szRemoteName, _nRemotePort); }
// Functions specific to HTTP Proxy
bool HTTPInitProxy();
bool HTTPOpenProxyConnection(const char *_szRemoteName, unsigned short _nRemotePort);
};
|