From 768ff9c0cbd7be85447fcc436edf94466e40780c Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 25 Jan 2006 19:50:36 +0000 Subject: [PATCH] Several commands now send the fqdn from the servers setup to the neighbours --- ChangeLog | 2 ++ mbtask/taskchat.c | 20 +++++++++++--------- mbtask/taskibc.c | 33 +++++++++++++++++++++++++++++++++ mbtask/taskibc.h | 2 ++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98d24cca..144c997c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ v0.83.9 23-Jan-2006 the chatserver setup. Added some code to trap mbtask crashing during chat and start mail processing. + Several commands now send the server address from the servers + setup to the neighbours. v0.83.8 22-Jan-2006 - 23-Jan-2006 diff --git a/mbtask/taskchat.c b/mbtask/taskchat.c index e7657091..3228526d 100644 --- a/mbtask/taskchat.c +++ b/mbtask/taskchat.c @@ -224,7 +224,7 @@ int join(pid_t pid, char *channel, int sysop) * The sysop channel is private to the system, no broadcast */ if (strcasecmp(channel, "#sysop")) - send_all("JOIN %s@%s %s\r\n", tmpu->nick, CFG.myfqdn, channel); + send_at((char *)"JOIN", tmpu->nick, channel); return TRUE; } } @@ -261,7 +261,7 @@ int join(pid_t pid, char *channel, int sysop) chat_msg(channel, NULL, buf); chat_dump(); if (strcasecmp(channel, "#sysop")) - send_all("JOIN %s@%s %s\r\n", tmpu->nick, CFG.myfqdn, channel); + send_at((char *)"JOIN", tmpu->nick, channel); return TRUE; } @@ -306,10 +306,12 @@ int part(pid_t pid, char *reason) snprintf(buf, 81, "%s has left channel %s, %d users left", tmpu->nick, tmp->name, tmp->users); chat_msg(tmpu->channel, NULL, buf); if (strcasecmp(tmp->name, (char *)"#sysop")) { - if (reason && strlen(reason)) - send_all("PART %s@%s %s %s\r\n", tmpu->nick, CFG.myfqdn, tmp->name, reason); - else - send_all("PART %s@%s %s\r\n", tmpu->nick, CFG.myfqdn, tmp->name); + if (reason && strlen(reason)) { + sprintf(buf, "%s %s", tmp->name, reason); + send_at((char *)"PART", tmpu->nick, buf); + } else { + send_at((char *)"PART", tmpu->nick, tmp->name); + } } /* @@ -423,7 +425,7 @@ char *chat_connect(char *data) sys = atoi(strtok(NULL, ";")); /* Sysop flag */ add_user(&users, CFG.myfqdn, nick, realname); - send_all("USER %s@%s %s\r\n", nick, CFG.myfqdn, realname); + send_at((char *)"USER", nick, realname); /* * Now search the added entry to update the data @@ -486,7 +488,7 @@ char *chat_close(char *data) /* * Remove from IBC network */ - send_all("QUIT %s@%s Leaving chat\r\n", tmpu->name, CFG.myfqdn); + send_at((char *)"QUIT", tmpu->name, (char *)"Leaving chat"); del_user(&users, CFG.myfqdn, tmpu->name); Syslog('c', "Closing chat for pid %s", pid); snprintf(buf, 81, "100:0;"); @@ -625,7 +627,7 @@ char *chat_put(char *data) strncpy(tmpu->nick, cmd, 9); snprintf(buf, 200, "Nick set to \"%s\"", cmd); system_msg(tmpu->pid, buf); - send_all("NICK %s %s %s %s\r\n", tmpu->nick, tmpu->name, CFG.myfqdn, tmpu->realname); + send_nick(tmpu->nick, tmpu->name, tmpu->realname); usrchg = TRUE; chat_dump(); goto ack; diff --git a/mbtask/taskibc.c b/mbtask/taskibc.c index 4d84be2d..551d6428 100644 --- a/mbtask/taskibc.c +++ b/mbtask/taskibc.c @@ -631,6 +631,39 @@ void send_all(const char *format, ...) +/* + * Send command message to each connected neighbour server and use the correct own fqdn. + */ +void send_at(char *cmd, char *nick, char *param) +{ + ncs_list *tnsl; + char buf[512]; + + for (tnsl = ncsl; tnsl; tnsl = tnsl->next) { + if (tnsl->state == NCS_CONNECT) { + sprintf(buf, "%s %s@%s %s\r\n", cmd, nick, tnsl->myname, param); + send_msg(tnsl, buf); + } + } +} + + + +void send_nick(char *nick, char *name, char *realname) +{ + ncs_list *tnsl; + char buf[512]; + + for (tnsl = ncsl; tnsl; tnsl = tnsl->next) { + if (tnsl->state == NCS_CONNECT) { + sprintf(buf, "NICK %s %s %s %s\r\n", nick, name, tnsl->myname, realname); + send_msg(tnsl, buf); + } + } +} + + + /* * Broadcast a message to all servers except the originating server */ diff --git a/mbtask/taskibc.h b/mbtask/taskibc.h index 53305212..2ba698e3 100644 --- a/mbtask/taskibc.h +++ b/mbtask/taskibc.h @@ -116,6 +116,8 @@ void del_channel(chn_list **, char *); int do_command(char *, char *, char *); void send_all(const char *, ...); +void send_at(char *, char *, char *); +void send_nick(char *, char *, char *); void *ibc_thread(void *);