-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCDNConnection.h
More file actions
55 lines (44 loc) · 1.33 KB
/
CDNConnection.h
File metadata and controls
55 lines (44 loc) · 1.33 KB
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
#ifndef _CDNCONNECTION_H_
#define _CDNCONNECTION_H_
#include "HLSProxy.h"
#include "mbedtls/net.h"
#include "mbedtls/ssl.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/debug.h"
class CDNConnection
{
public:
CDNConnection();
virtual ~CDNConnection();
virtual void connect(std::string host, uint32_t port);
virtual void send(char * data, size_t data_size);
virtual size_t read_next_chunk(DataBuffer * buffer);
virtual void close();
protected:
SOCKET _socket;
int _CHUNK_SIZE_;
int _RECVBUF_SIZE;
int _SENDBUF_SIZE;
std::string _hostname;
};
class CDNConnectionSSL : public CDNConnection
{
public:
CDNConnectionSSL();
virtual ~CDNConnectionSSL();
virtual void connect(std::string host, uint32_t port);
virtual void send(char * data, size_t data_size);
virtual size_t read_next_chunk(DataBuffer * buffer);
virtual void close();
protected:
mbedtls_entropy_context _entropy;
mbedtls_ctr_drbg_context _ctr_drbg;
mbedtls_ssl_context _ssl;
mbedtls_ssl_config _conf;
mbedtls_x509_crt _cacert;
bool _ssl_context_valid;
static int _ssl_send_(void *ctx, const unsigned char *buf, size_t len);
static int _ssl_recv_(void *ctx, unsigned char *buf, size_t len);
};
#endif