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 /blabouncer.c | |
parent | cf27363f56e2ba4cf91d2bcfde3b1017237068eb (diff) |
Support connecting to passworded servers.
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 13 |
1 files changed, 13 insertions, 0 deletions
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")); |