diff --git a/Changes b/Changes index 50c12f318..f40084b6b 100644 --- a/Changes +++ b/Changes @@ -198,3 +198,5 @@ - Fixed a bunch of possible bugs in newconf - Added sendto_realops logging of config errors - Made /rehash work .. sortof. Fixed some crash bugs +- Added /stats P on listener info (oper-only) +- listener temporary stuff works now diff --git a/src/list.c b/src/list.c index 58af64ed6..e13be7f8e 100644 --- a/src/list.c +++ b/src/list.c @@ -77,7 +77,6 @@ void initlists() bzero((char *)&servs, sizeof(servs)); bzero((char *)&links, sizeof(links)); bzero((char *)&classs, sizeof(classs)); -// bzero((char *)&aconfs, sizeof(aconfs)); #endif } diff --git a/src/s_conf2.c b/src/s_conf2.c index 1f42edd6e..2f172f56e 100644 --- a/src/s_conf2.c +++ b/src/s_conf2.c @@ -1957,6 +1957,26 @@ void run_configuration(void) } } +void listen_cleanup() +{ + int i = 0; + ConfigItem_listen *listen_ptr; + ConfigItem t; + for (listen_ptr = conf_listen; listen_ptr; listen_ptr = (ConfigItem_listen *)listen_ptr->next) + { + if (listen_ptr->flag.temporary && !listen_ptr->clients) + { + ircfree(listen_ptr->ip); + t.next = del_ConfigItem((ConfigItem *) listen_ptr, (ConfigItem **)&conf_listen); + MyFree(listen_ptr); + listen_ptr = (ConfigItem_listen *) &t; + i++; + } + } + if (i) + close_listeners(); +} + int rehash(cptr, sptr, sig) aClient *cptr, *sptr; int sig; @@ -2083,17 +2103,8 @@ int rehash(cptr, sptr, sig) init_conf2("unrealircd.conf"); /* Clean up listen records */ close_listeners(); - for (listen_ptr = conf_listen; listen_ptr; listen_ptr = (ConfigItem_listen *)listen_ptr->next) - { - if (listen_ptr->flag.temporary) - { - ircfree(listen_ptr->ip); - t.next = del_ConfigItem((ConfigItem *) listen_ptr, (ConfigItem **)&conf_listen); - MyFree(listen_ptr); - listen_ptr = (ConfigItem_listen *) &t; - - } - } + listen_cleanup(); + run_configuration(); check_pings(TStime(), 1); sendto_realops("Completed rehash"); } diff --git a/src/s_misc.c b/src/s_misc.c index 2241d6ad8..92c9b5187 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -429,6 +429,7 @@ int exit_client(cptr, sptr, from, comment) #ifdef FNAME_USERLOG time_t on_for; #endif + ConfigItem_listen *listen_conf; static char comment1[HOSTLEN + HOSTLEN + 2]; static int recurse = 0; @@ -452,7 +453,16 @@ int exit_client(cptr, sptr, from, comment) if (sptr->listener) if (sptr->listener->class) - ((ConfigItem_listen *)sptr->listener->class)->clients--; + { + listen_conf = (ConfigItem_listen *) sptr->listener->class; + listen_conf->clients--; + if (listen_conf->flag.temporary + && (listen_conf->clients == 0)) + { + /* Call listen cleanup */ + listen_cleanup(); + } + } sptr->flags |= FLAGS_CLOSING; if (IsPerson(sptr)) { diff --git a/src/s_serv.c b/src/s_serv.c index 7040c8329..9fb9b8a23 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -2576,6 +2576,24 @@ int m_stats(cptr, sptr, parc, parv) } if (SHOWOPERS == 1) break; + case 'P': + if (IsOper(sptr)) + { + for (i = 0; i <= highest_fd; i++) + { + if (!(acptr = local[i])) + continue; + if (!IsListening(acptr)) + continue; + sendto_one(sptr, ":%s NOTICE %s :*** Listener on %s:%i, clients %i. is %s", + me.name, sptr->name, + ((ConfigItem_listen *)acptr->class)->ip, + ((ConfigItem_listen *)acptr->class)->port, + ((ConfigItem_listen *)acptr->class)->clients, + ((ConfigItem_listen *)acptr->class)->flag.temporary ? "TEMPORARY" : "PERM"); + } + } + break; case 'Q': { ConfigItem_ban *bans;