From ccb48f3cc3267969e501b3c000f9e2786c8d43c3 Mon Sep 17 00:00:00 2001 From: "zokutyou2@gmail.com" Date: Thu, 10 Jun 2021 22:13:49 +0900 Subject: [PATCH] apply suggested changes --- mitmproxy/flowfilter.py | 12 ------------ web/src/js/components/FlowTable/HoverMenu.jsx | 10 ++-------- web/src/js/components/Header/FilterInput.jsx | 2 +- web/src/js/components/ProxyApp.jsx | 4 ++-- web/src/js/filt/filt.peg | 11 ----------- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 81c25afec..fea8e9e42 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -381,17 +381,6 @@ class FDst(_Rex): return f.server_conn.address and self.re.search(r) -class FDstIP(_Rex): - code = "ip" - help = "Match destination ip address" - is_binary = False - - def __call__(self, f): - if not f.server_conn or not f.server_conn.ip_address: - return False - return f.server_conn.ip_address and self.re.search(f.server_conn.ip_address[0]) - - class FReplay(_Action): code = "replay" help = "Match replayed flows" @@ -525,7 +514,6 @@ filter_rex: Sequence[Type[_Rex]] = [ FContentTypeResponse, FDomain, FDst, - FDstIP, FHead, FHeadRequest, FHeadResponse, diff --git a/web/src/js/components/FlowTable/HoverMenu.jsx b/web/src/js/components/FlowTable/HoverMenu.jsx index 824ca6508..8016c9471 100644 --- a/web/src/js/components/FlowTable/HoverMenu.jsx +++ b/web/src/js/components/FlowTable/HoverMenu.jsx @@ -35,24 +35,18 @@ class HoverMenu extends Component {  Intercept {flow.request.host} - { + { flow.request.path != "/" ? { this.onClick(e, flow.request.host + flow.request.path) }}>  Intercept {flow.request.host + flow.request.path} - + : null } { this.onClick(e, `~m POST & ${flow.request.host}`) }}>  Intercept all POST requests from this host - { - this.onClick(e, `~ip ${flow.server_conn.ip_address[0]}`) - }}> - -  Intercept all requests from {flow.server_conn.ip_address[0]} - ) } diff --git a/web/src/js/components/Header/FilterInput.jsx b/web/src/js/components/Header/FilterInput.jsx index 151036109..8ae964b2c 100644 --- a/web/src/js/components/Header/FilterInput.jsx +++ b/web/src/js/components/Header/FilterInput.jsx @@ -25,7 +25,7 @@ export default class FilterInput extends Component { this.selectFilter = this.selectFilter.bind(this) } - componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps) { this.setState({ value: nextProps.value }) } diff --git a/web/src/js/components/ProxyApp.jsx b/web/src/js/components/ProxyApp.jsx index 15384e020..8dc4c7e02 100644 --- a/web/src/js/components/ProxyApp.jsx +++ b/web/src/js/components/ProxyApp.jsx @@ -11,11 +11,11 @@ import Modal from './Modal/Modal' class ProxyAppMain extends Component { - componentWillMount() { + componentDidMount() { window.addEventListener('keydown', this.props.onKeyDown); } - componentWillUnmount() { + UNSAFE_componentWillUnmount() { window.removeEventListener('keydown', this.props.onKeyDown); } diff --git a/web/src/js/filt/filt.peg b/web/src/js/filt/filt.peg index 387a9bb87..80f430185 100644 --- a/web/src/js/filt/filt.peg +++ b/web/src/js/filt/filt.peg @@ -111,16 +111,6 @@ function destination(regex){ destinationFilter.desc = "destination address matches " + regex; return destinationFilter; } -function ip(regex) { - regex = new RegExp(regex, "i"); - function ipFilter(flow){ - return (!!flow.server_conn.ip_address) - && - regex.test(flow.server_conn.ip_address[0] + ":" + flow.server_conn.ip_address[1]); - } - ipFilter.desc = "destination ip address matches " + regex; - return ipFilter; -} function errorFilter(flow){ return !!flow.error; } @@ -277,7 +267,6 @@ Expr / "~c" ws+ s:IntegerLiteral { return responseCode(s); } / "~d" ws+ s:StringLiteral { return domain(s); } / "~dst" ws+ s:StringLiteral { return destination(s); } - / "~ip" ws+ s:StringLiteral { return ip(s); } / "~e" { return errorFilter; } / "~h" ws+ s:StringLiteral { return header(s); } / "~hq" ws+ s:StringLiteral { return requestHeader(s); }