|
@@ -24,14 +24,14 @@ from .constants import * # NOQA
|
|
|
from .helpers import Error, IntegrityError
|
|
|
from .helpers import bin_to_hex
|
|
|
from .helpers import get_home_dir
|
|
|
+from .helpers import get_limited_unpacker
|
|
|
from .helpers import hostname_is_unique
|
|
|
from .helpers import replace_placeholders
|
|
|
from .helpers import sysinfo
|
|
|
from .helpers import format_file_size
|
|
|
from .helpers import truncate_and_unlink
|
|
|
-from .helpers import StableDict
|
|
|
from .logger import create_logger, setup_logging
|
|
|
-from .repository import Repository, MAX_OBJECT_SIZE, LIST_SCAN_LIMIT
|
|
|
+from .repository import Repository
|
|
|
from .version import parse_version, format_version
|
|
|
from .algorithms.checksums import xxh64
|
|
|
|
|
@@ -41,8 +41,6 @@ RPC_PROTOCOL_VERSION = 2
|
|
|
BORG_VERSION = parse_version(__version__)
|
|
|
MSGID, MSG, ARGS, RESULT = b'i', b'm', b'a', b'r'
|
|
|
|
|
|
-BUFSIZE = 10 * 1024 * 1024
|
|
|
-
|
|
|
MAX_INFLIGHT = 100
|
|
|
|
|
|
RATELIMIT_PERIOD = 0.1
|
|
@@ -67,35 +65,6 @@ def os_write(fd, data):
|
|
|
return amount
|
|
|
|
|
|
|
|
|
-def get_limited_unpacker(kind):
|
|
|
- """return a limited Unpacker because we should not trust msgpack data received from remote"""
|
|
|
- args = dict(use_list=False, # return tuples, not lists
|
|
|
- max_bin_len=0, # not used
|
|
|
- max_ext_len=0, # not used
|
|
|
- max_buffer_size=3 * max(BUFSIZE, MAX_OBJECT_SIZE),
|
|
|
- max_str_len=MAX_OBJECT_SIZE, # a chunk or other repo object
|
|
|
- )
|
|
|
- if kind == 'server':
|
|
|
- args.update(dict(max_array_len=100, # misc. cmd tuples
|
|
|
- max_map_len=100, # misc. cmd dicts
|
|
|
- ))
|
|
|
- elif kind == 'client':
|
|
|
- args.update(dict(max_array_len=LIST_SCAN_LIMIT, # result list from repo.list() / .scan()
|
|
|
- max_map_len=100, # misc. result dicts
|
|
|
- ))
|
|
|
- elif kind == 'manifest':
|
|
|
- args.update(dict(use_list=True, # default value
|
|
|
- max_array_len=100, # ITEM_KEYS ~= 22
|
|
|
- max_map_len=MAX_ARCHIVES, # list of archives
|
|
|
- max_str_len=255, # archive name
|
|
|
- object_hook=StableDict,
|
|
|
- unicode_errors='surrogateescape',
|
|
|
- ))
|
|
|
- else:
|
|
|
- raise ValueError('kind must be "server", "client" or "manifest"')
|
|
|
- return msgpack.Unpacker(**args)
|
|
|
-
|
|
|
-
|
|
|
class ConnectionClosed(Error):
|
|
|
"""Connection closed by remote host"""
|
|
|
|