sn0b4ll / aria2-onion-downloader

Download from .onion-domains faster.
GNU Lesser General Public License v2.1
158 stars 21 forks source link

Speed-up downloads how-to #6

Closed ValdikSS closed 1 year ago

ValdikSS commented 1 year ago

Hi there. This is not an issue with the project.

I've had to download 950 GB from Tor recently, from a very slow server, for which I used aria2, and found your project in one of aria2's issues as a pingback. Here are some of the caveats your system does not address:

  1. Tor is an anonymous system, that's why it selects entry and intermediate relays using various metrics. However, for downloading purposes we should prefer relay speed and latency, not anonymity.
    You can use tor-relay-scanner to filter the relays, I used filtering by the countries closest to mine, for the lowest possible ping.

  2. Tor shares (aggregates), or non-isolates, circuits based on the clients' source IP address, SOCKS port, destination port, etc. In your configuration, it would aggregate the circuits as long as possible, leading to lower overall downloading speed. I ended up configuring v2ray proxy as a balancer, but each connection uses random source localhost IP (127.0.0.1, 127.0.0.2, 127.0.0.3, ... 127.0.0.50), to make Tor believe that each of the connection is a unique client required circuit isolation. This way you don't have to configure that many Tor instances, I had only three, each of which used 30+ unique circuits.
    Check SocksPort Isolate* options in the man to learn more. Circuits could be checked using control port with GETINFO stream-status and GETINFO circuit-status commands.

  3. Is it very important to use --max-tries=0 --retry-wait=5 configuration for aria, otherwise it won't reestablish the connection in case of failure indefinitely. I also used --http-accept-gzip=true to speed-up uncompressed text files transfer, as well as some other compressible data. However pipelining, which is enabled in your configuration, I believe slows things down a bit, as the additional TCP connection is almost always more preferable than additional transfer inside existing connection.

sn0b4ll commented 1 year ago

That is really cool input, many thanks!

I will have a look at it in the upcoming weeks to see what if this can be implemented easily. I understand that you did this without using this project but with your own environment? If am wrong and you did already modify this project, a PR would be highly appreciated :smile:

But again, many thanks for the great feedback and I will have a look into it :+1:

ValdikSS commented 1 year ago

I understand that you did this without using this project but with your own environment?

Yes, just a regular Tor and regular aria2.

The command like for aria used was:

aria2c -s 16 -x 16 -j 3 --stream-piece-selector=random --http-proxy='127.0.0.1:9052' --save-session=session.state \
 --http-accept-gzip=true -i session.state --save-session-interval=60 --max-tries=0 --retry-wait=5 -l log.txt --log-level=info
V2ray configuration: ``` { "log": { "loglevel": "warning" }, // List of inbound proxy configurations. "inbounds": [{ "port": 9052, "listen": "127.0.0.1", "protocol": "http", "sniffing": { "enabled": true, "destOverride": ["http", "tls"] } }], "outbounds": [{ "protocol": "socks", "sendThrough": "127.0.0.1", "tag": "tor-1", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.2", "tag": "tor-2", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.3", "tag": "tor-3", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.4", "tag": "tor-4", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.5", "tag": "tor-5", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.6", "tag": "tor-6", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.7", "tag": "tor-7", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.8", "tag": "tor-8", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.9", "tag": "tor-9", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.10", "tag": "tor-10", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.11", "tag": "tor-11", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.12", "tag": "tor-12", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.13", "tag": "tor-13", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.14", "tag": "tor-14", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.15", "tag": "tor-15", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.16", "tag": "tor-16", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.17", "tag": "tor-17", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.18", "tag": "tor-18", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.19", "tag": "tor-19", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.20", "tag": "tor-20", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.21", "tag": "tor-21", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.22", "tag": "tor-22", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.23", "tag": "tor-23", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.24", "tag": "tor-24", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.25", "tag": "tor-25", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.26", "tag": "tor-26", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.27", "tag": "tor-27", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.28", "tag": "tor-28", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.29", "tag": "tor-29", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.30", "tag": "tor-30", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.31", "tag": "tor-31", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.32", "tag": "tor-32", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.33", "tag": "tor-33", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.34", "tag": "tor-34", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.35", "tag": "tor-35", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} },{ "protocol": "socks", "sendThrough": "127.0.0.36", "tag": "tor-36", "settings": {"servers": [{"address": "127.0.0.1", "port": 9050}]} }], "routing": { "rules": [{ "type": "field", "network": "tcp", "balancerTag": "balancer" }], "balancers": [{ "tag": "balancer", "selector": ["tor-"], "strategy": { "type": "random" } }] } } ```
jauninp commented 1 year ago

I understand that you did this without using this project but with your own environment?

Yes, just a regular Tor and regular aria2.

The command like for aria used was:

aria2c -s 16 -x 16 -j 3 --stream-piece-selector=random --http-proxy='127.0.0.1:9052' --save-session=session.state \
 --http-accept-gzip=true -i session.state --save-session-interval=60 --max-tries=0 --retry-wait=5 -l log.txt --log-level=info

V2ray configuration:

Many thanks for that !!!!

sn0b4ll commented 1 year ago

With the recent additions by @reece394 this should be fixed.

reece394 commented 1 year ago

Might be good to keep this one open due to 1. not being implemented yet as filtering tor nodes offers a significant performance uplift. If I have time at a later date I will try and implement an automated solution to do this if someone else doesn't tackle it first