summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/blabouncer.c b/blabouncer.c
index c56fc9d..72118ec 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -180,7 +180,7 @@ int connecttoircserver(SSL_CTX **serverctx, SSL **server_ssl, int *serversockfd,
// Return 0 if we didn't process it and the caller might want to do something
//int processircmessage(int *serversockfd, int *clientsockfd, char *str, int source) {
int processircmessage(SSL *server_ssl, char *str, int source, struct client *clients, int sourcefd, struct ircdstate *ircdstate, struct channel *channels,
- struct settings *settings, struct clientcodes *clientcodes) {
+ struct settings *settings, struct clientcodes *clientcodes, SSL_CTX *ctx) {
// Track which space-separated token within this response we're on
int counter = 0;
@@ -219,7 +219,7 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Don't return if we got here because this means we didn't process something in processservermessage()
break;
case SOURCE_CLIENT: // If message(s) were from a real IRC client
- if (processclientmessage(server_ssl, str, clients, sourcefd, ircdstate, channels, settings, tokens, counter, clientcodes)) {
+ if (processclientmessage(server_ssl, str, clients, sourcefd, ircdstate, channels, settings, tokens, counter, clientcodes, ctx)) {
// We processed something so return true
free(strcopyPtr);
return 1;
@@ -265,7 +265,7 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Return 0 if something went wrong
// Return 1 if everything OK
int processrawstring(SSL *server_ssl, char *str, int source, struct client *clients, int sourcefd, struct ircdstate *ircdstate, struct channel *channels,
- struct settings *settings, struct clientcodes *clientcodes) {
+ struct settings *settings, struct clientcodes *clientcodes, SSL_CTX *ctx) {
// Copy to a temporary string so we still have the original in case it's not processed
char *strcopy = strdup(str);
// Keep track of initial pointer for free()ing later
@@ -334,7 +334,7 @@ int processrawstring(SSL *server_ssl, char *str, int source, struct client *clie
for (int i = 0; i < messagecount; i++) {
// Copy to a temporary string so we still have the original in case it's not processed
char *messagecopy = strdup(messages[i]);
- if (processircmessage(server_ssl, messagecopy, source, clients, sourcefd, ircdstate, channels, settings, clientcodes)) {
+ if (processircmessage(server_ssl, messagecopy, source, clients, sourcefd, ircdstate, channels, settings, clientcodes, ctx)) {
debugprint(DEBUG_FULL, "Message processed: \"%s\", NULLing...\n", messages[i]);
messages[i][0] = '\0';
}
@@ -518,7 +518,7 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
failuremsg[0] = '\0';
// Try to rehash...
- if (!rehash(settings, failuremsg)) {
+ if (!rehash(settings, failuremsg, ctx)) {
// ...or log and tell all clients if it failed
debugprint(DEBUG_CRIT, "SIGHUP REHASH failed: %s.\n", failuremsg);
if (!snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :SIGHUP REHASH failed: %s.", ircdstate.ircnick, failuremsg)) {
@@ -707,7 +707,7 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
// Try to process received string (which should contain one or more server responses/commands)
// TODO - What if there were two server responses/commands and only one didn't need relaying?
- if (!processrawstring(server_ssl, serverbuf, SOURCE_SERVER, clients, EXCEPT_NONE, &ircdstate, channels, settings, clientcodes)) {
+ if (!processrawstring(server_ssl, serverbuf, SOURCE_SERVER, clients, EXCEPT_NONE, &ircdstate, channels, settings, clientcodes, ctx)) {
fprintf(stderr, "Error: bouncer-server failed to process raw string.\n");
debugprint(DEBUG_CRIT, "Error: bouncer-server failed to process raw string.\n");
}
@@ -736,6 +736,8 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
}
// STDIN based commands for debugging
+
+ // STDIN: List all channels
if (strncmp(outgoingmsg, "listchannels", strlen("listchannels")) == 0) {
printf("STDIN command starting: listchannels\n");
debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command starting: listchannels\n");
@@ -761,6 +763,19 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
continue;
}
+ // STDIN: Reconfigure OpenSSL context
+ if (strncmp(outgoingmsg, "reopenssl", strlen("reopenssl")) == 0) {
+ printf("STDIN command starting: reopenssl\n");
+ debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command starting: reopenssl\n");
+
+ configure_openssl_context(ctx, settings->certfile, settings->keyfile);
+
+ debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command complete: reopenssl\n");
+ printf("STDIN command complete: reopenssl\n");
+
+ continue;
+ }
+
debugprint(DEBUG_FULL, "dochat(): stdin: '%s' not processed as a command, sending to server.\n", outgoingmsg);
// sourcefd = 0 as this is a trusted message
sendtoserver(server_ssl, outgoingmsg, strlen(outgoingmsg), 0, clients, settings);
@@ -919,7 +934,7 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
// Try to process received string (which should contain one or more client responses/commands)
// TODO - What if there were two client responses/commands and only one didn't need relaying?
- if (!processrawstring(server_ssl, clientbuf, SOURCE_CLIENT, clients, i, &ircdstate, channels, settings, clientcodes)) {
+ if (!processrawstring(server_ssl, clientbuf, SOURCE_CLIENT, clients, i, &ircdstate, channels, settings, clientcodes, ctx)) {
fprintf(stderr, "Error: bouncer-client failed to process raw string.\n");
debugprint(DEBUG_CRIT, "Error: bouncer-client failed to process raw string.\n");
}