We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Client Address is not displayed for flows from dumpfiles
I have two clients connecting to mitmproxy now, and I'd like to see the client IP for each request in the "Detail" tab.

Maybe show the server's IP too, since it can differ when connections come from different local IPs (e.g. 127.0.0.1 and 192.168.1.101).


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `libmproxy/console/flowdetailview.py`
Content:
```
1 from __future__ import absolute_import
2 import urwid
3 from . import common, searchable
4 from .. import utils
5 
6 
7 def maybe_timestamp(base, attr):
8     if base and getattr(base, attr):
9         return utils.format_timestamp_with_milli(getattr(base, attr))
10     else:
11         return "active"
12     pass
13 
14 
15 def flowdetails(state, flow):
16     text = []
17 
18     cc = flow.client_conn
19     sc = flow.server_conn
20     req = flow.request
21     resp = flow.response
22 
23     if sc:
24         text.append(urwid.Text([("head", "Server Connection:")]))
25         parts = [
26             ["Address", "%s:%s" % sc.address()],
27         ]
28 
29         text.extend(
30             common.format_keyvals(parts, key="key", val="text", indent=4)
31         )
32 
33         c = sc.cert
34         if c:
35             text.append(urwid.Text([("head", "Server Certificate:")]))
36             parts = [
37                 ["Type", "%s, %s bits" % c.keyinfo],
38                 ["SHA1 digest", c.digest("sha1")],
39                 ["Valid to", str(c.notafter)],
40                 ["Valid from", str(c.notbefore)],
41                 ["Serial", str(c.serial)],
42                 [
43                     "Subject",
44                     urwid.BoxAdapter(
45                         urwid.ListBox(
46                             common.format_keyvals(
47                                 c.subject,
48                                 key="highlight",
49                                 val="text"
50                             )
51                         ),
52                         len(c.subject)
53                     )
54                 ],
55                 [
56                     "Issuer",
57                     urwid.BoxAdapter(
58                         urwid.ListBox(
59                             common.format_keyvals(
60                                 c.issuer, key="highlight", val="text"
61                             )
62                         ),
63                         len(c.issuer)
64                     )
65                 ]
66             ]
67 
68             if c.altnames:
69                 parts.append(
70                     [
71                         "Alt names",
72                         ", ".join(c.altnames)
73                     ]
74                 )
75             text.extend(
76                 common.format_keyvals(parts, key="key", val="text", indent=4)
77             )
78 
79     if cc:
80         text.append(urwid.Text([("head", "Client Connection:")]))
81 
82         parts = [
83             ["Address", "%s:%s" % cc.address()],
84             # ["Requests", "%s"%cc.requestcount],
85         ]
86 
87         text.extend(
88             common.format_keyvals(parts, key="key", val="text", indent=4)
89         )
90 
91     parts = []
92 
93     parts.append(
94         [
95             "Client conn. established",
96             maybe_timestamp(cc, "timestamp_start")
97         ]
98     )
99     parts.append(
100         [
101             "Server conn. initiated",
102             maybe_timestamp(sc, "timestamp_start")
103         ]
104     )
105     parts.append(
106         [
107             "Server conn. TCP handshake",
108             maybe_timestamp(sc, "timestamp_tcp_setup")
109         ]
110     )
111     if sc.ssl_established:
112         parts.append(
113             [
114                 "Server conn. SSL handshake",
115                 maybe_timestamp(sc, "timestamp_ssl_setup")
116             ]
117         )
118         parts.append(
119             [
120                 "Client conn. SSL handshake",
121                 maybe_timestamp(cc, "timestamp_ssl_setup")
122             ]
123         )
124     parts.append(
125         [
126             "First request byte",
127             maybe_timestamp(req, "timestamp_start")
128         ]
129     )
130     parts.append(
131         [
132             "Request complete",
133             maybe_timestamp(req, "timestamp_end")
134         ]
135     )
136     parts.append(
137         [
138             "First response byte",
139             maybe_timestamp(resp, "timestamp_start")
140         ]
141     )
142     parts.append(
143         [
144             "Response complete",
145             maybe_timestamp(resp, "timestamp_end")
146         ]
147     )
148 
149     # sort operations by timestamp
150     parts = sorted(parts, key=lambda p: p[1])
151 
152     text.append(urwid.Text([("head", "Timing:")]))
153     text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
154     return searchable.Searchable(state, text)
155
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py
--- a/libmproxy/console/flowdetailview.py
+++ b/libmproxy/console/flowdetailview.py
@@ -20,7 +20,7 @@
     req = flow.request
     resp = flow.response
 
-    if sc:
+    if sc is not None:
         text.append(urwid.Text([("head", "Server Connection:")]))
         parts = [
             ["Address", "%s:%s" % sc.address()],
@@ -76,7 +76,7 @@
                 common.format_keyvals(parts, key="key", val="text", indent=4)
             )
 
-    if cc:
+    if cc is not None:
         text.append(urwid.Text([("head", "Client Connection:")]))
 
         parts = [

{"golden_diff": "diff --git a/libmproxy/console/flowdetailview.py b/libmproxy/console/flowdetailview.py\n--- a/libmproxy/console/flowdetailview.py\n+++ b/libmproxy/console/flowdetailview.py\n@@ -20,7 +20,7 @@\n     req = flow.request\n     resp = flow.response\n \n-    if sc:\n+    if sc is not None:\n         text.append(urwid.Text([(\"head\", \"Server Connection:\")]))\n         parts = [\n             [\"Address\", \"%s:%s\" % sc.address()],\n@@ -76,7 +76,7 @@\n                 common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n             )\n \n-    if cc:\n+    if cc is not None:\n         text.append(urwid.Text([(\"head\", \"Client Connection:\")]))\n \n         parts = [\n", "issue": "Client Address is not displayed for flows from dumpfiles\nI have two clients connecting to mitmproxy now, and I'd like to see the client IP for each request in the \"Detail\" tab.\n\nMaybe show the server's IP too, since it can differ when connections come from different local IPs (e.g. 127.0.0.1 and 192.168.1.101).\n\n", "before_files": [{"content": "from __future__ import absolute_import\nimport urwid\nfrom . import common, searchable\nfrom .. import utils\n\n\ndef maybe_timestamp(base, attr):\n    if base and getattr(base, attr):\n        return utils.format_timestamp_with_milli(getattr(base, attr))\n    else:\n        return \"active\"\n    pass\n\n\ndef flowdetails(state, flow):\n    text = []\n\n    cc = flow.client_conn\n    sc = flow.server_conn\n    req = flow.request\n    resp = flow.response\n\n    if sc:\n        text.append(urwid.Text([(\"head\", \"Server Connection:\")]))\n        parts = [\n            [\"Address\", \"%s:%s\" % sc.address()],\n        ]\n\n        text.extend(\n            common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n        )\n\n        c = sc.cert\n        if c:\n            text.append(urwid.Text([(\"head\", \"Server Certificate:\")]))\n            parts = [\n                [\"Type\", \"%s, %s bits\" % c.keyinfo],\n                [\"SHA1 digest\", c.digest(\"sha1\")],\n                [\"Valid to\", str(c.notafter)],\n                [\"Valid from\", str(c.notbefore)],\n                [\"Serial\", str(c.serial)],\n                [\n                    \"Subject\",\n                    urwid.BoxAdapter(\n                        urwid.ListBox(\n                            common.format_keyvals(\n                                c.subject,\n                                key=\"highlight\",\n                                val=\"text\"\n                            )\n                        ),\n                        len(c.subject)\n                    )\n                ],\n                [\n                    \"Issuer\",\n                    urwid.BoxAdapter(\n                        urwid.ListBox(\n                            common.format_keyvals(\n                                c.issuer, key=\"highlight\", val=\"text\"\n                            )\n                        ),\n                        len(c.issuer)\n                    )\n                ]\n            ]\n\n            if c.altnames:\n                parts.append(\n                    [\n                        \"Alt names\",\n                        \", \".join(c.altnames)\n                    ]\n                )\n            text.extend(\n                common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n            )\n\n    if cc:\n        text.append(urwid.Text([(\"head\", \"Client Connection:\")]))\n\n        parts = [\n            [\"Address\", \"%s:%s\" % cc.address()],\n            # [\"Requests\", \"%s\"%cc.requestcount],\n        ]\n\n        text.extend(\n            common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n        )\n\n    parts = []\n\n    parts.append(\n        [\n            \"Client conn. established\",\n            maybe_timestamp(cc, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Server conn. initiated\",\n            maybe_timestamp(sc, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Server conn. TCP handshake\",\n            maybe_timestamp(sc, \"timestamp_tcp_setup\")\n        ]\n    )\n    if sc.ssl_established:\n        parts.append(\n            [\n                \"Server conn. SSL handshake\",\n                maybe_timestamp(sc, \"timestamp_ssl_setup\")\n            ]\n        )\n        parts.append(\n            [\n                \"Client conn. SSL handshake\",\n                maybe_timestamp(cc, \"timestamp_ssl_setup\")\n            ]\n        )\n    parts.append(\n        [\n            \"First request byte\",\n            maybe_timestamp(req, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Request complete\",\n            maybe_timestamp(req, \"timestamp_end\")\n        ]\n    )\n    parts.append(\n        [\n            \"First response byte\",\n            maybe_timestamp(resp, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Response complete\",\n            maybe_timestamp(resp, \"timestamp_end\")\n        ]\n    )\n\n    # sort operations by timestamp\n    parts = sorted(parts, key=lambda p: p[1])\n\n    text.append(urwid.Text([(\"head\", \"Timing:\")]))\n    text.extend(common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4))\n    return searchable.Searchable(state, text)\n", "path": "libmproxy/console/flowdetailview.py"}], "after_files": [{"content": "from __future__ import absolute_import\nimport urwid\nfrom . import common, searchable\nfrom .. import utils\n\n\ndef maybe_timestamp(base, attr):\n    if base and getattr(base, attr):\n        return utils.format_timestamp_with_milli(getattr(base, attr))\n    else:\n        return \"active\"\n    pass\n\n\ndef flowdetails(state, flow):\n    text = []\n\n    cc = flow.client_conn\n    sc = flow.server_conn\n    req = flow.request\n    resp = flow.response\n\n    if sc is not None:\n        text.append(urwid.Text([(\"head\", \"Server Connection:\")]))\n        parts = [\n            [\"Address\", \"%s:%s\" % sc.address()],\n        ]\n\n        text.extend(\n            common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n        )\n\n        c = sc.cert\n        if c:\n            text.append(urwid.Text([(\"head\", \"Server Certificate:\")]))\n            parts = [\n                [\"Type\", \"%s, %s bits\" % c.keyinfo],\n                [\"SHA1 digest\", c.digest(\"sha1\")],\n                [\"Valid to\", str(c.notafter)],\n                [\"Valid from\", str(c.notbefore)],\n                [\"Serial\", str(c.serial)],\n                [\n                    \"Subject\",\n                    urwid.BoxAdapter(\n                        urwid.ListBox(\n                            common.format_keyvals(\n                                c.subject,\n                                key=\"highlight\",\n                                val=\"text\"\n                            )\n                        ),\n                        len(c.subject)\n                    )\n                ],\n                [\n                    \"Issuer\",\n                    urwid.BoxAdapter(\n                        urwid.ListBox(\n                            common.format_keyvals(\n                                c.issuer, key=\"highlight\", val=\"text\"\n                            )\n                        ),\n                        len(c.issuer)\n                    )\n                ]\n            ]\n\n            if c.altnames:\n                parts.append(\n                    [\n                        \"Alt names\",\n                        \", \".join(c.altnames)\n                    ]\n                )\n            text.extend(\n                common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n            )\n\n    if cc is not None:\n        text.append(urwid.Text([(\"head\", \"Client Connection:\")]))\n\n        parts = [\n            [\"Address\", \"%s:%s\" % cc.address()],\n            # [\"Requests\", \"%s\"%cc.requestcount],\n        ]\n\n        text.extend(\n            common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4)\n        )\n\n    parts = []\n\n    parts.append(\n        [\n            \"Client conn. established\",\n            maybe_timestamp(cc, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Server conn. initiated\",\n            maybe_timestamp(sc, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Server conn. TCP handshake\",\n            maybe_timestamp(sc, \"timestamp_tcp_setup\")\n        ]\n    )\n    if sc.ssl_established:\n        parts.append(\n            [\n                \"Server conn. SSL handshake\",\n                maybe_timestamp(sc, \"timestamp_ssl_setup\")\n            ]\n        )\n        parts.append(\n            [\n                \"Client conn. SSL handshake\",\n                maybe_timestamp(cc, \"timestamp_ssl_setup\")\n            ]\n        )\n    parts.append(\n        [\n            \"First request byte\",\n            maybe_timestamp(req, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Request complete\",\n            maybe_timestamp(req, \"timestamp_end\")\n        ]\n    )\n    parts.append(\n        [\n            \"First response byte\",\n            maybe_timestamp(resp, \"timestamp_start\")\n        ]\n    )\n    parts.append(\n        [\n            \"Response complete\",\n            maybe_timestamp(resp, \"timestamp_end\")\n        ]\n    )\n\n    # sort operations by timestamp\n    parts = sorted(parts, key=lambda p: p[1])\n\n    text.append(urwid.Text([(\"head\", \"Timing:\")]))\n    text.extend(common.format_keyvals(parts, key=\"key\", val=\"text\", indent=4))\n    return searchable.Searchable(state, text)\n", "path": "libmproxy/console/flowdetailview.py"}]}