From: Perry Lorier Date: Thu, 30 Mar 2000 22:09:52 +0000 (+0000) Subject: Author: Isomer X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=0424d9fb7dc3bc29ffd1a72abefe48fef14d3e58 Author: Isomer Log message: Well: * Fixed wrapped U: in example.conf * Added reason to when people are glined. *** Quits: BadBoy (G-Lined (You're a bad boy)) * Rewrote check pings. * Fixed several problems with /map * Added some reasons to quit msg's. * removed redundant nick[socket] from error quitmsg's. * Updated the error messages for 'write error' * Made server rejection notices explain why the server was rejected hopefully we'll get less people asking questions :) * Probably some other patches I've been sitting on for a while. Not very tested for much of this stuff, but it's there. I'm sure the usual alpha testers will enjoy themselves :) git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@109 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 538c044..cda5b24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2000-03-30 Perry Lorier + * ircd/ircd.c: rewrote check_pings() for maintainability + and speed. Also changed quit msg's so they don't have + redundant nick[host] info in them. + + * ircd/send.c: Changed write errors to report what error + occured (if possible). + + * ircd/gline.c: added gline comment to the quit. + + * ircd/m_server.c: Added suggestions to server quits mentioning + what went wrong so the admin can fix it earlier instead of asking + questions... + + * ircd/map.c: Changed m_map() to hide numerics, show a * beside + servers that aren't fully burst yet. And show '(--s)' for servers + where its not sure. + + * doc/example.conf: Fixed wrapped U: + 2000-03-30 Kevin L. Mitchell * ircd/m_mode.c (ms_mode): implemented a new m_mode in terms of @@ -201,7 +221,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.45 2000-03-30 22:03:36 kev Exp $ +# $Id: ChangeLog,v 1.46 2000-03-30 22:09:51 isomer Exp $ # # Insert new changes at beginning of the change list. # diff --git a/doc/example.conf b/doc/example.conf index 77da1d5..bbc0e82 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -196,9 +196,8 @@ T:*.london.ac.uk:london.motd # it is not allowed to jupe others as well. U:Uworld.EU.undernet.org:EuWorld,E,protocol,StatServ,NoteServ,Undernet:* -U:Uworld2.undernet.org:UWorld2,W,ChanSvr,ChanSaver,ChanServ,COM1,COM2,COM3,COM4: -* -U:Uworld.undernet.org:Uworld,X,NickSvr,NickSaver,NickServ,LPT1,LPT2,AUX:* +U:Uworld2.undernet.org:UWorld2,ChanSvr,ChanSaver,ChanServ,COM1,COM2,COM3,COM4:* +U:Uworld.undernet.org:Uworld,X,W,NickSvr,NickSaver,NickServ,LPT1,LPT2,AUX:* # # While running your server, you will most probably encounter individuals diff --git a/ircd/gline.c b/ircd/gline.c index 4e5245d..b7ffdd9 100644 --- a/ircd/gline.c +++ b/ircd/gline.c @@ -259,7 +259,7 @@ void add_gline(struct Client *sptr, int ip_mask, char *host, char *comment, /* and get rid of him */ if (sptr != acptr) - exit_client(sptr->from, acptr, &me, "G-lined"); + exit_client_msg(sptr->from, acptr, &me, "G-lined (%s)", agline->reason); } } } diff --git a/ircd/ircd.c b/ircd/ircd.c index 64418cf..6fa51e5 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -254,16 +254,136 @@ static time_t try_connections(void) return (next); } +static time_t check_pings(void) +{ + int expire=0; + /* Temp to figure out what time this connection will next need + * to be checked. + */ + int next_check = CurrentTime + PINGFREQUENCY; + /* + * The current lowest expire time - ie: the time that check_pings + * needs to be called next. + */ + int max_ping = 0; + /* + * The time you've got before a ping is sent/your connection is + * terminated. + */ + + int i=0; /* loop counter */ + + /* Scan through the client table */ + for (i=0; i <= HighestFd; i++) { + struct Client *cptr; + + cptr = LocalClientArray[i]; + + /* Skip empty entries */ + if (!cptr) + continue; + + assert(&me != cptr); /* I should never be in the local client array, + * so if I am, dying is a good thing(tm). + */ + + /* Remove dead clients. + * We will have sent opers a message when we set the dead flag, + * so don't bother to send one now. + */ + if (IsDead(cptr)) { + exit_client(cptr, cptr, &me, cptr->info); + continue; + } + + /* Should we concider adding a class 0 for 'unregistered clients', + * where we can specify their 'ping timeout' etc? + */ + max_ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT; + + /* Ok, the thing that will happen most frequently, is that someone will + * have sent something recently. Cover this first for speed. + */ + if (CurrentTime-cptr->lasttime <= max_ping) { + expire=cptr->lasttime + max_ping; + if (next_checklasttime <= (max_ping*2) ) { + + /* If it was a server, then tell ops about it. */ + if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr)) + sendto_ops("No response from %s, closing link", cptr->name); + + exit_client_msg(cptr, cptr, &me, "Ping timeout"); + continue; + } /* of testing to see if ping has been sent */ + + /* Unregistered clients pingout after max_ping seconds, they don't + * get given a second chance. + */ + if (!IsRegistered(cptr)) { + /* Display message if they have sent a NICK and a USER but no + * nospoof PONG. + */ + if (*cptr->name && *cptr->user->username) { + sendto_one(cptr, + ":%s %d %s :Your client may not be compatible with this server.", + me.name, ERR_BADPING, cptr->name); + sendto_one(cptr, + ":%s %d %s :Compatible clients are available at " + "ftp://ftp.undernet.org/pub/irc/clients", + me.name, ERR_BADPING, cptr->name); + } + exit_client_msg(cptr,cptr,&me, "Ping Timeout"); + continue; + } /* of not registered */ + + if (0 == (cptr->flags & FLAGS_PINGSENT)) { + /* + * If we havent PINGed the connection and we havent heard from it in a + * while, PING it to make sure it is still alive. + */ + cptr->flags |= FLAGS_PINGSENT; + + /* + * If we're late in noticing don't hold it against them :) + */ + cptr->lasttime = CurrentTime - max_ping; + + if (IsUser(cptr)) + sendto_one(cptr, "PING :%s", me.name); + else + sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name); + } /* of if not ping sent... */ + + expire=cptr->lasttime+max_ping*2; + + if (expire=CurrentTime); + + return next_check; +} + +#if 0 static time_t check_pings(void) { struct Client *cptr; - int ping = 0; + int max_ping = 0; int i; time_t oldest = CurrentTime + PINGFREQUENCY; time_t timeout; + /* For each client... */ for (i = 0; i <= HighestFd; i++) { - if (!(cptr = LocalClientArray[i])) + if (!(cptr = LocalClientArray[i])) /* oops! not a client... */ continue; /* * me is never in the local client array @@ -278,15 +398,21 @@ static time_t check_pings(void) continue; } - ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT; - Debug((DEBUG_DEBUG, "c(%s)=%d p %d a %d", - cptr->name, cptr->status, ping, + max_ping = IsRegistered(cptr) ? get_client_ping(cptr) : CONNECTTIMEOUT; + + Debug((DEBUG_DEBUG, "check_pings(%s)=status:%d ping: %d current: %d", + cptr->name, cptr->status, max_ping, (int)(CurrentTime - cptr->lasttime))); + /* * Ok, so goto's are ugly and can be avoided here but this code * is already indented enough so I think its justified. -avalon */ - if (IsRegistered(cptr) && (ping >= CurrentTime - cptr->lasttime)) + /* + * If this is a registered client that we've heard of in a reasonable + * time, then skip them. + */ + if (IsRegistered(cptr) && (max_ping >= CurrentTime - cptr->lasttime)) goto ping_timeout; /* * If the server hasnt talked to us in 2 * ping seconds @@ -313,8 +439,7 @@ static time_t check_pings(void) "ftp://ftp.undernet.org/pub/irc/clients", me.name, ERR_BADPING, cptr->name); } - exit_client_msg(cptr, cptr, &me, "Ping timeout for %s", - get_client_name(cptr, HIDE_IP)); + exit_client_msg(cptr, cptr, &me, "Ping timeout"); } continue; } @@ -335,9 +460,9 @@ static time_t check_pings(void) sendto_one(cptr, "%s " TOK_PING " :%s", NumServ(&me), me.name); } ping_timeout: - timeout = cptr->lasttime + ping; + timeout = cptr->lasttime + max_ping; while (timeout <= CurrentTime) - timeout += ping; + timeout += max_ping; if (timeout < oldest) oldest = timeout; } @@ -349,6 +474,7 @@ ping_timeout: return (oldest); } +#endif /* * bad_command diff --git a/ircd/list.c b/ircd/list.c index f798394..bc44e63 100644 --- a/ircd/list.c +++ b/ircd/list.c @@ -153,6 +153,7 @@ struct Server *make_server(struct Client *cptr) servs.inuse++; #endif cptr->serv = serv; + cptr->serv->lag = 10000; *serv->by = '\0'; DupString(serv->last_error_msg, "<>"); /* String must be non-empty */ } diff --git a/ircd/m_nick.c b/ircd/m_nick.c index 875a8a1..02c61f3 100644 --- a/ircd/m_nick.c +++ b/ircd/m_nick.c @@ -268,15 +268,17 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) ircd_strncpy(nick, parv[1], NICKLEN); nick[NICKLEN] = '\0'; - if (IsServer(sptr)) { - lastnick = atoi(parv[3]); - if (lastnick > OLDEST_TS) - sptr->serv->lag = TStime() - lastnick; - } - else { - lastnick = atoi(parv[2]); - if (lastnick > OLDEST_TS) - sptr->user->server->serv->lag = TStime() - lastnick; + if (!IsBurstOrBurstAck(sptr)) { + if (IsServer(sptr)) { + lastnick = atoi(parv[3]); + if (lastnick > OLDEST_TS) + sptr->serv->lag = TStime() - lastnick; + } + else { + lastnick = atoi(parv[2]); + if (lastnick > OLDEST_TS) + sptr->user->server->serv->lag = TStime() - lastnick; + } } /* * If do_nick_name() returns a null name OR if the server sent a nick diff --git a/ircd/m_server.c b/ircd/m_server.c index 3b20d0f..5578d0f 100644 --- a/ircd/m_server.c +++ b/ircd/m_server.c @@ -400,7 +400,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) * If my ircd.conf sucks, I can try to connect to myself: */ if (acptr == &me) - return exit_client_msg(cptr, cptr, &me, "nick collision with me (%s)", host); + return exit_client_msg(cptr, cptr, &me, "nick collision with me (%s), check server number?", host); /* * Detect wrong numeric. */ @@ -627,7 +627,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { if (LHcptr == 0) { return exit_new_server(cptr, sptr, host, timestamp, - (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)", + (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s), check H:" : + "Leaf-only link %s <- %s(%s), check L:", cptr->name, host, lhconf ? (lhconf->name ? lhconf->name : "*") : "!"); } @@ -637,7 +638,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (active_lh_line < 3) { if (exit_client_msg(cptr, LHcptr, &me, - (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)", + (active_lh_line == 2) ? "Non-Hub link %s <- %s(%s), check H:" : + "Leaf-only link %s <- %s(%s), check L:", cptr->name, host, lhconf ? (lhconf->name ? lhconf->name : "*") : "!") == CPTR_KILLED) return CPTR_KILLED; @@ -645,7 +647,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) else { ServerStats->is_ref++; - if (exit_client(cptr, LHcptr, &me, "I'm a leaf") == CPTR_KILLED) + if (exit_client(cptr, LHcptr, &me, "I'm a leaf, define HUB") == CPTR_KILLED) return CPTR_KILLED; } /* diff --git a/ircd/m_stats.c b/ircd/m_stats.c index 9cc5616..291f1c7 100644 --- a/ircd/m_stats.c +++ b/ircd/m_stats.c @@ -265,7 +265,9 @@ int m_stats(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) if (doall && IsUser(acptr)) continue; /* Don't show invisible people to unauthorized people when using - * wildcards -- Is this still needed now /stats is oper only ? */ + * wildcards -- Is this still needed now /stats is oper only ? + * Yeah it is -- non opers can /stats l, just not remotely. + */ if (IsInvisible(acptr) && (doall || wilds) && !(MyConnect(sptr) && IsOper(sptr)) && !IsAnOper(acptr) && (acptr != sptr)) diff --git a/ircd/map.c b/ircd/map.c index 09396fb..c4914ad 100644 --- a/ircd/map.c +++ b/ircd/map.c @@ -41,11 +41,21 @@ void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt if (prompt_length > 60) sendto_one(cptr, rpl_str(RPL_MAPMORE), me.name, cptr->name, prompt, server->name); - else + else { + char lag[512]; + if (server->serv->lag>10000) + strcpy(lag,"(--s)"); + else if (server->serv->lag<0) + strcpy(lag,"(0s)"); + else + sprintf(lag,"(%is)",server->serv->lag); sendto_one(cptr, rpl_str(RPL_MAP), me.name, cptr->name, - prompt, NumServ(server), server->name, - server->serv->lag>0 ? server->serv->lag : 0, + prompt, + ((IsBurstOrBurstAck(server)) ? "*" : ""), + server->name, + lag, (server == &me) ? UserStats.local_clients : server->serv->clients); + } if (prompt_length > 0) { p[-1] = ' '; diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 31fdbaa..03d95be 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -1051,8 +1051,8 @@ int read_message(time_t delay) const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client"; if (!msg) msg = "Unknown error"; - exit_client_msg(cptr, cptr, &me, "Read error to %s: %s", - get_client_name(cptr, HIDE_IP), msg); + exit_client_msg(cptr, cptr, &me, "Read error: %s", + msg); } } return 0; @@ -1271,8 +1271,8 @@ int read_message(time_t delay) const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client"; if (!msg) msg = "Unknown error"; - exit_client_msg(cptr, cptr, &me, "Read error to %s: %s", - get_client_name(cptr, HIDE_IP), msg); + exit_client_msg(cptr, cptr, &me, "Read error: %s", + msg); } } return 0; diff --git a/ircd/s_err.c b/ircd/s_err.c index 47c390f..182c169 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -60,7 +60,7 @@ static Numeric local_replies[] = { /* 014 */ { 0 }, /* 015 */ - { RPL_MAP, ":%s%s:%s (%is) [%i clients]", "015" }, + { RPL_MAP, ":%s%s%s %s [%i clients]", "015" }, /* 016 */ { RPL_MAPMORE, ":%s%s --> *more*", "016" }, /* 017 */ diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 08b391d..c74be25 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -69,7 +69,7 @@ int exit_new_server(struct Client *cptr, struct Client *sptr, va_start(vl, fmt); if (!IsServer(sptr)) return vexit_client_msg(cptr, cptr, &me, fmt, vl); - sprintf_irc(buf, ":%s SQUIT %s " TIME_T_FMT " :", me.name, host, timestamp); + sprintf_irc(buf, ":%s " TOK_SQUIT " %s " TIME_T_FMT " :", me.name, host, timestamp); strcat(buf, fmt); vsendto_one(cptr, buf, vl); va_end(vl); diff --git a/ircd/send.c b/ircd/send.c index c160a9e..f5adb86 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -61,7 +61,7 @@ int sdbflag; * generate ExitClient from the main loop. * * If 'notice' is not NULL, it is assumed to be a format - * for a message to local opers. I can contain only one + * for a message to local opers. It can contain only one * '%s', which will be replaced by the sockhost field of * the failing link. * @@ -162,8 +162,11 @@ void send_queued(struct Client *to) break; } else { - if (IsDead(to)) - dead_link(to, "Write error, closing link"); + if (IsDead(to)) { + char tmp[512]; + sprintf(tmp,"Write error: %s",(strerror(to->error)) ? (strerror(to->error)) : "Unknown error" ); + dead_link(to, tmp); + } break; } }