Skip to content
KitploitKITPLOIT
도구익스플로잇블로그
Log in
제출
도구익스플로잇블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
limitrr-php — Redis를 사용한 더 나은 PHP 속도 제한 | Kitploit
도구/GitHubGitHub/eddiejibson/limitrr-php
Authentication & AuthorizationScripting & AutomationWeb SecurityUtilities & FrameworksAPI Security
GitHubeddiejibson/limitrr-php

limitrr-php

Redis를 사용한 더 나은 PHP 속도 제한

저장소 보기
206176년 전Kitploit 검토 완료

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유
chae

Redis를 사용하여 PHP 내에서 가벼운 속도 제한을 제공합니다.

Limitrr PHP는 제가 만든 다른 라이브러리인 NodeJS용 Limitrr에서 크게 영감을 받았습니다. 여기에서 확인해 보세요.

Limitrr PHP를 사용하면 애플리케이션에 속도 제한을 쉽게 통합할 수 있습니다. 다른 유사한 패키지와 달리 이 유틸리티는 요청 수뿐만 아니라 완료된 작업 수(예: 특정 시간 내에 성공적으로 생성할 수 있는 계정 수)도 제한할 수 있으며, 그러한 제한에 사용자 지정 옵션을 적용할 수 있습니다. 또한 사용자 지정 식별자(discriminator)를 사용할 수 있으므로 더 이상 사용자의 IP로만 제한할 필요가 없습니다.

이 라이브러리는 또한 SlimPHP 프로젝트 내 다양한 라우트에 속도 제한을 쉽게 적용할 수 있는 미들웨어 함수를 제공합니다.

이 프로젝트가 마음에 드신다면 GitHub에서 🌟로 표시해 주세요.

Pull Request를 환영합니다

설치

limitrr-php 라이브러리는 터미널에서 다음 명령어를 실행하여 설치할 수 있습니다 (composer가 설치되어 있다고 가정합니다).

composer require eddiejibson/limitrr-php "^1.0"

빠른 가이드

기본 사용법

require "/vendor/autoload.php"; //Require composer's autoload

$options = [
    //Redis keystore information
    "redis" => [
        "host" => "666.chae.sh",
        "port" => 6379,
        "password" => "supersecret",
    ],
    "routes" => [
        "default" => [
            "requestsPerExpiry" => 5,
        ],
    ],

];

//Initialize the Limitrr class and pass the options defined above into it
//Note that the options are not required.
$limitrr = new \eddiejibson\limitrr\Limitrr($options);

//Various examples like this can be found further into the documentation,
//for each function.
$result = $limitrr->get(["discriminator" => $ip]);
echo $result["requests"] + " Requests";
echo $result["completed"] + " Completed";
//Note that this library is no means just for SlimPHP, it just happens to
//provide a middleware function for those who may need it.

//Usage within SlimPHP
$app = new Slim\App();

//Use the Limitrr SlimPHP middleware function, if you wish:
$app->add(new \eddiejibson\limitrr\RateLimitMiddleware($limitrr)); //Make sure to pass in the main Limitrr
//instance we defined above into the middleware function. This is mandatory.

//You can also add the get IP middleware function, it will append the user's real IP
//(behind Cloudflare or not) to the request.
$app->add(new \eddiejibson\limitrr\getIpMiddleware());

//Example usage within a route
$app->get("/hello/{name}", function ($request, $response, $args) {
    $name = $args["name"];
    $ip = $request->getAttribute('realip'); //Get the IP that was defined within Limitrr's get IP middleware function
    return $response->getBody()->write("Hello, ${name}. Your IP is ${ip}.");
});

//You do not have to app the middleware function to every single route, globally.
//You can do it indivually, too - along with passing options into such. Like so:
$app->get("/createUser/{name}", function ($request, $response, $args) {
    //Non intensive actions like simple verification will have a different limit to intensive ones.
    //and will only be measured in terms of each request via the middleware.
    //No further action is required.
    if (strlen($args["name"]) < 5) {
        //Dummy function creating user
        $res = $someRandomClass->registerUser();
        if ($res) {
            //Intensive actions like actually registering a user should have a
            //different limit to normal requests, hence the completedActionsPerExpiry option.
            //and should only be added to once this task has been completed fully
            //In this example, we will be limiting the amount of completed actions a certain IP can make.
            //Anything can be passed in here, however. For example, a email address or user ID.
            //$request->getAttribute('realip') was determined by calling the middleware earlier - getIpMiddleware()
            $limitrr->complete(["discriminator"] => $ip);
        }
    }
})->add(new \eddiejibson\limitrr\RateLimitMiddleware($limitrr, ["route"=>"createUser"]));
//You can also pass the route name within the limitrr middleware function

