access list
Greetings,
is there a way to have some sort of access list? like allow specific networks and/or domains
Hi @acoul, Do you mean allowing only specific sites to be proxied via Censor Dodge? If so, then yes this is possible by leveraging the blacklisting functionality and regular expressions (RegEx). You can use a regex to whitelist/blacklist specific URLs by domain, and these will be verified whenever a page is proxied.
Something like: $proxy->blacklistWebsite("example.com"); to block a specific domain (blacklist) or $proxy->blacklistWebsite("(?=^(?!\s*$).+)(?=^((?!example.com).)*$)"); to block everything except a specific domain or no domain entered (whitelist).
Let me know how you get on with this!
Thanks, Ryan
Hi @ryanmab
I would like to use CensorDodge as a gateway to our free wireless community here @ Athens (AWMN)
looking at includes/class.censorDodge.php I see:
private $blacklistedWebsites = array("localhost", "127.0.0.1", cdURL);
I am looking for something perhaps like:
private $blacklistedNetworks = array("!10.0.0.0/8", cdURL);
or
private $blacklistedNetworks = array("0.0.0.0/0", cdURL);
private $whitelistedNetworks = array("10.0.0.0/8", cdURL);
thereof I guess this is NOT a bug report, rather a feature request
Edit: I was successful by using the following:
private $blacklistedWebsites = array("(?=^(?!\s*$).+)(?=^((?!.awmn).)*$)", cdURL);
now I need to figure out how to additionally allow only the 10.0.0.0/8 network
Hi @acoul, Great to hear you've managed to get the website blacklist working!
If you wanted to blacklist or whitelist an IP address, or series of IPs (like a network), then this would be fairly similar to the method used for websites.
For example, something like:
$this->blacklistIPAddress("(?=^((?!10\.[0-9.]+).)*$)");
will block any users who do not have an IP address like "10.x.x.x.x" (where x is any amount of digits between 0 and 9).
Let me know how you get on with this.
Thanks, Ryan
Greetings Ryan & thank you for the feedback,
I would like to ask if the following two functions are actually used anywhere:
function blacklistWebsite & function blacklistIPAddress
using grep recursively I was unable to locate them anywhere in the source tree besides their declaration location
instead, private $blacklistedWebsites looks like is been hard-coded here
& similarly private $blacklistedIPs hard-coded here
coming to your kind reply, where would be the best place/practice to place the following filter rule:
$this->blacklistIPAddress("(?=^((?!10\.[0-9.]+).)*$)");
in order to combine it with the earlier filter rule:
$proxy->blacklistWebsite("(?=^(?!\s*$).+)(?=^((?!example.com).)*$)");
which I have successfully placed it here
best regards, Alexandros
Hi @acoul,
So the blacklistWebsite and blacklistIPAddress methods are included as setters for the private $blacklistedWebsites and $blacklistedIPs variables included the censorDodge class, as, for security purposes, the variables cannot be accessed publicly (the private declaration). This means, they aren't so much hardcoded, as the values of the two variables can be added to at run-time, rather they're declared with default values when Censor Dodge is loaded.
At present the two methods are not used, as the base implementation doesn't block anything other than the 3 addresses which have been added as exclusions into the core implementation of the class for security reasons (it's not ideal to allow proxying of a servers local address, or recursive proxying of the website itself). The ideal method to add blacklisted websites or blacklisted IP addresses (or anything else like hotlinking exceptions, etc) is not to modify the class (inside class.censorDodge.php), and instead to add the two lines (as they are shown below) into index.php after line 3 (after the instantiation of the censorDodge class in the variable $proxy).
$proxy->blacklistIPAddress("(?=^((?!10\.[0-9.]+).)*$)");
$proxy->blacklistWebsite("(?=^(?!\s*$).+)(?=^((?!example.com).)*$)");
This acts as an 'addition' to the basic implementation (in this case, adding extra blocks to IPs and websites), where needed, without the need to modify anything Censor Dodge currently does.
Also, blacklisted IPs and blacklisted websites have a few key distinctions, and they're completely separate as they evaluate and block different things (you can use these together without issue, or having to consider each other). Blacklisted websites are URLs which cannot be proxied through Censor Dodge (e.g. blocking example.com from being loaded), and blacklisted IPs are IP addresses of visitors which cannot access the website Censor Dodge is running on at all (e.g. blocking the visitor with the IP address 100.10.10.5 from accessing the website). This means that its not necessary to consider how they work together, as they do separate things.
I hope I was able to help you :)
Thanks, Ryan