Skip to content
KitploitKITPLOIT
उपकरणब्लॉग
Log in
जमा करें
उपकरणब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

··फ़ीड·संपर्क·गोपनीयता·© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
limitrr-php — Redis का उपयोग करके बेहतर PHP रेट लिमिटिंग। | Kitploit
उपकरण/GitHubGitHub/eddiejibson/limitrr-php
प्रमाणीकरण और प्राधिकरणस्क्रिप्टिंग और स्वचालनवेब सुरक्षाउपयोगिताएँ और फ्रेमवर्कAPI सुरक्षा
GitHubeddiejibson/limitrr-php

limitrr-php

Redis का उपयोग करके बेहतर PHP रेट लिमिटिंग।

रिपॉजिटरी देखें
206186 साल पहलेKitploit द्वारा समीक्षित

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें
chae

PHP में Redis का उपयोग करके हल्की दर सीमित करना।

Limitrr PHP मेरी दूसरी लाइब्रेरी, Limitrr से बहुत अधिक प्रेरित है, जिसे NodeJS के लिए बनाया गया था। इसे यहाँ देखें।

Limitrr PHP उपयोगकर्ताओं को अपने एप्लिकेशन में आसानी से दर सीमा (रेट लिमिटिंग) एकीकृत करने की अनुमति देता है। अन्य समान पैकेजों के विपरीत, यह उपयोगिता उपयोगकर्ता को न केवल अनुरोधों की संख्या से, बल्कि पूर्ण किए गए कार्यों की संख्या (जैसे किसी समयावधि में सफलतापूर्वक बनाए गए खातों की एक निश्चित संख्या की अनुमति देना) से भी सीमित करने की अनुमति देती है, और ऐसे प्रतिबंधों को कस्टम विकल्पों के साथ लागू करती है। इसके अलावा, कस्टम डिस्क्रिमिनेटर संभव हैं - अब आपको केवल उपयोगकर्ता के IP से सीमित नहीं होना होगा।

यह लाइब्रेरी SlimPHP प्रोजेक्ट के भीतर विभिन्न रूट्स पर आसानी से दर सीमित करने के लिए एक मिडलवेयर फ़ंक्शन भी प्रदान करती है।

यदि आप इस प्रोजेक्ट की सराहना करते हैं, तो कृपया इसे GitHub पर 🌟 करें।

पुल रिक्वेस्ट का स्वागत है

इंस्टॉलेशन

आप 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()

रिटर्न: Array

$limitrr->get([
    "discriminator" => $discriminator, //आवश्यक
    "route" => $route, //आवश्यक नहीं, डिफ़ॉल्ट मान लिया जाता है
    "type" => $type //आवश्यक नहीं
]);
->get() पैरामीटर

फ़ंक्शन में एक ऐरे के माध्यम से पास किया जाना चाहिए

  • discriminator: आवश्यक जहां discriminator वह चीज़ है जिसे सीमित किया जा रहा है (जैसे प्रति discriminator पूर्ण किए गए कार्यों की x संख्या)
  • route: String किस रूट से मान प्राप्त किए जाएँ? यदि यह सेट नहीं है, तो यह default रूट से गणना प्राप्त करेगा
  • type: String दोनों मानों को पुनर्प्राप्त करने के बजाय, आप इस कुंजी में requests या completed निर्दिष्ट कर सकते हैं और केवल वही एक पूर्णांक के रूप में लौटाया जाएगा।
->get() उदाहरण
$limitrr->get([
    "discriminator" => $discriminator,
    "type" => $type,
    "route" => $route
]); //discriminator के अलावा, सभी पैरामीटर वैकल्पिक हैं।
//यदि फ़ंक्शन में type पास नहीं किया गया है, तो यह
//अनुरोधों और पूर्ण कार्यों दोनों की मात्रा लौटाएगा

//जहां discriminator वह चीज़ है जिसे सीमित किया जा रहा है
//जैसे प्रति discriminator पूर्ण कार्यों/अनुरोधों की x संख्या
$limitrr->get(["discriminator" => $discriminator]);

//यह आमतौर पर उपयोगकर्ता का IP होता है।
$limitrr->get(["discriminator" => $ip]);
//यह प्रदान किए गए discriminator के अंतर्गत संग्रहीत अनुरोधों और पूर्ण कार्यों दोनों की मात्रा को एक ऑब्जेक्ट में लौटाएगा। आप इसे इस तरह संभाल सकते हैं:
$result = $limitrr->get(["discriminator" => $ip]);
echo $result["requests"] + " Requests";
echo $result["completed"] + " Completed";

//उपरोक्त उदाहरण default रूट से अनुरोध और पूर्ण कार्य गणना प्राप्त करेगा।
//यदि आप किसी भिन्न रूट से मान प्राप्त करना चाहते हैं, तो आप इसे भी निर्दिष्ट कर सकते हैं।
//इसे इस तरह किया जा सकता है:
$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";

//आप केवल एक प्रकार का मान भी प्राप्त कर सकते हैं - अनुरोध और पूर्ण दोनों के बजाय।
$result = $limitrr->get(["discriminator" => $ip, "route" => "exampleRouteName", "type" => "completed"]);
echo $result["completed"] . " Completed tasks made through the route exampleRouteName";

कार्य/कार्य गणना पूर्ण करें

limitrr->complete()

रिटर्न: Integer

$limitrr->get([
    "discriminator" => $discriminator, //आवश्यक
    "route" => $route, //आवश्यक नहीं, डिफ़ॉल्ट मान लिया जाता है
]);
->complete() पैरामीटर

फ़ंक्शन में एक ऐरे के माध्यम से पास किया जाना चाहिए

टूल डाउनलोड करें