From dba30066da1c929a140281cbbb6a8f177fdf14d4 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sun, 12 May 2019 21:07:56 +0100 Subject: Move real IRC server and port specification to configuration file. Also remove '-d' debug mode which doesn't do anything. --- blabouncer.c | 38 +++++++++++++++++++------------------- blabouncer.conf | 6 ++++++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/blabouncer.c b/blabouncer.c index 5da18e0..a370d71 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -103,10 +103,10 @@ struct settings { char ircnick[MAXNICKLENGTH]; // In both settings and ircdstrings as settings is from our file whereas server may change ircdstrings copy char ircusername[MAXUSERNAMELEN]; // (Is this also true for the username? Can the server change that?) char ircrealname[MAXREALNAMELEN]; + char ircserver[HOST_NAME_MAX]; + char ircserverport[MAXPORTLEN]; }; -int debugmode = 0; - // Return index of requested client FD within arr_clients // This is used because at least arr_clients, arr_authed, and ssl share the same element order. // TODO - Use this wherever we are calculating the position (various places) instead of @@ -1268,18 +1268,6 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) { } int main(int argc, char *argv[]) { - if (argc < 3) { - fprintf(stderr,"usage: %s hostname port [-d]\n", argv[0]); - exit(1); - } - - if (argc == 4) { - if (!strcmp(argv[3], "-d")) { - debugmode = 1; - debug("debug mode enabled\n"); - } - } - // Structure of our various settings which are to either be read from the configuration file or set at runtime struct settings settings; @@ -1289,25 +1277,37 @@ int main(int argc, char *argv[]) { settings.replayseconds = getconfint("replayseconds", CONFFILE); // What port should the bouncer listen on if (!getconfstr("clientport", CONFFILE, settings.clientport)) { - printf("main(): error getting clientport from configuration file.\n"); + printf("main(): error getting 'clientport' from configuration file.\n"); exit(1); } // What is the configured nick? if (!getconfstr("nick", CONFFILE, settings.ircnick)) { - printf("main(): error getting nick from configuration file.\n"); + printf("main(): error getting 'nick' from configuration file.\n"); exit(1); } // What is the configured username? if (!getconfstr("username", CONFFILE, settings.ircusername)) { - printf("main(): error getting username from configuration file.\n"); + printf("main(): error getting 'username' from configuration file.\n"); exit(1); } // What is the configured real name? if (!getconfstr("realname", CONFFILE, settings.ircrealname)) { - printf("main(): error getting real name from configuration file.\n"); + printf("main(): error getting 'realname' from configuration file.\n"); + exit(1); + } + + // What is the real IRC server address? + if (!getconfstr("ircserver", CONFFILE, settings.ircserver)) { + printf("main(): error getting 'ircserver' from configuration file.\n"); + exit(1); + } + + // What is the real IRC server port? + if (!getconfstr("ircserverport", CONFFILE, settings.ircserverport)) { + printf("main(): error getting 'ircserverport' from configuration file.\n"); exit(1); } @@ -1320,7 +1320,7 @@ int main(int argc, char *argv[]) { // BOUNCER-TO-SERVER socket things // Create server socket - int serversockfd = createserversocket(argv[1], argv[2]); + int serversockfd = createserversocket(settings.ircserver, settings.ircserverport); // Create client socket (after server so we can use its fd number later as fdmax) int clientsockfd = createclientsocket(settings.clientport); diff --git a/blabouncer.conf b/blabouncer.conf index e5d6613..466fb37 100644 --- a/blabouncer.conf +++ b/blabouncer.conf @@ -16,3 +16,9 @@ password = "bananas" # Port the bouncer should listen on clientport = "1234" + +# Real IRC server the bouncer connects to +ircserver = "irc.blatech.net" + +# Real IRC server port +ircserverport = "6667" -- cgit v1.2.3