From 4890ead7f08c85751e7d1026be343dc067569819 Mon Sep 17 00:00:00 2001 From: lqqyt2423 <974923609@qq.com> Date: Tue, 9 Feb 2021 17:55:49 +0800 Subject: [PATCH] web addon web interface --- addon/web/client/package.json | 1 + addon/web/client/src/App.css | 44 +++++++++++++++- addon/web/client/src/App.js | 99 +++++++++++++++++++++++++++++++++-- addon/web/client/yarn.lock | 5 ++ cmd/mitmproxy/main.go | 1 + 5 files changed, 144 insertions(+), 6 deletions(-) diff --git a/addon/web/client/package.json b/addon/web/client/package.json index 6f39ebf..5700cef 100644 --- a/addon/web/client/package.json +++ b/addon/web/client/package.json @@ -7,6 +7,7 @@ "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "bootstrap": "^4.6.0", + "js-base64": "^3.6.0", "react": "^17.0.1", "react-bootstrap": "^1.4.3", "react-dom": "^17.0.1", diff --git a/addon/web/client/src/App.css b/addon/web/client/src/App.css index e0e7307..13df450 100644 --- a/addon/web/client/src/App.css +++ b/addon/web/client/src/App.css @@ -1,4 +1,46 @@ .main-table-wrap { font-family: Menlo,Monaco; - font-size: 0.9rem; + font-size: 0.8rem; +} + +.flow-detail { + position: fixed; + top: 0; + right: 0; + + height: 100vh; + background-color: #fff; + min-width: 500px; + width: 50%; + overflow-y: auto; + + word-break: break-all; +} + +.flow-detail .header-tabs span { + display: inline-block; + line-height: 1; + padding: 8px; + cursor: pointer; +} + +.flow-detail .header-tabs .selected { + border-bottom: 2px rgb(35, 118, 229) solid; +} + +/* .flow-detail .header-block { + margin: 20px; +} */ + +.flow-detail .header-block > p { + font-weight: bold; +} + +.flow-detail .header-block .header-block-content p { + margin: 5px 0; +} + +.flow-detail .header-block .header-block-content { + margin-left: 20px; + line-height: 1.5; } \ No newline at end of file diff --git a/addon/web/client/src/App.js b/addon/web/client/src/App.js index 40f6989..6e3bf66 100644 --- a/addon/web/client/src/App.js +++ b/addon/web/client/src/App.js @@ -1,7 +1,16 @@ import React from 'react' import Table from 'react-bootstrap/Table' +import { Base64 } from 'js-base64' import './App.css' +const isTextResponse = response => { + if (!response) return false + if (!response.header) return false + if (!response.header['Content-Type']) return false + + return /text|javascript|json/.test(response.header['Content-Type'].join('')) +} + class App extends React.Component { constructor(props) { @@ -9,6 +18,9 @@ class App extends React.Component { this.state = { flows: [], + flow: null, + + flowTab: 'Headers', // Headers, Preview, Response } this.ws = null } @@ -53,6 +65,79 @@ class App extends React.Component { // this.ws.send('msg') // this.ws.close() } + + renderFlow() { + const { flow, flowTab } = this.state + if (!flow) return null + + const request = flow.request + const response = flow.response || {} + + return ( +
General
+Request URL: {request.url}
+Request Method: {request.method}
+Status Code: {`${response.statusCode || '(pending)'}`}
+Response Headers
+{key}: {response.header[key].join(' ')}
+ ) + }) + } +Request Headers
+{key}: {request.header[key].join(' ')}
+ ) + }) + } +Status | -Method | Host | Path | +Method | +Status |
---|---|---|---|---|---|
{response.statusCode || '(pending)'} | -{request.method} | +||||
{u.host} | {path} | +{request.method} | +{response.statusCode || '(pending)'} |