Skip to content

Instantly share code, notes, and snippets.

@RafPe
Created May 17, 2016 18:38
Show Gist options
  • Select an option

  • Save RafPe/5498fc1fb7cb61ed280fc9dbfa2427df to your computer and use it in GitHub Desktop.

Select an option

Save RafPe/5498fc1fb7cb61ed280fc9dbfa2427df to your computer and use it in GitHub Desktop.
This response rule allows for whitelisting URLs for specific IP addresses
$allowedIPs = [ "1.2.0.0/16", "4.3.0.0/16"];
$drop=true;
$FeedsToblock =[
"www.some.com/feed/xyz",
"www.some.com/feed/abc",
"www.some.com/feed/rrr"
];
$clientip = request.getRemoteIP();
$fullurl = string.append( http.getHostHeader(), http.getPath() );
foreach ($singleIP in $allowedIPs){
if( string.ipmaskmatch( $clientip, $singleIP )){
$drop=false;
break;
}
}
if ($drop == true && array.contains($FeedsToblock, $fullurl )) {
connection.discard();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment