Results 1 to 9 of 9

Thread: getstatus source ip

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Private
    Join Date
    Jan 2016
    Posts
    17
    Thanks
    4
    Thanked 4 Times in 4 Posts

    getstatus source ip

    Hi, I have modified the libcod getstatus function to allow a certain IP with no limits, but limit all other, my language knowledge isnt the best but it works.
    Now how can I modify this to load a list query_whitelist.txt of whitelisted IPs into a array in libcod and check them the same way?
    I have only 1 IP for now, but want it to be more flexible, as to not have it hardcoded and have to recompile to change it or add more.

    Code:
    void hook_SVC_Status(netadr_t from)
    {
    	char ip[64];
    	Com_sprintf (ip, sizeof(ip), "%i.%i.%i.%i", from.ip[0], from.ip[1], from.ip[2], from.ip[3]);
    	
    	if ( strcmp(ip, "XXX.XXX.XXX.XXX") == 0)
    	{
    		SVC_Status(from);
    	}
    	else
    	{
    		// Prevent using getstatus as an amplifier
    		// 3x in 5 minutes per address
    		if ( SVC_RateLimitAddress( from, 3, 200000 ) )
    		{
    			Com_DPrintf( "SVC_Status: rate limit from %s exceeded, dropping request\n", NET_AdrToString( from ) );
    			return;
    		}
    
    		// Global
    		// Allow getstatus to be DoSed relatively easily, but prevent
    		// excess outbound bandwidth usage when being flooded inbound
    		if ( SVC_RateLimit( &outboundLeakyBucket, 5, 1000 ) )
    		{
    			Com_DPrintf( "SVC_Status: rate limit exceeded, dropping request\n" );
    			return;
    		}
    
    		SVC_Status(from);
    	}
    }
    Last edited by v1rto; 17th February 2023 at 14:26.

  2. The Following User Says Thank You to v1rto For This Useful Post:

    kung foo man (17th February 2023)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •