python-proxy icon indicating copy to clipboard operation
python-proxy copied to clipboard

how to do it in python

Open MdTalhaZubayer opened this issue 4 years ago • 3 comments

this is working on the cmd or terminal 'pproxy -r socks5://proxy:port#username:password. what will be the equivalent python code? please help.

MdTalhaZubayer avatar Oct 20 '21 09:10 MdTalhaZubayer

import pproxy args = '-r socks5://proxy:port#username:password' pproxy.server.main(args.split(' '))

Jonney avatar Nov 08 '21 10:11 Jonney

import pproxy args = '-r socks5://proxy:port#username:password' pproxy.server.main(args.split(' '))

No matter what the arguments are, the server always starts the same way. And I can't connect to it. Can you help us?

args = '-r http://0.0.0.0:8000'

Output : Serving on :8080 by http,socks4,socks5

lucydjo avatar Feb 07 '22 22:02 lucydjo

Anyone struggling to get this working as a background process, I combined this with command_runner. https://pypi.org/project/command-runner/

Might be a pretty janky solution but it works for me:

from command_runner import command_runner_threaded

def main():
    global stop_running_proxy
    run_proxy(proxy_url, proxy_port, proxy_username, proxy_password, proxy_server_port)
    time.sleep(5)
    stop_proxy_answer = True

def run_proxy(proxy_host, proxy_port, proxy_user, proxy_pass, server_port):
    command_runner_threaded(
        f"pproxy -r http://{proxy_host}:{proxy_port}#{proxy_user}:{proxy_pass} -l http://:{server_port}", shell=True,
        stop_on=stop_proxy, check_interval=1)


def stop_proxy():
    while True:
        global stop_running_proxy
        is_true = stop_running_proxy
        time.sleep(1)
        if is_true:
            return True

strangeh21 avatar Jul 13 '22 13:07 strangeh21