mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
proxy/protocol/base: Allow spoofing fixed source
Allow combining --spoof-source-address and --upstream-bind-address to spoof a fixed source address. Also update the help text for --spoof-source-address to indicate this new possibility.
This commit is contained in:
parent
d6cfd93357
commit
0ff1967226
@ -109,12 +109,14 @@ class ServerConnectionMixin:
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.server_conn = None
|
self.server_conn = None
|
||||||
if self.config.options.spoof_source_address:
|
if self.config.options.spoof_source_address and self.config.options.upstream_bind_address == '':
|
||||||
self.server_conn = connections.ServerConnection(
|
self.server_conn = connections.ServerConnection(
|
||||||
server_address, (self.ctx.client_conn.address.host, 0), True)
|
server_address, (self.ctx.client_conn.address.host, 0), True)
|
||||||
else:
|
else:
|
||||||
self.server_conn = connections.ServerConnection(
|
self.server_conn = connections.ServerConnection(
|
||||||
server_address, (self.config.options.upstream_bind_address, 0))
|
server_address, (self.config.options.upstream_bind_address, 0),
|
||||||
|
self.config.options.spoof_source_address
|
||||||
|
)
|
||||||
|
|
||||||
self.__check_self_connect()
|
self.__check_self_connect()
|
||||||
|
|
||||||
|
@ -485,7 +485,8 @@ def proxy_options(parser):
|
|||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--spoof-source-address",
|
"--spoof-source-address",
|
||||||
action="store_true", dest="spoof_source_address",
|
action="store_true", dest="spoof_source_address",
|
||||||
help="Use the client's IP for server-side connections"
|
help="Use the client's IP for server-side connections. "
|
||||||
|
"Combine with --upstream-bind-address to spoof a fixed source address."
|
||||||
)
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--upstream-bind-address",
|
"--upstream-bind-address",
|
||||||
|
Loading…
Reference in New Issue
Block a user