From fbe68389b2e0a84d6fe81d751a2fc66f6f59edaf Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 5 Nov 2009 18:00:00 +0000 Subject: [PATCH] * When performing a network poll of another Citadel node, connecting to a node other than the one we were expecting is now an error condition that causes processing to immediately stop. --- citadel/modules/network/serv_network.c | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index b289851dc..0f1d37183 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -2028,22 +2028,24 @@ void network_poll_node(char *node, char *secret, char *host, char *port) { if (strcmp(connected_to, node)) { snprintf (err_buf, sizeof(err_buf), "Connected to node \"%s\" but I was expecting to connect to node \"%s\".", connected_to, node); - CtdlAideMessage(err_buf, "IGNet Networking error."); + CtdlLogPrintf(CTDL_ERR, "%s\n", err_buf); + CtdlAideMessage(err_buf, "Network error"); + } + else { + /* We're talking to the correct node. Now identify ourselves. */ + snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret); + CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf); + if (sock_puts(sock, buf) <0) goto bail; + if (sock_getln(sock, buf, sizeof buf) < 0) goto bail; + CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf); + if (buf[0] != '2') goto bail; + + /* At this point we are authenticated. */ + if (!CtdlThreadCheckStop()) + receive_spool(sock, node); + if (!CtdlThreadCheckStop()) + transmit_spool(sock, node); } - - /* Identify ourselves */ - snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret); - CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf); - if (sock_puts(sock, buf) <0) goto bail; - if (sock_getln(sock, buf, sizeof buf) < 0) goto bail; - CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf); - if (buf[0] != '2') goto bail; - - /* At this point we are authenticated. */ - if (!CtdlThreadCheckStop()) - receive_spool(sock, node); - if (!CtdlThreadCheckStop()) - transmit_spool(sock, node); sock_puts(sock, "QUIT"); bail: sock_close(sock); -- 2.39.2