diff options
| author | default <nobody@localhost> | 2024-12-19 18:54:15 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-12-19 18:54:15 +0100 |
| commit | 57a8716f72dd5c75c98ead085fbd8d7f12660da6 (patch) | |
| tree | 745fd52496988f1625a22689870cb94b8f4ddec2 /html.c | |
| parent | f82c7a5cdb2238e8c32649227daee05a0f885155 (diff) | |
Added bad login throttling.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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); + } } } |