brute force attacks – Block bruteforce attempts with nginx & cloudflare without rate limiting

So I discovered servers trying to bruteforce my API so I want to block them…but my specific scenario made it difficult to work with common solutions found on the internet.

1] I don't want to just rate limit, if any IP attempts to authenticate with the API and fail more than X times in ~6 hours I want to block them. No answers anymore at all. Not even 429 replies

2] I'm using cloudflare, so I need to use the CF IP header

3] I can't block the traffic based on iptables or similar solutions, since the only IPs that talk to my server are cloudflare IPs

4] The API generates nginx errors if the authentication fails with `2: no such file or directory` if that helps with something

Given my scenario, what are the possible solutions?

performance – Rate limit a method by generating particular load on demand in C#

I am working on a project where I want to generate random throughput on a particular method so that I can do some performance testing on it. This way I can test my method by generating random throughputs and see how my method works under all those scenarios.

For example: I need to call my doIOStuff method at an approximate rate of x requests per second from multiple threads where x will be less than 2000 mostly but it really doesn’t matter in this case. It doesn’t have to be accurate so there is some room for an error but the overall idea is I need to make sure that my method doIOStuff is executed no more than x times in a sliding window of y seconds.

Assuming we start n threads and want a maximum of m calls per second. We can achieve this by having each thread generate a random number between 0 and 1, k times per second and call doIOStuff method only if the generated number is less than m / n / k.

Below is the code I got which uses global variables and it does the job but I think it can be improved a lot where I can use some cancellation tokens as well and make it more efficient and clean.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;


namespace ConsoleApp
{
    class Program
    {
        const int m_threads = 100;
        const int n_throughput = 2000;
        const int k_toss_per_second = 2000; // Note that k_toss_per_second x  m_threads >= n_throughput

        static void Main(string() args)
        {
            var tasks = new List<Task>();

            for (int i = 0; i < m_threads; i++)
                tasks.Add(Task.Factory.StartNew(() => doIOStuff()));

            Task.WaitAll(tasks.ToArray());
            Console.WriteLine("All threads complete");
        }


        static void callDoIOStuff()
        {
           int sleep_time = (int) (1000 * 1.0d / k_toss_per_second);
           double threshold = (double) n_throughput / m_threads / k_toss_per_second; 
           Random random = new Random();
           while (true) {
                Thread.Sleep(sleep_time);
                if (random.NextDouble() < threshold)
                    doIOStuff();
            }
        }

        static void doIOStuff()
        {
            // do some IO work
        }
    }
}

I wanted to see what can we do here to make it more efficient and clean so that it can used in production testing for generating random throughput load.

php – How to add a flat rate cost for a shipping class

I have customized WC Product Vendors and added as many features as I like. I have a value field Delivery fee that should set a shipping class flat rate cost that equals vendors slug, but I dont know how to get and set a flat rate per specific shipping cost.

                    <th scope="row" valign="top"><label for="wcpv-vendor-delivery-fee"><?php esc_html_e( 'Delivery Fee', 'woocommerce-product-vendors' ); ?></label>                     </th>

                    <td>
                        <?php $get_classes = WC()->shipping->get_shipping_classes(); 
                        $vendor_slug = $vendor_data('slug');
                        foreach ($get_classes as $get_class){
                            $class_slug = $get_class->slug;
                            if ($class_slug == $vendor_slug){
                                //Set that shipping class a value of vendor_data(delivery_fee)
                            };
                        }
                        ?>
                        <input type="text" placeholder="30" name="vendor_data(delivery_fee)" value="<?php echo $vendor_data('delivery_fee'); ?>" />

                        <p><?php esc_html_e( 'Set a delivery fee.', 'woocommerce-product-vendors' ); ?></p>
                    </td>
                </tr>```

What’s the difference between landing page optimization and conversion rate optimization? – SEO Help (General Chat)

Hi Friends,

Conversion Rate Optimization: Conversion Rate Optimization (CRO)in simpler terms refers to the process of boosting the number of site visitors. Also these visitors are the ones who actually respond to a certain pop-up or button on your site. Such actions may involve filling a form, placing an order or even commenting/sharing/liking a content. For Quality CRO, it’s important to recognize how a visitor responds to certain features, and what exactly he/she looks for in a site. That way, you can remove those elements which prevent them from taking further action and become your customers.

Landing page optimization: (LPO) is the process of improving elements on a website to increase conversions. You can define Landing page optimization as a subset of Conversion Rate Optimization (CRO), as in the fact that improving your landing page activity is a part of improving your overall Conversion rate statistics. For Landing Page Optimization A/B testing is one of the better strategies to improve the conversion rates.

What Bounce Rate Is Too High?