mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont change the type of opts.trusted_ips
This commit is contained in:
parent
d36c916e67
commit
b4ab128f8d
@ -171,14 +171,6 @@ class Text(QLineEdit):
|
|||||||
self.setText(str(val or ''))
|
self.setText(str(val or ''))
|
||||||
|
|
||||||
|
|
||||||
class IPAddresses(Text):
|
|
||||||
|
|
||||||
def set(self, val):
|
|
||||||
if isinstance(val, tuple):
|
|
||||||
val = ', '.join(map(str, val))
|
|
||||||
self.setText(str(val or ''))
|
|
||||||
|
|
||||||
|
|
||||||
class Path(QWidget):
|
class Path(QWidget):
|
||||||
|
|
||||||
changed_signal = pyqtSignal()
|
changed_signal = pyqtSignal()
|
||||||
@ -265,8 +257,6 @@ class AdvancedTab(QWidget):
|
|||||||
w = Text
|
w = Text
|
||||||
if name in ('ssl_certfile', 'ssl_keyfile'):
|
if name in ('ssl_certfile', 'ssl_keyfile'):
|
||||||
w = Path
|
w = Path
|
||||||
elif name == 'trusted_ips':
|
|
||||||
w = IPAddresses
|
|
||||||
w = w(name, l)
|
w = w(name, l)
|
||||||
setattr(self, 'opt_' + name, w)
|
setattr(self, 'opt_' + name, w)
|
||||||
self.widgets.append(w)
|
self.widgets.append(w)
|
||||||
|
@ -11,7 +11,7 @@ import socket
|
|||||||
import ssl
|
import ssl
|
||||||
import traceback
|
import traceback
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial, lru_cache
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
@ -165,7 +165,7 @@ class Connection: # {{{
|
|||||||
self.remote_addr = self.remote_port = self.parsed_remote_addr = None
|
self.remote_addr = self.remote_port = self.parsed_remote_addr = None
|
||||||
self.is_trusted_ip = bool(self.opts.local_write and getattr(self.parsed_remote_addr, 'is_loopback', False))
|
self.is_trusted_ip = bool(self.opts.local_write and getattr(self.parsed_remote_addr, 'is_loopback', False))
|
||||||
if not self.is_trusted_ip and self.opts.trusted_ips and self.parsed_remote_addr is not None:
|
if not self.is_trusted_ip and self.opts.trusted_ips and self.parsed_remote_addr is not None:
|
||||||
self.is_trusted_ip = is_ip_trusted(self.parsed_remote_addr, self.opts.trusted_ips)
|
self.is_trusted_ip = is_ip_trusted(self.parsed_remote_addr, parsed_trusted_ips(self.opts.trusted_ips))
|
||||||
self.orig_send_bufsize = self.send_bufsize = 4096
|
self.orig_send_bufsize = self.send_bufsize = 4096
|
||||||
self.tdir = tdir
|
self.tdir = tdir
|
||||||
self.wait_for = READ
|
self.wait_for = READ
|
||||||
@ -367,6 +367,11 @@ class Connection: # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=2)
|
||||||
|
def parsed_trusted_ips(raw):
|
||||||
|
return tuple(parse_trusted_ips(raw)) if raw else ()
|
||||||
|
|
||||||
|
|
||||||
class ServerLoop:
|
class ServerLoop:
|
||||||
|
|
||||||
LISTENING_MSG = 'calibre server listening on'
|
LISTENING_MSG = 'calibre server listening on'
|
||||||
@ -386,8 +391,6 @@ class ServerLoop:
|
|||||||
self.ready = False
|
self.ready = False
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
self.opts = opts or Options()
|
self.opts = opts or Options()
|
||||||
if self.opts.trusted_ips:
|
|
||||||
self.opts.trusted_ips = tuple(parse_trusted_ips(self.opts.trusted_ips))
|
|
||||||
self.log = log or ThreadSafeLog(level=ThreadSafeLog.DEBUG)
|
self.log = log or ThreadSafeLog(level=ThreadSafeLog.DEBUG)
|
||||||
self.jobs_manager = JobsManager(self.opts, self.log)
|
self.jobs_manager = JobsManager(self.opts, self.log)
|
||||||
self.access_log = access_log
|
self.access_log = access_log
|
||||||
|
Loading…
x
Reference in New Issue
Block a user