extern char *show_iline_prefix(struct Client *, struct ConfItem *, char *);
extern void get_printable_conf(struct ConfItem *,
char **, char **, char **, char **, int *, char **);
+extern char *get_user_ban_reason(struct ConfItem *aconf);
extern void get_printable_kline(struct Client *, struct ConfItem *,
char **, char **, char **, char **);
{
struct ConfItem *aconf;
char *oper_reason;
- char dlbuffer[IRCD_BUFSIZE];
struct rb_sockaddr_storage daddr;
int t = AF_INET, ty, b;
const char *creason;
aconf->status = CONF_DLINE;
aconf->created = rb_current_time();
aconf->host = rb_strdup(dlhost);
+ aconf->passwd = rb_strdup(reason);
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
if(tdline_time > 0)
{
- rb_snprintf(dlbuffer, sizeof(dlbuffer),
- "Temporary D-line %d min. - %s",
- (int) (tdline_time / 60), reason);
- aconf->passwd = rb_strdup(dlbuffer);
aconf->hold = rb_current_time() + tdline_time;
add_temp_dline(aconf);
}
else
{
- aconf->passwd = rb_strdup(reason);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, NULL, aconf);
bandb_add(BANDB_DLINE, source_p, aconf->host, NULL,
char def[] = "No Reason";
char user[USERLEN + 2];
char host[HOSTLEN + 2];
- char buffer[IRCD_BUFSIZE];
char *reason = def;
char *oper_reason;
const char *target_server = NULL;
aconf->host = rb_strdup(host);
aconf->user = rb_strdup(user);
aconf->port = 0;
+ aconf->passwd = rb_strdup(reason);
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
}
if(tkline_time > 0)
- {
- rb_snprintf(buffer, sizeof(buffer),
- "Temporary K-line %d min. - %s",
- (int) (tkline_time / 60), reason);
- aconf->passwd = rb_strdup(buffer);
apply_tkline(source_p, aconf, reason, oper_reason, tkline_time);
- }
else
- {
- aconf->passwd = rb_strdup(reason);
apply_kline(source_p, aconf, reason, oper_reason);
- }
if(ConfigFileEntry.kline_delay)
{
handle_remote_kline(struct Client *source_p, int tkline_time,
const char *user, const char *host, const char *kreason)
{
- char buffer[BUFSIZE];
char *reason = LOCAL_COPY(kreason);
struct ConfItem *aconf = NULL;
char *oper_reason;
aconf->created = rb_current_time();
aconf->user = rb_strdup(user);
aconf->host = rb_strdup(host);
+ aconf->passwd = rb_strdup(reason);
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
}
if(tkline_time > 0)
- {
- rb_snprintf(buffer, sizeof(buffer),
- "Temporary K-line %d min. - %s",
- (int) (tkline_time / 60), reason);
- aconf->passwd = rb_strdup(buffer);
apply_tkline(source_p, aconf, reason, oper_reason, tkline_time);
- }
else
- {
- aconf->passwd = rb_strdup(reason);
apply_kline(source_p, aconf, reason, oper_reason);
- }
if(ConfigFileEntry.kline_delay)
{
static const char k_lined[] = "K-lined";
const char *reason = NULL;
const char *exit_reason = conn_closed;
- char reasonbuf[BUFSIZE];
- if(ConfigFileEntry.kline_with_reason && !EmptyString(aconf->passwd))
+ if(ConfigFileEntry.kline_with_reason)
{
- if(aconf->created)
- {
- rb_snprintf(reasonbuf, sizeof reasonbuf, "%s (%s)",
- aconf->passwd,
- smalldate(aconf->created));
- reason = reasonbuf;
- }
- else
- reason = aconf->passwd;
+ reason = get_user_ban_reason(aconf);
exit_reason = reason;
}
else
if(ConfigFileEntry.dline_with_reason)
{
- len = aconf->created ?
- rb_snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s (%s)\r\n", aconf->passwd, smalldate(aconf->created)) :
- rb_snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", aconf->passwd);
+ len = rb_snprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", get_user_ban_reason(aconf));
if (len >= (int)(sizeof(buf)-1))
{
buf[sizeof(buf) - 3] = '\r';
{
struct ConfItem *aconf;
char non_ident[USERLEN + 1];
- char reasonbuf[BUFSIZE];
- char *reason;
if(IsGotId(client_p))
{
else if(aconf->status & CONF_KILL)
{
if(ConfigFileEntry.kline_with_reason)
- {
- if(aconf->created)
- {
- snprintf(reasonbuf, sizeof reasonbuf, "%s (%s)",
- aconf->passwd,
- smalldate(aconf->created));
- reason = reasonbuf;
- }
- else
- reason = aconf->passwd;
sendto_one(client_p,
form_str(ERR_YOUREBANNEDCREEP),
- me.name, client_p->name, reason);
- }
+ me.name, client_p->name,
+ get_user_ban_reason(aconf));
add_reject(client_p, aconf->user, aconf->host);
return (BANNED_CLIENT);
}
*port = (int) aconf->port;
}
+char *
+get_user_ban_reason(struct ConfItem *aconf)
+{
+ static char reasonbuf[BUFSIZE];
+
+ if (aconf->flags & CONF_FLAGS_TEMPORARY &&
+ (aconf->status == CONF_KILL || aconf->status == CONF_DLINE))
+ rb_snprintf(reasonbuf, sizeof reasonbuf,
+ "Temporary %c-line %d min. - ",
+ aconf->status == CONF_DLINE ? 'D' : 'K',
+ (aconf->hold - aconf->created) / 60);
+ else
+ reasonbuf[0] = '\0';
+ if (aconf->passwd)
+ rb_strlcat(reasonbuf, aconf->passwd, sizeof reasonbuf);
+ else
+ rb_strlcat(reasonbuf, "No Reason", sizeof reasonbuf);
+ if (aconf->created)
+ {
+ rb_strlcat(reasonbuf, " (", sizeof reasonbuf);
+ rb_strlcat(reasonbuf, smalldate(aconf->created),
+ sizeof reasonbuf);
+ rb_strlcat(reasonbuf, ")", sizeof reasonbuf);
+ }
+ return reasonbuf;
+}
+
void
get_printable_kline(struct Client *source_p, struct ConfItem *aconf,
char **host, char **reason,
char **user, char **oper_reason)
{
static char null[] = "<NULL>";
- static char reasonbuf[BUFSIZE];
*host = EmptyString(aconf->host) ? null : aconf->host;
*user = EmptyString(aconf->user) ? null : aconf->user;
-
- *reason = EmptyString(aconf->passwd) ? null : aconf->passwd;
- if(aconf->created)
- {
- rb_snprintf(reasonbuf, sizeof reasonbuf, "%s (%s)",
- *reason, smalldate(aconf->created));
- *reason = reasonbuf;
- }
+ *reason = get_user_ban_reason(aconf);
if(EmptyString(aconf->spasswd) || !IsOper(source_p))
*oper_reason = NULL;