aboutsummaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-12-19 18:54:15 +0100
committerdefault <nobody@localhost>2024-12-19 18:54:15 +0100
commit57a8716f72dd5c75c98ead085fbd8d7f12660da6 (patch)
tree745fd52496988f1625a22689870cb94b8f4ddec2 /html.c
parentf82c7a5cdb2238e8c32649227daee05a0f885155 (diff)
Added bad login throttling.
Diffstat (limited to 'html.c')
-rw-r--r--html.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/html.c b/html.c
index f2b1252..8c00961 100644
--- a/html.c
+++ b/html.c
@@ -29,9 +29,18 @@ int login(snac *snac, const xs_dict *headers)
xs *l1 = xs_split_n(s2, ":", 1);
if (xs_list_len(l1) == 2) {
- logged_in = check_password(
- xs_list_get(l1, 0), xs_list_get(l1, 1),
- xs_dict_get(snac->config, "passwd"));
+ const char *user = xs_list_get(l1, 0);
+ const char *pwd = xs_list_get(l1, 1);
+ const char *addr = xs_or(xs_dict_get(headers, "remote-addr"),
+ xs_dict_get(headers, "x-forwarded-for"));
+
+ if (badlogin_check(user, addr)) {
+ logged_in = check_password(user, pwd,
+ xs_dict_get(snac->config, "passwd"));
+
+ if (!logged_in)
+ badlogin_inc(user, addr);
+ }
}
}