"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/server.c" between
ircd-hybrid-8.2.27.tgz and ircd-hybrid-8.2.28.tgz

About: IRCD-Hybrid is a Internet Relay Chat server.

server.c  (ircd-hybrid-8.2.27.tgz):server.c  (ircd-hybrid-8.2.28.tgz)
skipping to change at line 24 skipping to change at line 24
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA * USA
*/ */
/*! \file server.c /*! \file server.c
* \brief Server related functions. * \brief Server related functions.
* \version $Id: server.c 9156 2020-01-13 14:51:47Z michael $ * \version $Id: server.c 9223 2020-01-26 11:35:22Z michael $
*/ */
#include "stdinc.h" #include "stdinc.h"
#include "list.h" #include "list.h"
#include "client.h" #include "client.h"
#include "event.h" #include "event.h"
#include "hash.h" #include "hash.h"
#include "irc_string.h" #include "irc_string.h"
#include "ircd.h" #include "ircd.h"
#include "ircd_defs.h" #include "ircd_defs.h"
skipping to change at line 59 skipping to change at line 59
* write_links_file * write_links_file
* *
* inputs - void pointer which is not used * inputs - void pointer which is not used
* output - NONE * output - NONE
* side effects - called from an event, write out list of linked servers * side effects - called from an event, write out list of linked servers
* but in no particular order. * but in no particular order.
*/ */
void void
write_links_file(void *unused) write_links_file(void *unused)
{ {
FILE *file = NULL; char buf[IRCD_BUFSIZE];
dlink_node *node, *node_next; dlink_node *node, *node_next;
char buff[IRCD_BUFSIZE] = "";
if (EmptyString(ConfigServerHide.flatten_links_file)) if (EmptyString(ConfigServerHide.flatten_links_file))
return; return;
if ((file = fopen(ConfigServerHide.flatten_links_file, "w")) == NULL) FILE *file = fopen(ConfigServerHide.flatten_links_file, "w");
if (file == NULL)
{ {
ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_lin ks_file, ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_lin ks_file,
strerror(errno)); strerror(errno));
return; return;
} }
DLINK_FOREACH_SAFE(node, node_next, flatten_links.head) DLINK_FOREACH_SAFE(node, node_next, flatten_links.head)
{ {
dlinkDelete(node, &flatten_links); dlinkDelete(node, &flatten_links);
xfree(node->data); xfree(node->data);
skipping to change at line 100 skipping to change at line 100
if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services) if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
continue; continue;
/* /*
* Attempt to format the file in such a way it follows the usual links outpu t * Attempt to format the file in such a way it follows the usual links outpu t
* ie "servername uplink :hops info" * ie "servername uplink :hops info"
* Mostly for aesthetic reasons - makes it look pretty in mIRC ;) * Mostly for aesthetic reasons - makes it look pretty in mIRC ;)
* - madmax * - madmax
*/ */
snprintf(buff, sizeof(buff), "%s %s :1 %s", target_p->name, snprintf(buf, sizeof(buf), "%s %s :1 %s", target_p->name, me.name, target_p-
me.name, target_p->info); >info);
dlinkAddTail(xstrdup(buff), make_dlink_node(), &flatten_links); dlinkAddTail(xstrdup(buf), make_dlink_node(), &flatten_links);
strlcat(buff, "\n", sizeof(buff)); strlcat(buf, "\n", sizeof(buf));
fputs(buff, file); fputs(buf, file);
} }
fclose(file); fclose(file);
} }
void void
read_links_file(void) read_links_file(void)
{ {
FILE *file = NULL; char buf[IRCD_BUFSIZE];
char *p = NULL;
char buff[IRCD_BUFSIZE] = "";
if (EmptyString(ConfigServerHide.flatten_links_file)) if (EmptyString(ConfigServerHide.flatten_links_file))
return; return;
if ((file = fopen(ConfigServerHide.flatten_links_file, "r")) == NULL) FILE *file = fopen(ConfigServerHide.flatten_links_file, "r");
if (file == NULL)
{ {
ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_lin ks_file, ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", ConfigServerHide.flatten_lin ks_file,
strerror(errno)); strerror(errno));
return; return;
} }
while (fgets(buff, sizeof(buff), file)) while (fgets(buf, sizeof(buf), file))
{ {
if ((p = strchr(buff, '\n'))) char *p = strchr(buf, '\n');
if (p)
*p = '\0'; *p = '\0';
dlinkAddTail(xstrdup(buff), make_dlink_node(), &flatten_links); dlinkAddTail(xstrdup(buf), make_dlink_node(), &flatten_links);
} }
fclose(file); fclose(file);
} }
/* server_hunt() /* server_hunt()
* Do the basic thing in delivering the message (command) * Do the basic thing in delivering the message (command)
* across the relays to the specific server (server) for * across the relays to the specific server (server) for
* actions. * actions.
* *
skipping to change at line 174 skipping to change at line 173
dlink_node *node; dlink_node *node;
/* Assume it's me, if no server */ /* Assume it's me, if no server */
if (parc <= server || EmptyString(parv[server])) if (parc <= server || EmptyString(parv[server]))
{ {
h->target_p = &me; h->target_p = &me;
h->ret = HUNTED_ISME; h->ret = HUNTED_ISME;
return h; return h;
} }
if ((h->target_p = find_person(source_p, parv[server])) == NULL) h->target_p = find_person(source_p, parv[server]);
if (h->target_p == NULL)
h->target_p = hash_find_server(parv[server]); h->target_p = hash_find_server(parv[server]);
/* /*
* These are to pickup matches that would cause the following * These are to pickup matches that would cause the following
* message to go in the wrong direction while doing quick fast * message to go in the wrong direction while doing quick fast
* non-matching lookups. * non-matching lookups.
*/ */
if (h->target_p) if (h->target_p)
if (h->target_p->from == source_p->from && !MyConnect(h->target_p)) if (h->target_p->from == source_p->from && !MyConnect(h->target_p))
h->target_p = NULL; h->target_p = NULL;
skipping to change at line 382 skipping to change at line 382
* creates a client, saves the socket information in the client, and * creates a client, saves the socket information in the client, and
* initiates a connection to the server through comm_connect_tcp(). The * initiates a connection to the server through comm_connect_tcp(). The
* completion of this goes through serv_completed_connection(). * completion of this goes through serv_completed_connection().
* *
* We return 1 if the connection is attempted, since we don't know whether * We return 1 if the connection is attempted, since we don't know whether
* it suceeded or not, and 0 if it fails in here somewhere. * it suceeded or not, and 0 if it fails in here somewhere.
*/ */
bool bool
server_connect(struct MaskItem *conf, struct Client *by) server_connect(struct MaskItem *conf, struct Client *by)
{ {
char buf[HOSTIPLEN + 1] = ""; char buf[HOSTIPLEN + 1];
/* Make sure conf is useful */ /* Make sure conf is useful */
assert(conf); assert(conf);
assert(conf->type == CONF_SERVER); assert(conf->type == CONF_SERVER);
assert(hash_find_server(conf->name) == NULL); /* This should have been checke d by the caller */ assert(hash_find_server(conf->name) == NULL); /* This should have been checke d by the caller */
/* Still processing a DNS lookup? -> exit */ /* Still processing a DNS lookup? -> exit */
if (conf->dns_pending == true) if (conf->dns_pending == true)
{ {
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
skipping to change at line 469 skipping to change at line 469
* The socket has been connected or connect is in progress. * The socket has been connected or connect is in progress.
*/ */
return true; return true;
} }
static void static void
server_finish_tls_handshake(struct Client *client_p) server_finish_tls_handshake(struct Client *client_p)
{ {
const struct MaskItem *conf = find_conf_name(&client_p->connection->confs, const struct MaskItem *conf = find_conf_name(&client_p->connection->confs,
client_p->name, CONF_SERVER); client_p->name, CONF_SERVER);
if (!conf) if (conf == NULL)
{ {
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Lost connect{} block for %s", client_get_name(client_p , SHOW_IP)); "Lost connect{} block for %s", client_get_name(client_p , SHOW_IP));
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Lost connect{} block for %s", client_get_name(client_p , MASK_IP)); "Lost connect{} block for %s", client_get_name(client_p , MASK_IP));
exit_client(client_p, "Lost connect{} block"); exit_client(client_p, "Lost connect{} block");
return; return;
} }
skipping to change at line 538 skipping to change at line 538
"Error connecting to %s: %s", client_p->name, "Error connecting to %s: %s", client_p->name,
sslerr ? sslerr : "unknown TLS error"); sslerr ? sslerr : "unknown TLS error");
exit_client(client_p, "Error during TLS handshake"); exit_client(client_p, "Error during TLS handshake");
return; return;
} }
} }
} }
comm_settimeout(F, 0, NULL, NULL); comm_settimeout(F, 0, NULL, NULL);
if (tls_verify_cert(&F->tls, ConfigServerInfo.message_digest_algorithm, &clien if (tls_verify_certificate(&F->tls, ConfigServerInfo.message_digest_algorithm,
t_p->certfp) == false) &client_p->certfp) == false)
ilog(LOG_TYPE_IRCD, "Server %s!%s@%s gave bad TLS client certificate", ilog(LOG_TYPE_IRCD, "Server %s gave bad TLS client certificate",
client_p->name, client_p->username, client_p->host); client_get_name(client_p, MASK_IP));
server_finish_tls_handshake(client_p); server_finish_tls_handshake(client_p);
} }
static void static void
server_tls_connect_init(struct Client *client_p, const struct MaskItem *conf, fd e_t *F) server_tls_connect_init(struct Client *client_p, const struct MaskItem *conf, fd e_t *F)
{ {
assert(client_p); assert(client_p);
assert(client_p->connection); assert(client_p->connection);
assert(client_p->connection->fd); assert(client_p->connection->fd);
skipping to change at line 608 skipping to change at line 608
* longer valid for reading or writing. * longer valid for reading or writing.
*/ */
dead_link_on_write(client_p, 0); dead_link_on_write(client_p, 0);
return; return;
} }
/* COMM_OK, so continue the connection procedure */ /* COMM_OK, so continue the connection procedure */
/* Get the connect {} block */ /* Get the connect {} block */
const struct MaskItem *conf = find_conf_name(&client_p->connection->confs, const struct MaskItem *conf = find_conf_name(&client_p->connection->confs,
client_p->name, CONF_SERVER); client_p->name, CONF_SERVER);
if (!conf) if (conf == NULL)
{ {
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
"Lost connect{} block for %s", client_get_name(client_p , SHOW_IP)); "Lost connect{} block for %s", client_get_name(client_p , SHOW_IP));
sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE, sendto_realops_flags(UMODE_SERVNOTICE, L_OPER, SEND_NOTICE,
"Lost connect{} block for %s", client_get_name(client_p , MASK_IP)); "Lost connect{} block for %s", client_get_name(client_p , MASK_IP));
exit_client(client_p, "Lost connect{} block"); exit_client(client_p, "Lost connect{} block");
return; return;
} }
 End of changes. 16 change blocks. 
24 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)