- Timestamp:
- 02/12/07 05:52:32 (5 years ago)
- Location:
- trunk/ithildin/modules/ircd
- Files:
-
- 1 added
- 5 deleted
- 15 edited
-
addons/acl.c (modified) (22 diffs)
-
addons/acl.h (modified) (3 diffs)
-
addons/core.c (deleted)
-
addons/core.h (deleted)
-
addons/drone_fizzer.c (deleted)
-
addons/pscan.c (deleted)
-
addons/throttle.c (modified) (5 diffs)
-
channel.c (modified) (16 diffs)
-
channel.h (modified) (2 diffs)
-
client.c (modified) (7 diffs)
-
client.h (modified) (4 diffs)
-
commands/akill.c (modified) (3 diffs)
-
commands/trace.c (modified) (2 diffs)
-
connection.c (modified) (13 diffs)
-
connection.h (modified) (2 diffs)
-
etc/pscan.conf (deleted)
-
ircd.c (modified) (9 diffs)
-
ircd.h (modified) (3 diffs)
-
modconfig.h (added)
-
protocol.c (modified) (3 diffs)
-
server.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ithildin/modules/ircd/addons/acl.c
r787 r801 82 82 /* insert into lists.. */ 83 83 LIST_INSERT_HEAD(acl.list, ap, lp); 84 if (ap->stage == ACL_STAGE_CONNECT )85 list = acl. stage1_list;86 else if (ap->stage == ACL_STAGE_ PREREG)87 list = acl. stage2_list;84 if (ap->stage == ACL_STAGE_CONNECTED) 85 list = acl.connected_list; 86 else if (ap->stage == ACL_STAGE_UNREGISTERED) 87 list = acl.unregistered_list; 88 88 else 89 list = acl. stage3_list;89 list = acl.registered_list; 90 90 91 91 if (LIST_EMPTY(list)) … … 176 176 rule = acl.default_rule; 177 177 178 if (stage == ACL_STAGE_CONNECT )179 list = acl. stage1_list;180 else if (stage == ACL_STAGE_ PREREG)181 list = acl. stage2_list;178 if (stage == ACL_STAGE_CONNECTED) 179 list = acl.connected_list; 180 else if (stage == ACL_STAGE_UNREGISTERED) 181 list = acl.unregistered_list; 182 182 else 183 list = acl. stage3_list;183 list = acl.registered_list; 184 184 185 185 /* now try and find them in the bucket. */ … … 210 210 211 211 /* and remove it from whatever list it's in */ 212 if (ap->stage == ACL_STAGE_CONNECT) 213 LIST_REMOVE(ap, intlp); 214 else if (ap->stage == ACL_STAGE_PREREG) 215 LIST_REMOVE(ap, intlp); 216 else 217 LIST_REMOVE(ap, intlp); 212 LIST_REMOVE(ap, intlp); 218 213 219 214 /* now free the memory */ … … 256 251 void *ret; 257 252 258 if (stage == 0 || stage == ACL_STAGE_CONNECT ) {259 cp = LIST_FIRST(ircd.connections. stage1);253 if (stage == 0 || stage == ACL_STAGE_CONNECTED) { 254 cp = LIST_FIRST(ircd.connections.connected); 260 255 while (cp != NULL) { 261 256 cp2 = LIST_NEXT(cp, lp); 262 if ((ret = acl_ stage1_hook(NULL, (void *)cp)) != NULL) {257 if ((ret = acl_connected_stage_hook(NULL, (void *)cp)) != NULL) { 263 258 destroy_connection(cp, ret); 264 259 nukes++; … … 268 263 } 269 264 } 270 if (stage == 0 || stage == ACL_STAGE_ PREREG) {271 cp = LIST_FIRST(ircd.connections. stage2);265 if (stage == 0 || stage == ACL_STAGE_UNREGISTERED) { 266 cp = LIST_FIRST(ircd.connections.unregistered); 272 267 while (cp != NULL) { 273 268 cp2 = LIST_NEXT(cp, lp); 274 if ((ret = acl_ stage2_hook(NULL, (void *)cp)) != NULL) {269 if ((ret = acl_unregistered_stage_hook(NULL, (void *)cp)) != NULL) { 275 270 destroy_connection(cp, ret); 276 271 nukes++; … … 280 275 } 281 276 } 282 if (stage == 0 || stage == ACL_STAGE_REGISTER ) {277 if (stage == 0 || stage == ACL_STAGE_REGISTERED) { 283 278 cp = LIST_FIRST(ircd.connections.clients); 284 279 while (cp != NULL) { 285 280 cp2 = LIST_NEXT(cp, lp); 286 if ((ret = acl_ stage3_hook(NULL, (void *)cp)) != NULL) {281 if ((ret = acl_registered_stage_hook(NULL, (void *)cp)) != NULL) { 287 282 destroy_connection(cp, ret); 288 283 nukes++; … … 299 294 by, ap->type, 300 295 (ap->stage > 1 ? ap->user : ""), (ap->stage > 1 ? "@" : ""), 301 ap->host, a p->stage,296 ap->host, acl_stage_int_to_str(ap->stage), 302 297 (ap->access == ACL_DENY ? "DENY" : 303 298 (ap->access == ACL_ALLOW ? "ALLOW" : "UNKNOWN")), … … 307 302 } 308 303 309 /* vi:set ts=8 sts=4 sw=4 tw=76 et: */ 304 /* Returns the integer representation of an ACL stage name, or 0 if the name 305 * is not understood. */ 306 int acl_stage_str_to_int(const char *str) { 307 int ret = 0; 308 309 /* see if it's a number first */ 310 ret = str_conv_int(str, 0); 311 if (ret < 1 || ret > 3) 312 return 0; 313 else if (!strncasecmp(s, "connected", 4)) 314 return ACL_STAGE_CONNECTED; 315 else if (!strncasecmp(s, "unregistered", 5)) 316 return ACL_STAGE_UNREGISTERED; 317 else if (!strncasecmp(s, "registered", 3)) 318 return ACL_STAGE_REGISTERED; 319 320 return 0; 321 } 322 323 /* Return a string representing the name of the ACL stage, or NULL if it 324 * cannot be converted. */ 325 const char *acl_stage_int_to_str(int stg) { 326 switch (stg) { 327 case ACL_STAGE_CONNECTED: 328 return "connected"; 329 case ACL_STAGE_UNREGISTERED: 330 return "unregistered"; 331 case ACL_STAGE_REGISTERED: 332 return "registered"; 333 default: 334 return NULL; 335 } 336 } 337 310 338 /* handling for stage one is by far the easiest, there are no classes or 311 * passwords involved. also, stuff in stage1should always be in a single339 * passwords involved. also, stuff this stage should always be in a single 312 340 * place. we create a hashtable, but it's mostly just a glorified list (for 313 341 * now, anyways) */ 314 HOOK_FUNCTION(acl_ stage1_hook) {342 HOOK_FUNCTION(acl_connected_stage_hook) { 315 343 acl_t *ap; 316 344 connection_t *cp = (connection_t *)data; … … 319 347 /* now match. skip over any entries that aren't the default hash or our 320 348 * hash. */ 321 LIST_FOREACH(ap, acl. stage1_list, intlp) {349 LIST_FOREACH(ap, acl.connected_list, intlp) { 322 350 if (ap->hash != hash && ap->hash != ACL_DEFAULT_HASH) 323 351 continue; … … 342 370 } 343 371 344 /* stage2 is next, and resembles stage1 except that we do class checks, and we345 * actually have a full mask now. */346 HOOK_FUNCTION(acl_ stage2_hook) {372 /* the unregistered stage is next, and resembles the connected stage except 373 * that we do class checks, and we actually have a full mask now. */ 374 HOOK_FUNCTION(acl_unregistered_stage_hook) { 347 375 acl_t *ap; 348 376 connection_t *cp = (connection_t *)data; … … 358 386 * and the ip (using hostmatch and ipmatch). All together that is four 359 387 * calls. Also, our hash space is expanded. */ 360 LIST_FOREACH(ap, acl. stage2_list, intlp) {388 LIST_FOREACH(ap, acl.unregistered_list, intlp) { 361 389 if (ap->hash != hash && ap->hash != iphash && 362 390 ap->hash != ACL_DEFAULT_HASH) … … 383 411 } 384 412 385 /* stage3 is the last stage, it's nearly identical to stage2, but there is a386 * slight change for 'allow-always' type rules and passwords, also, unlike the387 * previous two, the default is to *deny* clients. Also, unlike the othertwo388 * stages, while the first match *usually* wins, we do check for 'allow-always'389 * rules. */390 HOOK_FUNCTION(acl_ stage3_hook) {413 /* the final stage (registered) is a client only check. additionally rules 414 * for allow-always and passwords are available, along with rules for 415 * banning the 'gecos' field (info line) of a user. unlike the previous two 416 * rulesets the default is to deny (in line with other IRC servers). 417 * An allow-always match will be sought even if an allow match is found. */ 418 HOOK_FUNCTION(acl_registered_stage_hook) { 391 419 acl_t *ap; 392 420 connection_t *cp = (connection_t *)data; … … 404 432 * aren't allowed because of a class being full we actually have to keep on 405 433 * looking to see if they fit in somewhere else. blechhh. */ 406 LIST_FOREACH(ap, acl. stage3_list, intlp) {434 LIST_FOREACH(ap, acl.registered_list, intlp) { 407 435 if (ap->hash != hash && ap->hash != iphash && 408 436 ap->hash != ACL_DEFAULT_HASH) … … 451 479 } 452 480 453 if (ret == NULL && !LIST_EMPTY(acl. stage3_list))481 if (ret == NULL && !LIST_EMPTY(acl.registered_list)) 454 482 return "You are not authorised to use this server."; 455 483 return ret; … … 518 546 519 547 clp = cep->list; 520 stg = str_conv_int(conf_find_entry("stage", clp, 1), 521 ACL_STAGE_REGISTER); 548 stg = ACL_STAGE_REGISTERED; 549 if ((s = conf_find_entry("stage", clp, 1)) != NULL) { 550 if ((stg = acl_stage_str_to_int(s)) == 0) { 551 log_warn("invalid stage %s", s); 552 continue; 553 } 554 555 /* warn about use of stage numbers */ 556 if (str_conv_int(s, -1) != -1) 557 log_warn("stage numbers in ACLs are deprecated, please " 558 "use one of 'connected', 'unregistered' or " 559 "'registered' instead."); 560 } 522 561 s = conf_find_entry("access", clp, 1); 523 562 if (s == NULL) { … … 646 685 mask = s; 647 686 else if (!strcasecmp(tok, "stage")) { 648 stage = str_conv_int(s, 0); 649 if (stage < ACL_STAGE_CONNECT || 650 stage > ACL_STAGE_REGISTER) { 687 if ((stage = acl_stage_str_to_int(s)) == 0) { 651 688 snprintf(rpl, XINFO_LEN, 652 689 "%s is not a valid stage type", s); … … 684 721 /* okay, now dump them the list.. */ 685 722 switch (stage) { 686 case ACL_STAGE_ PREREG:687 list = acl. stage2_list;723 case ACL_STAGE_UNREGISTERED: 724 list = acl.unregistered_list; 688 725 break; 689 case ACL_STAGE_REGISTER :690 list = acl. stage3_list;726 case ACL_STAGE_REGISTERED: 727 list = acl.unregistered_list; 691 728 break; 692 case ACL_STAGE_CONNECT :729 case ACL_STAGE_CONNECTED: 693 730 default: 694 list = acl. stage1_list;731 list = acl.connected_list; 695 732 } 696 733 while (list != NULL) { … … 705 742 continue; 706 743 snprintf(rpl, XINFO_LEN, 707 "STAGE % dRULE %5hu ADDRESS %s%s%s ACCESS %s TYPE %s",708 a p->stage, ap->rule,744 "STAGE %s RULE %5hu ADDRESS %s%s%s ACCESS %s TYPE %s", 745 acl_stage_int_to_str(ap->stage), ap->rule, 709 746 (*ap->user ? ap->user : ""), (*ap->user ? "@" : ""), 710 747 ap->host, (ap->access == ACL_DENY ? "DENY" : … … 728 765 /* keep looping? */ 729 766 if (stage == 0) { 730 if (list == acl. stage1_list)731 list = acl. stage2_list;732 else if (list == acl. stage2_list)733 list = acl. stage3_list;767 if (list == acl.connected_list) 768 list = acl.unregistered_list; 769 else if (list == acl.unregistered_list) 770 list = acl.registered_list; 734 771 else 735 772 break; … … 744 781 745 782 LIST_ALLOC(acl.list); 746 LIST_ALLOC(acl. stage1_list);747 LIST_ALLOC(acl. stage2_list);748 LIST_ALLOC(acl. stage3_list);783 LIST_ALLOC(acl.connected_list); 784 LIST_ALLOC(acl.unregisted_list); 785 LIST_ALLOC(acl.registered_list); 749 786 750 787 add_xinfo_handler(xinfo_acl_handler, "ACL", XINFO_HANDLER_OPER, … … 752 789 753 790 /* add hooks for stage checks */ 754 add_hook(ircd.events. stage1_connect, acl_stage1_hook);755 add_hook(ircd.events. stage2_connect, acl_stage2_hook);756 add_hook(ircd.events. stage3_connect, acl_stage3_hook);791 add_hook(ircd.events.connection_connected, acl_connected_hook); 792 add_hook(ircd.events.connection_unregistered, acl_unregistered_hook); 793 add_hook(ircd.events.connection_registered, acl_registered_hook); 757 794 add_hook(me.events.read_conf, acl_conf_hook); 758 795 … … 766 803 destroy_acl(LIST_FIRST(acl.list)); 767 804 LIST_FREE(acl.list); 768 LIST_FREE(acl. stage1_list);769 LIST_FREE(acl. stage2_list);770 LIST_FREE(acl. stage3_list);805 LIST_FREE(acl.connected_list); 806 LIST_FREE(acl.unregistered_list); 807 LIST_FREE(acl.registered_list); 771 808 772 809 remove_xinfo_handler(xinfo_acl_handler); 773 810 774 remove_hook(ircd.events. stage1_connect, acl_stage1_hook);775 remove_hook(ircd.events. stage2_connect, acl_stage2_hook);776 remove_hook(ircd.events. stage3_connect, acl_stage3_hook);811 remove_hook(ircd.events.connection_connected, acl_connected_hook); 812 remove_hook(ircd.events.connection_unregistered, acl_unregistered_hook); 813 remove_hook(ircd.events.connection_registered, acl_registered_hook); 777 814 remove_hook(me.events.read_conf, acl_conf_hook); 778 815 } -
trunk/ithildin/modules/ircd/addons/acl.h
r787 r801 12 12 13 13 typedef struct acl { 14 #define ACL_STAGE_CONNECT 115 #define ACL_STAGE_ PREREG216 #define ACL_STAGE_REGISTER 314 #define ACL_STAGE_CONNECTED 1 15 #define ACL_STAGE_UNREGISTERED 2 16 #define ACL_STAGE_REGISTERED 3 17 17 int stage; /* one of 1, 2, or 3 */ 18 18 #define ACL_ACCESS_ANY -1 … … 56 56 57 57 extern struct acl_module_data { 58 struct acl_list * stage1_list;59 struct acl_list * stage2_list;60 struct acl_list * stage3_list;58 struct acl_list *connected_list; 59 struct acl_list *unregistered_list; 60 struct acl_list *registered_list; 61 61 struct acl_list *list; 62 62 … … 71 71 void acl_add_timer(acl_t *, time_t); 72 72 void acl_force_check(int, const acl_t *, const char *, bool); 73 HOOK_FUNCTION(acl_stage1_hook); 74 HOOK_FUNCTION(acl_stage2_hook); 75 HOOK_FUNCTION(acl_stage3_hook); 73 int acl_stage_str_to_int(const char *); 74 const char *acl_stage_int_to_str(int); 75 HOOK_FUNCTION(acl_connected_stage_hook); 76 HOOK_FUNCTION(acl_unregistered_stage_hook); 77 HOOK_FUNCTION(acl_registered_stage_hook); 76 78 77 79 #endif -
trunk/ithildin/modules/ircd/addons/throttle.c
r787 r801 61 61 static void destroy_throttle(throttle_t *); 62 62 63 HOOK_FUNCTION(throttle_ stage1_hook);63 HOOK_FUNCTION(throttle_connected_hook); 64 64 HOOK_FUNCTION(throttle_conf_hook); 65 65 HOOK_FUNCTION(throttle_timer_hook); … … 106 106 #define THROTTLE_ERRMSG \ 107 107 "Your host is trying to (re)connect too fast -- throttled." 108 HOOK_FUNCTION(throttle_ stage1_hook) {108 HOOK_FUNCTION(throttle_connected_hook) { 109 109 connection_t *cp = (connection_t *)data; 110 110 throttle_t *tp = find_throttle(isock_raddr(cp->sock)); … … 164 164 165 165 if (tp->banned + len >= me.now) { 166 if ((ap = find_acl(ACL_STAGE_CONNECT , ACL_DENY, cp->host,166 if ((ap = find_acl(ACL_STAGE_CONNECTED, ACL_DENY, cp->host, 167 167 throttle_acl_type, ACL_DEFAULT_RULE, NULL, NULL)) == NULL) { 168 ap = create_acl(ACL_STAGE_CONNECT , ACL_DENY, cp->host,168 ap = create_acl(ACL_STAGE_CONNECTED, ACL_DENY, cp->host, 169 169 throttle_acl_type, ACL_DEFAULT_RULE); 170 170 ap->reason = strdup(THROTTLE_ERRMSG); … … 272 272 LIST_ALLOC(throttle.list); 273 273 274 add_hook_before(ircd.events. stage1_connect, throttle_stage1_hook,275 acl_stage1_hook);274 add_hook_before(ircd.events.connection_connected, 275 throttle_connected_stage_hook, acl_connected_stage_hook); 276 276 add_hook(me.events.read_conf, throttle_conf_hook); 277 277 … … 288 288 LIST_FREE(throttle.list); 289 289 290 remove_hook(ircd.events.stage1_connect, throttle_stage1_hook); 290 remove_hook(ircd.events.connection_connected, 291 throttle_connected_stage_hook); 291 292 remove_hook(me.events.read_conf, throttle_conf_hook); 292 293 } -
trunk/ithildin/modules/ircd/channel.c
r744 r801 73 73 void destroy_channel(channel_t *chan) { 74 74 unsigned char *s; 75 chanmode_func changefn;76 75 int dummy; 77 76 … … 81 80 s = ircd.cmodes.avail; 82 81 while (*s) { 83 changefn = (chanmode_func)getsym(ircd.cmodes.modes[*s].changefunc); 84 changefn(NULL, chan, *s, CHANMODE_CLEAR, NULL, &dummy); 82 ircd.cmodes.modes[*s].changefunc(NULL, chan, *s, CHANMODE_CLEAR, NULL, &dummy); 85 83 s++; 86 84 } … … 123 121 124 122 uint64_t chanmode_request(unsigned char suggested, unsigned char *actual, 125 int flags, char *changefn, char *queryfn, size_t extra, void *extdata) { 123 int flags, chanmode_func changefn, chanmode_query_func queryfn, 124 size_t extra, void *extdata) { 126 125 struct chanmode *md = NULL; 127 126 int i, j; … … 156 155 md->umask = 0; 157 156 md->prefix = '\0'; 158 md->changefunc = import_symbol(changefn);159 md->queryfunc = import_symbol(queryfn);157 md->changefunc = changefn; 158 md->queryfunc = queryfn; 160 159 md->flags = flags; 161 160 md->mdi = NULL; … … 196 195 void chanmode_release(unsigned char mode) { 197 196 channel_t *chan; 198 chanmode_func changefn =199 (chanmode_func)getsym(ircd.cmodes.modes[mode].changefunc);200 197 int dummy; 201 198 202 199 /* clear the mode from all the channels .. */ 203 200 LIST_FOREACH(chan, ircd.lists.channels, lp) 204 changefn(NULL, chan, mode, CHANMODE_CLEAR, NULL, &dummy);201 ircd.cmodes.modes[mode].changefunc(NULL, chan, mode, CHANMODE_CLEAR, NULL, &dummy); 205 202 206 203 /* we don't touch the mode or mask members because those are set elsewhere … … 219 216 destroy_mdext_item(ircd.mdext.channel, ircd.cmodes.modes[mode].mdi); 220 217 chanmode_build_lists(); 218 } 219 220 void chanmode_update_funcs(unsigned char mode, chanmode_func changefunc, 221 chanmode_query_func queryfunc) { 222 struct chanmode *cmp = &ircd.cmodes.modes[mode]; 223 224 if (cmp->avail || !cmp->mask) /* only if it exists.. */ 225 return; 226 227 cmp->changefunc = changefunc; 228 cmp->queryfunc = queryfunc; 221 229 } 222 230 … … 285 293 int *argused) { 286 294 struct chanmode *cmp = &ircd.cmodes.modes[mode]; 287 chanmode_func changefn;288 295 289 296 if (cmp->avail || !cmp->mask) /* only if it exists.. */ … … 292 299 /* otherwise, just try and set the mode with the given functions, returning 293 300 * the value as requested */ 294 changefn = (chanmode_func)getsym(cmp->changefunc); 295 return changefn(cli, chan, mode, CHANMODE_SET, arg, argused); 301 return cmp->changefunc(cli, chan, mode, CHANMODE_SET, arg, argused); 296 302 } 297 303 … … 299 305 int *argused) { 300 306 struct chanmode *cmp = ircd.cmodes.pfxmap[prefix]; 301 chanmode_func changefn;302 307 303 308 if (cmp == NULL) … … 305 310 306 311 /* found it, now set it */ 307 changefn = (chanmode_func)getsym(cmp->changefunc); 308 return changefn(NULL, chan, cmp->mode, CHANMODE_SET, arg, argused); 312 return cmp->changefunc(NULL, chan, cmp->mode, CHANMODE_SET, arg, argused); 309 313 } 310 314 … … 312 316 char *arg, int *argused) { 313 317 struct chanmode *cmp = &ircd.cmodes.modes[mode]; 314 chanmode_func changefn;315 318 316 319 if (cmp->avail || !cmp->mask) /* only if it exists.. */ … … 319 322 /* otherwise, just try and set the mode with the given functions, returning 320 323 * the value as requested */ 321 changefn = (chanmode_func)getsym(cmp->changefunc); 322 return changefn(cli, chan, mode, CHANMODE_UNSET, arg, argused); 324 return cmp->changefunc(cli, chan, mode, CHANMODE_UNSET, arg, argused); 323 325 } 324 326 … … 326 328 int *argused) { 327 329 struct chanmode *cmp = ircd.cmodes.pfxmap[prefix]; 328 chanmode_func changefn;329 330 330 331 if (cmp == NULL) … … 332 333 333 334 /* found it, now unset it */ 334 changefn = (chanmode_func)getsym(cmp->changefunc); 335 return changefn(NULL, chan, cmp->mode, CHANMODE_UNSET, arg, argused); 335 return cmp->changefunc(NULL, chan, cmp->mode, CHANMODE_UNSET, arg, argused); 336 336 } 337 337 … … 339 339 int *argused, void **state) { 340 340 struct chanmode *cmp = &ircd.cmodes.modes[mode]; 341 chanmode_query_func queryfn;342 341 343 342 if (cmp->avail || !cmp->mask) /* only if it exists.. */ … … 345 344 346 345 /* let's ask 'em about it. */ 347 queryfn = (chanmode_query_func)getsym(cmp->queryfunc); 348 return queryfn(chan, mode, arg, argused, state); 346 return cmp->queryfunc(chan, mode, arg, argused, state); 349 347 } 350 348 -
trunk/ithildin/modules/ircd/channel.h
r629 r801 93 93 #define CHANMODE_NOARG -4 94 94 95 uint64_t chanmode_request(unsigned char, unsigned char *, int, char *,96 cha r *, size_t, void *);95 uint64_t chanmode_request(unsigned char, unsigned char *, int, 96 chanmode_func, chanmode_query_func, size_t, void *); 97 97 void chanmode_release(unsigned char); 98 void chanmode_update_funcs(unsigned char, chanmode_func, 99 chanmode_query_func); 98 100 /* ways to set and unset channel modes. channel modes are typically set by 99 101 * their mode character, but can also be set by prefix in the case of userflag … … 174 176 the prefix (specified by the caller in extdata). 175 177 no error checking is done on this value. */ 176 msymbol_t *changefunc;/* the symbol/function to change the mode */177 msymbol_t *queryfunc;/* the symbol/function to query the mode */178 chanmode_func changefunc; /* the symbol/function to change the mode */ 179 chanmode_query_func queryfunc; /* the symbol/function to query the mode */ 178 180 int flags; /* flags given for this mode */ 179 181 struct mdext_item *mdi; /* the mdext_item which describes the channel mode. -
trunk/ithildin/modules/ircd/client.c
r787 r801 186 186 /* only do this stuff if it's a real client, and not a fake one */ 187 187 if (cp != NULL) { 188 /* check to see if our client is stage3okay */189 returns = hook_event(ircd.events. stage3_connect, cp);188 /* check to see if our client is okay */ 189 returns = hook_event(ircd.events.connection_registered, cp); 190 190 while (x < hook_num_returns) { 191 191 if (returns[x] != NULL) {/* denied, with a reason */ … … 195 195 x++; 196 196 } 197 /* remove our client from the stage2 list, and put it in the stage3198 * list. */197 /* remove our client from the unregistered list, and put it in 198 * the registered * list. */ 199 199 LIST_REMOVE(cp, lp); 200 200 LIST_INSERT_HEAD(ircd.connections.clients, cp, lp); … … 315 315 /* mode goodies below here */ 316 316 uint64_t usermode_request(unsigned char suggested, unsigned char *actual, 317 int flags, int sflag, char *changer) {317 int flags, int sflag, usermode_func changefunc) { 318 318 struct usermode *md = NULL; 319 319 uint64_t allmodes = 0; … … 355 355 md->avail = 0; /* mark it used */ 356 356 md->flags = flags; 357 if (changer != NULL) 358 md->changer = import_symbol(changer); 359 else 360 md->changer = NULL; 357 md->changefunc = changefunc; 361 358 md->sflag = sflag; 362 359 *actual = md->mode; … … 384 381 ircd.umodes.modes[mode].avail = 1; 385 382 ircd.umodes.modes[mode].flags = 0; 386 ircd.umodes.modes[mode].change r= NULL;383 ircd.umodes.modes[mode].changefunc = NULL; 387 384 allmodes &= ~ircd.umodes.modes[mode].mask; 388 385 389 386 strcpy(ircd.umodes.avail, usermode_getstr(allmodes, 0) + 1); 387 } 388 389 void usermode_update_func(unsigned char mode, usermode_func changefunc) { 390 struct usermode *md = &ircd.umodes.modes[mode]; 391 392 if (md->avail || !md->mask) 393 return 0; 394 395 md->changefunc = changefunc; 390 396 } 391 397 … … 467 473 /* always call the set function. if they're not our client, we ignore the 468 474 * return value. */ 469 if ((md->changer != NULL && 470 !((usermode_func)getsym(md->changer))(cli, on, mode, 1, arg, 471 argused)) && MYCLIENT(on)) 475 if ((md->changefunc != NULL && 476 !md->changefunc(cli, on, mode, 1, arg, argused)) && MYCLIENT(on)) 472 477 return 0; 473 478 /* if they're local, not opered, and the mode is an oper mode, don't let … … 500 505 /* always call the unset function. if they're not our client, we ignore 501 506 * the return value. */ 502 if ((md->changer != NULL && 503 !((usermode_func)getsym(md->changer))(cli, on, mode, 0, arg, 504 argused)) && MYCLIENT(on)) 507 if ((md->changefunc != NULL && 508 !md->changefunc(cli, on, mode, 0, arg, argused)) && MYCLIENT(on)) 505 509 return 0; 506 510 -
trunk/ithildin/modules/ircd/client.h
r787 r801 66 66 67 67 /* this registers a client on the network/server. registering a client 68 * consists of checking it against stage3acls, placing it in a connection68 * consists of checking it against registered acls, placing it in a connection 69 69 * class (for real, not the default) (or dropping it if the class is full), 70 70 * then propogating the user creation across the network, and finally … … 98 98 char *, int *); 99 99 100 uint64_t usermode_request(unsigned char, unsigned char *, int, int, char *); 100 uint64_t usermode_request(unsigned char, unsigned char *, int, int, 101 usermode_func); 101 102 102 103 /* use this function to release a mode if you no longer care about it being set … … 104 105 * had one */ 105 106 void usermode_release(unsigned char); 107 108 /* this function provides a way to update the assigned function for a 109 * usermode */ 110 void usermode_update_func(unsigned char, usermode_func); 106 111 107 112 /* this function returns a mode string from the passed 64bit integer. the … … 147 152 int flags; /* flags for the usermode */ 148 153 uint64_t mask; /* the bitmask for the mode */ 149 msymbol_t *changer;/* the changer function for the mode */154 usermode_func changefunc; /* the changer function for the mode */ 150 155 int sflag; /* send flag (if any) for this mode. */ 151 156 }; -
trunk/ithildin/modules/ircd/commands/akill.c
r787 r801 49 49 #define ACL_DEL 1 50 50 int op = ACL_ADD; 51 int stage = ACL_STAGE_REGISTER ;51 int stage = ACL_STAGE_REGISTERED; 52 52 time_t expire = 0; 53 53 char *reason = NULL; … … 123 123 } 124 124 125 stage = ACL_STAGE_CONNECT ;125 stage = ACL_STAGE_CONNECTED; 126 126 type = acl_szline_type; 127 127 strlcpy(mask, argv[1], HOSTLEN + 1); … … 141 141 } 142 142 143 stage = ACL_STAGE_CONNECT ;143 stage = ACL_STAGE_CONNECTED; 144 144 type = acl_szline_type; 145 145 strlcpy(mask, argv[1], HOSTLEN + 1); -
trunk/ithildin/modules/ircd/commands/trace.c
r579 r801 125 125 * fairly valueless, especially on big servers, and there are other ways to 126 126 * get full listings. Only dump unknowns/opers/servers/classes for now */ 127 LIST_FOREACH(connp, ircd.connections. stage1, lp)127 LIST_FOREACH(connp, ircd.connections.connected, lp) 128 128 sendto_one(cli, RPL_FMT(cli, RPL_TRACEUNKNOWN), connp->cls->name, 129 129 connp->host, me.now - connp->last); 130 LIST_FOREACH(connp, ircd.connections. stage2, lp)130 LIST_FOREACH(connp, ircd.connections.unregistered, lp) 131 131 sendto_one(cli, RPL_FMT(cli, RPL_TRACEUNKNOWN), connp->cls->name, 132 132 connp->host, me.now - connp->last); … … 147 147 scnt++; 148 148 sp = connp->srv; 149 sendto_one(cli, RPL_FMT(cli, RPL_TRACESERVER), connp->cls->name, cnt,150 scnt, sp->name, "*", me.now - connp->last);149 sendto_one(cli, RPL_FMT(cli, RPL_TRACESERVER), connp->cls->name, scnt, 150 cnt, sp->name, "*", me.now - connp->last); 151 151 } 152 152 LIST_FOREACH(clsp, ircd.lists.classes, lp) { -
trunk/ithildin/modules/ircd/connection.c
r787 r801 22 22 IDSTRING(rcsid, "$Id$"); 23 23 24 static void connection_stage2_done(connection_t *); 25 static void connection_init_lookups(connection_t *); 24 static void connection_init_done(connection_t *); 26 25 27 26 void destroy_connection(connection_t *c, char *reason) { … … 71 70 } 72 71 73 /* this function closes all 'unknown' ( stage1/stage2) connections, handy in74 * various places. */72 /* this function closes all 'unknown' (connected/unregistered) connections, 73 * handy in various places. */ 75 74 int close_unknown_connections(char *reason) { 76 75 connection_t *cp; 77 76 int count = 0; 78 77 79 while (!LIST_EMPTY(ircd.connections. stage1)) {80 cp = LIST_FIRST(ircd.connections. stage1);78 while (!LIST_EMPTY(ircd.connections.connected)) { 79 cp = LIST_FIRST(ircd.connections.connected); 81 80 destroy_connection(cp, reason); 82 81 count++; 83 82 } 84 while (!LIST_EMPTY(ircd.connections. stage2)) {85 cp = LIST_FIRST(ircd.connections. stage2);83 while (!LIST_EMPTY(ircd.connections.unregistered)) { 84 cp = LIST_FIRST(ircd.connections.unregistered); 86 85 destroy_connection(cp, reason); 87 86 count++; … … 122 121 return 0; 123 122 } 123 124 124 return 1; 125 125 } … … 129 129 isocket_t *sp = NULL; 130 130 isocket_t *listener = (isocket_t *)data; 131 void **returns;132 int x;133 int dead;134 131 135 132 while ((sp = socket_accept(listener)) != NULL) { … … 143 140 144 141 add_to_class(LIST_FIRST(ircd.lists.classes), c); 145 LIST_INSERT_HEAD(ircd.connections.stage1, c, lp); 146 147 /* check for stage 1 access */ 148 returns = hook_event(ircd.events.stage1_connect, c); 149 x = 0; 150 dead = 0; 151 while (x < hook_num_returns) { 152 if (returns[x] != NULL) { 153 /* this is not an allowed connection, drop it with the given 154 * error message. */ 155 destroy_connection(c, returns[x]); 156 dead = 1; 157 break; 158 } 159 x++; 160 } 161 162 if (dead) 163 continue; /* connection was dropped above */ 164 142 LIST_INSERT_HEAD(ircd.connections.connected, c, lp); 165 143 add_hook(sp->datahook, ircd_connection_datahook); 166 144 167 /* success? do auth-stuff*/145 /* Check first for SSL goodies */ 168 146 #ifdef HAVE_OPENSSL 169 147 if (SOCKET_SSL(listener)) { 170 148 if (socket_ssl_enable(c->sock)) { 171 149 if (socket_ssl_accept(c->sock)) { 172 if ( !SOCKET_SSL_HANDSHAKING(c->sock))173 connection_init_lookups(c); /* handshake is done? */174 else150 if (SOCKET_SSL_HANDSHAKING(c->sock)) { 151 /* handshake isn't done... we have to defer the 152 * event calling */ 175 153 c->flags |= IRCD_CONNFL_SSLINIT; 176 continue; /* handshake isn't done. */ 154 continue; 155 } 177 156 } 178 157 } … … 183 162 #endif 184 163 185 connection_init_lookups(c); 164 connection_init_done(c); 165 186 166 } 187 167 … … 189 169 } 190 170 191 /* this is used to initialize the stage2 lookups. it is kept separate so that 192 * SSL accepts can be done prior to the data sending. */ 193 static void connection_init_lookups(connection_t *c) { 194 char msg[256]; 195 196 if (!(c->flags & IRCD_CONNFL_DNS)) { 197 sprintf(msg, ":%s NOTICE AUTH :*** Looking up your hostname...\r\n", 198 ircd.me->name); 199 socket_write(c->sock, msg, strlen(msg)); 200 dns_lookup(DNS_C_IN, DNS_T_PTR, c->host, connection_lookup_hook); 201 } 202 if (!(c->flags & IRCD_CONNFL_IDENT)) { 203 sprintf(msg, ":%s NOTICE AUTH :*** Checking Ident...\r\n", 204 ircd.me->name); 205 socket_write(c->sock, msg, strlen(msg)); 206 check_ident(c->sock, connection_ident_hook); 207 } 208 if (IRCD_CONN_DONE(c) && IRCD_CONN_NEED_STAGE2(c)) 209 connection_stage2_done(c); 210 } 211 212 /* this function handles receiving/sending of lookups. the first time it is 213 * called for a socket it will either have a successful ptr lookup or a 214 * failure. if the ptr lookup is successful it then performs a host lookup on 215 * the host returned. if that lookup succeeds the connection's hostname is set 216 * to that, otherwise in any case of failure the connection's hostname is set 217 * to its IP address */ 218 HOOK_FUNCTION(connection_lookup_hook) { 219 dns_lookup_t *dlp = (dns_lookup_t *)data; 220 struct dns_rr *drp; 221 connection_t *c, *c2; 222 char msg[256]; 223 char ip[FQDN_MAXLEN]; 224 225 c = LIST_FIRST(ircd.connections.stage1); 226 while (c != NULL) { 227 c2 = LIST_NEXT(c, lp); 228 229 if (dlp->type == DNS_T_PTR) { 230 /* this was a reverse lookup. skip hosts doing address lookups and 231 * non-matching connections. */ 232 if (c->flags & IRCD_CONNFL_DNS || strcasecmp(c->host, dlp->data)) { 233 c = c2; 234 continue; 235 } 236 237 /* this connection matches. look for a ptr record. */ 238 drp = LIST_FIRST(&dlp->rrs.an); 239 while (drp != NULL) { 240 /* Use the first PTR answer we get. */ 241 if (drp->type == DNS_T_PTR) 242 break; 243 drp = LIST_NEXT(drp, lp); 244 } 245 if (dlp->flags & DNS_LOOKUP_FL_FAILED || drp == NULL) { 246 sprintf(msg, ":%s NOTICE AUTH :*** Couldn't find your " 247 "hostname.\r\n", ircd.me->name); 248 socket_write(c->sock, msg, strlen(msg)); 249 c->flags |= IRCD_CONNFL_DNS; 250 } else { 251 strlcpy(c->host, drp->rdata.txt, HOSTLEN + 1); 252 c->flags |= IRCD_CONNFL_DNS_PTR; 253 dns_lookup(DNS_C_IN, (c->sock->peeraddr.family == PF_INET6 254 ? DNS_T_AAAA : DNS_T_A), c->host, 255 connection_lookup_hook); 256 } 257 } else { 258 dns_type_t atype; 259 260 /* this was a forward lookup. skip reverses and non-matching 261 * connections as above. */ 262 if (!(c->flags & IRCD_CONNFL_DNS) || 263 strcasecmp(c->host, dlp->data)) { 264 c = c2; 265 continue; 266 } 267 268 get_socket_address(isock_raddr(c->sock), ip, FQDN_MAXLEN, NULL); 269 /* a match. look for the right A or AAAA record. there may, in 270 * this case, be several of them. */ 271 atype = (c->sock->peeraddr.family == PF_INET6 ? 272 DNS_T_AAAA : DNS_T_A); 273 drp = LIST_FIRST(&dlp->rrs.an); 274 while (drp != NULL) { 275 /* Check each answer.. */ 276 if (drp->type == atype && 277 !strcasecmp(drp->rdata.txt, ip)) 278 break; 279 drp = LIST_NEXT(drp, lp); 280 } 281 if (dlp->flags & DNS_LOOKUP_FL_FAILED || drp == NULL) { 282 sprintf(msg, ":%s NOTICE AUTH :*** Couldn't find your " 283 "hostname.\r\n", ircd.me->name); 284 socket_write(c->sock, msg, strlen(msg)); 285 c->flags |= IRCD_CONNFL_DNS; 286 strcpy(c->host, ip); 287 } else { 288 sprintf(msg, ":%s NOTICE AUTH :*** Found your hostname.\r\n", 289 ircd.me->name); 290 if (!istr_okay(ircd.maps.host, c->host)) { 291 sprintf(msg, ":%s NOTICE AUTH :*** Found your hostname, " 292 "but it contains invalid characters. Using IP " 293 "instead.\r\n", ircd.me->name); 294 /* log a warning, too */ 295 log_warn("bad hostname from %s: %s", ip, c->host); 296 strcpy(c->host, ip); 297 } 298 socket_write(c->sock, msg, strlen(msg)); 299 c->flags |= IRCD_CONNFL_DNS_ADDR; 300 } 301 } 302 if (IRCD_CONN_DONE(c) && IRCD_CONN_NEED_STAGE2(c)) 303 connection_stage2_done(c); 304 305 c = c2; 306 } 307 308 return NULL; 309 } 310 311 HOOK_FUNCTION(connection_ident_hook) { 312 struct ident_request *i = (struct ident_request *)data; 313 connection_t *c; 314 char msg[256]; 315 316 /* try and find our socket. */ 317 LIST_FOREACH(c, ircd.connections.stage1, lp) { 318 if (!memcmp(isock_laddr(c->sock), &i->laddr, 319 sizeof(struct isock_address)) && 320 !memcmp(isock_raddr(c->sock), &i->raddr, 321 sizeof(struct isock_address))) 322 break; /* found it */ 323 } 324 if (c == NULL) 325 return NULL; /* didn't find it. */ 326 327 c->flags |= IRCD_CONNFL_IDENT; 328 if (!strcmp(i->answer, "")) { 329 strcpy(c->user, "~"); 330 sprintf(msg, ":%s NOTICE AUTH :*** No Ident response.\r\n", 331 ircd.me->name); 332 } else { 333 strncpy(c->user, i->answer, USERLEN); 334 sprintf(msg, ":%s NOTICE AUTH :*** Got Ident response.\r\n", 335 ircd.me->name); 336 } 337 338 socket_write(c->sock, msg, strlen(msg)); 339 if (IRCD_CONN_DONE(c) && IRCD_CONN_NEED_STAGE2(c)) 340 connection_stage2_done(c); 341 342 return NULL; 343 } 344 345 static void connection_stage2_done(connection_t *c) { 171 /* Called when the initial work on a connection should be done. */ 172 static void connection_init_done(connection_t *c) { 173 void **returns; 174 int x; 175 176 /* check for preliminary connection access */ 177 returns = hook_event(ircd.events.connection_connected, c); 178 x = 0; 179 while (x < hook_num_returns) { 180 if (returns[x] != NULL) { 181 /* this is not an allowed connection, drop it with the given 182 * error message. */ 183 destroy_connection(c, returns[x]); 184 break; 185 } 186 x++; 187 } 188 } 189 190 bool connection_set_unregistered(connection_t *c) { 346 191 void **returns; 347 192 int x = 0; 348 193 349 returns = hook_event(ircd.events. stage2_connect, c);194 returns = hook_event(ircd.events.connection_unregistered, c); 350 195 while (x < hook_num_returns) { 351 196 if (returns[x] != NULL) { … … 353 198 * structure. */ 354 199 destroy_connection(c, (char *)returns[x]); 355 return ;200 return false; 356 201 } 357 202 x++; 358 203 } 359 204 LIST_REMOVE(c, lp); 360 LIST_INSERT_HEAD(ircd.connections. stage2, c, lp);205 LIST_INSERT_HEAD(ircd.connections.unregistered, c, lp); 361 206 362 207 /* now stick them in the default protocol */ … … 365 210 /* and monitor them */ 366 211 socket_monitor(c->sock, SOCKET_FL_READ|SOCKET_FL_WRITE); 212 213 return true; 367 214 } 368 215 … … 380 227 } 381 228 c->flags &= ~IRCD_CONNFL_SSLINIT; 382 connection_init_ lookups(c);229 connection_init_done(c); 383 230 return NULL; 384 } else if (!IRCD_CONN_DONE(c)) { 385 log_debug("!IRCD_CONN_DONE(%p) caught! (flags %x)", c, c->flags); 386 return NULL; /* ignore unfinished connections */ 387 } 231 } 232 /* XXX: removed debug message for hooks when the connection isn't 233 * completed. we probably don't need this anymore... */ 388 234 #endif 389 235 … … 463 309 464 310 /* handle sendqs for each of our three connection stages, in order */ 465 cp = LIST_FIRST(ircd.connections. stage1);311 cp = LIST_FIRST(ircd.connections.connected); 466 312 while (cp != NULL) { 467 313 cp2 = LIST_NEXT(cp, lp); … … 469 315 cp = cp2; 470 316 } 471 cp = LIST_FIRST(ircd.connections. stage2);317 cp = LIST_FIRST(ircd.connections.unregistered); 472 318 while (cp != NULL) { 473 319 cp2 = LIST_NEXT(cp, lp); … … 492 338 return NULL; 493 339 } 340 494 341 /* vi:set ts=8 sts=4 sw=4 tw=76 et: */ -
trunk/ithildin/modules/ircd/connection.h
r787 r801 46 46 } stats; 47 47 48 #define IRCD_CONNFL_DNS_PTR 0x149 #define IRCD_CONNFL_DNS_ADDR 0x250 #define IRCD_CONNFL_DNS (IRCD_CONNFL_DNS_PTR | IRCD_CONNFL_DNS_ADDR)51 #define IRCD_CONNFL_IDENT 0x452 #define IRCD_CONNFL_STAGE2 0x853 #define IRCD_CONN_DONE(x) \54 (((x)->flags & (IRCD_CONNFL_DNS | IRCD_CONNFL_IDENT)) == \55 (IRCD_CONNFL_DNS | IRCD_CONNFL_IDENT))56 #define IRCD_CONN_NEED_STAGE2(x) (!((x)->flags & IRCD_CONNFL_STAGE2))57 58 48 #define IRCD_CONNFL_WRITEABLE 0x100 /* set if the socket is writeable */ 59 49 #define CONN_PINGSENT(conn) (conn->flags & IRCD_CONNFL_PINGSENT) … … 81 71 }; 82 72 73 bool connection_set_unregistered(connection_t *); 74 bool connection_set_registered(connection_t *); 75 83 76 void destroy_connection(connection_t *, char *); 84 77 int close_unknown_connections(char *); 85 78 int sendq_flush(connection_t *); 86 79 87 HOOK_FUNCTION(connection_lookup_hook);88 HOOK_FUNCTION(connection_ident_hook);89 80 HOOK_FUNCTION(ircd_connection_datahook); 90 81 HOOK_FUNCTION(ircd_writer_hook); -
trunk/ithildin/modules/ircd/ircd.c
r787 r801 18 18 IDSTRING(rcsid, "$Id$"); 19 19 20 MODULE_REGISTER( PACKAGE_VERSION);20 MODULE_REGISTER(IRCD_VERSION); 21 21 /* 22 22 @DEPENDENCIES@: dns ident … … 66 66 } 67 67 68 /* time out dead clients in stage2/clients based on their class */ 69 cp = LIST_FIRST(ircd.connections.stage2); 68 /* XXX: does the connection timeout code actually belong in connection.c 69 * / client.c / server.c? */ 70 71 /* time out or promote connections based on callback completion and 72 * class ping frequency */ 73 cp = LIST_FIRST(ircd.connections.connected); 70 74 while (cp != NULL) { 71 75 cp2 = LIST_NEXT(cp, lp); 72 /* for stage2, drop connections 4x faster than normal, since 73 * connections should *not* sit in a stage2 situation */ 76 if (callback_pending(cp->sock) == 0) 77 connection_set_unregistered(cp); 78 /* there is no connection timeout for fresh connections */ 79 } 80 81 cp = LIST_FIRST(ircd.connections.unregistered); 82 while (cp != NULL) { 83 cp2 = LIST_NEXT(cp, lp); 84 /* for unregistered, drop connections 4x faster than normal, since 85 * connections should *not* sit in this state for long */ 74 86 if ((now - cp->last) > (cp->cls->freq / 4)) 75 87 destroy_connection(cp, "Ping timeout"); … … 259 271 if (!get_module_savedata(savelist, "ircd.connections", 260 272 &ircd.connections)) { 261 LIST_ALLOC(ircd.connections. stage1);262 LIST_ALLOC(ircd.connections. stage2);273 LIST_ALLOC(ircd.connections.connected); 274 LIST_ALLOC(ircd.connections.unregistered); 263 275 LIST_ALLOC(ircd.connections.clients); 264 276 LIST_ALLOC(ircd.connections.servers); … … 338 350 339 351 /* we know that all modes are free. grab i, o, and s */ 340 EXPORT_SYM(mode_set_counter);341 352 ircd.umodes.i = usermode_request('i', &c, USERMODE_FL_GLOBAL, -1, 342 "mode_set_counter");353 mode_set_counter); 343 354 ircd.umodes.o = usermode_request('o', &c, USERMODE_FL_GLOBAL, 344 ircd.sflag.ops, "mode_set_counter");355 ircd.sflag.ops, mode_set_counter); 345 356 ircd.umodes.s = usermode_request('s', &c, 0, ircd.sflag.servmsg, 346 357 NULL); 358 } else { 359 /* Be sure to update the function address for this channel mode in 360 * case it moved.. */ 361 usermode_update_func(ircd.umodes.i, mode_set_counter); 362 usermode_update_func(ircd.umodes.o, mode_set_counter); 363 usermode_update_func(ircd.umodes.s, mode_set_counter); 347 364 } 348 365 … … 357 374 * later in *this function*. :) */ 358 375 if (!get_module_savedata(savelist, "ircd.events", &ircd.events)) { 359 ircd.events. stage1_connect= create_event(0);360 ircd.events. stage2_connect= create_event(0);361 ircd.events. stage3_connect= create_event(0);376 ircd.events.connection_connected = create_event(0); 377 ircd.events.connection_unregistered = create_event(0); 378 ircd.events.connection_registered = create_event(0); 362 379 363 380 ircd.events.client_connect = create_event(EVENT_FL_NORETURN); … … 471 488 472 489 if (!get_module_savedata(savelist, "ircd.hashes", &ircd.hashes)) { 473 EXPORT_SYM(nickcmp);474 EXPORT_SYM(chancmp);475 490 476 491 ircd.hashes.command = create_hash_table(32, 477 492 offsetof(struct command, name), COMMAND_MAXLEN, 478 HASH_FL_NOCASE|HASH_FL_STRING, "strncasecmp"); 493 HASH_FL_NOCASE|HASH_FL_STRING, 494 (hashcmp_function_t)strncasecmp); 479 495 480 496 ircd.hashes.client = create_hash_table(128, offsetof(client_t, nick), 481 NICKLEN, HASH_FL_NOCASE|HASH_FL_STRING, "nickcmp"); 497 NICKLEN, HASH_FL_NOCASE|HASH_FL_STRING, 498 (hashcmp_function_t)nickcmp); 482 499 ircd.hashes.client_history = create_hash_table(1024, 483 500 offsetof(struct client_history, nick), NICKLEN, 484 HASH_FL_NOCASE|HASH_FL_STRING, "nickcmp"); 501 HASH_FL_NOCASE|HASH_FL_STRING, 502 (hashcmp_function_t)nickcmp); 485 503 486 504 ircd.hashes.channel = create_hash_table(128, offsetof(channel_t, name), 487 CHANLEN, HASH_FL_NOCASE|HASH_FL_STRING, "chancmp"); 505 CHANLEN, HASH_FL_NOCASE|HASH_FL_STRING, 506 (hashcmp_function_t)chancmp); 507 } else if (reload) { 508 ircd.hashes.client->cmpfunc = (hashcmp_function_t)nickcmp; 509 ircd.hashes.client_history->cmpfunc = (hashcmp_function_t)nickcmp; 510 ircd.hashes.channel->cmpfunc = (hashcmp_function_t)chancmp; 488 511 } 489 512 490 513 if (!get_module_savedata(savelist, "ircd.mdext", &ircd.mdext)) { 491 EXPORT_SYM(client_mdext_iter); 492 EXPORT_SYM(channel_mdext_iter); 493 EXPORT_SYM(class_mdext_iter); 494 ircd.mdext.client = create_mdext_header("client_mdext_iter"); 495 ircd.mdext.channel = create_mdext_header("channel_mdext_iter"); 496 ircd.mdext.class = create_mdext_header("class_mdext_iter"); 514 ircd.mdext.client = create_mdext_header(client_mdext_iter); 515 ircd.mdext.channel = create_mdext_header(channel_mdext_iter); 516 ircd.mdext.class = create_mdext_header(class_mdext_iter); 517 } else if (reload) { 518 ircd.mdext.client->iter = client_mdext_iter; 519 ircd.mdext.channel->iter = channel_mdext_iter; 520 ircd.mdext.class->iter = class_mdext_iter; 497 521 } 498 522 … … 548 572 free(ircd.argv[i]); 549 573 free(ircd.argv); 550 551 dns_lookup_cancel(connection_lookup_hook);552 ident_cancel(connection_ident_hook);553 574 554 575 /* close unknown connections and either remove our datahook if we're … … 644 665 645 666 /* events ... */ 646 destroy_event(ircd.events. stage1_connect);647 destroy_event(ircd.events. stage2_connect);648 destroy_event(ircd.events. stage3_connect);667 destroy_event(ircd.events.connection_connected); 668 destroy_event(ircd.events.connection_unregistered); 669 destroy_event(ircd.events.connection_registered); 649 670 destroy_event(ircd.events.client_connect); 650 671 destroy_event(ircd.events.client_disconnect); … … 670 691 671 692 /* And lists... */ 672 LIST_FREE(ircd.connections. stage1);673 LIST_FREE(ircd.connections. stage2);693 LIST_FREE(ircd.connections.connected); 694 LIST_FREE(ircd.connections.unregistered); 674 695 LIST_FREE(ircd.connections.clients); 675 696 LIST_FREE(ircd.connections.servers); -
trunk/ithildin/modules/ircd/ircd.h
r579 r801 149 149 150 150 /* the three connection stage events, used by the acl system, and 151 * maybe others. */ 152 event_t *stage1_connect; 153 event_t *stage2_connect; 154 event_t *stage3_connect; 151 * maybe others. connection_registered only fires for CLIENTS 152 * which are registered. */ 153 event_t *connection_connected; 154 event_t *connection_unregistered; 155 event_t *connection_registered; 155 156 156 157 /* other events */ 157 event_t *client_connect; /* called after the stage*_connectto note158 event_t *client_connect; /* called after connection_registered to note 158 159 the connection of a (local) client */ 159 160 event_t *client_disconnect; /* called when a registered client (local) 160 161 is disconnecting from the server */ 161 event_t *register_client; /* called from register_client() for all162 event_t *register_client; /* called from register_client() for all 162 163 connecting clients. */ 163 164 event_t *unregister_client; /* called from destroy_client() for all … … 170 171 initially created. */ 171 172 event_t *channel_destroy; /* same, but for destruction. */ 172 event_t *channel_add; /* hooked when a client joins a channel */173 event_t *channel_del; /* same, but with part */174 175 event_t *server_introduce; /* called when server_introduce() is173 event_t *channel_add; /* hooked when a client joins a channel */ 174 event_t *channel_del; /* same, but with part */ 175 176 event_t *server_introduce; /* called when server_introduce() is 176 177 called, the server's structure is passed 177 178 as the data */ 178 event_t *server_establish; /* called during the misc phase of179 event_t *server_establish; /* called during the misc phase of 179 180 server_establish(), extra data that 180 181 might need to be sent should be sent 181 182 here! */ 182 183 183 event_t *can_join_channel; /* called when the can_join_channel()184 function is called. see channel.h */ 185 event_t *can_see_channel; /* called when the can_see_channel()186 function is called. see channel.h */ 187 event_t *can_send_channel; /* called when the can_send_channel()188 function is called. see channel.h */ 189 event_t *can_nick_channel; /* called when the can_nick_channel()184 event_t *can_join_channel; /* called when the can_join_channel() 185 function is called. see channel.h */ 186 event_t *can_see_channel; /* called when the can_see_channel() 187 function is called. see channel.h */ 188 event_t *can_send_channel; /* called when the can_send_channel() 189 function is called. see channel.h */ 190 event_t *can_nick_channel; /* called when the can_nick_channel() 190 191 function is called. see channel.h */ 191 192 … … 197 198 198 199 struct { 199 /* while there are three connection stages, the last one has no list 200 * as it is very brief, clients who would pass stage3 are in the, you 201 * guessed it, client list */ 202 LIST_HEAD(, connection) *stage1; 203 LIST_HEAD(, connection) *stage2; 200 /* connection groupings. connected clients are fresh off an 201 * accept(), unregistered clients have passed a set of rudimentary 202 * checks but not yet registered, and registered connections are 203 * clients. servers share a separate list but would also be 204 * considered 'registered' */ 205 LIST_HEAD(, connection) *connected; 206 LIST_HEAD(, connection) *unregistered; 204 207 205 208 LIST_HEAD(, connection) *clients; 206 209 207 /* server connections are here, so they aren't handled with client208 * connections (which are (assumed)stages 1/2, and (known) stage3) */209 210 LIST_HEAD(, connection) *servers; 210 211 } connections; -
trunk/ithildin/modules/ircd/protocol.c
r787 r801 32 32 char *s; 33 33 34 if (!(cp->flags & IRCD_CONNFL_STAGE2)) { /* initialize the connection */ 34 if (cp->buf == NULL || cp->bufsize == 0) { 35 /* initialize the connection */ 35 36 cp->buf = malloc(DEFAULT_BUFFER_SIZE); 36 37 cp->buflen = 0; 37 38 cp->bufsize = DEFAULT_BUFFER_SIZE; 38 cp->flags |= IRCD_CONNFL_STAGE2;39 39 cp->buf[0] = '\0'; 40 40 } … … 252 252 return; /* don't do this here.. */ 253 253 254 cp = LIST_FIRST(ircd.connections. stage1);254 cp = LIST_FIRST(ircd.connections.connected); 255 255 while (cp != NULL) { 256 256 cp2 = LIST_NEXT(cp, lp); … … 259 259 cp = cp2; 260 260 } 261 cp = LIST_FIRST(ircd.connections. stage2);261 cp = LIST_FIRST(ircd.connections.unregistered); 262 262 while (cp != NULL) { 263 263 cp2 = LIST_NEXT(cp, lp); -
trunk/ithildin/modules/ircd/server.c
r787 r801 480 480 cp->last = me.now; 481 481 482 /* put it on the stage2 list. technically it should stay as stage2until482 /* put it on the unregistered list. it should stay unregistered until 483 483 * the negotiation is finished and server_register() is called. */ 484 LIST_INSERT_HEAD(ircd.connections. stage2, cp, lp);484 LIST_INSERT_HEAD(ircd.connections.unregistered, cp, lp); 485 485 proto->setup(cp); 486 486 … … 557 557 remove_hook(sock->datahook, server_connecting_hook); 558 558 sock->udata = sp->conn; /* set udata to what is expected */ 559 /* also, make sure IRCD_CONN_DONE() will test positive */560 cp->flags |= (IRCD_CONNFL_DNS | IRCD_CONNFL_IDENT);561 559 add_hook(sock->datahook, ircd_connection_datahook); 562 560 scp->srv = NULL; /* all done */
Note: See TracChangeset
for help on using the changeset viewer.
