mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #3069 from cortesi/mweb
A grab-bag of mitmweb-related fixes
This commit is contained in:
commit
6d5c8781e2
@ -22,8 +22,6 @@ socket_fileobject = socket.SocketIO
|
||||
# Python 3.6 for Windows is missing a constant
|
||||
IPPROTO_IPV6 = getattr(socket, "IPPROTO_IPV6", 41)
|
||||
|
||||
EINTR = 4
|
||||
|
||||
|
||||
class _FileLike:
|
||||
BLOCKSIZE = 1024 * 32
|
||||
@ -595,14 +593,7 @@ class TCPServer:
|
||||
self.__is_shut_down.clear()
|
||||
try:
|
||||
while not self.__shutdown_request:
|
||||
try:
|
||||
r, w_, e_ = select.select(
|
||||
[self.socket], [], [], poll_interval)
|
||||
except select.error as ex: # pragma: no cover
|
||||
if ex[0] == EINTR:
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
r, w_, e_ = select.select([self.socket], [], [], poll_interval)
|
||||
if self.socket in r:
|
||||
connection, client_address = self.socket.accept()
|
||||
t = basethread.BaseThread(
|
||||
|
@ -18,7 +18,6 @@ from mitmproxy import io
|
||||
from mitmproxy import log
|
||||
from mitmproxy import version
|
||||
from mitmproxy import optmanager
|
||||
from mitmproxy.tools.cmdline import CONFIG_PATH
|
||||
import mitmproxy.tools.web.master # noqa
|
||||
|
||||
|
||||
@ -457,10 +456,11 @@ class Options(RequestHandler):
|
||||
|
||||
class SaveOptions(RequestHandler):
|
||||
def post(self):
|
||||
try:
|
||||
optmanager.save(self.master.options, CONFIG_PATH, True)
|
||||
except Exception as err:
|
||||
raise APIError(400, "{}".format(err))
|
||||
# try:
|
||||
# optmanager.save(self.master.options, CONFIG_PATH, True)
|
||||
# except Exception as err:
|
||||
# raise APIError(400, "{}".format(err))
|
||||
pass
|
||||
|
||||
|
||||
class Application(tornado.web.Application):
|
||||
|
@ -105,33 +105,21 @@ class WebMaster(master.Master):
|
||||
|
||||
def run(self): # pragma: no cover
|
||||
AsyncIOMainLoop().install()
|
||||
|
||||
iol = tornado.ioloop.IOLoop.instance()
|
||||
|
||||
http_server = tornado.httpserver.HTTPServer(self.app)
|
||||
http_server.listen(self.options.web_port, self.options.web_iface)
|
||||
|
||||
iol.add_callback(self.start)
|
||||
|
||||
web_url = "http://{}:{}/".format(self.options.web_iface, self.options.web_port)
|
||||
self.log.info(
|
||||
"Web server listening at {}".format(web_url),
|
||||
)
|
||||
|
||||
# FIXME: This should be in an addon hooked to the "running" event, not in master
|
||||
if self.options.web_open_browser:
|
||||
success = open_browser(web_url)
|
||||
if not success:
|
||||
self.log.info(
|
||||
"No web browser found. Please open a browser and point it to {}".format(web_url),
|
||||
)
|
||||
try:
|
||||
iol.start()
|
||||
except KeyboardInterrupt:
|
||||
self.shutdown()
|
||||
|
||||
def shutdown(self):
|
||||
tornado.ioloop.IOLoop.instance().stop()
|
||||
super().shutdown()
|
||||
self.run_loop(iol.start)
|
||||
|
||||
|
||||
def open_browser(url: str) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user