blob: 94da4b27fcb10026dba608aeaacebf1a67b94f9e (
plain)
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
71
72
73
|
/*
* extendes sockets
*/
#ifndef _VDRMON_SOCK
#define _VDRMON_SOCK
#include <sys/types.h>
#include <sys/socket.h>
#include <string>
#include <openssl/ssl.h>
using namespace std;
class cVdrmanagerSocket
{
protected:
int sock;
const char * password;
bool forceCheckSvdrp;
bool useSSL;
protected:
cVdrmanagerSocket();
bool IsPasswordSet();
public:
virtual ~cVdrmanagerSocket();
void Close();
int GetSocket();
bool MakeDontBlock();
const char * GetPassword();
void LogSSLError();
};
class cVdrmanagerClientSocket : public cVdrmanagerSocket
{
private:
string readbuf;
string writebuf;
bool disconnected;
int client;
bool login;
SSL * sslContext;
public:
cVdrmanagerClientSocket(const char * password);
virtual ~cVdrmanagerClientSocket();
bool Attach(int fd);
bool IsLineComplete();
bool GetLine(string& line);
bool PutLine(string line);
bool Read();
bool Disconnected();
void Disconnect();
bool Flush();
int GetClientId();
bool WritePending();
bool IsLoggedIn();
void SetLoggedIn();
bool InitSSL(SSL_CTX * sslContext);
};
class cVdrmanagerServerSocket : public cVdrmanagerSocket
{
private:
SSL_CTX * sslContext;
public:
cVdrmanagerServerSocket();
virtual ~cVdrmanagerServerSocket();
bool Create(int port, const char * password, bool forceCheckSvdrp, bool useSSL, const char * pemFile);
cVdrmanagerClientSocket * Accept();
bool InitSSL(const char * pemFile);
};
#endif
|