diff options
author | Shav Kinderlehrer <[email protected]> | 2024-07-23 17:48:28 -0400 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-07-23 17:48:28 -0400 |
commit | dc0f2ce9ba97ebb47e05b80a511da6eb29818b63 (patch) | |
tree | dc83035069f5a015047be1ca3da6f65781eb4695 /include/connect.h | |
parent | f638f4bd1e3a03bc2bdd5f9dcd57d4830fd3c553 (diff) | |
download | molehole-dc0f2ce9ba97ebb47e05b80a511da6eb29818b63.tar.gz molehole-dc0f2ce9ba97ebb47e05b80a511da6eb29818b63.zip |
Merge old-moleholencurses
Diffstat (limited to 'include/connect.h')
-rwxr-xr-x | include/connect.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/connect.h b/include/connect.h new file mode 100755 index 0000000..d733c5e --- /dev/null +++ b/include/connect.h @@ -0,0 +1,44 @@ +#ifndef _CONNECT_H_ +#define _CONNECT_H_ + +#include <openssl/ssl.h> + +#include "config.h" +#include "url.h" + +/* Error codes */ +enum ConnectError { + ERR_GETADDRINFO = -1, + ERR_SOCKET = -2, + ERR_CONNECT = -3, + ERR_SSL_CTX = -4, + ERR_SSL_SSL = -5, +}; + +/** + * Holds all needed information to manage an open TLS connection. + */ +struct connection { + SSL *ssl; + int sockfd; + bool used; +}; + +/** + * Connect to molerat server. + * + * Sets `*ssl` in `struct config *conf` to the current active connection. + */ +int tls_connect(struct config *conf, struct url url); + +/** + * Disconnect and free open connection + */ +void tls_cleanup(struct connection *conn); + +/** + * Allocate a new instance of a `struct connection` + */ +struct connection *init_connection(void); + +#endif |