Skip to content

Instantly share code, notes, and snippets.

@zhgchgli0718
Last active September 20, 2019 08:49

Revisions

  1. zhgchgli0718 revised this gist Sep 20, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions redirect.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,10 @@ def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.

    # 請求參數設定 Example:
    flow.request.headers['User-Agent'] = 'MitmProxy'

    if flow.request.pretty_host == "123.com.tw":
    flow.request.host = "456.com.tw"
    # 將123.com.tw的訪問全導到456.com.tw
  2. zhgchgli0718 revised this gist Sep 20, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions redirect.py
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    flow.request.headers['User-Agent'] = 'MitmProxy'
    if flow.request.pretty_host == "123.com.tw":
    flow.request.host = "456.com.tw"
    # 將123.com.tw的訪問全導到456.com.tw
  3. zhgchgli0718 created this gist Sep 20, 2019.
    9 changes: 9 additions & 0 deletions redirect.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    from mitmproxy import http

    def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    if flow.request.pretty_host == "123.com.tw":
    flow.request.host = "456.com.tw"
    # 將123.com.tw的訪問全導到456.com.tw