mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-10 19:46:34 +03:00
restructuring folders
This commit is contained in:
parent
f07a4890f4
commit
a44bd22108
24
README.md
24
README.md
|
@ -17,27 +17,3 @@ My maxim is _"Your freedom ends when it starts to confine the freedom of others"
|
|||
|
||||
Looking at how Russian government [distorts TV](https://therussianreader.wordpress.com/2015/11/22/russian-truckers-strike-dagestan/) and blocks [critics of Putin](http://www.reuters.com/article/2014/03/13/us-russia-internet-idUSBREA2C21L20140313),
|
||||
I decided to write an anti-censorship extension for Chromium before they strike me first.
|
||||
|
||||
## PAC-Script Performance Analysis
|
||||
|
||||
```javascript
|
||||
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](./benchmark/Output.txt) in the following chart:
|
||||
|
||||
![Host Lookup Chart: Time-Memory, Hits-Misses](./chart/host-lookup-chart.png)
|
||||
|
||||
* __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__.
|
||||
|
||||
|
|
25
pac-script-performance-analyses/README.md
Executable file
25
pac-script-performance-analyses/README.md
Executable file
|
@ -0,0 +1,25 @@
|
|||
## PAC-Script Performance Analysis
|
||||
|
||||
Somewhere in PAC-script you may want:
|
||||
|
||||
```javascript
|
||||
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](./benchmark/Output.txt) in the following chart:
|
||||
|
||||
![Host Lookup Chart: Time-Memory, Hits-Misses](./chart/host-lookup-chart.png)
|
||||
|
||||
* __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__.
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -7,7 +7,7 @@
|
|||
"generate": "cd pac-generator && npm start",
|
||||
"prestart": "npm run generate",
|
||||
"start": "npm run bench",
|
||||
"bench": "cd Benchmark && dnx run ../pac-generator/generated-PACs",
|
||||
"bench": "cd ./pac-script-performance-analyses/benchmark && dnx run ../../pac-generator/generated-PACs",
|
||||
"test": "rm -r pac-generator/generated-PACs"
|
||||
},
|
||||
"author": "ilyaigpetrov",
|
||||
|
|
Loading…
Reference in New Issue
Block a user