Changeset 801


Ignore:
Timestamp:
02/12/07 05:52:32 (5 years ago)
Author:
wd
Message:

Get the base/existing IRC module compiling again. Clear out old junk.

Location:
trunk/ithildin/modules/ircd
Files:
1 added
5 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ithildin/modules/ircd/addons/acl.c

    r787 r801  
    8282    /* insert into lists.. */ 
    8383    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; 
    8888    else 
    89         list = acl.stage3_list; 
     89        list = acl.registered_list; 
    9090 
    9191    if (LIST_EMPTY(list)) 
     
    176176        rule = acl.default_rule; 
    177177 
    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; 
    182182    else 
    183         list = acl.stage3_list; 
     183        list = acl.registered_list; 
    184184 
    185185    /* now try and find them in the bucket. */ 
     
    210210     
    211211    /* 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); 
    218213 
    219214    /* now free the memory */ 
     
    256251    void *ret; 
    257252 
    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); 
    260255        while (cp != NULL) { 
    261256            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) { 
    263258                destroy_connection(cp, ret); 
    264259                nukes++; 
     
    268263        } 
    269264    } 
    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); 
    272267        while (cp != NULL) { 
    273268            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) { 
    275270                destroy_connection(cp, ret); 
    276271                nukes++; 
     
    280275        } 
    281276    } 
    282     if (stage == 0 || stage == ACL_STAGE_REGISTER) { 
     277    if (stage == 0 || stage == ACL_STAGE_REGISTERED) { 
    283278        cp = LIST_FIRST(ircd.connections.clients); 
    284279        while (cp != NULL) { 
    285280            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) { 
    287282                destroy_connection(cp, ret); 
    288283                nukes++; 
     
    299294                by, ap->type, 
    300295                (ap->stage > 1 ? ap->user : ""), (ap->stage > 1 ? "@" : ""), 
    301                 ap->host, ap->stage, 
     296                ap->host, acl_stage_int_to_str(ap->stage), 
    302297                (ap->access == ACL_DENY ? "DENY" : 
    303298                 (ap->access == ACL_ALLOW ? "ALLOW" : "UNKNOWN")), 
     
    307302} 
    308303 
    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. */ 
     306int 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. */ 
     325const 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 
    310338/* handling for stage one is by far the easiest, there are no classes or 
    311  * passwords involved.  also, stuff in stage1 should always be in a single 
     339 * passwords involved.  also, stuff this stage should always be in a single 
    312340 * place.  we create a hashtable, but it's mostly just a glorified list (for 
    313341 * now, anyways) */ 
    314 HOOK_FUNCTION(acl_stage1_hook) { 
     342HOOK_FUNCTION(acl_connected_stage_hook) { 
    315343    acl_t *ap; 
    316344    connection_t *cp = (connection_t  *)data; 
     
    319347    /* now match.  skip over any entries that aren't the default hash or our 
    320348     * hash. */ 
    321     LIST_FOREACH(ap, acl.stage1_list, intlp) { 
     349    LIST_FOREACH(ap, acl.connected_list, intlp) { 
    322350        if (ap->hash != hash && ap->hash != ACL_DEFAULT_HASH) 
    323351            continue; 
     
    342370} 
    343371 
    344 /* stage2 is next, and resembles stage1 except that we do class checks, and we 
    345  * 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. */ 
     374HOOK_FUNCTION(acl_unregistered_stage_hook) { 
    347375    acl_t *ap; 
    348376    connection_t  *cp = (connection_t  *)data; 
     
    358386     * and the ip (using hostmatch and ipmatch).  All together that is four 
    359387     * calls.  Also, our hash space is expanded. */ 
    360     LIST_FOREACH(ap, acl.stage2_list, intlp) { 
     388    LIST_FOREACH(ap, acl.unregistered_list, intlp) { 
    361389        if (ap->hash != hash && ap->hash != iphash && 
    362390                ap->hash != ACL_DEFAULT_HASH) 
     
    383411} 
    384412 
    385 /* stage3 is the last stage, it's nearly identical to stage2, but there is a 
    386  * slight change for 'allow-always' type rules and passwords, also, unlike the 
    387  * previous two, the default is to *deny* clients.  Also, unlike the other two 
    388  * 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. */ 
     418HOOK_FUNCTION(acl_registered_stage_hook) { 
    391419    acl_t *ap; 
    392420    connection_t  *cp = (connection_t  *)data; 
     
    404432     * aren't allowed because of a class being full we actually have to keep on 
    405433     * 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) { 
    407435        if (ap->hash != hash && ap->hash != iphash && 
    408436                ap->hash != ACL_DEFAULT_HASH) 
     
    451479    } 
    452480 
    453     if (ret == NULL && !LIST_EMPTY(acl.stage3_list)) 
     481    if (ret == NULL && !LIST_EMPTY(acl.registered_list)) 
    454482        return "You are not authorised to use this server."; 
    455483    return ret; 
     
    518546 
    519547        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        } 
    522561        s = conf_find_entry("access", clp, 1); 
    523562        if (s == NULL) { 
     
    646685                    mask = s; 
    647686                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) { 
    651688                        snprintf(rpl, XINFO_LEN, 
    652689                                "%s is not a valid stage type", s); 
     
    684721    /* okay, now dump them the list.. */ 
    685722    switch (stage) { 
    686         case ACL_STAGE_PREREG: 
    687             list = acl.stage2_list; 
     723        case ACL_STAGE_UNREGISTERED: 
     724            list = acl.unregistered_list; 
    688725            break; 
    689         case ACL_STAGE_REGISTER: 
    690             list = acl.stage3_list; 
     726        case ACL_STAGE_REGISTERED: 
     727            list = acl.unregistered_list; 
    691728            break; 
    692         case ACL_STAGE_CONNECT: 
     729        case ACL_STAGE_CONNECTED: 
    693730        default: 
    694             list = acl.stage1_list; 
     731            list = acl.connected_list; 
    695732    } 
    696733    while (list != NULL) { 
     
    705742                continue; 
    706743            snprintf(rpl, XINFO_LEN, 
    707                     "STAGE %d RULE %5hu ADDRESS %s%s%s ACCESS %s TYPE %s", 
    708                     ap->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, 
    709746                    (*ap->user ? ap->user : ""), (*ap->user ? "@" : ""), 
    710747                    ap->host, (ap->access == ACL_DENY ? "DENY" : 
     
    728765        /* keep looping? */ 
    729766        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; 
    734771            else 
    735772                break; 
     
    744781 
    745782    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); 
    749786 
    750787    add_xinfo_handler(xinfo_acl_handler, "ACL", XINFO_HANDLER_OPER,  
     
    752789 
    753790    /* 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); 
    757794    add_hook(me.events.read_conf, acl_conf_hook); 
    758795 
     
    766803        destroy_acl(LIST_FIRST(acl.list)); 
    767804    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); 
    771808 
    772809    remove_xinfo_handler(xinfo_acl_handler); 
    773810 
    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); 
    777814    remove_hook(me.events.read_conf, acl_conf_hook); 
    778815} 
  • trunk/ithildin/modules/ircd/addons/acl.h

    r787 r801  
    1212 
    1313typedef struct acl { 
    14 #define ACL_STAGE_CONNECT 1 
    15 #define ACL_STAGE_PREREG 2 
    16 #define ACL_STAGE_REGISTER 3 
     14#define ACL_STAGE_CONNECTED 1 
     15#define ACL_STAGE_UNREGISTERED 2 
     16#define ACL_STAGE_REGISTERED 3 
    1717    int     stage;                  /* one of 1, 2, or 3 */ 
    1818#define ACL_ACCESS_ANY -1 
     
    5656 
    5757extern 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; 
    6161    struct acl_list *list; 
    6262 
     
    7171void acl_add_timer(acl_t *, time_t); 
    7272void 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); 
     73int acl_stage_str_to_int(const char *); 
     74const char *acl_stage_int_to_str(int); 
     75HOOK_FUNCTION(acl_connected_stage_hook); 
     76HOOK_FUNCTION(acl_unregistered_stage_hook); 
     77HOOK_FUNCTION(acl_registered_stage_hook); 
    7678 
    7779#endif 
  • trunk/ithildin/modules/ircd/addons/throttle.c

    r787 r801  
    6161static void destroy_throttle(throttle_t *); 
    6262 
    63 HOOK_FUNCTION(throttle_stage1_hook); 
     63HOOK_FUNCTION(throttle_connected_hook); 
    6464HOOK_FUNCTION(throttle_conf_hook); 
    6565HOOK_FUNCTION(throttle_timer_hook); 
     
    106106#define THROTTLE_ERRMSG                                                        \ 
    107107    "Your host is trying to (re)connect too fast -- throttled." 
    108 HOOK_FUNCTION(throttle_stage1_hook) { 
     108HOOK_FUNCTION(throttle_connected_hook) { 
    109109    connection_t *cp = (connection_t *)data; 
    110110    throttle_t *tp = find_throttle(isock_raddr(cp->sock)); 
     
    164164 
    165165    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, 
    167167                        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, 
    169169                    throttle_acl_type, ACL_DEFAULT_RULE); 
    170170            ap->reason = strdup(THROTTLE_ERRMSG); 
     
    272272    LIST_ALLOC(throttle.list); 
    273273 
    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); 
    276276    add_hook(me.events.read_conf, throttle_conf_hook); 
    277277 
     
    288288    LIST_FREE(throttle.list); 
    289289 
    290     remove_hook(ircd.events.stage1_connect, throttle_stage1_hook); 
     290    remove_hook(ircd.events.connection_connected, 
     291            throttle_connected_stage_hook); 
    291292    remove_hook(me.events.read_conf, throttle_conf_hook); 
    292293} 
  • trunk/ithildin/modules/ircd/channel.c

    r744 r801  
    7373void destroy_channel(channel_t *chan) { 
    7474    unsigned char *s; 
    75     chanmode_func changefn; 
    7675    int dummy; 
    7776 
     
    8180    s = ircd.cmodes.avail; 
    8281    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); 
    8583        s++; 
    8684    } 
     
    123121 
    124122uint64_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) { 
    126125    struct chanmode *md = NULL; 
    127126    int i, j; 
     
    156155    md->umask = 0; 
    157156    md->prefix = '\0'; 
    158     md->changefunc = import_symbol(changefn); 
    159     md->queryfunc = import_symbol(queryfn); 
     157    md->changefunc = changefn; 
     158    md->queryfunc = queryfn; 
    160159    md->flags = flags; 
    161160    md->mdi = NULL; 
     
    196195void chanmode_release(unsigned char mode) { 
    197196    channel_t *chan; 
    198     chanmode_func changefn = 
    199         (chanmode_func)getsym(ircd.cmodes.modes[mode].changefunc); 
    200197    int dummy; 
    201198     
    202199    /* clear the mode from all the channels .. */ 
    203200    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); 
    205202 
    206203    /* we don't touch the mode or mask members because those are set elsewhere 
     
    219216        destroy_mdext_item(ircd.mdext.channel, ircd.cmodes.modes[mode].mdi); 
    220217    chanmode_build_lists(); 
     218} 
     219 
     220void 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; 
    221229} 
    222230 
     
    285293        int *argused) { 
    286294    struct chanmode *cmp = &ircd.cmodes.modes[mode]; 
    287     chanmode_func changefn; 
    288295 
    289296    if (cmp->avail || !cmp->mask) /* only if it exists.. */ 
     
    292299    /* otherwise, just try and set the mode with the given functions, returning 
    293300     * 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); 
    296302} 
    297303 
     
    299305        int *argused) { 
    300306    struct chanmode *cmp = ircd.cmodes.pfxmap[prefix]; 
    301     chanmode_func changefn; 
    302307 
    303308    if (cmp == NULL) 
     
    305310 
    306311    /* 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); 
    309313} 
    310314 
     
    312316        char *arg, int *argused) { 
    313317    struct chanmode *cmp = &ircd.cmodes.modes[mode]; 
    314     chanmode_func changefn; 
    315318 
    316319    if (cmp->avail || !cmp->mask) /* only if it exists.. */ 
     
    319322    /* otherwise, just try and set the mode with the given functions, returning 
    320323     * 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); 
    323325} 
    324326 
     
    326328        int *argused) { 
    327329    struct chanmode *cmp = ircd.cmodes.pfxmap[prefix]; 
    328     chanmode_func changefn; 
    329330 
    330331    if (cmp == NULL) 
     
    332333 
    333334    /* 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); 
    336336} 
    337337 
     
    339339        int *argused, void **state) { 
    340340    struct chanmode *cmp = &ircd.cmodes.modes[mode]; 
    341     chanmode_query_func queryfn; 
    342341 
    343342    if (cmp->avail || !cmp->mask) /* only if it exists.. */ 
     
    345344 
    346345    /* 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); 
    349347} 
    350348 
  • trunk/ithildin/modules/ircd/channel.h

    r629 r801  
    9393#define CHANMODE_NOARG      -4 
    9494 
    95 uint64_t chanmode_request(unsigned char, unsigned char *, int, char *, 
    96         char *, size_t, void *); 
     95uint64_t chanmode_request(unsigned char, unsigned char *, int, 
     96        chanmode_func, chanmode_query_func, size_t, void *); 
    9797void chanmode_release(unsigned char); 
     98void chanmode_update_funcs(unsigned char, chanmode_func, 
     99        chanmode_query_func); 
    98100/* ways to set and unset channel modes.  channel modes are typically set by 
    99101 * their mode character, but can also be set by prefix in the case of userflag 
     
    174176                                   the prefix (specified by the caller in extdata). 
    175177                                   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 */ 
    178180    int            flags;       /* flags given for this mode */ 
    179181    struct mdext_item *mdi;     /* the mdext_item which describes the channel mode. 
  • trunk/ithildin/modules/ircd/client.c

    r787 r801  
    186186        /* only do this stuff if it's a real client, and not a fake one */ 
    187187        if (cp != NULL) { 
    188             /* check to see if our client is stage3 okay */ 
    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); 
    190190            while (x < hook_num_returns) { 
    191191                if (returns[x] != NULL) {/* denied, with a reason */ 
     
    195195                x++; 
    196196            } 
    197             /* remove our client from the stage2 list, and put it in the stage3 
    198              * list. */ 
     197            /* remove our client from the unregistered list, and put it in 
     198             * the registered * list. */ 
    199199            LIST_REMOVE(cp, lp); 
    200200            LIST_INSERT_HEAD(ircd.connections.clients, cp, lp); 
     
    315315/* mode goodies below here */ 
    316316uint64_t usermode_request(unsigned char suggested, unsigned char *actual, 
    317         int flags, int sflag, char *changer) { 
     317        int flags, int sflag, usermode_func changefunc) { 
    318318    struct usermode *md = NULL; 
    319319    uint64_t allmodes = 0; 
     
    355355    md->avail = 0; /* mark it used */ 
    356356    md->flags = flags; 
    357     if (changer != NULL) 
    358         md->changer = import_symbol(changer); 
    359     else 
    360         md->changer = NULL; 
     357    md->changefunc = changefunc; 
    361358    md->sflag = sflag; 
    362359    *actual = md->mode; 
     
    384381    ircd.umodes.modes[mode].avail = 1; 
    385382    ircd.umodes.modes[mode].flags = 0; 
    386     ircd.umodes.modes[mode].changer = NULL; 
     383    ircd.umodes.modes[mode].changefunc = NULL; 
    387384    allmodes &= ~ircd.umodes.modes[mode].mask; 
    388385 
    389386    strcpy(ircd.umodes.avail, usermode_getstr(allmodes, 0) + 1); 
     387} 
     388 
     389void 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; 
    390396} 
    391397 
     
    467473    /* always call the set function.  if they're not our client, we ignore the 
    468474     * 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)) 
    472477        return 0; 
    473478    /* if they're local, not opered, and the mode is an oper mode, don't let 
     
    500505    /* always call the unset function.  if they're not our client, we ignore 
    501506     * 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)) 
    505509        return 0; 
    506510 
  • trunk/ithildin/modules/ircd/client.h

    r787 r801  
    6666 
    6767/* this registers a client on the network/server.  registering a client 
    68  * consists of checking it against stage3 acls, placing it in a connection 
     68 * consists of checking it against registered acls, placing it in a connection 
    6969 * class (for real, not the default) (or dropping it if the class is full), 
    7070 * then propogating the user creation across the network, and finally 
     
    9898        char *, int *); 
    9999 
    100 uint64_t usermode_request(unsigned char, unsigned char *, int, int, char *); 
     100uint64_t usermode_request(unsigned char, unsigned char *, int, int, 
     101        usermode_func); 
    101102 
    102103/* use this function to release a mode if you no longer care about it being set 
     
    104105 * had one */ 
    105106void usermode_release(unsigned char); 
     107 
     108/* this function provides a way to update the assigned function for a 
     109 * usermode */ 
     110void usermode_update_func(unsigned char, usermode_func); 
    106111 
    107112/* this function returns a mode string from the passed 64bit integer. the 
     
    147152    int     flags;                  /* flags for the usermode */ 
    148153    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 */ 
    150155    int     sflag;                  /* send flag (if any) for this mode. */ 
    151156}; 
  • trunk/ithildin/modules/ircd/commands/akill.c

    r787 r801  
    4949#define ACL_DEL 1 
    5050    int op = ACL_ADD; 
    51     int stage = ACL_STAGE_REGISTER; 
     51    int stage = ACL_STAGE_REGISTERED; 
    5252    time_t expire = 0; 
    5353    char *reason = NULL; 
     
    123123        } 
    124124 
    125         stage = ACL_STAGE_CONNECT; 
     125        stage = ACL_STAGE_CONNECTED; 
    126126        type = acl_szline_type; 
    127127        strlcpy(mask, argv[1], HOSTLEN + 1); 
     
    141141        } 
    142142 
    143         stage = ACL_STAGE_CONNECT; 
     143        stage = ACL_STAGE_CONNECTED; 
    144144        type = acl_szline_type; 
    145145        strlcpy(mask, argv[1], HOSTLEN + 1); 
  • trunk/ithildin/modules/ircd/commands/trace.c

    r579 r801  
    125125     * fairly valueless, especially on big servers, and there are other ways to 
    126126     * 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) 
    128128        sendto_one(cli, RPL_FMT(cli, RPL_TRACEUNKNOWN), connp->cls->name, 
    129129                connp->host, me.now - connp->last); 
    130     LIST_FOREACH(connp, ircd.connections.stage2, lp) 
     130    LIST_FOREACH(connp, ircd.connections.unregistered, lp) 
    131131        sendto_one(cli, RPL_FMT(cli, RPL_TRACEUNKNOWN), connp->cls->name, 
    132132                connp->host, me.now - connp->last); 
     
    147147                scnt++; 
    148148        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); 
    151151    } 
    152152    LIST_FOREACH(clsp, ircd.lists.classes, lp) { 
  • trunk/ithildin/modules/ircd/connection.c

    r787 r801  
    2222IDSTRING(rcsid, "$Id$"); 
    2323 
    24 static void connection_stage2_done(connection_t *); 
    25 static void connection_init_lookups(connection_t *); 
     24static void connection_init_done(connection_t *); 
    2625 
    2726void destroy_connection(connection_t *c, char *reason) { 
     
    7170} 
    7271 
    73 /* this function closes all 'unknown' (stage1/stage2) connections, handy in 
    74  * various places. */ 
     72/* this function closes all 'unknown' (connected/unregistered) connections, 
     73 * handy in various places. */ 
    7574int close_unknown_connections(char *reason) { 
    7675    connection_t *cp; 
    7776    int count = 0; 
    7877 
    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); 
    8180        destroy_connection(cp, reason); 
    8281        count++; 
    8382    } 
    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); 
    8685        destroy_connection(cp, reason); 
    8786        count++; 
     
    122121        return 0; 
    123122    } 
     123 
    124124    return 1; 
    125125} 
     
    129129    isocket_t *sp = NULL; 
    130130    isocket_t *listener = (isocket_t *)data; 
    131     void **returns; 
    132     int x; 
    133     int dead; 
    134131 
    135132    while ((sp = socket_accept(listener)) != NULL) { 
     
    143140 
    144141        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); 
    165143        add_hook(sp->datahook, ircd_connection_datahook); 
    166144 
    167         /* success?  do auth-stuff */ 
     145        /* Check first for SSL goodies */ 
    168146#ifdef HAVE_OPENSSL 
    169147        if (SOCKET_SSL(listener)) { 
    170148            if (socket_ssl_enable(c->sock)) { 
    171149                if (socket_ssl_accept(c->sock)) { 
    172                     if (!SOCKET_SSL_HANDSHAKING(c->sock)) 
    173                         connection_init_lookups(c); /* handshake is done? */ 
    174                     else 
     150                    if (SOCKET_SSL_HANDSHAKING(c->sock)) { 
     151                        /* handshake isn't done... we have to defer the 
     152                         * event calling */ 
    175153                        c->flags |= IRCD_CONNFL_SSLINIT; 
    176                     continue; /* handshake isn't done. */ 
     154                        continue; 
     155                    } 
    177156                } 
    178157            } 
     
    183162#endif 
    184163 
    185         connection_init_lookups(c); 
     164        connection_init_done(c); 
     165 
    186166    } 
    187167 
     
    189169} 
    190170 
    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. */ 
     172static 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 
     190bool connection_set_unregistered(connection_t *c) { 
    346191    void **returns; 
    347192    int x = 0; 
    348193 
    349     returns = hook_event(ircd.events.stage2_connect, c); 
     194    returns = hook_event(ircd.events.connection_unregistered, c); 
    350195    while (x < hook_num_returns) { 
    351196        if (returns[x] != NULL) { 
     
    353198             * structure. */ 
    354199            destroy_connection(c, (char *)returns[x]); 
    355             return; 
     200            return false; 
    356201        } 
    357202        x++; 
    358203    } 
    359204    LIST_REMOVE(c, lp); 
    360     LIST_INSERT_HEAD(ircd.connections.stage2, c, lp); 
     205    LIST_INSERT_HEAD(ircd.connections.unregistered, c, lp); 
    361206 
    362207    /* now stick them in the default protocol */ 
     
    365210    /* and monitor them */ 
    366211    socket_monitor(c->sock, SOCKET_FL_READ|SOCKET_FL_WRITE); 
     212 
     213    return true; 
    367214} 
    368215 
     
    380227        } 
    381228        c->flags &= ~IRCD_CONNFL_SSLINIT; 
    382         connection_init_lookups(c); 
     229        connection_init_done(c); 
    383230        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... */ 
    388234#endif 
    389235             
     
    463309 
    464310    /* 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); 
    466312    while (cp != NULL) { 
    467313        cp2 = LIST_NEXT(cp, lp); 
     
    469315        cp = cp2; 
    470316    } 
    471     cp = LIST_FIRST(ircd.connections.stage2); 
     317    cp = LIST_FIRST(ircd.connections.unregistered); 
    472318    while (cp != NULL) { 
    473319        cp2 = LIST_NEXT(cp, lp); 
     
    492338    return NULL; 
    493339} 
     340 
    494341/* vi:set ts=8 sts=4 sw=4 tw=76 et: */ 
  • trunk/ithildin/modules/ircd/connection.h

    r787 r801  
    4646    } stats; 
    4747 
    48 #define IRCD_CONNFL_DNS_PTR     0x1 
    49 #define IRCD_CONNFL_DNS_ADDR    0x2 
    50 #define IRCD_CONNFL_DNS        (IRCD_CONNFL_DNS_PTR | IRCD_CONNFL_DNS_ADDR) 
    51 #define IRCD_CONNFL_IDENT       0x4 
    52 #define IRCD_CONNFL_STAGE2      0x8 
    53 #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  
    5848#define IRCD_CONNFL_WRITEABLE 0x100 /* set if the socket is writeable */ 
    5949#define CONN_PINGSENT(conn) (conn->flags & IRCD_CONNFL_PINGSENT) 
     
    8171}; 
    8272 
     73bool connection_set_unregistered(connection_t *); 
     74bool connection_set_registered(connection_t *); 
     75 
    8376void destroy_connection(connection_t *, char *); 
    8477int close_unknown_connections(char *); 
    8578int sendq_flush(connection_t *); 
    8679 
    87 HOOK_FUNCTION(connection_lookup_hook); 
    88 HOOK_FUNCTION(connection_ident_hook); 
    8980HOOK_FUNCTION(ircd_connection_datahook); 
    9081HOOK_FUNCTION(ircd_writer_hook); 
  • trunk/ithildin/modules/ircd/ircd.c

    r787 r801  
    1818IDSTRING(rcsid, "$Id$"); 
    1919 
    20 MODULE_REGISTER(PACKAGE_VERSION); 
     20MODULE_REGISTER(IRCD_VERSION); 
    2121/* 
    2222@DEPENDENCIES@: dns ident 
     
    6666    } 
    6767 
    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); 
    7074    while (cp != NULL) { 
    7175        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 */ 
    7486        if ((now - cp->last) > (cp->cls->freq / 4)) 
    7587            destroy_connection(cp, "Ping timeout"); 
     
    259271    if (!get_module_savedata(savelist, "ircd.connections", 
    260272                &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); 
    263275        LIST_ALLOC(ircd.connections.clients); 
    264276        LIST_ALLOC(ircd.connections.servers); 
     
    338350 
    339351        /* we know that all modes are free.  grab i, o, and s */ 
    340         EXPORT_SYM(mode_set_counter); 
    341352        ircd.umodes.i = usermode_request('i', &c, USERMODE_FL_GLOBAL, -1, 
    342                 "mode_set_counter"); 
     353                mode_set_counter); 
    343354        ircd.umodes.o = usermode_request('o', &c, USERMODE_FL_GLOBAL, 
    344                 ircd.sflag.ops, "mode_set_counter"); 
     355                ircd.sflag.ops, mode_set_counter); 
    345356        ircd.umodes.s = usermode_request('s', &c, 0, ircd.sflag.servmsg, 
    346357                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); 
    347364    } 
    348365 
     
    357374     * later in *this function*. :) */ 
    358375    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); 
    362379 
    363380        ircd.events.client_connect = create_event(EVENT_FL_NORETURN); 
     
    471488         
    472489    if (!get_module_savedata(savelist, "ircd.hashes", &ircd.hashes)) { 
    473         EXPORT_SYM(nickcmp); 
    474         EXPORT_SYM(chancmp); 
    475490 
    476491        ircd.hashes.command = create_hash_table(32, 
    477492                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); 
    479495 
    480496        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); 
    482499        ircd.hashes.client_history = create_hash_table(1024, 
    483500                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); 
    485503 
    486504        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; 
    488511    } 
    489512 
    490513    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; 
    497521    } 
    498522 
     
    548572        free(ircd.argv[i]); 
    549573    free(ircd.argv); 
    550  
    551     dns_lookup_cancel(connection_lookup_hook); 
    552     ident_cancel(connection_ident_hook); 
    553574 
    554575    /* close unknown connections and either remove our datahook if we're 
     
    644665 
    645666        /* 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); 
    649670        destroy_event(ircd.events.client_connect); 
    650671        destroy_event(ircd.events.client_disconnect); 
     
    670691 
    671692        /* 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); 
    674695        LIST_FREE(ircd.connections.clients); 
    675696        LIST_FREE(ircd.connections.servers); 
  • trunk/ithildin/modules/ircd/ircd.h

    r579 r801  
    149149 
    150150        /* 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; 
    155156 
    156157        /* other events */ 
    157         event_t        *client_connect;    /* called after the stage*_connect to note 
     158        event_t *client_connect;    /* called after connection_registered to note 
    158159                                       the connection of a (local) client */ 
    159160        event_t *client_disconnect; /* called when a registered client (local) 
    160161                                       is disconnecting from the server */ 
    161         event_t        *register_client;   /* called from register_client() for all 
     162        event_t *register_client;   /* called from register_client() for all 
    162163                                       connecting clients. */ 
    163164        event_t *unregister_client; /* called from destroy_client() for all 
     
    170171                                       initially created. */ 
    171172        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() is 
     173        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 
    176177                                       called, the server's structure is passed 
    177178                                       as the data */ 
    178         event_t        *server_establish;  /* called during the misc phase of 
     179        event_t *server_establish;  /* called during the misc phase of 
    179180                                       server_establish(), extra data that 
    180181                                       might need to be sent should be sent 
    181182                                       here! */ 
    182183 
    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() 
    190191                                       function is called.  see channel.h */ 
    191192 
     
    197198 
    198199    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; 
    204207 
    205208        LIST_HEAD(, connection) *clients; 
    206209 
    207         /* server connections are here, so they aren't handled with client 
    208          * connections (which are (assumed)stages 1/2, and (known) stage3) */ 
    209210        LIST_HEAD(, connection) *servers; 
    210211    } connections; 
  • trunk/ithildin/modules/ircd/protocol.c

    r787 r801  
    3232    char *s; 
    3333 
    34     if (!(cp->flags & IRCD_CONNFL_STAGE2)) { /* initialize the connection */ 
     34    if (cp->buf == NULL || cp->bufsize == 0) { 
     35        /* initialize the connection */ 
    3536        cp->buf = malloc(DEFAULT_BUFFER_SIZE); 
    3637        cp->buflen = 0; 
    3738        cp->bufsize = DEFAULT_BUFFER_SIZE; 
    38         cp->flags |= IRCD_CONNFL_STAGE2; 
    3939        cp->buf[0] = '\0'; 
    4040    } 
     
    252252        return; /* don't do this here.. */ 
    253253 
    254     cp = LIST_FIRST(ircd.connections.stage1); 
     254    cp = LIST_FIRST(ircd.connections.connected); 
    255255    while (cp != NULL) { 
    256256        cp2 = LIST_NEXT(cp, lp); 
     
    259259        cp = cp2; 
    260260    } 
    261     cp = LIST_FIRST(ircd.connections.stage2); 
     261    cp = LIST_FIRST(ircd.connections.unregistered); 
    262262    while (cp != NULL) { 
    263263        cp2 = LIST_NEXT(cp, lp); 
  • trunk/ithildin/modules/ircd/server.c

    r787 r801  
    480480    cp->last = me.now; 
    481481 
    482     /* put it on the stage2 list.  technically it should stay as stage2 until 
     482    /* put it on the unregistered list.  it should stay unregistered until 
    483483     * 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); 
    485485    proto->setup(cp); 
    486486 
     
    557557    remove_hook(sock->datahook, server_connecting_hook); 
    558558    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); 
    561559    add_hook(sock->datahook, ircd_connection_datahook); 
    562560    scp->srv = NULL; /* all done */ 
Note: See TracChangeset for help on using the changeset viewer.