added ssl support

This commit is contained in:
Your Name 2024-02-21 20:11:23 +03:00
parent b4825a3fb7
commit de4223170b
7 changed files with 117 additions and 111 deletions

View file

@ -5,17 +5,16 @@
#include "irc.h"
//Config
#define HOST "192.168.0.184"
#define PORT 6667
#define HOST "irc.rizon.net"
#define PORT 6697
#define NICK "tester134"
char *channels[] = {"#test"};
char *channels[] = {"#testssl"};
#define CHECK_NULL() (client.irc_nick != NULL && client.irc_channel != NULL && client.irc_msg != NULL)
IRCC_client client;
void die(char *msg) {
puts(msg);
void die(const char *msg) {
perror(msg);
IRCC_close(&client);
exit(1);
}
@ -30,7 +29,7 @@ void recvinfo(void) {
//Print
if (CHECK_NULL() && irc_status == IRCC_PRIVMSG)
printf("[%s %s] %s\n", client.irc_channel, client.irc_nick, client.irc_msg);
printf("%s\n", client.irc_msg);
else if (client.irc_nick != NULL && client.irc_msg != NULL && irc_status == IRCC_NICK)
printf("[N] %s is know as %s\n", client.irc_nick, client.irc_msg);
@ -47,17 +46,17 @@ void recvinfo(void) {
}
int main(void) {
//512 - size of raw buffer (max irc)
IRCC_init(&client);
int status = IRCC_connect(&client, HOST, PORT);
if (status == IRCC_ERROR)
die("Conn refused");
//Register
int ie = 0;
if (IRCC_initssl(&client, &ie) == IRCC_ERROR)
die(IRCC_errno[ie]);
//Register and skip motd
IRCC_register(&client, NICK);
//Recv motd and join in channel
sleep(5);
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) {
if (channels[i] == NULL)