mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Keep original IP address if the IP address is not in address map
dict.get() returns None if the key is not in dict.
This commit is contained in:
parent
70ba016b1f
commit
b5cdb0e6ea
@ -27,7 +27,11 @@ def local_url_for_content_server():
|
|||||||
from calibre.srv.opts import server_config
|
from calibre.srv.opts import server_config
|
||||||
opts = server_config()
|
opts = server_config()
|
||||||
interface = opts.listen_on or '0.0.0.0'
|
interface = opts.listen_on or '0.0.0.0'
|
||||||
interface = {'0.0.0.0': '127.0.0.1', '::':'::1'}.get(interface)
|
|
||||||
|
addr_map = {'0.0.0.0': '127.0.0.1',
|
||||||
|
'::': '::1'}
|
||||||
|
if interface in addr_map:
|
||||||
|
interface = addr_map[interface]
|
||||||
|
|
||||||
if is_ipv6_addr(interface):
|
if is_ipv6_addr(interface):
|
||||||
interface = f'[{interface}]'
|
interface = f'[{interface}]'
|
||||||
|
@ -1310,7 +1310,11 @@ class ConfigWidget(ConfigWidgetBase):
|
|||||||
prefix = self.advanced_tab.get('url_prefix') or ''
|
prefix = self.advanced_tab.get('url_prefix') or ''
|
||||||
protocol = 'https' if self.advanced_tab.has_ssl else 'http'
|
protocol = 'https' if self.advanced_tab.has_ssl else 'http'
|
||||||
lo = self.advanced_tab.get('listen_on') or '0.0.0.0'
|
lo = self.advanced_tab.get('listen_on') or '0.0.0.0'
|
||||||
lo = {'0.0.0.0': '127.0.0.1', '::':'::1'}.get(lo)
|
|
||||||
|
addr_map = {'0.0.0.0': '127.0.0.1',
|
||||||
|
'::': '::1'}
|
||||||
|
if lo in addr_map:
|
||||||
|
lo = addr_map[lo]
|
||||||
|
|
||||||
if is_ipv6_addr(lo):
|
if is_ipv6_addr(lo):
|
||||||
lo = f'[{lo}]'
|
lo = f'[{lo}]'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user