Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support [feature] #29

Open
zefr0x opened this issue Sep 7, 2021 · 2 comments
Open

Proxy support [feature] #29

zefr0x opened this issue Sep 7, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request stale

Comments

@zefr0x
Copy link

zefr0x commented Sep 7, 2021

I don't like frequent requests from my computer to a web services, so I like to transfer the requests through Tor for this kind of tools, I usually use SOCKS5 tor proxy witch gives you socks5://127.0.0.1:9050 by default when you start tor serves.

Describe the solution you'd like

I would like to see a proxy section in the extention config page in ulauncher, or if it's hard to make it more customized you can just put an on/off button to use tor.

How to implement it?

I found thet you are using urllib to get data so you can use this solution for tor's SOCKS5 before importing urlopen:

import socket
import socks

def create_connection(addr, timeout=None, src=None):
    sock = socks.socksocket()
    sock.connect(addr)
    return sock

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9050, True)

socket.socket = socks.socksocket
socket.create_connection = create_connection

# then importing urlopen
from urllib.request import urlopen

Source: https://hackeradam.com/post/how-to-route-urllib2-through-tor/

🔴🔴 Be aware about the True in:

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9050, True)

If you don't use it the DNS will be leaked.

Source: https://security.stackexchange.com/questions/40414/tor-via-python-can-the-real-ip-address-leak

@zefr0x zefr0x added the enhancement New feature or request label Sep 7, 2021
@zefr0x zefr0x changed the title [feature] Proxy support [feature] Sep 7, 2021
@tchar
Copy link
Owner

tchar commented Sep 8, 2021

@ZER0-X Hello, thanks for the suggestion.

I have implemented something similar in another project of mine using requests (I even think it is possible to use the 9051 port which is the control port or whatever that's called and refresh the ip). Practically, it should not be difficult, however, these days I don't have enough time to implement and test this, due to other responsibilities.

Until I have free time (which may take months) I would be happy to accept a pull request with proper tests, or even suggest alternatives:

  • The minimum refresh time is once per day, you can reduce that to be every week or month for example.
  • Maybe there is an iptables workaround (Pretty sure there is) to redirect all outbound traffic through the tor service, something along the lines of AnonSurf.
  • Use something like proxychains and define one proxy (the tor socks5 proxy)

Maybe that doesn't sound too good, but since I am the only maintainer of the project and don't have much time to implement this at the moment, it could take some time to implement something like that. I obviously will accept a proper PR for this.

Thanks very much for taking the time to provide sample code on how to do this. It will be helpful if I start implementing this in the future.

Cheers,
tchar

@github-actions
Copy link

github-actions bot commented Nov 8, 2021

Issue has been marked as stale due to no activity

@github-actions github-actions bot added the stale label Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

2 participants