@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorClientConnectionLimit
4 extends PhabricatorClientLimit {
5
6 protected function getBucketDuration() {
7 return 60;
8 }
9
10 protected function getBucketCount() {
11 return 15;
12 }
13
14 protected function shouldRejectConnection($score) {
15 // Reject connections if the cumulative score across all buckets exceeds
16 // the limit.
17 return ($score > $this->getLimit());
18 }
19
20 protected function getConnectScore() {
21 return 1;
22 }
23
24 protected function getPenaltyScore() {
25 return 0;
26 }
27
28 protected function getDisconnectScore(array $request_state) {
29 return -1;
30 }
31
32 protected function getRateLimitReason($score) {
33 $client_key = $this->getClientKey();
34
35 // NOTE: This happens before we load libraries, so we can not use pht()
36 // here.
37
38 return
39 "TOO MANY CONCURRENT CONNECTIONS\n".
40 "You (\"{$client_key}\") have too many concurrent ".
41 "connections.\n";
42 }
43
44}