Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/configuration/AphrontApplicationConfiguration.php
| Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | public static function runHTTPRequest(AphrontHTTPSink $sink) { | ||||
| $access_log->write(); | $access_log->write(); | ||||
| $multimeter->saveEvents(); | $multimeter->saveEvents(); | ||||
| DarkConsoleXHProfPluginAPI::saveProfilerSample($access_log); | DarkConsoleXHProfPluginAPI::saveProfilerSample($access_log); | ||||
| // Add points to the rate limits for this request. | // Add points to the rate limits for this request. | ||||
| if (isset($_SERVER['REMOTE_ADDR'])) { | $rate_token = PhabricatorStartup::getRateLimitToken(); | ||||
| $user_ip = $_SERVER['REMOTE_ADDR']; | if ($rate_token !== null) { | ||||
| // The base score for a request allows users to make 30 requests per | // The base score for a request allows users to make 30 requests per | ||||
| // minute. | // minute. | ||||
| $score = (1000 / 30); | $score = (1000 / 30); | ||||
| // If the user was logged in, let them make more requests. | // If the user was logged in, let them make more requests. | ||||
| if ($request->getUser() && $request->getUser()->getPHID()) { | if ($request->getUser() && $request->getUser()->getPHID()) { | ||||
| $score = $score / 5; | $score = $score / 5; | ||||
| } | } | ||||
| PhabricatorStartup::addRateLimitScore($user_ip, $score); | PhabricatorStartup::addRateLimitScore($rate_token, $score); | ||||
| } | } | ||||
| if ($processing_exception) { | if ($processing_exception) { | ||||
| throw $processing_exception; | throw $processing_exception; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 491 Lines • Show Last 20 Lines | |||||