3 final class PhabricatorClientRateLimit
4 extends PhabricatorClientLimit
{
6 protected function getBucketDuration() {
10 protected function getBucketCount() {
14 protected function shouldRejectConnection($score) {
15 $limit = $this->getLimit();
17 // Reject connections if the average score across all buckets exceeds the
19 $average_score = $score / $this->getBucketCount();
21 return ($average_score > $limit);
24 protected function getConnectScore() {
28 protected function getPenaltyScore() {
32 protected function getDisconnectScore(array $request_state) {
35 // If the user was logged in, let them make more requests.
36 if (isset($request_state['viewer'])) {
37 $viewer = $request_state['viewer'];
38 if ($viewer->isOmnipotent()) {
39 // If the viewer was omnipotent, this was an intracluster request or
40 // some other kind of special request, so don't give it any points
41 // toward rate limiting.
43 } else if ($viewer->isLoggedIn()) {
44 // If the viewer was logged in, give them fewer points than if they
45 // were logged out, since this traffic is much more likely to be
54 protected function getRateLimitReason($score) {
55 $client_key = $this->getClientKey();
57 // NOTE: This happens before we load libraries, so we can not use pht()
61 "TOO MANY REQUESTS\n".
62 "You (\"{$client_key}\") are issuing too many requests ".