Skip to content

Commit cd23782

Browse files
point to correct location for mitmproxy addon
1 parent 2f9e529 commit cd23782

15 files changed

+11
-10
lines changed

bin/interception-proxy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
22
// This is the script which will be run when you run this package via `npx`.
3-
require("../dist/server.js");
3+
require("../dist/js/server.js");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"scripts": {
1010
"prepare": "npm run build",
11-
"build": "tsc",
11+
"build": "tsc && cp -r src/python dist",
1212
"start": "npm run build && bin/interception-proxy",
1313
"format:check": "prettier . --check",
1414
"format:fix": "prettier . --write",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/MitmproxyLauncher.ts renamed to src/js/MitmproxyLauncher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { spawn } from "child_process";
22
import { InterceptionModeDTO } from "./ControlRPC";
3+
import path from "path";
34

45
export class MitmproxyLauncher {
56
private _onMitmproxyReady: (() => void) | null = null;
@@ -47,7 +48,7 @@ export class MitmproxyLauncher {
4748
"stream_large_bodies=1",
4849
...(mitmdumpMode === null ? [] : ["--mode", mitmdumpMode]),
4950
"-s",
50-
"test/mitmproxy_addon_2.py",
51+
path.join(__dirname, "..", "python", "mitmproxy_addon.py"),
5152
"--set",
5253
// "full request URL with response status code and HTTP headers" (the default truncates the URL)
5354
"flow_detail=2",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mitmproxy_addon_2.py renamed to src/python/mitmproxy_addon.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async def send_ready_notification() -> None:
1212
data = json.dumps(notification_dto)
1313
await websocket.send(data)
1414

15-
class MitmproxyAddon2:
15+
class MitmproxyAddon:
1616
def running(self) -> None:
1717
# tell the control API that we’re ready to receive traffic
1818
asyncio.get_running_loop().create_task(send_ready_notification())
@@ -25,14 +25,14 @@ def request(self, flow: http.HTTPFlow) -> None:
2525
return
2626

2727
# (b'Connection', b'Upgrade'), (b'Upgrade', b'websocket')
28-
intercept = MitmproxyAddon2.is_websocket_upgrade_request(flow.request)
29-
logging.info(f'MitmproxyAddon2 {"intercepting" if intercept else "not intercepting"} `request` {flow.request.url}, headers {flow.request.headers}')
28+
intercept = MitmproxyAddon.is_websocket_upgrade_request(flow.request)
29+
logging.info(f'MitmproxyAddon {"intercepting" if intercept else "not intercepting"} `request` {flow.request.url}, headers {flow.request.headers}')
3030
# pretty_host takes the "Host" header of the request into account,
3131
# which is useful in transparent mode where we usually only have the IP
3232
# otherwise.
3333
# if flow.request.pretty_host == "example.org":
3434
# I tried doing it in websocket_start instead but that didn’t work
35-
if MitmproxyAddon2.is_websocket_upgrade_request(flow.request):
35+
if MitmproxyAddon.is_websocket_upgrade_request(flow.request):
3636
original_host = flow.request.pretty_host
3737
original_scheme = flow.request.scheme
3838

@@ -52,4 +52,4 @@ def is_websocket_upgrade_request(request: http.Request) -> bool:
5252
# TODO this request handling is a bit fragile, the special case for `split` is just to handle the fact that Firefox sends 'Connection: keep-alive, Upgrade'
5353
return True if 'Connection' in request.headers and ('Upgrade' in request.headers['Connection'].split(", ")) and 'Upgrade' in request.headers and request.headers['Upgrade'] == 'websocket' else False
5454

55-
addons = [MitmproxyAddon2()]
55+
addons = [MitmproxyAddon()]

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "@tsconfig/node-lts/tsconfig.json",
3-
"include": ["src"],
3+
"include": ["src/js"],
44
"compilerOptions": {
5-
"outDir": "dist"
5+
"outDir": "dist/js"
66
}
77
}

0 commit comments

Comments
 (0)