Netconfigs: start abstracting handling of network config files
[citadel.git] / citadel / modules / network / serv_network.c
1 /*
2  * This module handles shared rooms, inter-Citadel mail, and outbound
3  * mailing list processing.
4  *
5  * Copyright (c) 2000-2012 by the citadel.org team
6  *
7  *  This program is open source software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License, version 3.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
16  * This is a fairly high-level type of critical section.  It ensures that no
17  * two threads work on the netconfigs files at the same time.  Since we do
18  * so many things inside these, here are the rules:
19  *  1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
20  *  2. Do *not* perform any I/O with the client during these sections.
21  *
22  */
23
24 /*
25  * Duration of time (in seconds) after which pending list subscribe/unsubscribe
26  * requests that have not been confirmed will be deleted.
27  */
28 #define EXP     259200  /* three days */
29
30 #include "sysdep.h"
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <stdio.h>
34 #include <fcntl.h>
35 #include <ctype.h>
36 #include <signal.h>
37 #include <pwd.h>
38 #include <errno.h>
39 #include <sys/stat.h>
40 #include <sys/types.h>
41 #include <dirent.h>
42 #if TIME_WITH_SYS_TIME
43 # include <sys/time.h>
44 # include <time.h>
45 #else
46 # if HAVE_SYS_TIME_H
47 #  include <sys/time.h>
48 # else
49 #  include <time.h>
50 # endif
51 #endif
52 #ifdef HAVE_SYSCALL_H
53 # include <syscall.h>
54 #else 
55 # if HAVE_SYS_SYSCALL_H
56 #  include <sys/syscall.h>
57 # endif
58 #endif
59
60 #include <sys/wait.h>
61 #include <string.h>
62 #include <limits.h>
63 #include <libcitadel.h>
64 #include "citadel.h"
65 #include "server.h"
66 #include "citserver.h"
67 #include "support.h"
68 #include "config.h"
69 #include "user_ops.h"
70 #include "database.h"
71 #include "msgbase.h"
72 #include "internet_addressing.h"
73 #include "serv_network.h"
74 #include "clientsocket.h"
75 #include "file_ops.h"
76 #include "citadel_dirs.h"
77 #include "threads.h"
78 #include "context.h"
79 #include "netconfig.h"
80 #include "netspool.h"
81 #include "netmail.h"
82 #include "ctdl_module.h"
83
84 int NetQDebugEnabled = 0;
85 struct CitContext networker_spool_CC;
86
87 /* comes from lookup3.c from libcitadel... */
88 extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
89
90 typedef struct __roomlists {
91         RoomProcList *rplist;
92         HashList *RoomsInterestedIn;
93 }roomlists;
94 /*
95  * When we do network processing, it's accomplished in two passes; one to
96  * gather a list of rooms and one to actually do them.  It's ok that rplist
97  * is global; we have a mutex that keeps it safe.
98  */
99 struct RoomProcList *rplist = NULL;
100
101 int GetNetworkedRoomNumbers(const char *DirName, HashList *DirList)
102 {
103         DIR *filedir = NULL;
104         struct dirent *d;
105         struct dirent *filedir_entry;
106         long RoomNR;
107         long Count = 0;
108                 
109         filedir = opendir (DirName);
110         if (filedir == NULL) {
111                 return 0;
112         }
113
114         d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
115         if (d == NULL) {
116                 return 0;
117         }
118
119         while ((readdir_r(filedir, d, &filedir_entry) == 0) &&
120                (filedir_entry != NULL))
121         {
122                 RoomNR = atol(filedir_entry->d_name);
123                 if (RoomNR != 0) {
124                         Count++;
125                         Put(DirList, LKEY(RoomNR), &Count, reference_free_handler);
126                 }
127         }
128         free(d);
129         closedir(filedir);
130         return Count;
131 }
132
133
134
135
136 /*
137  * Check the use table.  This is a list of messages which have recently
138  * arrived on the system.  It is maintained and queried to prevent the same
139  * message from being entered into the database multiple times if it happens
140  * to arrive multiple times by accident.
141  */
142 int network_usetable(struct CtdlMessage *msg)
143 {
144         struct CitContext *CCC = CC;
145         char msgid[SIZ];
146         struct cdbdata *cdbut;
147         struct UseTable ut;
148
149         /* Bail out if we can't generate a message ID */
150         if (msg == NULL) {
151                 return(0);
152         }
153         if (msg->cm_fields['I'] == NULL) {
154                 return(0);
155         }
156         if (IsEmptyStr(msg->cm_fields['I'])) {
157                 return(0);
158         }
159
160         /* Generate the message ID */
161         strcpy(msgid, msg->cm_fields['I']);
162         if (haschar(msgid, '@') == 0) {
163                 strcat(msgid, "@");
164                 if (msg->cm_fields['N'] != NULL) {
165                         strcat(msgid, msg->cm_fields['N']);
166                 }
167                 else {
168                         return(0);
169                 }
170         }
171
172         cdbut = cdb_fetch(CDB_USETABLE, msgid, strlen(msgid));
173         if (cdbut != NULL) {
174                 cdb_free(cdbut);
175                 QN_syslog(LOG_DEBUG, "network_usetable() : we already have %s\n", msgid);
176                 return(1);
177         }
178
179         /* If we got to this point, it's unique: add it. */
180         strcpy(ut.ut_msgid, msgid);
181         ut.ut_timestamp = time(NULL);
182         cdb_store(CDB_USETABLE, msgid, strlen(msgid), &ut, sizeof(struct UseTable) );
183         return(0);
184 }
185
186
187
188
189
190
191
192 #if 0
193
194
195 /*
196  * Send the *entire* contents of the current room to one specific network node,
197  * ignoring anything we know about which messages have already undergone
198  * network processing.  This can be used to bring a new node into sync.
199  */
200 int network_sync_to(char *target_node, long len)
201 {
202         struct CitContext *CCC = CC;
203         SpoolControl sc;
204         int num_spooled = 0;
205         int found_node = 0;
206         char buf[256];
207         char sc_type[256];
208         char sc_node[256];
209         char sc_room[256];
210         char filename[PATH_MAX];
211         FILE *fp;
212
213         /* Grab the configuration line we're looking for */
214         assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
215         begin_critical_section(S_NETCONFIGS);
216         fp = fopen(filename, "r");
217         if (fp == NULL) {
218                 end_critical_section(S_NETCONFIGS);
219                 return(-1);
220         }
221         while (fgets(buf, sizeof buf, fp) != NULL)
222         {
223                 buf[strlen(buf)-1] = 0;
224
225                 extract_token(sc_type, buf, 0, '|', sizeof sc_type);
226                 if (strcasecmp(sc_type, "ignet_push_share"))
227                         continue;
228
229                 extract_token(sc_node, buf, 1, '|', sizeof sc_node);
230                 if (strcasecmp(sc_node, target_node))
231                         continue;
232
233                 extract_token(sc_room, buf, 2, '|', sizeof sc_room);
234                 found_node = 1;
235                         
236                 /* Concise syntax because we don't need a full linked-list */
237                 memset(&sc, 0, sizeof(SpoolControl));
238                 sc.ignet_push_shares = (maplist *)
239                         malloc(sizeof(maplist));
240                 sc.ignet_push_shares->next = NULL;
241                 safestrncpy(sc.ignet_push_shares->remote_nodename,
242                             sc_node,
243                             sizeof sc.ignet_push_shares->remote_nodename);
244                 safestrncpy(sc.ignet_push_shares->remote_roomname,
245                             sc_room,
246                             sizeof sc.ignet_push_shares->remote_roomname);
247         }
248         fclose(fp);
249         end_critical_section(S_NETCONFIGS);
250
251         if (!found_node) {
252                 free(sc.ignet_push_shares);
253                 return(-1);
254         }
255
256         sc.working_ignetcfg = load_ignetcfg();
257         sc.the_netmap = read_network_map();
258
259         /* Send ALL messages */
260         num_spooled = CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL,
261                 network_spool_msg, &sc);
262
263         /* Concise cleanup because we know there's only one node in the sc */
264         free(sc.ignet_push_shares);
265
266         DeleteHash(&sc.working_ignetcfg);
267         DeleteHash(&sc.the_netmap);
268
269         QN_syslog(LOG_NOTICE, "Synchronized %d messages to <%s>\n",
270                   num_spooled, target_node);
271         return(num_spooled);
272 }
273
274 #endif
275
276
277 /*
278  * Implements the NSYN command
279  */
280 void cmd_nsyn(char *argbuf) {
281         int num_spooled;
282         long len;
283         char target_node[256];
284
285         if (CtdlAccessCheck(ac_aide)) return;
286
287         len = extract_token(target_node, argbuf, 0, '|', sizeof target_node);
288         ///// TODO num_spooled = network_sync_to(target_node, len);
289         if (num_spooled >= 0) {
290                 cprintf("%d Spooled %d messages.\n", CIT_OK, num_spooled);
291         }
292         else {
293                 cprintf("%d No such room/node share exists.\n",
294                         ERROR + ROOM_NOT_FOUND);
295         }
296 }
297
298
299
300 /*
301  * Batch up and send all outbound traffic from the current room
302  */
303 void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data) {
304         int i;
305         struct RoomProcList *ptr;
306         long QRNum = qrbuf->QRnumber;
307         void *v;
308         roomlists *RP = (roomlists*) data;
309
310         if (!GetHash(RP->RoomsInterestedIn, LKEY(QRNum), &v))
311                 return;
312
313         ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList));
314         if (ptr == NULL) return;
315
316         ptr->namelen = strlen(qrbuf->QRname);
317         if (ptr->namelen > ROOMNAMELEN)
318                 ptr->namelen = ROOMNAMELEN - 1;
319
320         memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
321         ptr->name[ptr->namelen] = '\0';
322         ptr->QRNum = qrbuf->QRnumber;
323
324         for (i = 0; i < ptr->namelen; i++)
325         {
326                 ptr->lcname[i] = tolower(ptr->name[i]);
327         }
328
329         ptr->lcname[ptr->namelen] = '\0';
330         ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);
331         ptr->next = RP->rplist;
332         RP->rplist = ptr;
333 }
334
335 /*
336  * Batch up and send all outbound traffic from the current room
337  */
338 void network_queue_room(struct ctdlroom *qrbuf, void *data) {
339         int i;
340         struct RoomProcList *ptr;
341
342         if (qrbuf->QRdefaultview == VIEW_QUEUE)
343                 return;
344         ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList));
345         if (ptr == NULL) return;
346
347         ptr->namelen = strlen(qrbuf->QRname);
348         if (ptr->namelen > ROOMNAMELEN)
349                 ptr->namelen = ROOMNAMELEN - 1;
350
351         memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
352         ptr->name[ptr->namelen] = '\0';
353         ptr->QRNum = qrbuf->QRnumber;
354
355         for (i = 0; i < ptr->namelen; i++)
356         {
357                 ptr->lcname[i] = tolower(ptr->name[i]);
358         }
359         ptr->lcname[ptr->namelen] = '\0';
360         ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);
361
362         begin_critical_section(S_RPLIST);
363         ptr->next = rplist;
364         rplist = ptr;
365         end_critical_section(S_RPLIST);
366 }
367
368 void destroy_network_queue_room(RoomProcList *rplist)
369 {
370         struct RoomProcList *cur, *p;
371
372         cur = rplist;
373         while (cur != NULL)
374         {
375                 p = cur->next;
376                 free (cur);
377                 cur = p;                
378         }
379 }
380
381 void destroy_network_queue_room_locked (void)
382 {
383         begin_critical_section(S_RPLIST);
384         destroy_network_queue_room(rplist);
385         end_critical_section(S_RPLIST);
386 }
387
388
389
390 /*
391  * Bounce a message back to the sender
392  */
393 void network_bounce(struct CtdlMessage *msg, char *reason)
394 {
395         struct CitContext *CCC = CC;
396         char *oldpath = NULL;
397         char buf[SIZ];
398         char bouncesource[SIZ];
399         char recipient[SIZ];
400         struct recptypes *valid = NULL;
401         char force_room[ROOMNAMELEN];
402         static int serialnum = 0;
403         size_t size;
404
405         QNM_syslog(LOG_DEBUG, "entering network_bounce()\n");
406
407         if (msg == NULL) return;
408
409         snprintf(bouncesource, sizeof bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
410
411         /* 
412          * Give it a fresh message ID
413          */
414         if (msg->cm_fields['I'] != NULL) {
415                 free(msg->cm_fields['I']);
416         }
417         snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
418                 (long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
419         msg->cm_fields['I'] = strdup(buf);
420
421         /*
422          * FIXME ... right now we're just sending a bounce; we really want to
423          * include the text of the bounced message.
424          */
425         if (msg->cm_fields['M'] != NULL) {
426                 free(msg->cm_fields['M']);
427         }
428         msg->cm_fields['M'] = strdup(reason);
429         msg->cm_format_type = 0;
430
431         /*
432          * Turn the message around
433          */
434         if (msg->cm_fields['R'] == NULL) {
435                 free(msg->cm_fields['R']);
436         }
437
438         if (msg->cm_fields['D'] == NULL) {
439                 free(msg->cm_fields['D']);
440         }
441
442         snprintf(recipient, sizeof recipient, "%s@%s",
443                 msg->cm_fields['A'], msg->cm_fields['N']);
444
445         if (msg->cm_fields['A'] == NULL) {
446                 free(msg->cm_fields['A']);
447         }
448
449         if (msg->cm_fields['N'] == NULL) {
450                 free(msg->cm_fields['N']);
451         }
452
453         if (msg->cm_fields['U'] == NULL) {
454                 free(msg->cm_fields['U']);
455         }
456
457         msg->cm_fields['A'] = strdup(BOUNCESOURCE);
458         msg->cm_fields['N'] = strdup(config.c_nodename);
459         msg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
460
461         /* prepend our node to the path */
462         if (msg->cm_fields['P'] != NULL) {
463                 oldpath = msg->cm_fields['P'];
464                 msg->cm_fields['P'] = NULL;
465         }
466         else {
467                 oldpath = strdup("unknown_user");
468         }
469         size = strlen(oldpath) + SIZ;
470         msg->cm_fields['P'] = malloc(size);
471         snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
472         free(oldpath);
473
474         /* Now submit the message */
475         valid = validate_recipients(recipient, NULL, 0);
476         if (valid != NULL) if (valid->num_error != 0) {
477                 free_recipients(valid);
478                 valid = NULL;
479         }
480         if ( (valid == NULL) || (!strcasecmp(recipient, bouncesource)) ) {
481                 strcpy(force_room, config.c_aideroom);
482         }
483         else {
484                 strcpy(force_room, "");
485         }
486         if ( (valid == NULL) && IsEmptyStr(force_room) ) {
487                 strcpy(force_room, config.c_aideroom);
488         }
489         CtdlSubmitMsg(msg, valid, force_room, 0);
490
491         /* Clean up */
492         if (valid != NULL) free_recipients(valid);
493         CtdlFreeMessage(msg);
494         QNM_syslog(LOG_DEBUG, "leaving network_bounce()\n");
495 }
496
497
498
499
500
501
502
503 /*
504  * network_do_queue()
505  * 
506  * Run through the rooms doing various types of network stuff.
507  */
508 void network_do_queue(void)
509 {
510         struct CitContext *CCC = CC;
511         static int doing_queue = 0;
512         static time_t last_run = 0L;
513         int full_processing = 1;
514         HashList *working_ignetcfg;
515         HashList *the_netmap = NULL;
516         int netmap_changed = 0;
517         roomlists RL;
518
519         /*
520          * Run the full set of processing tasks no more frequently
521          * than once every n seconds
522          */
523         if ( (time(NULL) - last_run) < config.c_net_freq ) {
524                 full_processing = 0;
525                 syslog(LOG_DEBUG, "Network full processing in %ld seconds.\n",
526                        config.c_net_freq - (time(NULL)- last_run)
527                 );
528         }
529
530         /*
531          * This is a simple concurrency check to make sure only one queue run
532          * is done at a time.  We could do this with a mutex, but since we
533          * don't really require extremely fine granularity here, we'll do it
534          * with a static variable instead.
535          */
536         if (doing_queue) {
537                 return;
538         }
539         doing_queue = 1;
540
541         become_session(&networker_spool_CC);
542         begin_critical_section(S_RPLIST);
543         RL.rplist = rplist;
544         rplist = NULL;
545         end_critical_section(S_RPLIST);
546
547         RL.RoomsInterestedIn = NewHash(1, lFlathash);
548         if (full_processing &&
549             (GetNetworkedRoomNumbers(ctdl_netcfg_dir, RL.RoomsInterestedIn)==0))
550         {
551                 doing_queue = 0;
552                 DeleteHash(&RL.RoomsInterestedIn);
553                 if (RL.rplist == NULL)
554                         return;
555         }
556         /* Load the IGnet Configuration into memory */
557         working_ignetcfg = load_ignetcfg();
558
559         /*
560          * Load the network map and filter list into memory.
561          */
562         if (!server_shutting_down)
563                 the_netmap = read_network_map();
564         if (!server_shutting_down)
565                 load_network_filter_list();
566
567         /* 
568          * Go ahead and run the queue
569          */
570         if (full_processing && !server_shutting_down) {
571                 QNM_syslog(LOG_DEBUG, "network: loading outbound queue");
572                 CtdlForEachRoom(network_queue_interesting_rooms, &RL);
573         }
574
575         if ((RL.rplist != NULL) && (!server_shutting_down)) {
576                 RoomProcList *ptr, *cmp;
577                 ptr = RL.rplist;
578                 QNM_syslog(LOG_DEBUG, "network: running outbound queue");
579                 while (ptr != NULL && !server_shutting_down) {
580                         
581                         cmp = ptr->next;
582
583                         while (cmp != NULL) {
584                                 if ((cmp->namelen > 0) &&
585                                     (cmp->key == ptr->key) &&
586                                     (cmp->namelen == ptr->namelen) &&
587                                     (strcmp(cmp->lcname, ptr->lcname) == 0))
588                                 {
589                                         cmp->namelen = 0;
590                                 }
591                                 cmp = cmp->next;
592                         }
593
594                         if (ptr->namelen > 0) {
595                                 network_spoolout_room(ptr, 
596                                                       working_ignetcfg,
597                                                       the_netmap);
598                         }
599                         ptr = ptr->next;
600                 }
601         }
602
603         /* If there is anything in the inbound queue, process it */
604         if (!server_shutting_down) {
605                 network_do_spoolin(working_ignetcfg, 
606                                    the_netmap,
607                                    &netmap_changed);
608         }
609
610         /* Free the filter list in memory */
611         free_netfilter_list();
612
613         /* Save the network map back to disk */
614         if (netmap_changed) {
615                 StrBuf *MapStr = SerializeNetworkMap(the_netmap);
616                 CtdlPutSysConfig(IGNETMAP, SmashStrBuf(&MapStr));
617         }
618
619         /* combine singe message files into one spool entry per remote node. */
620         network_consolidate_spoolout(working_ignetcfg, the_netmap);
621
622         /* shut down. */
623
624         DeleteHash(&the_netmap);
625
626         DeleteHash(&working_ignetcfg);
627
628         QNM_syslog(LOG_DEBUG, "network: queue run completed");
629
630         if (full_processing) {
631                 last_run = time(NULL);
632         }
633         DeleteHash(&RL.RoomsInterestedIn);
634         destroy_network_queue_room(RL.rplist);
635         doing_queue = 0;
636 }
637
638
639
640
641 int network_room_handler (struct ctdlroom *room)
642 {
643         network_queue_room(room, NULL);
644         return 0;
645 }
646
647 int NTTDebugEnabled = 0;
648
649 /*
650  * network_talking_to()  --  concurrency checker
651  */
652 static HashList *nttlist = NULL;
653 int network_talking_to(const char *nodename, long len, int operation) {
654
655         int retval = 0;
656         HashPos *Pos = NULL;
657         void *vdata;
658
659         begin_critical_section(S_NTTLIST);
660
661         switch(operation) {
662
663                 case NTT_ADD:
664                         if (nttlist == NULL) 
665                                 nttlist = NewHash(1, NULL);
666                         Put(nttlist, nodename, len, NewStrBufPlain(nodename, len), HFreeStrBuf);
667                         if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: added <%s>\n", nodename);
668                         break;
669                 case NTT_REMOVE:
670                         if ((nttlist == NULL) ||
671                             (GetCount(nttlist) == 0))
672                                 break;
673                         Pos = GetNewHashPos(nttlist, 1);
674                         if (GetHashPosFromKey (nttlist, nodename, len, Pos))
675                                 DeleteEntryFromHash(nttlist, Pos);
676                         DeleteHashPos(&Pos);
677                         if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: removed <%s>\n", nodename);
678
679                         break;
680
681                 case NTT_CHECK:
682                         if ((nttlist == NULL) ||
683                             (GetCount(nttlist) == 0))
684                                 break;
685                         if (GetHash(nttlist, nodename, len, &vdata))
686                                 retval ++;
687                         if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: have [%d] <%s>\n", retval, nodename);
688                         break;
689         }
690
691         end_critical_section(S_NTTLIST);
692         return(retval);
693 }
694
695 void cleanup_nttlist(void)
696 {
697         begin_critical_section(S_NTTLIST);
698         DeleteHash(&nttlist);
699         end_critical_section(S_NTTLIST);
700 }
701
702
703
704 void network_logout_hook(void)
705 {
706         CitContext *CCC = MyContext();
707
708         /*
709          * If we were talking to a network node, we're not anymore...
710          */
711         if (!IsEmptyStr(CCC->net_node)) {
712                 network_talking_to(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
713                 CCC->net_node[0] = '\0';
714         }
715 }
716 void network_cleanup_function(void)
717 {
718         struct CitContext *CCC = CC;
719
720         if (!IsEmptyStr(CCC->net_node)) {
721                 network_talking_to(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
722                 CCC->net_node[0] = '\0';
723         }
724 }
725
726
727 /*
728  * Module entry point
729  */
730 void SetNTTDebugEnabled(const int n)
731 {
732         NTTDebugEnabled = n;
733 }
734 void SetNetQDebugEnabled(const int n)
735 {
736         NetQDebugEnabled = n;
737 }
738
739 CTDL_MODULE_INIT(network)
740 {
741         if (!threading)
742         {
743                 CtdlFillSystemContext(&networker_spool_CC, "CitNetSpool");
744                 CtdlRegisterDebugFlagHook(HKEY("networktalkingto"), SetNTTDebugEnabled, &NTTDebugEnabled);
745                 CtdlRegisterDebugFlagHook(HKEY("networkqueue"), SetNetQDebugEnabled, &NetQDebugEnabled);
746                 CtdlRegisterCleanupHook(cleanup_nttlist);
747                 CtdlRegisterSessionHook(network_cleanup_function, EVT_STOP, PRIO_STOP + 30);
748                 CtdlRegisterSessionHook(network_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 10);
749                 CtdlRegisterProtoHook(cmd_nsyn, "NSYN", "Synchronize room to node");
750                 CtdlRegisterRoomHook(network_room_handler);
751                 CtdlRegisterCleanupHook(destroy_network_queue_room_locked);
752                 CtdlRegisterSessionHook(network_do_queue, EVT_TIMER, PRIO_QUEUE + 10);
753         }
754         return "network";
755 }