-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtls.c
More file actions
54 lines (48 loc) · 1.1 KB
/
Copy pathtls.c
File metadata and controls
54 lines (48 loc) · 1.1 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
#include "tls.h"
#include "utils.h"
typedef struct TlsSock {
uint32_t idx;
uint32_t rawSock;
uintptr_t ssl;
struct TlsSock*next;
} TlsSock;
bool tlsReady = false;
TlsSock*socks = NULL;
void tlsInit(void) {
}
void tlsHandleSocks(void) {
return; // wip
}
/*
uint32_t tlsRawOpen(c*host, uint16_t p, TlsSock*alloc) {
alloc->rawSock = netOpen(host,p);
alloc->open = true;
alloc->state = malloc(sizeof(TlsState));
alloc->state->serverKey = NULL;
alloc->state->sentHello = false;
return alloc->idx;
}
uint32_t tlsOpen(c*host, uint16_t p) {
TlsSock*prev = NULL;
TlsSock*key = socks;
while (key!=NULL) {
if (!(key->open)) { // closed key => closed tcp socket => free for realloc
if (key->state != NULL) free(key->state);
key->state = NULL;
return tlsRawOpen(host,p,key);
}
prev = key;
key = key->next;
}
key = malloc(sizeof(TlsSock)); // oh BOY i LOVE memory management!!!!
key->next = NULL;
if (prev == NULL) { // in other words, |socks == NULL|
socks=key;
key->idx=0;
return tlsRawOpen(host,p,key);
}
prev->next = key;
key->idx = (prev->idx)+1;
return tlsRawOpen(host,p,key);
}
*/