Changeset 725 for branches/ithildin-1.1


Ignore:
Timestamp:
05/03/06 22:12:57 (6 years ago)
Author:
wd
Message:

Add redirect numeric support, redirect support in acls

Location:
branches/ithildin-1.1/modules/ircd
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ithildin-1.1/modules/ircd/addons/acl.c

    r662 r725  
    217217    if (ap->info != NULL) 
    218218        free(ap->info); 
     219    if (ap->redirect != NULL) 
     220        free(ap->redirect); 
    219221    if (ap->timer != TIMER_INVALID) 
    220222        destroy_timer(ap->timer); 
     
    409411                /* okay, it actually matches. */ 
    410412                if (ap->access == ACL_DENY) { 
     413                    /* Is this a redirect?  Maybe so, let's send them the 
     414                     * redirect message if it is. */ 
     415                    if (ap->redirect != NULL) 
     416                        sendto_one(cp->cli, RPL_FMT(cp->cli, RPL_REDIR), 
     417                                ap->redirect, ap->redirect_port); 
     418 
    411419                    /* if there's a reason for the ban and they weren't already 
    412                      * denied set ret, otherwise just leave it alone */ 
     420                     * denied set ret, otherwise just leave it alone.  Why? 
     421                     * this is possible if there is no more room in their 
     422                     * connection class.  We want them to know that they 
     423                     * would be authorized if the class wasn't full, instead 
     424                     * of telling them they are not at all authorized. */ 
    413425                    ret = (ret != NULL ? ret : ap->reason); 
    414426                    break; /* we'll return below. */ 
     
    448460    conf_list_t *clp; 
    449461    acl_t *ap, *ap2; 
    450     int stg, acc; 
    451     char *s, *class, *pass, *info, *reason; 
     462    int stg, acc, redirect_port = 0; 
     463    char *s, *class, *pass, *info, *reason, *redir; 
     464    char redirect[SERVLEN + 1]; 
    452465    class_t *cls; 
    453466    int odr, rn, dcr; /* Old Default Rule, Rule Number, Default Conf Rule */ 
     
    522535        pass = conf_find_entry("pass", clp, 1); 
    523536        info = conf_find_entry("info", clp, 1); 
    524         if (access == ACL_DENY) { 
     537        if (acc == ACL_DENY) { 
    525538            if ((reason = conf_find_entry("reason", clp, 1)) == NULL) 
    526539                reason = "You are not authorised to use this server."; 
    527540        } 
     541 
     542        if ((redir = conf_find_entry("redirect", clp, 1)) != NULL) { 
     543            /* try finding the port .. */ 
     544            if ((s = strchr(redir, ':')) != NULL) { 
     545                strlcpy(redirect, redir, (s - redir <= SERVLEN ? 
     546                            (s - redir) + 1 : SERVLEN + 1)); 
     547                if ((redirect_port = str_conv_int(s + 1, 0)) == 0) 
     548                    log_warn("Could not parse server:port combo for redirect " 
     549                            "%s", redir); 
     550            } else { 
     551                strlcpy(redirect, redir, SERVLEN + 1); 
     552                redirect_port = 6667; 
     553            } 
     554 
     555            if (acc != ACL_DENY) { 
     556                log_warn("Redirection forces a DENY ACL type."); 
     557                acc = ACL_DENY; 
     558            } 
     559        } else 
     560            *redirect = '\0'; 
     561                 
     562 
    528563 
    529564        /* now iterate through all the host lists and all the regular hosts and 
     
    546581        if (str_conv_bool(conf_find_entry("skip-ident", clp, 1), 0))          \ 
    547582            ap->flags |= ACL_FL_SKIP_IDENT;                                   \ 
     583        if (*redirect != '\0' && redirect_port != 0) {                        \ 
     584            ap->redirect = strdup(redirect);                                  \ 
     585            ap->redirect_port = redirect_port;                                \ 
     586        }                                                                     \ 
    548587} while (0) 
    549588 
  • branches/ithildin-1.1/modules/ircd/addons/acl.h

    r662 r725  
    3131                                       only) */ 
    3232    char    *pass;                  /* password */ 
     33    char    *redirect;              /* redirect server (or NULL if none) */ 
     34    int     redirect_port;          /* redirect port */ 
     35 
    3336    time_t  added;                  /* when it was added */ 
    3437    time_t  expire;                 /* when this will expire */ 
  • branches/ithildin-1.1/modules/ircd/doc/conf.txt

    r579 r725  
    6565    // connection.  This only works for deny entries. 
    6666    reason "You are not authorized to use this server."; 
     67 
     68    // redirect: (optional) 
     69    // This specifies that a connection should be redirected to the 
     70    // specified server/port (server:port form).  If the port is left off 
     71    // it is assumed to be the default port (typically 6667).  This applies 
     72    // only to entries in stage 3. 
     73    // NB: redirect ACLs are always deny type.  That is, the redirect message 
     74    // is provided and then the connection is closed. 
     75    redirect <some-irc-server:some-port>; 
    6776 
    6877    // skip-dns: (optional) 
  • branches/ithildin-1.1/modules/ircd/ircd.c

    r579 r725  
    443443        CMSG("004", "%s %s %s %s");                         /* rpl_myinfo */ 
    444444        CMSG("005", "%s :are available on this server.");   /* rpl_isupport */ 
     445        CMSG("010", "%s %d :Please redirect your client to this server and " 
     446                "port."); /* rpl_redir */ 
    445447        CMSG("263", ":Server load is temporarily too heavy, please wait a " 
    446448                "while and try again."); /* rpl_loadtoohigh */ 
  • branches/ithildin-1.1/modules/ircd/send.h

    r593 r725  
    172172#define RPL_MYINFO 004 
    173173#define RPL_ISUPPORT 005 
     174#define RPL_REDIR 010 
    174175#define RPL_LOADTOOHIGH 263 
    175176 
Note: See TracChangeset for help on using the changeset viewer.