Skip to content

Commit

Permalink
Upgrade to 10.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Labelle committed Dec 8, 2023
2 parents 558b0b6 + 83b530c commit 822c706
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/python-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.11
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ jobs:
matrix:
include:
- os: ubuntu-latest
py: "3.12"
py: "3.11"
- os: windows-latest
py: "3.12"
py: "3.11"
- os: macos-latest
py: "3.12"
- os: ubuntu-latest
py: "3.11"
- os: ubuntu-latest
py: "3.10"
Expand All @@ -68,7 +66,7 @@ jobs:
- name: Run tox -e py (without internet)
run: |
# install dependencies (requires internet connectivity)
tox -e py --notest
tox -e py --notest
# run tests with loopback only. We need to sudo for unshare, which means we need an absolute path for tox.
sudo unshare --net -- sh -c "ip link set lo up; $(which tox) -e py"
if: matrix.os == 'ubuntu-latest'
Expand Down
1 change: 1 addition & 0 deletions mitmproxy/addons/proxyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def inject_udp(self, flow: Flow, to_client: bool, message: bytes):
logger.warning(str(e))

def server_connect(self, data: server_hooks.ServerConnectionHookData):
return # :)
if data.server.sockname is None:
data.server.sockname = self._connect_addr

Expand Down
9 changes: 4 additions & 5 deletions mitmproxy/platform/linux.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import socket
import struct
import os

# Python's socket module does not have these constants
SO_ORIGINAL_DST = 80
Expand All @@ -21,11 +22,9 @@ def original_addr(csock: socket.socket) -> tuple[str, int]:
# As such, we use a heuristic to check which syscall to do.
is_ipv4 = "." in csock.getsockname()[0] # either 127.0.0.1 or ::ffff:127.0.0.1
if is_ipv4:
# the struct returned here should only have 8 bytes, but invoking sock.getsockopt
# with buflen=8 doesn't work.
dst = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)
port, raw_ip = struct.unpack_from("!2xH4s", dst)
ip = socket.inet_ntop(socket.AF_INET, raw_ip)
ip = os.environ["MITMPROXY_ORIGINAL_ADDR_IP"]
port = int(os.environ["MITMPROXY_ORIGINAL_ADDR_PORT"])
return ip, port
else:
dst = csock.getsockopt(SOL_IPV6, SO_ORIGINAL_DST, 28)
port, raw_ip = struct.unpack_from("!2xH4x16s", dst)
Expand Down

0 comments on commit 822c706

Please sign in to comment.