srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mitmuxd
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-08-29 22:03:00 +0200
committersrdusr <[email protected]>2024-08-29 22:03:00 +0200
commit70f675e59ac4bb0e469ca0073f8cc0506b17677e (patch)
treee3a525b26dfcf16ce4f9bde97b1408a373d87944 /cmd/mitmuxd
parent8d15c2e0b326933f8fc912e3b13f37e78a9bc0b6 (diff)
downloadmitmux-70f675e59ac4bb0e469ca0073f8cc0506b17677e.tar.gz
mitmux-70f675e59ac4bb0e469ca0073f8cc0506b17677e.zip
Repeater: raw-byte send/resend
Implements build-order step 4, the feature the plan calls out as used daily. internal/proxy/repeat.go adds Server.Repeat(scheme, host, raw): dials fresh (HTTP/1.1-only - raw edited text has no equivalent in HTTP/2's binary framing), writes raw exactly as given with no framing correction or header injection, and captures the exact response bytes. This is deliberately separate from forward()'s parsed-*http.Request path since Repeater's entire point is letting a malformed/edited request reach the wire unmodified. Repeater sends are recorded to the same history table as proxy traffic (added a "source" column: "proxy" vs "repeater") so they show up in the unified history view and the live subscribe stream, not a separate silo. internal/ipc gains a "repeat" request/response pair; cmd/mitmuxd wires proxy.Server into ipc.NewServer via a small Repeater interface so the daemon keeps owning all network I/O and the TUI stays a thin client. cmd/mitmux gains a repeater view (bubbles/textarea for the editable raw request, a read-only viewport for the response), reachable with 'r' from either the list or detail view, ctrl+r to send. One real bug found via testing: bubbles/textarea only understands LF, but HTTP/1.1 requires CRLF, so loading raw bytes straight into it split each line in two on render. Fixed by normalizing CRLF<->LF at the editor boundary only (load: strip \r; send: restore it) - documented as a narrow, known trade-off for bodies with their own embedded LF line breaks, which is the cost of being able to edit raw HTTP as text at all. Verified live: edited and sent a plain-HTTP repeater request (confirmed in SQLite that the edit - including an intentional extra blank line from imprecise cursor navigation during testing - went out completely unmodified, which is the correct behavior: mitmux must never "fix" what the user typed), and sent an HTTPS repeater request against a freshly captured entry, both getting real 200 responses with exact response bytes back.
Diffstat (limited to 'cmd/mitmuxd')
-rw-r--r--cmd/mitmuxd/main.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/mitmuxd/main.go b/cmd/mitmuxd/main.go
index 0d7f214..812e146 100644
--- a/cmd/mitmuxd/main.go
+++ b/cmd/mitmuxd/main.go
@@ -70,17 +70,17 @@ func main() {
defer os.Remove(sockFile)
log.Printf("control socket: %s", sockFile)
+ srv := proxy.New(*listen, root, db)
+
hub := ipc.NewHub()
- ipcSrv := ipc.NewServer(db, hub)
+ srv.OnEntry = ipc.LogAndBroadcast(hub)
+ ipcSrv := ipc.NewServer(db, hub, srv)
go func() {
if err := ipcSrv.Serve(sockLn); err != nil {
log.Printf("control socket: %v", err)
}
}()
- srv := proxy.New(*listen, root, db)
- srv.OnEntry = ipc.LogAndBroadcast(hub)
-
errCh := make(chan error, 1)
go func() {
errCh <- srv.ListenAndServe()