benchmark | ||
chart | ||
extensions/chromium | ||
pac-generator | ||
.gitignore | ||
package.json | ||
README.md |
Anti-censorship Solution for Russia on PAC-scripts
Chrome Extension
Why I do This
I believe information mustn't be blocked based on political or other subjective views. See arguments against censorship (ru)
My maxim is "Your freedom ends when it starts to confine the freedom of others".
Looking at how Russian government distorts TV and blocks Internet, I decided to write an Anti-censorship extension for Chomium before they strike first.
For good or bad, Russian government blocks Main Kampf and critics of Putin.
PAC-script performance analysis
if (Is_subdomain_of( host, blocked_hosts ))
return 'use proxy';
You have to make Is_subdomain_of
very fast.
This check is executed on each request. You should watch memeory consumption too.
The naive solution is to keep array of blocked ips and check if the host resolves to one of the ips.
You may do it with indexOf
, binary search, etc.
The shortcoming of every ip solution is that some providers resolve blocked hosts to wrong ips, so we eventually need list of hosts.
I have tested different solutions, and depicted results in the following chart:
- IPs indexOf – Blocked IP is searched by
indexOf
- IPs binary – Blocked IP is searched by binary search. For some reason miss time slightly increased.
- IPs switch – Simply
switch(Blocked_IP) { case1: ... caseN: return true }
. Works even better than binary search. Magic. - Hosts switch – Radix trie built on
switch
. Comparable to IPs switch.