TLS1.2 and command execution
This commit is contained in:
parent
bc96196ffd
commit
33bb5b8775
10 changed files with 459 additions and 19 deletions
36
imap.h
36
imap.h
|
|
@ -31,11 +31,22 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <netinet/in.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#define BACKLOG 4
|
||||
#define IMAP_SUCCESS 0x0
|
||||
#define IMAP_FAIL 0x1
|
||||
#define IMAP_LOGOUT 0x2
|
||||
#define IMAP_STARTTLS 0x3
|
||||
|
||||
#define IMAP_STATE_NO_AUTH 0x0
|
||||
#define IMAP_STATE_AUTH 0x1
|
||||
#define IMAP_STATE_SELECTED 0x2
|
||||
|
||||
typedef struct _client_list {
|
||||
int32_t socket;
|
||||
int32_t socket, fd;
|
||||
SSL *ssl;
|
||||
struct _client_list *next;
|
||||
struct _client_list *prev;
|
||||
} client_list;
|
||||
|
|
@ -45,8 +56,17 @@ typedef struct imap {
|
|||
int32_t socket;
|
||||
client_list *clients;
|
||||
struct sockaddr_in addr;
|
||||
uint8_t state, ssl;
|
||||
SSL_CTX *ssl_ctx;
|
||||
} imap_t;
|
||||
|
||||
typedef struct {
|
||||
char tag[4];
|
||||
uint8_t id;
|
||||
size_t p_count;
|
||||
char **params;
|
||||
} imap_cmd;
|
||||
|
||||
/* Create a new imap_t instance and initialize the server. */
|
||||
uint8_t imap_init(uint8_t daemon, imap_t *instance);
|
||||
/* Start the IMAP server. */
|
||||
|
|
@ -54,11 +74,19 @@ void imap_start(imap_t *instance);
|
|||
/* Close all connections and free the allocated memory. */
|
||||
void imap_close(imap_t *instance);
|
||||
/* Add client to client list */
|
||||
client_list *imap_add_client(client_list *list, int sock);
|
||||
client_list *imap_add_client(imap_t *instance, client_list *list, int sock);
|
||||
/* Close connection with client */
|
||||
client_list *imap_remove_client(client_list *list, client_list *node);
|
||||
client_list *imap_remove_sock(client_list *list, int sock);
|
||||
client_list *imap_remove_client(imap_t *instance, client_list *list, client_list *node);
|
||||
client_list *imap_remove_sock(imap_t *instance, client_list *list, int sock);
|
||||
/* Get the higher file descriptor in the client list */
|
||||
int imap_get_max_fd(client_list *list, int master);
|
||||
imap_cmd imap_parse_cmd(char *s);
|
||||
uint8_t imap_match_cmd(char *cmd, size_t len);
|
||||
void imap_create_ssl_ctx(imap_t *imap);
|
||||
void imap_starttls(imap_t *imap, client_list *list);
|
||||
int imap_read(client_list *node, char *buf, size_t len, uint8_t ssl);
|
||||
void imap_write(client_list *node, uint8_t ssl, char *fmt, ...);
|
||||
void imap_flush(client_list *node, uint8_t ssl);
|
||||
uint8_t imap_cmd_exec(imap_cmd cmd, client_list *node, uint8_t ssl, uint8_t state);
|
||||
|
||||
#endif /* ifndef IMAP_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue