Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
- smarter expire patches [Kamen Sabeff]
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Apr 30, 2013
1 parent d231cd2 commit beab337
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions include/settings.h
Expand Up @@ -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 */
30 changes: 27 additions & 3 deletions src/nickserv.c
Expand Up @@ -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]",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions src/settings.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 } } },
Expand Down

0 comments on commit beab337

Please sign in to comment.