Repository navigation
Expand file tree
/
Copy pathmitmproxy
More file actions
executable file
·73 lines (62 loc) · 2.65 KB
/
Copy pathmitmproxy
File metadata and controls
executable file
·73 lines (62 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
import sys, argparse, os
from libmproxy import proxy, console, cmdline
from libmproxy.proxy.config import process_proxy_options
from libmproxy.proxy.primitives import ProxyServerError
from libmproxy.proxy.server import DummyServer, ProxyServer
import libmproxy.version, netlib.version
from libmproxy.console import palettes
if __name__ == '__main__':
# We don't introduce backward-incompatible changes in patch versions. Only consider major and minor version.
if netlib.version.IVERSION[:2] != libmproxy.version.IVERSION[:2]:
print >> sys.stderr, ("warning: You are using mitmproxy %s with netlib %s. "
"Most likely, that doesn't work - please upgrade!") % (libmproxy.version.VERSION,
netlib.version.VERSION)
parser = argparse.ArgumentParser(usage = "%(prog)s [options]")
parser.add_argument('--version', action='version', version=libmproxy.version.NAMEVERSION)
cmdline.common_options(parser)
parser.add_argument(
"--palette", type=str, default="dark",
action="store", dest="palette",
help="Select color palette: " + ", ".join(palettes.palettes.keys())
)
parser.add_argument(
"-e",
action="store_true", dest="eventlog",
help="Show event log."
)
group = parser.add_argument_group(
"Filters",
"See help in mitmproxy for filter expression syntax."
)
group.add_argument(
"-i", "--intercept", action="store",
type = str, dest="intercept", default=None,
help = "Intercept filter expression."
)
options = parser.parse_args()
config = process_proxy_options(parser, options)
if options.no_server:
server = DummyServer(config)
else:
try:
server = ProxyServer(config, options.port, options.addr)
except ProxyServerError, v:
print >> sys.stderr, "mitmproxy:", v.args[0]
sys.exit(1)
opts = console.Options(**cmdline.get_common_options(options))
opts.eventlog = options.eventlog
opts.intercept = options.intercept
opts.palette = options.palette
spec = ""
for i in ["LANG", "LC_CTYPE", "LC_ALL"]:
spec += os.environ.get(i, "").lower()
if "utf" not in spec:
print >> sys.stderr, "Error: mitmproxy requires a UTF console environment."
print >> sys.stderr, "Set your LANG enviroment variable to something like en_US.UTF-8"
sys.exit(1)
m = console.ConsoleMaster(server, opts)
try:
m.run()
except KeyboardInterrupt:
pass