IRCWebHooks
Barry Adding non-SSL IRC option e15b4c0 (4 years, 1 month ago)
diff --git a/src/irc.c b/src/irc.c
index 5ab201b..aa8f545 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -57,17 +57,23 @@ raw(char *fmt, ...)
#ifdef VERBOSE
printf("<< %s", sbuf);
#endif
+#ifdef SSL_IRC
SSL_write(ssl, sbuf, strlen(sbuf));
+#else
+ write(conn, sbuf, strlen(sbuf));
+#endif
}
/* Bot code */
void
bot(void)
{
+#ifdef SSL_IRC
BIO *certbio = NULL, *outbio = NULL;
X509 *cert = NULL;
X509_NAME *certname = NULL;
const SSL_METHOD *method;
+#endif
char *user, *ident, *vhost, *command, *where, *message, *sep, *target;
int i, j, l, sl, o = -1, start, wordcount;
@@ -83,6 +89,7 @@ bot(void)
conn = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
connect(conn, res->ai_addr, res->ai_addrlen);
+#ifdef SSL_IRC
/* SSL connection */
{
OpenSSL_add_all_algorithms();
@@ -115,6 +122,7 @@ bot(void)
certname = X509_NAME_new();
certname = X509_get_subject_name(cert);
}
+#endif
/* IRC user */
raw("USER %s 0 0 :%s\r\n", NICK, NICK);
@@ -131,7 +139,11 @@ bot(void)
}
/* IRC messages */
+#ifdef SSL_IRC
while (sl = SSL_read(ssl, sbuf, 512))
+#else
+ while (sl = read(conn, sbuf, 512))
+#endif
for (i = 0; i < sl; i++) {
o++;
buf[o] = sbuf[i];
@@ -233,8 +245,10 @@ bot(void)
}
}
+#ifdef SSL_IRC
SSL_free(ssl);
- close(conn);
X509_free(cert);
SSL_CTX_free(ctx);
+#endif
+ close(conn);
}