runet-censorship-bypass/README.md

44 lines
2.1 KiB
Markdown
Raw Normal View History

2015-12-20 23:39:47 +03:00
# Anti-censorship Solution for Russia on PAC-scripts
2015-12-20 23:47:21 +03:00
## Chrome Extension
2015-12-20 23:39:47 +03:00
2015-12-20 23:48:07 +03:00
[WebStore](https://chrome.google.com/webstore/developer/edit/npgcnondjocldhldegnakemclmfkngch)
[Sources](https://github.com/ilyaigpetrov/anti-censorship-russia/tree/master/extensions/chromium/minimalistic-pac-setter),
2015-11-28 18:21:20 +03:00
2015-12-20 23:47:21 +03:00
## Why I do This
2015-11-28 18:21:20 +03:00
2015-12-20 23:47:21 +03:00
I believe __information mustn't be blocked based on political or other subjective views__.
[See arguments against censorship (ru)](https://gist.github.com/ilyaigpetrov/9452b93ef3d7dd3d8cc2)
2015-11-28 18:21:20 +03:00
2015-12-20 23:47:21 +03:00
My maxim is "Your freedom ends when it starts to confine the freedom of others".
2015-11-28 18:21:20 +03:00
2015-12-02 14:55:36 +03:00
Looking at how Russian government [distorts TV](https://therussianreader.wordpress.com/2015/11/22/russian-truckers-strike-dagestan/) and blocks Internet, I decided to write an Anti-censorship extension for Chomium before they strike first.
2015-11-28 18:21:20 +03:00
2015-12-20 23:47:21 +03:00
For good or bad, Russian government blocks
[Main Kampf](https://en.wikipedia.org/wiki/Mein_Kampf) and
[critics of Putin](http://www.reuters.com/article/2014/03/13/us-russia-internet-idUSBREA2C21L20140313).
2015-12-02 14:55:36 +03:00
2015-12-20 23:39:47 +03:00
## PAC-script performance analysis
2015-11-28 18:21:20 +03:00
2015-11-28 18:30:59 +03:00
```javascript
if (Is_subdomain_of( host, blocked_hosts ))
return 'use proxy';
```
2015-11-28 18:21:20 +03:00
2015-11-28 18:30:59 +03:00
You have to make `Is_subdomain_of` very fast.
This check is executed on each request. You should watch memeory consumption too.
2015-11-28 18:21:20 +03:00
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.
2015-12-02 10:40:24 +03:00
The shortcoming of every ip solution is that __some providers resolve blocked hosts to wrong ips__, so we eventually need list of hosts.
2015-11-27 23:47:27 +03:00
2015-11-28 19:03:14 +03:00
I have tested different solutions, and depicted [results](./benchmark/Output.txt) in the following chart:
2015-11-28 18:30:59 +03:00
2015-11-28 16:20:17 +03:00
![Host Lookup Chart: Time-Memory, Hits-Misses](./chart/host-lookup-chart.png)
2015-12-20 23:32:10 +03:00
* __IPs indexOf__ Blocked IP is searched by `indexOf`
* __IPs binary__ Blocked IP is searched by binary search. For some reason miss time slightly increased.
2015-11-28 16:20:17 +03:00
* __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__.
2015-12-02 15:00:20 +03:00