From: Michael Poole Date: Mon, 25 Apr 2005 03:35:54 +0000 (+0000) Subject: Add autoconnect option for Connect block. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=082c4d238ff866f4c5bc2e4493de67c13391ec12 Add autoconnect option for Connect block. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1383 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index bfe5003..189441f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2005-04-24 Michael Poole + + * doc/example.conf: Document new autoconnect field of Connect. + + * include/s_conf.h: Add CONF_AUTOCONNECT and field for it. + + * ircd/ircd.c (try_connections): Skip non-autoconnect servers. + + * ircd/ircd_lexer.l: Recognize autoconnect token. + + * ircd/ircd_parser.y: Add autoconnect= option to Connect block. + + * ircd/m_invite.c (m_invite): Avoid sending channel timestamp to + user being invited. + (ms_invite): Likewise. + + * ircd/s_user.c (register_user): Show class name rather than + pointer-as-integer. + 2005-04-24 Michael Poole * ircd/ircd_parser.y: Rewrite so each error condition gets its own diff --git a/doc/example.conf b/doc/example.conf index 930fe43..6407f1d 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -520,12 +520,15 @@ Kill # class = "classname"; # maxhops = 2; # hub = "*.eu.undernet.org"; +# autoconnect = no; # }; # # The "port" field defines the default port the server tries to connect # to if an operator uses /connect without specifying a port. This is also # the port used when the server attempts to auto-connect to the remote # server. (See Class blocks for more informationa about auto-connects). +# You may tell ircu to not automatically connect to a server by adding +# "autoconnect = no;"; the default is to autoconnect. # # The maxhops field causes an SQUIT if a hub tries to introduce # servers farther away than that; the element 'leaf;' is an alias for diff --git a/include/s_conf.h b/include/s_conf.h index 8860e0b..0907f9b 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -32,6 +32,8 @@ struct Message; #define CONF_OPERATOR 0x0020 /**< ConfItem describes an Operator block */ #define CONF_UWORLD 0x8000 /**< ConfItem describes a Uworld server */ +#define CONF_AUTOCONNECT 0x0001 /**< Autoconnect to a server */ + /** Indicates ConfItem types that count associated clients. */ #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_OPERATOR | CONF_SERVER) @@ -63,6 +65,7 @@ struct ConfItem time_t hold; /**< Earliest time to attempt an outbound connect on this ConfItem. */ int dns_pending; /**< A dns request is pending. */ + int flags; /**< Additional modifiers for item. */ int addrbits; /**< Number of bits valid in ConfItem::address. */ struct Privs privs; /**< Privileges for opers. */ /** Used to detect if a privilege has been set by this ConfItem. */ diff --git a/ircd/ircd.c b/ircd/ircd.c index bf82c8c..f290300 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -265,6 +265,7 @@ static void try_connections(struct Event* ev) { */ if (!(aconf->status & CONF_SERVER) || aconf->address.port == 0 + || !(aconf->flags & CONF_AUTOCONNECT) || ((ajupe = jupe_find(aconf->name)) && JupeIsActive(ajupe))) continue; diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 590e3bc..930d3e6 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -100,9 +100,11 @@ static struct lexer_token { TOKEN(PREPEND), TOKEN(USERMODE), TOKEN(FAST), + TOKEN(AUTOCONNECT), #undef TOKEN { "administrator", ADMIN }, { "apass_opmode", TPRIV_APASS_OPMODE }, + { "auto", AUTOCONNECT }, { "b", BYTES }, { "badchan", TPRIV_BADCHAN }, { "chan_limit", TPRIV_CHAN_LIMIT }, diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index e02f4ba..c7d726d 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -68,7 +68,7 @@ int yylex(void); /* Now all the globals we need :/... */ - int tping, tconn, maxlinks, sendq, port, invert, stringno; + int tping, tconn, maxlinks, sendq, port, invert, stringno, flags; char *name, *pass, *host, *ip, *username, *origin, *hub_limit; char *stringlist[MAX_STRINGS]; struct ConnectionClass *c_class; @@ -155,6 +155,7 @@ static void parse_error(char *pattern,...) { %token IAUTH %token TIMEOUT %token FAST +%token AUTOCONNECT /* and now a lot of privileges... */ %token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN %token TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE @@ -395,6 +396,7 @@ classusermode: USERMODE '=' QSTRING ';' connectblock: CONNECT { maxlinks = 65535; + flags = CONF_AUTOCONNECT; } '{' connectitems '}' { struct ConfItem *aconf = NULL; @@ -418,6 +420,7 @@ connectblock: CONNECT aconf->host = host; aconf->maximum = maxlinks; aconf->hub_limit = hub_limit; + aconf->flags = flags; lookup_confhost(aconf); } if (!aconf) { @@ -429,12 +432,12 @@ connectblock: CONNECT } name = pass = host = origin = hub_limit = NULL; c_class = NULL; - port = 0; + port = flags = 0; }';'; connectitems: connectitem connectitems | connectitem; connectitem: connectname | connectpass | connectclass | connecthost | connectport | connectvhost | connectleaf | connecthub - | connecthublimit | connectmaxhops | error; + | connecthublimit | connectmaxhops | connectauto | error; connectname: NAME '=' QSTRING ';' { MyFree(name); @@ -482,6 +485,8 @@ connectmaxhops: MAXHOPS '=' expr ';' { maxlinks = $3; }; +connectauto: AUTOCONNECT '=' YES ';' { flags |= CONF_AUTOCONNECT; } + | AUTOCONNECT '=' NO ';' { flags &= ~CONF_AUTOCONNECT; }; uworldblock: UWORLD '{' uworlditems '}' ';'; uworlditems: uworlditem uworlditems | uworlditem; diff --git a/ircd/m_invite.c b/ircd/m_invite.c index e068e48..478ff5b 100644 --- a/ircd/m_invite.c +++ b/ircd/m_invite.c @@ -177,24 +177,23 @@ int m_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (cli_user(acptr)->away) send_reply(sptr, RPL_AWAY, cli_name(acptr), cli_user(acptr)->away); - if (MyConnect(acptr)) + if (MyConnect(acptr)) { add_invite(acptr, chptr); + sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H", cli_name(acptr), chptr); + } if (!IsLocalChannel(chptr->chname) || MyConnect(acptr)) { if (feature_bool(FEAT_ANNOUNCE_INVITES)) { /* Announce to channel operators. */ sendcmdto_channel_butserv_butone(&me, get_error_numeric(RPL_ISSUEDINVITE)->str, - NULL, chptr, sptr, SKIP_NONOPS, + NULL, chptr, sptr, SKIP_NONOPS, "%H %C %C :%C has been invited by %C", chptr, acptr, sptr, acptr, sptr); - /* Announce to servers with channel operators, but skip acptr, - * since they will be notified below. */ - sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, acptr, SKIP_NONOPS, + /* Announce to servers with channel operators. */ + sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, NULL, SKIP_NONOPS, "%s %H %Tu", cli_name(acptr), chptr, chptr->creationtime); } - sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H %Tu", cli_name(acptr), - chptr, chptr->creationtime); } return 0; @@ -280,8 +279,10 @@ int ms_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (is_silenced(sptr, acptr)) return 0; - if (MyConnect(acptr)) + if (MyConnect(acptr)) { add_invite(acptr, chptr); + sendcmdto_one(sptr, CMD_INVITE, acptr, "%s %H", cli_name(acptr), chptr); + } if (feature_bool(FEAT_ANNOUNCE_INVITES)) { /* Announce to channel operators. */ @@ -289,16 +290,12 @@ int ms_invite(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) NULL, chptr, sptr, SKIP_NONOPS, "%H %C %C :%C has been invited by %C", chptr, acptr, sptr, acptr, sptr); - /* Announce to servers with channel operators, but skip acptr, - * since they will be notified below. */ - sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, acptr, SKIP_NONOPS, + /* Announce to servers with channel operators. */ + sendcmdto_channel_servers_butone(sptr, NULL, TOK_INVITE, chptr, NULL, SKIP_NONOPS, "%s %H %Tu", cli_name(acptr), chptr, chptr->creationtime); } - sendcmdto_one(sptr, CMD_INVITE, acptr, - "%s %H %Tu", - cli_name(acptr), chptr, chptr->creationtime); return 0; } diff --git a/ircd/s_user.c b/ircd/s_user.c index af7b93b..f69acdf 100644 --- a/ircd/s_user.c +++ b/ircd/s_user.c @@ -430,7 +430,7 @@ int register_user(struct Client *cptr, struct Client *sptr, { last_too_many1 = CurrentTime; sendto_opmask_butone(0, SNO_TOOMANY, "Too many connections in " - "class %i for %s.", get_client_class(sptr), + "class %s for %s.", get_client_class(sptr), get_client_name(sptr, SHOW_IP)); } ++ServerStats->is_ref;