File: licq_proxy.h

package info (click to toggle)
licq 1.3.4-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 22,048 kB
  • ctags: 8,640
  • sloc: cpp: 76,924; sh: 9,845; ansic: 5,424; perl: 3,449; lex: 857; xml: 804; php: 691; makefile: 393; csh: 48
file content (70 lines) | stat: -rw-r--r-- 1,848 bytes parent folder | download | duplicates (3)
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);
};