diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-05-27 13:17:41 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-05-27 13:17:41 +0100 |
commit | f45ca7022725d7f68aa68555e081f55d8f02db00 (patch) | |
tree | 69395957551fdefe37c33e651feda06b824c4aa1 | |
parent | cf27363f56e2ba4cf91d2bcfde3b1017237068eb (diff) |
Support connecting to passworded servers.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | blabouncer.c | 13 | ||||
-rw-r--r-- | blabouncer.conf.example | 3 | ||||
-rw-r--r-- | config.c | 3 |
4 files changed, 19 insertions, 2 deletions
@@ -11,8 +11,6 @@ Add various auto replay options: Allow log replay time to be specified with days:hours:minutes:seconds. -Allow connecting to a passworded server. - Might need to #include <limits.h> in blabouncer.c to make some operating systems and/or compilers happy. Test CTCP. diff --git a/blabouncer.c b/blabouncer.c index e5637cf..886d8b8 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -89,6 +89,7 @@ struct settings { char autochannels[MAXAUTOCHANLEN]; char ircserver[HOST_NAME_MAX]; char ircserverport[MAXPORTLEN]; + char ircserverpassword[MAXDATASIZE - 5]; // -5 for "PASS " char conffile[PATH_MAX]; char certfile[PATH_MAX]; char keyfile[PATH_MAX]; @@ -1906,6 +1907,13 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) { strcpy(ircdstrings.ircnick, settings->ircnick); strcpy(ircdstrings.ircusername, settings->ircusername); + // Send the server password if one was configured + if (settings->ircserverpassword[0]) { + snprintf(outgoingmsg, MAXDATASIZE, "PASS %s", settings->ircserverpassword); + // sourcefd = 0 as this is a trusted message + sendtoserver(server_ssl, outgoingmsg, strlen(outgoingmsg), 0, clients, settings); + } + // Send our NICK snprintf(outgoingmsg, MAXDATASIZE, "NICK %s", ircdstrings.ircnick); // TODO - Check for success (with return code) // sourcefd = 0 as this is a trusted message @@ -2212,6 +2220,11 @@ int main(int argc, char *argv[]) { exit(1); } + // What is the real IRC server password, if any? + if (!getconfstr("ircserverpassword", settings.conffile, settings.ircserverpassword)) { + settings.ircserverpassword[0] = '\0'; + } + // Is the base directory set? If not, use the default. if (!getconfstr("basedir", settings.conffile, settings.basedir)) { snprintf(settings.basedir, PATH_MAX, "%s/.blabouncer/", getenv("HOME")); diff --git a/blabouncer.conf.example b/blabouncer.conf.example index 3aa8a7f..1395f97 100644 --- a/blabouncer.conf.example +++ b/blabouncer.conf.example @@ -40,6 +40,9 @@ ircserver = "irc.blatech.net" # Real IRC server port ircserverport = "6697" +# Real IRC server password +#ircserverpassword = "apples" + # Base directory (defaults to $HOME/.blabouncer/) # Things such as the logs directory will be placed below this #basedir = "/home/foo/.blabouncer/" @@ -201,6 +201,9 @@ int createconfigfile(char *filename) { "# Real IRC server port\n" "ircserverport = \"6697\"\n" "\n" + "# Real IRC server password\n" + "#ircserverpassword = \"apples\"\n" + "\n" "# Base directory (defaults to $HOME/.blabouncer/)\n" "# Things such as the logs directory will be placed below this\n" "#basedir = \"/home/foo/.blabouncer/\"\n" |