console: slightly less hacky hack show http2 warning after first tick

This commit is contained in:
Aldo Cortesi 2016-02-19 12:16:55 +13:00
parent 3d477c72d3
commit a635e04fbf

View File

@ -454,13 +454,6 @@ class ConsoleMaster(flow.FlowMaster):
signals.update_settings.send()
self.loop.set_alarm_in(0.01, self.ticker)
if not hasattr(self, 'http2_error_shown') and self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover
self.http2_error_shown = True
signals.status_message.send(
message="ALPN support missing (OpenSSL 1.0.2+ required). "
"HTTP/2 is disabled. Use --no-http2 to silence this warning.",
expire=5
)
def run(self):
self.ui = urwid.raw_display.Screen()
@ -491,6 +484,14 @@ class ConsoleMaster(flow.FlowMaster):
sys.exit(1)
self.loop.set_alarm_in(0.01, self.ticker)
if self.server.config.http2 and not tcp.HAS_ALPN: # pragma: no cover
def http2err(*args, **kwargs):
signals.status_message.send(
message = "HTTP/2 disabled - OpenSSL 1.0.2+ required."
" Use --no-http2 to silence this warning.",
expire=5
)
self.loop.set_alarm_in(0.01, http2err)
# It's not clear why we need to handle this explicitly - without this,
# mitmproxy hangs on keyboard interrupt. Remove if we ever figure it