()
| 54 | """ |
| 55 | |
| 56 | async def main() -> T: |
| 57 | logging.getLogger().setLevel(logging.DEBUG) |
| 58 | logging.getLogger("tornado").setLevel(logging.WARNING) |
| 59 | logging.getLogger("asyncio").setLevel(logging.WARNING) |
| 60 | logging.getLogger("hpack").setLevel(logging.WARNING) |
| 61 | logging.getLogger("urwid").setLevel(logging.INFO) |
| 62 | logging.getLogger("quic").setLevel( |
| 63 | logging.WARNING |
| 64 | ) # aioquic uses a different prefix... |
| 65 | debug.register_info_dumpers() |
| 66 | |
| 67 | opts = options.Options() |
| 68 | master = master_cls(opts) |
| 69 | |
| 70 | parser = make_parser(opts) |
| 71 | |
| 72 | # To make migration from 2.x to 3.0 bearable. |
| 73 | if "-R" in sys.argv and sys.argv[sys.argv.index("-R") + 1].startswith("http"): |
| 74 | print( |
| 75 | "To use mitmproxy in reverse mode please use --mode reverse:SPEC instead" |
| 76 | ) |
| 77 | |
| 78 | try: |
| 79 | args = parser.parse_args(arguments) |
| 80 | except SystemExit: |
| 81 | arg_check.check() |
| 82 | sys.exit(1) |
| 83 | |
| 84 | try: |
| 85 | opts.set(*args.setoptions, defer=True) |
| 86 | optmanager.load_paths( |
| 87 | opts, |
| 88 | os.path.join(opts.confdir, "config.yaml"), |
| 89 | os.path.join(opts.confdir, "config.yml"), |
| 90 | ) |
| 91 | process_options(parser, opts, args) |
| 92 | |
| 93 | if args.options: |
| 94 | # Load custom addons so that their options are registered |
| 95 | if sl := master.addons.get("scriptloader"): |
| 96 | for s in sl.addons: |
| 97 | if s.ns is None: |
| 98 | s.loadscript() |
| 99 | optmanager.dump_defaults(opts, sys.stdout) |
| 100 | sys.exit(0) |
| 101 | if args.commands: |
| 102 | master.commands.dump() |
| 103 | sys.exit(0) |
| 104 | if extra: |
| 105 | if args.filter_args: |
| 106 | logging.info( |
| 107 | f'Only processing flows that match "{" & ".join(args.filter_args)}"' |
| 108 | ) |
| 109 | opts.update(**extra(args)) |
| 110 | |
| 111 | except exceptions.OptionsError as e: |
| 112 | print(f"{sys.argv[0]}: {e}", file=sys.stderr) |
| 113 | sys.exit(1) |
no test coverage detected
searching dependent graphs…