def main(): parser = cli.args() args, extra_args = parser.parse_known_args() try: config = cli.config(args) except IOError as err: parser.error(err) except toml.core.TomlError as err: parser.error("Errors found in the config file:\n\n", err) mitm_args = cli.mitm_args(config) is_sudo = os.getuid() == 0 host = config["core"]["host"] port = config["core"]["port"] pid_filename = pid.filename(host, port) if args.pid: parser.exit(message=pid.message(host, port)) if type(mitm_args) == Exception: parser.error(mitm_args.message) say.level(config["core"]["verbose"]) try: if config["os"]["proxy-settings"]: if not is_sudo: parser.error("proxy-settings is enabled," + "please provide sudo in order to change the" + "OSX proxy configuration.") proxyswitch.enable(host, str(port)) pid.create(pid_filename, pid.get()) mitmdump(mitm_args + extra_args) finally: pid.remove(pid_filename) if config["os"]["proxy-settings"] and is_sudo: proxyswitch.disable()
def main(profiler, clock_type, concurrency): outfile = "callgrind.mitmdump-{}-c{}".format(clock_type, concurrency) a = ApacheBenchThread(concurrency) a.start() if profiler == "yappi": yappi.set_clock_type(clock_type) yappi.start(addons=True) print("Start mitmdump...") mitmdump(["-k", "-q", "-S", "1024example"]) print("mitmdump stopped.") print("Save profile information...") if profiler == "yappi": yappi.stop() stats = yappi.get_func_stats() stats.save(outfile, type='callgrind') print("Done.")
#!/usr/local/opt/python/bin/python2.7 # -*- coding: utf-8 -*- import re import sys from mitmproxy.main import mitmdump if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(mitmdump())