Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add transparent server mode based on WireGuard #5562

Merged
merged 26 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
151dbd6
add mode spec for WireGuard mode
decathorpe Sep 4, 2022
8238f9c
add WireGuard server implementation
decathorpe Sep 6, 2022
573b058
remove coverage excludes
mhils Sep 11, 2022
0fe25ff
simplify wireguard spec
mhils Sep 11, 2022
964a692
Merge remote-tracking branch 'origin/main' into pr-5562
mhils Sep 11, 2022
884af87
lint!
mhils Sep 11, 2022
b267d2d
remove superfluous tests
mhils Sep 11, 2022
3bc9a1b
bump to mitmproxy_wireguard 0.1.1
decathorpe Sep 12, 2022
53d14a1
proxy/test_mode_specs: remove unused import
decathorpe Sep 12, 2022
767fa18
fix wireguard server mode
decathorpe Sep 12, 2022
1160e48
WireGuard: move keyfile gen into `.start()`
mhils Sep 13, 2022
a5f75a0
fixup UDP support
mhils Sep 13, 2022
336ce6e
bump to mitmproxy_wireguard v0.1.2
decathorpe Sep 13, 2022
4000ec2
fix crash handler
mhils Sep 14, 2022
6c22471
add simple test for WireGuard server instances
decathorpe Sep 16, 2022
a857f1a
bump to mitmproxy_wireguard v0.1.5 and fix launching wg-test-client
decathorpe Sep 18, 2022
6838abe
Merge remote-tracking branch 'origin/main' into pr-5562
mhils Sep 18, 2022
77c65f4
fixups
mhils Sep 18, 2022
aa90aa6
nits
mhils Sep 18, 2022
77124b9
bump to mitmproxy_wireguard 0.1.6 for fixed test client
decathorpe Sep 18, 2022
6005811
move WireGuardDatagramTransport into dedicated module
mhils Sep 18, 2022
122f0c2
cover WireGuardServerInstance.is_running property with tests
decathorpe Sep 18, 2022
8c8cf46
enable specialized server instance creation
mhils Sep 18, 2022
7fd35e7
test wireguard conf generation
mhils Sep 18, 2022
12cbfea
deduplicate tcp/udp handlers
mhils Sep 18, 2022
0da0031
update CHANGELOG
mhils Sep 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bump to mitmproxy_wireguard v0.1.5 and fix launching wg-test-client
  • Loading branch information
decathorpe committed Sep 18, 2022
commit a857f1ad3c173ba405a39aeb76522069dec898ce
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"hyperframe>=6.0,<7",
"kaitaistruct>=0.10,<0.11",
"ldap3>=2.8,<2.10",
"mitmproxy_wireguard>=0.1.2,<0.2",
"mitmproxy_wireguard>=0.1.5,<0.2",
"msgpack>=1.0.0, <1.1.0",
"passlib>=1.6.5, <1.8",
"protobuf>=3.14,<5",
Expand Down
26 changes: 20 additions & 6 deletions test/mitmproxy/proxy/test_mode_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ async def test_wireguard(monkeypatch):

async def echo_tcp(stream: wg.TcpStream):
data = await stream.read(1000)
stream.write(data)
stream.write(data.upper())
await stream.drain()
stream.close()

def echo_udp(self: WireGuardServerInstance, data: bytes, src_addr: Address, dst_addr: Address):
self._server.send_datagram(data, dst_addr, src_addr)
self._server.send_datagram(data.upper(), dst_addr, src_addr)

monkeypatch.setattr(WireGuardServerInstance, "handle_tcp_connection", echo_tcp)
monkeypatch.setattr(WireGuardServerInstance, "handle_udp_datagram", echo_udp)
Expand All @@ -145,12 +145,26 @@ def echo_udp(self: WireGuardServerInstance, data: bytes, src_addr: Address, dst_
await tctx.master.await_log("WireGuard server listening")

_, port = inst.listen_addrs[0]
ret = subprocess.run([test_client_path, str(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = await asyncio.create_subprocess_exec(
test_client_path,
str(port),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()

try:
ret.check_returncode()
except subprocess.CalledProcessError:
raise
assert proc.returncode == 0
except AssertionError:
print(stdout)
print(stderr)

raise subprocess.CalledProcessError(
proc.returncode,
[test_client_path, str(port)],
output=stdout,
stderr=stderr,
)
finally:
await inst.stop()
assert await tctx.master.await_log("Stopped WireGuard server")
Expand Down
6 changes: 3 additions & 3 deletions test/wg-test-client/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cipher v0.4.3: MIT OR Apache-2.0
cpufeatures v0.2.5: MIT OR Apache-2.0
crypto-common v0.1.6: MIT OR Apache-2.0
curve25519-dalek v3.2.0: BSD-3-Clause
digest v0.10.3: MIT OR Apache-2.0
digest v0.10.5: MIT OR Apache-2.0
digest v0.9.0: MIT OR Apache-2.0
generic-array v0.14.6: MIT
getrandom v0.1.16: MIT OR Apache-2.0
Expand All @@ -65,7 +65,7 @@ parking_lot v0.12.1: MIT OR Apache-2.0
pin-project-lite v0.2.9: Apache-2.0 OR MIT
poly1305 v0.8.0: Apache-2.0 OR MIT
rand_core v0.5.1: MIT OR Apache-2.0
rand_core v0.6.3: MIT OR Apache-2.0
rand_core v0.6.4: MIT OR Apache-2.0
ring v0.16.20:
scopeguard v1.1.0: MIT/Apache-2.0
smallvec v1.9.0: MIT OR Apache-2.0
Expand All @@ -83,7 +83,7 @@ zeroize v1.5.7: Apache-2.0 OR MIT

--------------------------------------------------------------------------------

This list of third-party crates and their licenses was collected for v0.1.4 of
This list of third-party crates and their licenses was collected for v0.1.5 of
the test client by running this command:

$ cargo tree --prefix none --edges no-build,no-dev,no-proc-macro --format "{p}: {l}" --no-dedupe | sort -u
Binary file modified test/wg-test-client/linux-x86_64
Binary file not shown.
Binary file modified test/wg-test-client/macos-aarch64
Binary file not shown.
Binary file modified test/wg-test-client/macos-x86_64
Binary file not shown.
Binary file modified test/wg-test-client/windows-x86_64.exe
Binary file not shown.