summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 1a781df..d96ec09 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -20,6 +20,8 @@
// - Comma separated channel list in JOINs/PARTs
// - Long raw strings like a 321/322/323 channel LIST, and the initial server welcome, need to be read and split properly
// - Only send some things to the requesting client (e.g. LIST replies)
+// - Normal (non-replay) log
+// - Alert when clients connect/authenticate/disconnect
//
// Example WHOIS reply:
// BOUNCER-SERVER RECEIVED: :irc.tghost.co.uk 307 blabounce l_bratch :is identified for this nick
@@ -66,6 +68,7 @@
#define MAXNICKLENGTH 64 // Randomly picked (TODO - is there an actual maximum number (ignoring the RFC preference of 9)?)
#define MAXUSERNAMELEN 64 // Randomly picked (TODO - is there an actual maximum username length?)
#define MAXREALNAMELEN 128 // Randomly picked (TODO - is there an actual maximum real name length?)
+#define MAXPORTLEN 6 // Up to 65535, so 5 characters + 1 for null
struct channel {
char name[MAXCHANLENGTH];
@@ -95,6 +98,7 @@ struct ircdstrings {
// Structure of settings either to be read from the configuration file or set/changed at runtime
struct settings {
int replayseconds;
+ char clientport[MAXPORTLEN];
};
int debugmode = 0;
@@ -998,7 +1002,7 @@ int processrawstring(int *serversockfd, int *clientsockfd, char *str, int source
}
// Where the big bouncing loop is
-void dochat(int *serversockfd, int *clientsockfd) {
+void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
char serverbuf[MAXRCVSIZE]; // buffer for receiving data on server socket
char clientbuf[MAXRCVSIZE]; // buffer for receiving data on client socket(s)
int servernumbytes; // Number of bytes received from remote server
@@ -1048,10 +1052,6 @@ void dochat(int *serversockfd, int *clientsockfd) {
ircdstrings.ircrealname[0] = '\0';
ircdstrings.currentmsg[0] = '\0';
- // Structure of our various settings which are to either be read from the configuration file or set at runtime
- struct settings settings;
- settings.replayseconds = confreplayseconds();
-
// Read required things from configuration file
readnames(ircdstrings.ircnick, ircdstrings.ircusername, ircdstrings.ircrealname);
@@ -1126,7 +1126,7 @@ void dochat(int *serversockfd, int *clientsockfd) {
// Try to process received string (which should contain one or more server responses/commands)
// TODO - What if there were two server respones/commands and only one didn't need relaying?
- if (!processrawstring(serversockfd, clientsockfd, serverbuf, SOURCE_SERVER, fdmax, arr_clients, EXCEPT_NONE, &ircdstrings, channels, arr_authed, arr_ssl, &settings)) {
+ if (!processrawstring(serversockfd, clientsockfd, serverbuf, SOURCE_SERVER, fdmax, arr_clients, EXCEPT_NONE, &ircdstrings, channels, arr_authed, arr_ssl, settings)) {
fprintf(stderr, "Error: bouncer-server failed to process raw string.\n");
exit(1);
}
@@ -1252,7 +1252,7 @@ void dochat(int *serversockfd, int *clientsockfd) {
// Try to process received string (which should contain one or more client responses/commands)
// TODO - What if there were two server respones/commands and only one didn't need relaying?
- if (!processrawstring(serversockfd, clientsockfd, clientbuf, SOURCE_CLIENT, fdmax, arr_clients, i, &ircdstrings, channels, arr_authed, arr_ssl, &settings)) {
+ if (!processrawstring(serversockfd, clientsockfd, clientbuf, SOURCE_CLIENT, fdmax, arr_clients, i, &ircdstrings, channels, arr_authed, arr_ssl, settings)) {
fprintf(stderr, "Error: bouncer-client failed to process raw string.\n");
exit(1);
}
@@ -1276,6 +1276,11 @@ int main(int argc, char *argv[]) {
}
}
+ // Structure of our various settings which are to either be read from the configuration file or set at runtime
+ struct settings settings;
+ settings.replayseconds = confreplayseconds();
+ confclientport(settings.clientport);
+
// TODO: see if any of this can be shared (i.e. 1. avoid code duplication, and 2. see if variables can be shared between client/server sockets)
// TODO: track fdmax - kind of doing this now with arr_clients and num_clients but might be pointlessly tracking both in some places (?)
@@ -1288,9 +1293,9 @@ int main(int argc, char *argv[]) {
int serversockfd = createserversocket(argv[1], argv[2]);
// Create client socket (after server so we can use its fd number later as fdmax)
- int clientsockfd = createclientsocket(BOUNCERLISTENPORT);
+ int clientsockfd = createclientsocket(settings.clientport);
- dochat(&serversockfd, &clientsockfd);
+ dochat(&serversockfd, &clientsockfd, &settings);
printf("dochat() complete, closing socket...\n");