X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fs_serv.c;h=abcf6aa55b66825e333e7f8c26fa9c7368d1807f;hb=refs%2Fheads%2Fupstream;hp=f66cf0d01fa5a995e5596c0681397a3e7a87f04c;hpb=59600ba2b200c0e9223317c51f29fdb515902ff7;p=ircu2.10.12-pk.git diff --git a/ircd/s_serv.c b/ircd/s_serv.c index f66cf0d..abcf6aa 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -19,8 +19,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ + */ +/** @file + * @brief Miscellaneous server support functions. + * @version $Id$ */ #include "config.h" @@ -32,10 +34,11 @@ #include "hash.h" #include "ircd.h" #include "ircd_alloc.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "ircd_snprintf.h" -#include "ircd_xopen.h" +#include "ircd_crypt.h" #include "jupe.h" #include "list.h" #include "match.h" @@ -55,13 +58,23 @@ #include "sys.h" #include "userload.h" -#include +/* #include -- Now using assert in ircd_log.h */ #include #include +/** Maximum connection count since last restart. */ unsigned int max_connection_count = 0; +/** Maximum (local) client count since last restart. */ unsigned int max_client_count = 0; +/** Squit a new (pre-burst) server. + * @param cptr Local client that tried to introduce the server. + * @param sptr Server to disconnect. + * @param host Name of server being disconnected. + * @param timestamp Link time of server being disconnected. + * @param pattern Format string for squit message. + * @return CPTR_KILLED if cptr == sptr, else 0. + */ int exit_new_server(struct Client *cptr, struct Client *sptr, const char *host, time_t timestamp, const char *pattern, ...) { @@ -81,17 +94,22 @@ int exit_new_server(struct Client *cptr, struct Client *sptr, const char *host, return retval; } +/** Indicate whether \a a is between \a b and #me (that is, \a b would + * be killed if \a a squits). + * @param a A server that may be between us and \a b. + * @param b A client that may be on the far side of \a a. + * @return Non-zero if \a a is between \a b and #me. + */ int a_kills_b_too(struct Client *a, struct Client *b) { for (; b != a && b != &me; b = cli_serv(b)->up); return (a == b ? 1 : 0); } -/* - * server_estab - * - * May only be called after a SERVER was received from cptr, - * and thus make_server was called, and serv->prot set. --Run +/** Handle a connection that has sent a valid PASS and SERVER. + * @param cptr New peer server. + * @param aconf Connect block for \a cptr. + * @return Zero. */ int server_estab(struct Client *cptr, struct ConfItem *aconf) { @@ -110,29 +128,20 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) /* * Pass my info to the new server */ - sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s", + sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s", cli_name(&me), cli_serv(&me)->timestamp, cli_serv(cptr)->timestamp, MAJOR_PROTOCOL, NumServCap(&me), feature_bool(FEAT_HUB) ? "h" : "", *(cli_info(&me)) ? cli_info(&me) : "IRCers United"); - /* - * Don't charge this IP# for connecting - * XXX - if this comes from a server port, it will not have been added - * to the IP check registry, see add_connection in s_bsd.c - */ - IPcheck_connect_fail(cli_ip(cptr)); } - det_confs_butmask(cptr, CONF_LEAF | CONF_HUB | CONF_SERVER | CONF_UWORLD); + det_confs_butmask(cptr, CONF_SERVER | CONF_UWORLD); if (!IsHandshake(cptr)) hAddClient(cptr); SetServer(cptr); cli_handler(cptr) = SERVER_HANDLER; Count_unknownbecomesserver(UserStats); - - release_dns_reply(cptr); - SetBurst(cptr); /* nextping = CurrentTime; */ @@ -175,18 +184,25 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) if (!match(cli_name(&me), cli_name(cptr))) continue; sendcmdto_one(&me, CMD_SERVER, acptr, - "%s 2 0 %Tu J%02u %s%s +%s%s :%s", cli_name(cptr), + "%s 2 0 %Tu J%02u %s%s +%s%s%s :%s", cli_name(cptr), cli_serv(cptr)->timestamp, Protocol(cptr), NumServCap(cptr), IsHub(cptr) ? "h" : "", IsService(cptr) ? "s" : "", - cli_info(cptr)); + IsIPv6(cptr) ? "6" : "", cli_info(cptr)); } + /* Send these as early as possible so that glined users/juped servers can + * be removed from the network while the remote server is still chewing + * our burst. + */ + gline_burst(cptr); + jupe_burst(cptr); + /* * Pass on my client information to the new server * * First, pass only servers (idea is that if the link gets - * cancelled beacause the server was already there, - * there are no NICK's to be cancelled...). Of course, + * canceled because the server was already there, + * there are no NICK's to be canceled...). Of course, * if cancellation occurs, all this info is sent anyway, * and I guess the link dies when a read is attempted...? --msa * @@ -211,11 +227,11 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) if (0 == match(cli_name(&me), cli_name(acptr))) continue; sendcmdto_one(cli_serv(acptr)->up, CMD_SERVER, cptr, - "%s %d 0 %Tu %s%u %s%s +%s%s :%s", cli_name(acptr), + "%s %d 0 %Tu %s%u %s%s +%s%s%s :%s", cli_name(acptr), cli_hopcount(acptr) + 1, cli_serv(acptr)->timestamp, protocol_str, Protocol(acptr), NumServCap(acptr), IsHub(acptr) ? "h" : "", IsService(acptr) ? "s" : "", - cli_info(acptr)); + IsIPv6(acptr) ? "6" : "", cli_info(acptr)); } } @@ -226,14 +242,14 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) continue; if (IsUser(acptr)) { - char xxx_buf[8]; + char xxx_buf[25]; char *s = umode_str(acptr); sendcmdto_one(cli_user(acptr)->server, CMD_NICK, cptr, "%s %d %Tu %s %s %s%s%s%s %s%s :%s", cli_name(acptr), cli_hopcount(acptr) + 1, cli_lastnick(acptr), - cli_user(acptr)->username, cli_user(acptr)->host, + cli_user(acptr)->username, cli_user(acptr)->realhost, *s ? "+" : "", s, *s ? " " : "", - inttobase64(xxx_buf, ntohl(cli_ip(acptr).s_addr), 6), + iptobase64(xxx_buf, &cli_ip(acptr), sizeof(xxx_buf), IsIPv6(cptr)), NumNick(acptr), cli_info(acptr)); } } @@ -246,8 +262,6 @@ int server_estab(struct Client *cptr, struct ConfItem *aconf) for (chptr = GlobalChannelList; chptr; chptr = chptr->next) send_channel_modes(cptr, chptr); } - jupe_burst(cptr); - gline_burst(cptr); sendcmdto_one(&me, CMD_END_OF_BURST, cptr, ""); return 0; }