Show both domain and ip URL in issue banner

This commit is contained in:
Disassembler 2018-11-01 23:57:03 +01:00
parent 5f58109373
commit 7eaab3d6e2
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -100,10 +100,10 @@ ISSUE_TEMPLATE = '''
device. Unauthorized attempts and actions to access or use this system may device. Unauthorized attempts and actions to access or use this system may
result in civil or criminal penalties. result in civil or criminal penalties.
Pro přístup k aplikacím otevřete jednu z následujících URL ve Vašem
Pro přístup k aplikacím otevřete URL \x1b[1m{url}\x1b[0m ve Vašem
internetovém prohlížeči. internetovém prohlížeči.
\x1b[1m{url}\x1b[0m
\x1b[1m{ip}\x1b[0m
\x1b[0;30m \x1b[0;30m
''' '''
@ -275,18 +275,15 @@ class VMMgr:
f.write(NGINX_DEFAULT_TEMPLATE.format(port=self.port)) f.write(NGINX_DEFAULT_TEMPLATE.format(port=self.port))
def rebuild_issue(self): def rebuild_issue(self):
# Compile the HTTPS host displayed in terminal banner # Compile the URLs displayed in terminal banner
domain = self.domain ip = tools.get_local_ip(4)
# If the dummy host is used, take an IP address of a primary interface instead if not ip:
if domain == 'spotter.vm': ip = tools.get_local_ip(6)
domain = tools.get_local_ip(4) if not ip:
if not domain: ip = '127.0.0.1'
domain = tools.get_local_ip(6)
if not domain:
domain = '127.0.0.1'
# Rebuild the terminal banner # Rebuild the terminal banner
with open(ISSUE_FILE, 'w') as f: with open(ISSUE_FILE, 'w') as f:
f.write(ISSUE_TEMPLATE.format(url=tools.compile_url(domain, self.port))) f.write(ISSUE_TEMPLATE.format(url=tools.compile_url(self.domain, self.port), ip=tools.compile_url(ip, self.port)))
def update_common(self, email, gmaps_api_key): def update_common(self, email, gmaps_api_key):
# Update common configuration values # Update common configuration values