nstrydom2 / anonfile-api

An unofficial Python Anonfiles.com API
MIT License
62 stars 24 forks source link

add TOR support #72

Closed nstrydom2 closed 1 year ago

aminelaabi commented 1 year ago

Can you please develop what you mean by TOR support

nstrydom2 commented 1 year ago

We can include this feature in the next patch

aminelaabi commented 1 year ago

Just list the list of features i can work on it

DtxdF commented 1 year ago

I think it is not difficult to add Tor support, but I think it should be called "proxy socks support".

# service tor onestatus
tor is running as pid 54026.
# sockstat -4l | grep 54026
_tor     tor        54026 5  tcp4   127.0.0.1:9050        *:*

There is a problem that should be fixed:

$ python3.9
Python 3.9.16 (main, Apr  6 2023, 01:15:39) 
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> proxies = "http://1.2.3.4:1234 https://4.3.2.1:4321"
>>> {prot: f"{prot}://{ip}" for (prot, ip) in [proxy.split('://') for proxy in proxies.split()]}
{'http': 'http://1.2.3.4:1234', 'https': 'https://4.3.2.1:4321'}
>>> 

The problem is the format_proxies() function which assumes that the scheme must be obtained from the proxy address when it should not as I could very well use { 'https' : 'socks5://127.0.0.1:9050' }. I think the --proxies argument should be renamed to --proxy and only the https scheme should be used as anonfiles works using only this scheme.

As a last note, requests[socks] must be added as a requirement to add socks support.

StefanGreve commented 1 year ago

@DtxdF There's an ongoing discussion about the inclusion of a config feature in https://github.com/nstrydom2/anonfile-api/discussions/91. Because passing proxy settings via command arguments can be tedious to type all out, the current idea is to configure that in a anonfile.ini file for persistent usage. Feel free to make suggestions related to this feature in the linked discussions thread.

nstrydom2 commented 1 year ago

Can you please develop what you mean by TOR support

This was an old issue that I believe was conceived before we had proxy support. The proxy feature can be used to proxy all requests through the TOR network.

We can include this feature in the next patch

This was a false statement. We already have proxy support.

I think it is not difficult to add Tor support, but I think it should be called "proxy socks support".

# service tor onestatus
tor is running as pid 54026.
# sockstat -4l | grep 54026
_tor     tor        54026 5  tcp4   127.0.0.1:9050        *:*

There is a problem that should be fixed:

$ python3.9
Python 3.9.16 (main, Apr  6 2023, 01:15:39) 
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> proxies = "http://1.2.3.4:1234 https://4.3.2.1:4321"
>>> {prot: f"{prot}://{ip}" for (prot, ip) in [proxy.split('://') for proxy in proxies.split()]}
{'http': 'http://1.2.3.4:1234', 'https': 'https://4.3.2.1:4321'}
>>> 

The problem is the format_proxies() function which assumes that the scheme must be obtained from the proxy address when it should not as I could very well use { 'https' : 'socks5://127.0.0.1:9050' }. I think the --proxies argument should be renamed to --proxy and only the https scheme should be used as anonfiles works using only this scheme.

As a last note, requests[socks] must be added as a requirement to add socks support.

You are absolutely right. Directing your anonfile requests through the TOR network is just redirecting traffic to the 'socks5' protocol on port 9050. So, I agree it's more accurate to call it "proxy socks support", which is already a feature. Granted we are missing that dependency you had mentioned. Thank you for letting me know.