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); } }

Reply With Quote

