forked from uroni/urbackup_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSChannelPipe.h
78 lines (52 loc) · 1.8 KB
/
SChannelPipe.h
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
74
75
76
77
78
#pragma once
#include "Interface/Pipe.h"
#include "StreamPipe.h"
#define SECURITY_WIN32
#include <Windows.h>
#include <security.h>
class SChannelPipe : public IPipe
{
public:
SChannelPipe(CStreamPipe* bpipe);
~SChannelPipe();
bool ssl_connect(const std::string& p_hostname, int timeoutms);
static void init();
// Inherited via IPipe
virtual size_t Read(char * buffer, size_t bsize, int timeoutms = -1);
virtual bool Write(const char * buffer, size_t bsize, int timeoutms = -1, bool flush = true);
virtual size_t Read(std::string * ret, int timeoutms = -1);
virtual bool Write(const std::string & str, int timeoutms = -1, bool flush = true);
virtual bool Flush(int timeoutms = -1);
virtual bool isWritable(int timeoutms = 0);
virtual bool isReadable(int timeoutms = 0);
virtual bool hasError(void);
virtual void shutdown(void);
virtual size_t getNumWaiters();
virtual size_t getNumElements(void);
virtual void addThrottler(IPipeThrottler * throttler);
virtual void addOutgoingThrottler(IPipeThrottler * throttler);
virtual void addIncomingThrottler(IPipeThrottler * throttler);
virtual _i64 getTransferedBytes(void);
virtual void resetTransferedBytes(void);
private:
bool ssl_connect_negotiate(int timeoutms, bool do_read);
CStreamPipe* bpipe;
static PSecurityFunctionTableW sec;
bool has_cred_handle;
CredHandle cred_handle;
TimeStamp time_stamp;
bool has_ctxt_handle;
CtxtHandle ctxt_handle;
std::vector<char> encbuf;
size_t encbuf_pos;
std::vector<char> decbuf;
size_t decbuf_pos;
std::vector<char> sendbuf;
size_t sendbuf_pos;
std::string hostname;
int64 last_flush_time;
std::vector<char> header_buf;
std::vector<char> trailer_buf;
bool has_error;
SecPkgContext_StreamSizes stream_sizes;
};