Description
hi,
I wish bind address option.
thank you.
ex) pc ips (1.1.1.2, 1.1.1.3, 1.1.1.4)
`# ip a
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether ****
inet 1.1.1.2/24 brd 1.1.1.255 scope global enp2s0
inet 1.1.1.3/24 brd 1.1.1.255 scope global enp2s0
inet 1.1.1.4/24 brd 1.1.1.255 scope global enp2s0`
I wish choice 1.1.1.3
`import http.client
conn = http.client.HTTPConnection('xenosi.de', source_address=tuple(['1.1.1.3', 0]));
h = {}
h['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
conn.request('GET', '/ip.php?json', headers=h);
res = conn.getresponse();
print(res.status, res.reason, res.read())`
result)
proxy --hostname=0.0.0.0 --bindip=1.1.1.3
Activity
crucifyer commentedon Apr 8, 2021
proxy --hostname=1.1.1.3 is not solution. proxy using 1.1.1.2
abhinavsingh commentedon Apr 8, 2021
Hi @crucifyer , IMO using desired interface IP with --hostname flag must do the trick.
Can you post the logs printed, when you start proxy with custom --hostname flag? Thank you!!!
crucifyer commentedon Apr 8, 2021
abhinavsingh commentedon Apr 8, 2021
crucifyer commentedon Apr 8, 2021
Of course.
The foxy proxy is set to 1.1.1.3:8899.
I have a lot of ips on my server.
I want to pick one of them and use it.
Add an option that accepts source_address= like the code above.
The exact purpose is
PCs in the office intranet do not have Internet by themselves,
This is to make the Internet work only by proxy settings in the browser.
thank you.
crucifyer commentedon Apr 8, 2021
Maybe this is the part.
Wouldn't it be possible to apply it with setsockopt?
https://docs.python.org/3/library/socket.html
Please understand that this may be wrong as this is not well known.
thank you.
abhinavsingh commentedon Apr 10, 2021
@crucifyer This possibly can work (haven't tried it myself before) but will definitely require sudo privileges.
Can you work on a small POC, where:
If it does, we can wrap this POC as a feature within
proxy.py
, wdyt?crucifyer commentedon Apr 11, 2021
I tested it like this. The bind() alone works very well.
thank you.
abhinavsingh commentedon Apr 12, 2021
Thank you @crucifyer , but I am left a little confused over what is our objective here. If I understand correctly, you did a bind on
1.1.1.3
and upstream server saw the request coming from1.1.1.3
.I think same should be achievable using
proxy --hostname 1.1.1.3
. Is you upstream server seeing1.1.1.2
when making a request fromproxy.py
? If yes, may be we must put thebind
login you demonstrated. Please let me know.crucifyer commentedon Apr 12, 2021
yes.
I think, need bind on self.client
crucifyer commentedon Apr 15, 2021
I want to put a bind statement, but I can't find where to make the client socket. 😿
abhinavsingh commentedon Apr 15, 2021
@crucifyer You may hardcode
bind
here in the constructor ofTcpClientConnection
class https://github.com/abhinavsingh/proxy.py/blob/develop/proxy/core/connection/client.py#L25. If it works out, we can later add this in a more generic sense.abhinavsingh commentedon Oct 29, 2021
@crucifyer Are you still here with me on this :). I am looking into it but would like to clarify what exactly are we after. Your example is a little misaligned, because
bind
is supposed to be used by servers andconnect
by clients. But IIUC, you are trying to callbind
andconnect
on the same socket object. This is not a valid usage.May you be can convey your requirement via this diagram and let me know where exactly are you expecting bind.
More useful will be to explain the scenario you are trying to achieve, Thank you!!!
21 remaining items