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

python-proxy如何获取用户来源IP? How to get user source ip?

Open xpfoxs opened this issue 1 year ago • 1 comments

我想实现根据用户来源IP不同,转发到不同的sock5服务器

I want to realize the different SOCK5 server depending on the user source IP

xpfoxs avatar Apr 15 '24 19:04 xpfoxs

You have to modify this line: https://github.com/qwj/python-proxy/blob/09d4752f17ed6787e1a073c93980eec019887ee3/pproxy/server.py#L82 to:

roption = choose(remote_ip)

And add this function:

def choose(remote_ip):
    if(remote_ip.startswith('192.168.')):
        return proxies_by_uri('socks5://192.168.0.1:8080')
    else:
        return proxies_by_uri('socks5://192.168.0.2:8080')

Jonney avatar Apr 25 '24 10:04 Jonney