$app->run();

특정 키 값 가져오기

limitrr->get()

반환: 배열

$limitrr->get([
    "discriminator" => $discriminator, //Required
    "route" => $route, //Not required, default is assumed
    "type" => $type //Not required
]);
->get() 매개변수

배열을 통해 함수에 전달되어야 합니다

  • discriminator: 필수 discriminator는 제한되는 대상입니다 (예: discriminator당 완료된 작업 x개).
  • route: 문자열 값을 가져올 라우트는 무엇입니까? 설정하지 않으면 default 라우트에서 개수를 가져옵니다.
  • type: 문자열 두 값을 모두 가져오는 대신 이 키에 requests 또는 completed를 지정하면 해당 값만 정수로 반환됩니다.
->get() 예제
$limitrr->get([
    "discriminator" => $discriminator,
    "type" => $type,
    "route" => $route
]); //Besides discriminator, all parameters are optional.
//If type is not passed into the function, it will
//return both the amount of requests and completed actions

//Where discriminator is the thing being limited
//e.g x amount of completed actions/requests per discriminator
$limitrr->get(["discriminator" => $discriminator]);

//This tends to be the user's IP.
$limitrr->get(["discriminator" => $ip]);
//This will return both the amount of requests and completed actions stored under the
//discriminator provided in an object. You can handle like this:
$result = $limitrr->get(["discriminator" => $ip]);
echo $result["requests"] + " Requests";
echo $result["completed"] + " Completed";

//The above example would get the request and completed task count from the default
//route. If you would like to retrieve values from a different route, you can specify
//this as well. It can be done like this:
$result = $limitrr->get(["discriminator" => $ip, "route" => "exampleRouteName"]);
echo $result["requests"] . " Requests made through the route exampleRouteName";
echo $result["completed"] . " Completed Tasks made through the route exampleRouteName";

//You may also only fetch only one type of value - instead of both requests and completed.
$result = $limitrr->get(["discriminator" => $ip, "route" => "exampleRouteName", "type" => "completed"]);
echo $result["completed"] . " Completed tasks made through the route exampleRouteName";

완료 작업/작업 수 카운트

limitrr->complete()

반환: 정수

$limitrr->get([
    "discriminator" => $discriminator, //Required
    "route" => $route, //Not required, default is assumed
]);
->complete() 매개변수

배열을 통해 함수에 전달되어야 합니다

  • discriminator: 필수 discriminator는 제한되는 대상입니다 (예: discriminator당 완료된 작업 x개).
  • route: 문자열 값이 삽입될 라우트는 무엇입니까? 설정하지 않으면 default 라우트에서 개수를 가져옵니다.

특정 요청/완료 키에서 값 제거

limitrr->reset()

반환: 부울

$limitrr->reset([
    "discriminator" => $discriminator, //Required
    "route" => $route, //Not required, default is assumed,
    "type" => $type //Not required
]);
->reset() 매개변수

배열을 통해 함수에 전달되어야 합니다

  • discriminator: 필수 discriminator는 제한되는 대상입니다 (예: discriminator당 완료된 작업 x개).
  • route: 문자열 어느 라우트의 값을 초기화하시겠습니까? 설정하지 않으면 default 라우트의 개수가 초기화됩니다.
  • type: 문자열 어떤 개수를 초기화하시겠습니까? requests 또는 completed? 설정하지 않으면 둘 다 제거됩니다.
//Where discriminator is the thing being limited
//e.g x amount of completed actions/requests per discriminator
//This will remove both the amount of requests and completed action count
$limitrr->reset(["discriminator" => $discriminator]);

//This tends to be the user's IP.
$limitrr->reset(["discriminator" => $ip]);
도구 다운로드