// config.set_option("proxy.isRemote", val)
def _print_remote_url(port, quoted_name):
ips = []
http_client = None
try:
http_client = httpclient.HTTPClient()
for key in ("local-ipv4", "public-ipv4"):
endpoint = os.path.join(EC2_METADATA_URL, key)
response = http_client.fetch(endpoint, request_timeout=0.01)
ips.append(response.body)
except (httpclient.HTTPError, RuntimeError) as e:
// Basically if not on EC2 do a hack and try to connect to
// internet and see what the local ip is.
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 53))
ips.append(s.getsockname()[0])
s.close()
finally:
if http_client is not None:
http_client.close()
timeout_secs = config.get_option("proxy.waitForConnectionSecs")
for ip in ips:
url = "http://{}:{}/?name={}".format(ip, port, quoted_name)
print("Please connect to %s within %s seconds." % (url, timeout_secs))
def _launch_web_client(name):
Launches a web browser to connect to the proxy to get the named
report.