Browse files

- smarter expire patches [Kamen Sabeff]

  • Loading branch information...
1 parent d231cd2 commit beab33708058cba833a31bd281a547fddb58d270 @dkorunic committed Apr 30, 2013
Showing with 34 additions and 3 deletions.
  1. +1 −0 ChangeLog
  2. +2 −0 include/settings.h
  3. +27 −3 src/nickserv.c
  4. +4 −0 src/settings.c
View
1 ChangeLog
@@ -38,6 +38,7 @@ Hybserv-1.9.5-dev
Sabeff]
- fixes for fake server handling (jupe), wildcard handling (don't use
irc.* in jupe names, etc.) [Kamen Sabeff]
+ + set of smarter nickname expire patches [Kamen Sabeff]
Hybserv-1.9.4
View
2 include/settings.h
@@ -172,5 +172,7 @@ extern long NickRegDelay;
extern long StatExpire;
extern long TelnetTimeout;
extern long MinNickAge;
+extern long NickNameExpireAddTime;
+extern long NickNameExpireAddPeriod;
#endif /* INCLUDED_settings_h */
View
30 src/nickserv.c
@@ -1379,8 +1379,19 @@ ExpireNicknames(time_t unixtime)
if (NickNameExpire)
{
- if ((!(nptr->flags & (NS_FORBID | NS_NOEXPIRE | NS_IDENTIFIED)))
- && ((unixtime - nptr->lastseen) >= NickNameExpire))
+ long exptime;
+ struct NickInfo *mptr;
+
+ /* Smart expire? */
+ if (NickNameExpireAddTime && NickNameExpireAddPeriod)
+ exptime = NickNameExpire + NickNameExpireAddTime * ((unixtime - nptr->created) / NickNameExpireAddPeriod);
+ else
+ exptime = NickNameExpire;
+
+ /* If the master has NoExpire, slave nicks won't expire, too */
+ mptr = GetMaster(nptr);
+ if ((!(nptr->flags & (NS_FORBID | NS_NOEXPIRE | NS_IDENTIFIED))) && (!(mptr->flags & NS_NOEXPIRE))
+ && ((unixtime - nptr->lastseen) >= exptime))
{
putlog(LOG2,
"%s: Expired nickname [%s]",
@@ -4383,6 +4394,19 @@ n_info(struct Luser *lptr, int ac, char **av)
" Registered: %s ago",
timeago(realptr->created, 1));
+ if ((isadmin || isowner) && NickNameExpire)
+ {
+ long exptime;
+ if (NickNameExpireAddTime && NickNameExpireAddPeriod)
+ exptime = NickNameExpire + NickNameExpireAddTime * ((current_ts - realptr->created) / NickNameExpireAddPeriod);
+ else
+ exptime = NickNameExpire;
+
+ notice(n_NickServ, lptr->nick,
+ " Expire Time: %s",
+ timeago(exptime, 3));
+ }
+
if (realptr->lastseen && !online)
notice(n_NickServ, lptr->nick,
" Last Seen: %s ago",
@@ -4439,7 +4463,7 @@ n_info(struct Luser *lptr, int ac, char **av)
if (nptr->flags & NS_PROTECTED)
strlcat(buf, "Kill Protection, ", sizeof(buf));
}
- if (nptr->flags & NS_NOEXPIRE)
+ if (realptr->flags & NS_NOEXPIRE) /* show the specific flag, not the master's one */
strlcat(buf, "NoExpire, ", sizeof(buf));
if (nptr->flags & NS_AUTOMASK)
strlcat(buf, "AutoMask, ", sizeof(buf));
View
4 src/settings.c
@@ -146,6 +146,8 @@ int AllowKillProtection;
int AllowKillImmed;
int AllowGuardChannel;
long MinNickAge;
+long NickNameExpireAddTime; /* How much time to add to NickNameExpire, and ... */
+long NickNameExpireAddPeriod; /* ... how often to increase that time */
int MaxChansPerUser;
int MinChanUsers;
int MaxAkicks;
@@ -240,6 +242,8 @@ struct Directive directives[] =
/* Expire Settings */
{ "NickNameExpire", D_OPTIONAL, { { PARAM_TIME, &NickNameExpire } } },
+ { "NickNameExpireAddPeriod", D_OPTIONAL, { { PARAM_TIME, &NickNameExpireAddPeriod } } },
+ { "NickNameExpireAddTime", D_OPTIONAL, { { PARAM_TIME, &NickNameExpireAddTime } } },
{ "ChannelExpire", D_OPTIONAL, { { PARAM_TIME, &ChannelExpire } } },
{ "MemoExpire", D_OPTIONAL, { { PARAM_TIME, &MemoExpire } } },
{ "StatExpire", D_OPTIONAL, { { PARAM_TIME, &StatExpire } } },

0 comments on commit beab337

Please sign in to comment.