diff options
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/blabouncer.c b/blabouncer.c index e6a56c1..772b969 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -137,8 +137,8 @@ int connecttoircserver(SSL_CTX **serverctx, SSL **server_ssl, int *serversockfd, // ircdstate.clientchangetime and ircdstate.clientsnonetime not set here as they are set at startup and only changed when clients connect/disconnect // ircdstate.clientcodes not set here, set on startup and whenever a client sets one - // Populate nick and username from our configuration file for now, real IRCd may change them later (TODO - Is this true of username?) - strcpy(ircdstate->ircnick, settings->ircnick); + // Populate nicks[0] and username from our configuration file for now, real IRCd may change them later (TODO - Is this true of username?) + strcpy(ircdstate->ircnick, settings->ircnicks[0]); strcpy(ircdstate->ircusername, settings->ircusername); // Send the server password if one was configured @@ -967,22 +967,27 @@ int main(int argc, char *argv[]) { exit(1); } - // What is the configured nick? - if (!getconfstr("nick", settings.conffile, settings.ircnick)) { - printf("main(): error getting 'nick' from configuration file.\n"); + // What are the configured nick(s)? + int ret = getconfarr("nicks", settings.conffile, settings.ircnicks); + if (!ret) { + printf("main(): error getting any 'nicks' from configuration file.\n"); + } else if (ret == -1) { + // Error reading an array line from the configuration file + // Remove any newlines from the middle of the string so error printing works nicely + for (size_t i = 0; i < strlen(settings.ircnicks[0]) - 1; i++) { + if (settings.ircnicks[0][i] == '\n') { + settings.ircnicks[0][i] = ' '; + } + } + printf("main(): error getting 'nicks' from configuration file: %s", settings.ircnicks[0]); exit(1); } - - // What is the configured nick2? - if (!getconfstr("nick2", settings.conffile, settings.ircnick2)) { - // Not configured, set to blank string - settings.ircnick2[0] = '\0'; - } - - // What is the configured nick3? - if (!getconfstr("nick3", settings.conffile, settings.ircnick3)) { - // Not configured, set to blank string - settings.ircnick3[0] = '\0'; + // Make sure nicks aren't too long (since getconfarr() has to use MAXDATASIZE for all string lengths) + for (int i = 0; i < MAXCONFARR; i++) { + if (settings.ircnicks[i][0] && strlen(settings.ircnicks[i]) > MAXNICKLENGTH) { + printf("main(): error: specified nick '%s' is too long, maximum length is %d.\n", settings.ircnicks[i], MAXNICKLENGTH); + exit(1); + } } // What is the configured username? @@ -1026,7 +1031,7 @@ int main(int argc, char *argv[]) { } // What are the connect commands, if any? - int ret = getconfarr("connectcommands", settings.conffile, settings.connectcommands); + ret = getconfarr("connectcommands", settings.conffile, settings.connectcommands); if (!ret) { for (int i = 0; i < MAXCONFARR; i++) { settings.connectcommands[i][0] = '\0'; |