Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Fix rate limit types | 0de3ee35d0d0e46521d64a596232765fb5d618a3 | Catalin(ux) M. BOIE | 2021-11-14 05:58:03 |
commented request_slowlog_timeout | 505877b567807e11f25695de58725f316f10043e | Catalin(ux) M. BOIE | 2021-11-13 17:32:46 |
systemctl git.socket rethinking | 3c71e58760f6abc69db661098840c277d4fc13fb | Catalin(ux) M. BOIE | 2021-11-13 17:25:52 |
PHP FALSE verus NULL correction | 42f8bc560a0ec2203f0974e203e6c33ec26aa983 | Catalin(ux) M. BOIE | 2021-11-13 16:31:33 |
.spec: some minor corrections | 70c3a23f507d57c729e0d710ec99060e0e88c238 | Catalin(ux) M. BOIE | 2021-11-13 16:22:11 |
Rework locking for struct update | da8c09e15e485563d9573de3aff2a7ad999d2527 | Catalin(ux) M. BOIE | 2021-11-13 16:15:45 |
gpg: specify rsa 4096 instead of default because it does not work on f34 | eccdc02a82ce87f426eebc995988f907d914a3c7 | Catalin(ux) M. BOIE | 2021-11-13 16:15:15 |
Cosmetic | 0b0a9f2d1922d4d28052c6b1fbe737cc4302ce73 | Catalin(ux) M. BOIE | 2021-11-13 16:14:37 |
PHP8 corrections | 51f2cabc7298b5006bf8f0d215c1a338bee92cdb | Catalin(ux) M. BOIE | 2021-11-13 16:13:13 |
.spec: require openldap-servers to test LDAP | 84e469d5d9fe81509ff3421bdb6517786ea96628 | Catalin(ux) M. BOIE | 2021-11-06 20:09:07 |
Cosmetic | a4543d8257235dc5c93dd5eecdfb9caa3c2acafa | Catalin(ux) M. BOIE | 2021-11-02 07:04:36 |
Fixed partion create logic | c8897c0e6f31a0ab917d2320018c5920e0abd36b | Catalin(ux) M. BOIE | 2021-11-02 06:01:58 |
Typos corrected | c1a5002a1763327f4df8d5d0b419fcc2604f4698 | Catalin(ux) M. BOIE | 2021-10-30 11:08:34 |
compare: Updated number of lines | d1052eb4b72309dd216e3fd0da2dd311bbeb1383 | Catalin(ux) M. BOIE | 2021-10-30 10:56:39 |
Added docs for distro pkgs | 401c582772303eff8ba7fde3fcf09064d11bf828 | Catalin(ux) M. BOIE | 2021-10-30 10:47:43 |
Added a feature island for packages | 115412032fca7ad2166ffbc0a526b358ee1006c4 | Catalin(ux) M. BOIE | 2021-10-28 07:00:14 |
Fixed spec file | a4c1a8218cfc9cc5b822c587fa3fc709e5d2bf6b | Catalin(ux) M. BOIE | 2021-10-27 19:37:23 |
Get rid of xinetd | ebc765c9a21a9803b67484795625f7eb46642ae9 | Catalin(ux) M. BOIE | 2021-10-27 14:18:45 |
Added /etc/ssh/sshd_config.d in .spec file (again) | f225de7ddc3d78d4ec3699c63df6fd754500a9e3 | Catalin(ux) M. BOIE | 2021-10-26 07:05:26 |
Compare updated to add .rpm info | 0d0a890fe98689b7b70987824e98d34ca5204d45 | Catalin(ux) M. BOIE | 2021-10-26 06:32:39 |
File | Lines added | Lines deleted |
---|---|---|
inc/ratelimit.inc.php | 7 | 8 |
root/index.php | 2 | 2 |
scripts/remote.php | 1 | 1 |
File inc/ratelimit.inc.php changed (mode: 100644) (index c28c23a..1419be0) | |||
5 | 5 | // TODO: rate limit 404 errors | // TODO: rate limit 404 errors |
6 | 6 | ||
7 | 7 | /* | /* |
8 | * Returns 1 in case of errors (fake "no over limit"). | ||
8 | * Returns -1 in case of errors or no conf present (fake "no over limit"). | ||
9 | * Returns 0 if the user is over limit. | ||
9 | 10 | * Returns >0 when the @ip is under limit (the return value represents how | * Returns >0 when the @ip is under limit (the return value represents how |
10 | 11 | * many requests are still allowed. | * many requests are still allowed. |
11 | * Returns 0 if the user is over limit. | ||
12 | 12 | */ | */ |
13 | 13 | function rg_rate_limit($db) | function rg_rate_limit($db) |
14 | 14 | { | { |
15 | 15 | rg_log_enter('rate_limit'); | rg_log_enter('rate_limit'); |
16 | 16 | ||
17 | $ret = 1; | ||
18 | while (1) { | ||
19 | $period = rg_state_get($db, 'rate_limit_period'); | ||
17 | $ret = -1; | ||
18 | do { | ||
19 | $period = rg_state_get_uint_uint($db, 'rate_limit_period'); | ||
20 | 20 | if (($period === FALSE) || ($period == 0)) | if (($period === FALSE) || ($period == 0)) |
21 | 21 | break; | break; |
22 | 22 | ||
23 | $limit = rg_state_get($db, 'rate_limit_max'); | ||
23 | $limit = rg_state_get_uint($db, 'rate_limit_max'); | ||
24 | 24 | if (($limit === FALSE) || ($limit == 0)) | if (($limit === FALSE) || ($limit == 0)) |
25 | 25 | break; | break; |
26 | 26 | ||
... | ... | function rg_rate_limit($db) | |
57 | 57 | ||
58 | 58 | rg_log('IP is not over limit (count=' . $row['count'] . '/' . $limit . ')'); | rg_log('IP is not over limit (count=' . $row['count'] . '/' . $limit . ')'); |
59 | 59 | $ret = $limit - $row['count']; | $ret = $limit - $row['count']; |
60 | break; | ||
61 | } | ||
60 | } while (0); | ||
62 | 61 | ||
63 | 62 | rg_log_exit(); | rg_log_exit(); |
64 | 63 | return $ret; | return $ret; |
File root/index.php changed (mode: 100644) (index 09f8b7a..fb33a11) | |||
... | ... | if (($lim == 0) && (rg_debug() == 0)) { | |
134 | 134 | header($rg['proto'] . ' 429 Too many requests'); | header($rg['proto'] . ' 429 Too many requests'); |
135 | 135 | echo 'Too many requests. Please slow down.' . "\n"; | echo 'Too many requests. Please slow down.' . "\n"; |
136 | 136 | exit(0); | exit(0); |
137 | } | ||
138 | header('X-RocketGit-Limit-Left: ' . $lim); | ||
137 | } else if ($lim > 0) | ||
138 | header('X-RocketGit-Limit-Left: ' . $lim); | ||
139 | 139 | ||
140 | 140 | // Sets http(s)_allow and hostname | // Sets http(s)_allow and hostname |
141 | 141 | $hostname = rg_state_get($db, 'hostname'); | $hostname = rg_state_get($db, 'hostname'); |
File scripts/remote.php changed (mode: 100644) (index 62bce94..1bff76e) | |||
... | ... | if (isset($_SERVER['SSH_CONNECTION'])) { | |
201 | 201 | rg_ip_set($ip); | rg_ip_set($ip); |
202 | 202 | ||
203 | 203 | $lim = rg_rate_limit($db); | $lim = rg_rate_limit($db); |
204 | if ($lim == 0) | ||
204 | if (($lim == 0) && (rg_debug() == 0)) | ||
205 | 205 | fatal('Too many requests! Please slow down.'); | fatal('Too many requests! Please slow down.'); |
206 | 206 | } | } |
207 | 207 |