Compare commits

..

6 commits

Author SHA1 Message Date
Ed Kellett
492d560ee1 valid_temp_time: style fixes 2022-03-06 22:51:19 +00:00
Ed Kellett
2644dcd166 Add tests for valid_temp_time 2022-03-06 22:51:19 +00:00
Ed Kellett
7a246575e5 remove some header dependencies on client.h 2022-03-06 22:51:19 +00:00
David Schultz
93035e75d9 Support more human friendly k/d/x-line duration format 2022-03-06 22:51:19 +00:00
Eric Mertens
22ebfd257e Fix comment in example configuration 2022-02-03 09:23:42 -08:00
Valentin Lorentz
18ac52f017 Remove ambiguity in descriptions +u
The old descriptions might be interpreted as meaning that +u enables
server-side filtering.
2022-01-31 00:02:07 +00:00
9 changed files with 97 additions and 20 deletions

View file

@ -306,7 +306,7 @@ operator "god" {
privset = "admin"; privset = "admin";
}; };
// See connecting-servers.rst for an introduction to using these files. /* See connecting-servers.rst for an introduction to using these files. */
connect "irc.uplink.com" { connect "irc.uplink.com" {
host = "203.0.113.3"; host = "203.0.113.3";

View file

@ -20,8 +20,8 @@ NO PARAMETERS:
messages is stripped. messages is stripped.
+g - Free invite. Everyone may invite users. Significantly +g - Free invite. Everyone may invite users. Significantly
weakens +i control. weakens +i control.
? +u - Unfiltered. Receive messages that are filtered server side based ? +u - Unfiltered. Receive messages that would otherwise be filtered
on content server side based on content.
+z - Op moderated. Messages blocked by +m, +b and +q are instead +z - Op moderated. Messages blocked by +m, +b and +q are instead
sent to ops. sent to ops.
+L - Large ban list. Increase maximum number of +beIq entries. +L - Large ban list. Increase maximum number of +beIq entries.

View file

@ -16,8 +16,8 @@ User modes: (* designates that the umode is oper only)
* +a - Is marked as a server admin in whois. * +a - Is marked as a server admin in whois.
* +l - Can see oper locops (local wallops). * +l - Can see oper locops (local wallops).
* +s - Can see server notices (see /quote help snomask). * +s - Can see server notices (see /quote help snomask).
? +u - Receive messages that are filtered server side based ? +u - Receive messages that would otherwise be filtered server side
on content based on content.
* +z - Can see operwalls. * +z - Can see operwalls.
? +C - Prevents you from receiving CTCPs other than ACTION. ? +C - Prevents you from receiving CTCPs other than ACTION.
+D - Deaf - ignores all channel messages. +D - Deaf - ignores all channel messages.

View file

@ -11,8 +11,8 @@ User modes: (? designates that the umode is provided by an extension
? +h - Has a cloaked host. May be +x depending on cloaking module ? +h - Has a cloaked host. May be +x depending on cloaking module
+g - Deny users not on your /ACCEPT list from messaging you and +g - Deny users not on your /ACCEPT list from messaging you and
inviting you to channels. inviting you to channels.
? +u - Receive messages that are filtered server side based ? +u - Receive messages that would otherwise be filtered server side
on content. based on content.
+w - Can see oper wallops. +w - Can see oper wallops.
? +C - Prevents you from receiving CTCPs other than ACTION. ? +C - Prevents you from receiving CTCPs other than ACTION.
+D - Deaf - ignores all channel messages. +D - Deaf - ignores all channel messages.

View file

@ -43,6 +43,8 @@
#include "stdinc.h" #include "stdinc.h"
struct Client;
enum { enum {
PRIV_NEEDOPER = 1 PRIV_NEEDOPER = 1
}; };

View file

@ -40,6 +40,7 @@
#include <openssl/rsa.h> #include <openssl/rsa.h>
#endif #endif
struct Client;
struct ConfItem; struct ConfItem;
extern rb_dlink_list cluster_conf_list; extern rb_dlink_list cluster_conf_list;

View file

@ -685,23 +685,44 @@ time_t
valid_temp_time(const char *p) valid_temp_time(const char *p)
{ {
time_t result = 0; time_t result = 0;
long current = 0;
while(*p) while (*p) {
{ char *endp;
if(IsDigit(*p))
{ errno = 0;
result *= 10; current = strtol(p, &endp, 10);
result += ((*p) & 0xF);
p++; if (errno == ERANGE)
} return -1;
else if (endp == p)
return -1;
switch (*endp) {
case '\0': /* No unit was given so send it back as minutes */
case 'm':
result += current * 60;
break;
case 'h':
result += current * 3600;
break;
case 'd':
result += current * 86400;
break;
case 'w':
result += current * 604800;
break;
default:
return -1; return -1;
} }
if(result > (60 * 24 * 7 * 52)) if (*endp == '\0')
result = (60 * 24 * 7 * 52); break;
return(result * 60); p = endp + 1;
}
return MIN(result, 60 * 60 * 24 * 7 * 52);
} }
/* Propagated bans are expired elsewhere. */ /* Propagated bans are expired elsewhere. */

View file

@ -1,6 +1,7 @@
check_PROGRAMS = runtests \ check_PROGRAMS = runtests \
chmode1 \ chmode1 \
match1 \ match1 \
misc \
msgbuf_parse1 \ msgbuf_parse1 \
msgbuf_unparse1 \ msgbuf_unparse1 \
hostmask1 \ hostmask1 \

52
tests/misc.c Normal file
View file

@ -0,0 +1,52 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "tap/basic.h"
#include "s_newconf.h"
#define MSG "%s:%d (%s)", __FILE__, __LINE__, __FUNCTION__
#define MINUTE (60)
#define HOUR (MINUTE * 60)
#define DAY (HOUR * 24)
#define WEEK (DAY * 7)
static void valid_temp_time1(void)
{
time_t t;
t = valid_temp_time("1");
is_int(MINUTE, t, MSG);
t = valid_temp_time("1m");
is_int(MINUTE, t, MSG);
t = valid_temp_time("1h");
is_int(HOUR, t, MSG);
t = valid_temp_time("1d");
is_int(DAY, t, MSG);
t = valid_temp_time("1w");
is_int(WEEK, t, MSG);
t = valid_temp_time("2d");
is_int(2 * DAY, t, MSG);
t = valid_temp_time("1w2d3h4m");
is_int(1 * WEEK + 2 * DAY + 3 * HOUR + 4 * MINUTE, t, MSG);
t = valid_temp_time("1w2d3h4");
is_int(1 * WEEK + 2 * DAY + 3 * HOUR + 4 * MINUTE, t, MSG);
t = valid_temp_time("4m3h2d1w");
is_int(1 * WEEK + 2 * DAY + 3 * HOUR + 4 * MINUTE, t, MSG);
t = valid_temp_time("7000w");
is_int(52 * WEEK, t, MSG);
}
int main(int argc, char *argv[])
{
plan_lazy();
valid_temp_time1();
return 0;
}