added TLS/SSL support
This commit is contained in:
@@ -13,8 +13,12 @@ void IRC_NOTICE(char* to, char* msg, irc_client_t *irc);
|
||||
void IRC_NICK(char *nick, irc_client_t *irc);
|
||||
void IRC_USER(char *ident, char* realname, irc_client_t *irc);
|
||||
|
||||
void IRC_CTCPSend(char *to, char *cmd, irc_client_t *irc);
|
||||
|
||||
// registration
|
||||
void IRC_Register(char *nick, char *username, char *realname, irc_client_t *irc);
|
||||
void IRC_SetConnectionParameters(char* host, int port, irc_connection_type_t conntype, irc_client_t *irc);
|
||||
void IRC_SetIdentityParameters(char* nickname, char* username, char* realname, irc_client_t *irc);
|
||||
void IRC_Register(irc_client_t *irc);
|
||||
void IRC_SetSASLParameters(irc_sasl_mechanism_t, char* username, char* password, irc_client_t *irc);
|
||||
|
||||
void IRC_RequestSASLAuthentication(irc_client_t *irc);
|
||||
@@ -26,7 +30,12 @@ void IRC_EndCapabilityNegotiation(irc_client_t *irc);
|
||||
|
||||
void IRC_NeedCapabilities(char* caps, irc_client_t *irc);
|
||||
|
||||
|
||||
int IRC_ParseCapabilities(char* caps, irc_capability_t *capabilities, int capsLength);
|
||||
|
||||
// raw socket things
|
||||
void IRC_Connect(irc_client_t *irc);
|
||||
ssize_t IRC_Receive(irc_client_t *irc, char* toBuf, size_t bufSize);
|
||||
void IRC_Send(irc_client_t *irc, char* toSend);
|
||||
void IRC_Close(irc_client_t *irc);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef IRC_STRUCTS_H
|
||||
#define IRC_STRUCTS_H
|
||||
|
||||
#include "netcode.h"
|
||||
#include <stdbool.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -34,7 +36,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
char name[64];
|
||||
char topic[512];
|
||||
char topic[513];
|
||||
irc_chanuser_t* users;
|
||||
} irc_channel_t;
|
||||
|
||||
@@ -68,22 +70,40 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sockfd;
|
||||
char nick[32];
|
||||
char altnick[32];
|
||||
char altnick2[32];
|
||||
char username[16];
|
||||
char realname[128];
|
||||
} irc_identity_t;
|
||||
typedef enum
|
||||
{
|
||||
IRC_CONNECTION_PLAINTEXT,
|
||||
IRC_CONNECTION_TLS
|
||||
} irc_connection_type_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char host[128];
|
||||
int port;
|
||||
irc_connection_type_t connType;
|
||||
} irc_connection_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
irc_connection_info_t connectionInfo;
|
||||
sslSockfd_t connection;
|
||||
irc_hostmask_t ownHostmask;
|
||||
char supportedCapabilities[512];
|
||||
char requestedCapabilities[512];
|
||||
char supportedCapabilities[513];
|
||||
char requestedCapabilities[513];
|
||||
irc_capability_t acked[24];
|
||||
|
||||
/* Authentication parameters */
|
||||
irc_auth_t saslAuth;
|
||||
} irc_client_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char nick[32];
|
||||
char ident[16];
|
||||
char realname[64];
|
||||
} irc_identity_t;
|
||||
/* Identity */
|
||||
irc_identity_t identity;
|
||||
} irc_client_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
#ifndef NETCODE_H
|
||||
#define NETCODE_H
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SSL *ssl;
|
||||
int sockfd;
|
||||
SSL_CTX *ctx;
|
||||
} sslSockfd_t;
|
||||
|
||||
// Returns a socket file descriptor.
|
||||
int NET_Connect(const char* host, int port);
|
||||
void NET_Send(int sockfd, const char* toSend);
|
||||
void NET_Close(int sockfd);
|
||||
sslSockfd_t NET_Connect(const char* host, int port);
|
||||
void NET_Send(sslSockfd_t info, const char* toSend);
|
||||
void NET_Close(sslSockfd_t info);
|
||||
|
||||
// TLS versions of the same thing
|
||||
sslSockfd_t NET_TLS_Connect(const char* host, int port);
|
||||
void NET_TLS_Send(sslSockfd_t info, const char* toSend);
|
||||
void NET_TLS_Close(sslSockfd_t info);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user