def test_parse_server_spec(): tutils.raises("Invalid server specification", cmdline.parse_server_spec, "") assert cmdline.parse_server_spec("http://foo.com:88") == ("http", ("foo.com", 88)) assert cmdline.parse_server_spec("http://foo.com") == ("http", ("foo.com", 80)) assert cmdline.parse_server_spec("https://foo.com") == ("https", ("foo.com", 443)) tutils.raises("Invalid server specification", cmdline.parse_server_spec, "foo.com") tutils.raises("Invalid server specification", cmdline.parse_server_spec, "http://")
def test_parse_server_spec(): tutils.raises("Invalid server specification", cmdline.parse_server_spec, "") assert cmdline.parse_server_spec( "http://foo.com:88") == ("http", ("foo.com", 88)) assert cmdline.parse_server_spec( "http://foo.com") == ("http", ("foo.com", 80)) assert cmdline.parse_server_spec( "https://foo.com") == ("https", ("foo.com", 443)) tutils.raises( "Invalid server specification", cmdline.parse_server_spec, "foo.com") tutils.raises( "Invalid server specification", cmdline.parse_server_spec, "http://")
def onDNSEvent(self, event): if self.proxy_master is not None: self.proxy_master.shutdown() if event.message.startswith('api-na'): region = 'NA' else: region = 'JP' config = wx.ConfigBase.Get() host = config.Read("host") or socket.gethostbyname( socket.gethostname()) httpsport = config.Read("httpsport") or "443" try: proxy_config = proxy.ProxyConfig( port=int(httpsport), host=host, mode='reverse', upstream_server=cmdline.parse_server_spec('https://%s:443/' % event.message)) proxy_server = ProxyServer(proxy_config) except Exception as e: evt = custom_events.wxStatusEvent( message='Error starting HTTPS proxy: %s' % e) wx.PostEvent(self.main_tab, evt) return self.proxy_master = PadMaster(proxy_server, self, region) thread.start_new_thread(self.proxy_master.run, ())
def onDNSEvent(self, message): if self.proxy_master is not None: self.proxy_master.shutdown() if message.startswith('api-na'): region = 'NA' else: region = 'JP' host = self.hostaddr httpsport = 443 try: proxy_config = proxy.ProxyConfig(port=httpsport, host=host, mode='reverse', upstream_server=cmdline.parse_server_spec('https://%s:443/' % message)) proxy_server = ProxyServer(proxy_config) except Exception as e: raise self.proxy_master = PadMaster(proxy_server, self, region) thread.start_new_thread(self.proxy_master.run, ())
def onDNSEvent(self, event): if self.proxy_master is not None: self.proxy_master.shutdown() if event.message.startswith('api-na'): region = 'NA' else: region = 'JP' config = wx.ConfigBase.Get() host = config.Read("host") or socket.gethostbyname(socket.gethostname()) httpsport = config.Read("httpsport") or "443" try: proxy_config = proxy.ProxyConfig(port=int(httpsport), host=host, mode='reverse', upstream_server=cmdline.parse_server_spec('https://%s:443/' % event.message)) proxy_server = ProxyServer(proxy_config) except Exception as e: evt = custom_events.wxStatusEvent(message='Error starting HTTPS proxy: %s' % e) wx.PostEvent(self.main_tab, evt) return self.proxy_master = PadMaster(proxy_server, self, region) thread.start_new_thread(self.proxy_master.run, ())