summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2024-12-19 18:54:15 +0100
committerGravatar default2024-12-19 18:54:15 +0100
commit57a8716f72dd5c75c98ead085fbd8d7f12660da6 (patch)
tree745fd52496988f1625a22689870cb94b8f4ddec2 /html.c
parentPropagate FastCGI variable REMOTE_ADDR. (diff)
downloadsnac2-57a8716f72dd5c75c98ead085fbd8d7f12660da6.tar.gz
snac2-57a8716f72dd5c75c98ead085fbd8d7f12660da6.tar.xz
snac2-57a8716f72dd5c75c98ead085fbd8d7f12660da6.zip
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)
29 xs *l1 = xs_split_n(s2, ":", 1); 29 xs *l1 = xs_split_n(s2, ":", 1);
30 30
31 if (xs_list_len(l1) == 2) { 31 if (xs_list_len(l1) == 2) {
32 logged_in = check_password( 32 const char *user = xs_list_get(l1, 0);
33 xs_list_get(l1, 0), xs_list_get(l1, 1), 33 const char *pwd = xs_list_get(l1, 1);
34 xs_dict_get(snac->config, "passwd")); 34 const char *addr = xs_or(xs_dict_get(headers, "remote-addr"),
35 xs_dict_get(headers, "x-forwarded-for"));
36
37 if (badlogin_check(user, addr)) {
38 logged_in = check_password(user, pwd,
39 xs_dict_get(snac->config, "passwd"));
40
41 if (!logged_in)
42 badlogin_inc(user, addr);
43 }
35 } 44 }
36 } 45 }
37 46