diff options
-rw-r--r-- | include/conf.h | 3 | ||||
-rw-r--r-- | include/message.h | 1 | ||||
-rw-r--r-- | modules/m_links.c | 10 | ||||
-rw-r--r-- | src/ircd.c | 4 | ||||
-rw-r--r-- | src/message.c | 12 | ||||
-rw-r--r-- | src/s_serv.c | 59 |
6 files changed, 29 insertions, 60 deletions
diff --git a/include/conf.h b/include/conf.h index e1090bb..250efd5 100644 --- a/include/conf.h +++ b/include/conf.h @@ -215,8 +215,6 @@ struct config_file_entry char *egdpool_path; char *service_name; - MessageFile linksfile; - int gline_min_cidr; int gline_min_cidr6; int dots_in_ident; @@ -326,6 +324,7 @@ struct logging_entry unsigned int use_logging; }; +extern dlink_list flatten_links; extern dlink_list server_items; extern dlink_list cluster_items; extern dlink_list xconf_items; diff --git a/include/message.h b/include/message.h index 0b76cb0..ea6b97b 100644 --- a/include/message.h +++ b/include/message.h @@ -38,7 +38,6 @@ struct MessageFileLine typedef struct MessageFileLine MessageFileLine; typedef enum { - USER_LINKS, ISSUPPORT } MessageType; diff --git a/modules/m_links.c b/modules/m_links.c index 7970097..e0fe286 100644 --- a/modules/m_links.c +++ b/modules/m_links.c @@ -38,6 +38,8 @@ static void do_links(struct Client *source_p, int parc, char *parv[]) { + dlink_node *ptr = NULL; + sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, "LINKS requested by %s (%s@%s) [%s]", source_p->name, @@ -48,7 +50,6 @@ do_links(struct Client *source_p, int parc, char *parv[]) { const char *mask = (parc > 2 ? parv[2] : parv[1]); const char *me_name, *nick; - dlink_node *ptr; me_name = ID_or_name(&me, source_p->from); nick = ID_or_name(source_p, source_p->from); @@ -93,7 +94,12 @@ do_links(struct Client *source_p, int parc, char *parv[]) ID_or_name(&me, source_p->from), ID_or_name(source_p, source_p->from), me.name, me.name, 0, me.info); - send_message_file(source_p, &ConfigFileEntry.linksfile); + + DLINK_FOREACH(ptr, flatten_links.head) + sendto_one(source_p, ":%s %d %s %s", + ID_or_name(&me, source_p->from), RPL_LINKS, + ID_or_name(source_p, source_p->from), + ptr->data); sendto_one(source_p, form_str(RPL_ENDOFLINKS), ID_or_name(&me, source_p->from), ID_or_name(source_p, source_p->from), "*"); @@ -306,10 +306,6 @@ initialize_global_set_options(void) static void initialize_message_files(void) { - init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile); - - read_message_file(&ConfigFileEntry.linksfile); - init_isupport(); } diff --git a/src/message.c b/src/message.c index 716cf8d..3ac3ad4 100644 --- a/src/message.c +++ b/src/message.c @@ -71,18 +71,6 @@ send_message_file(struct Client *source_p, MessageFile *motdToPrint) switch (msgType) { - case USER_LINKS: - if (motdToPrint->contentsOfFile != NULL) - { - for (linePointer = motdToPrint->contentsOfFile; linePointer; - linePointer = linePointer->next) - { - sendto_one(source_p, ":%s 364 %s %s", /* XXX */ - from, to, linePointer->line); - } - } - break; - case ISSUPPORT: if (motdToPrint->contentsOfFile != NULL) { diff --git a/src/s_serv.c b/src/s_serv.c index 4ca292d..2606204 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -54,6 +54,7 @@ #define MIN_CONN_FREQ 300 +dlink_list flatten_links; static dlink_list cap_list = { NULL, NULL, 0 }; static void server_burst(struct Client *); static void burst_all(struct Client *); @@ -72,68 +73,48 @@ static void burst_members(struct Client *, struct Channel *); * but in no particular order. */ void -write_links_file(void* notused) +write_links_file(void *notused) { - MessageFileLine *next_mptr = NULL; - MessageFileLine *mptr = NULL; - MessageFileLine *currentMessageLine = NULL; - MessageFileLine *newMessageLine = NULL; - MessageFile *MessageFileptr = &ConfigFileEntry.linksfile; - FILE *file; - char buff[512]; - dlink_node *ptr; + FILE *file = NULL; + dlink_node *ptr = NULL, *ptr_next = NULL;; + char buff[IRCD_BUFSIZE] = { '\0' }; - if ((file = fopen(MessageFileptr->fileName, "w")) == NULL) + if ((file = fopen(LIPATH, "w")) == NULL) return; - for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr) + DLINK_FOREACH_SAFE(ptr, ptr_next, flatten_links.head) { - next_mptr = mptr->next; - MyFree(mptr); + dlinkDelete(ptr, &flatten_links); + MyFree(ptr->data); + free_dlink_node(ptr); } - MessageFileptr->contentsOfFile = NULL; - DLINK_FOREACH(ptr, global_serv_list.head) { const struct Client *target_p = ptr->data; - /* skip ourselves, we send ourselves in /links */ - if (IsMe(target_p)) - continue; - - /* skip hidden servers */ - if (IsHidden(target_p)) + /* + * Skip hidden servers, aswell as ourselves, since we already send + * ourselves in /links + */ + if (IsHidden(target_p) || IsMe(target_p)) continue; if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services) continue; - newMessageLine = MyMalloc(sizeof(MessageFileLine)); - /* * Attempt to format the file in such a way it follows the usual links output * ie "servername uplink :hops info" * Mostly for aesthetic reasons - makes it look pretty in mIRC ;) * - madmax */ - snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s", - target_p->name, me.name, target_p->info); - - if (MessageFileptr->contentsOfFile) - { - if (currentMessageLine) - currentMessageLine->next = newMessageLine; - currentMessageLine = newMessageLine; - } - else - { - MessageFileptr->contentsOfFile = newMessageLine; - currentMessageLine = newMessageLine; - } + snprintf(buff, sizeof(buff), "%s %s :1 %s", target_p->name, + me.name, target_p->info); + dlinkAdd(xstrdup(buff), make_dlink_node(), &flatten_links); + snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, + me.name, target_p->info); - snprintf(buff, sizeof(buff), "%s %s :1 %s\n", - target_p->name, me.name, target_p->info); fputs(buff, file); } |