mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-20 21:27:32 +00:00
rpc negotiate: enable v3 log protocol only for supported clients
avoid seeing JSON log output when a 1.1.0b<5 client talks to a 1.1.0b>6 server.
This commit is contained in:
parent
fc105b49b1
commit
18a2902c9c
2 changed files with 11 additions and 4 deletions
|
@ -313,9 +313,10 @@ def negotiate(self, client_data):
|
|||
# clients since 1.1.0b3 use a dict as client_data
|
||||
if isinstance(client_data, dict):
|
||||
self.client_version = client_data[b'client_version']
|
||||
level = logging.getLevelName(logging.getLogger('').level)
|
||||
setup_logging(is_serve=True, json=True, level=level)
|
||||
logger.debug('Initialized loggin system for new protocol')
|
||||
if client_data.get(b'client_supports_log_v3', False):
|
||||
level = logging.getLevelName(logging.getLogger('').level)
|
||||
setup_logging(is_serve=True, json=True, level=level)
|
||||
logger.debug('Initialized logging system for new (v3) protocol')
|
||||
else:
|
||||
self.client_version = BORG_VERSION # seems to be newer than current version (no known old format)
|
||||
|
||||
|
@ -559,7 +560,10 @@ def __init__(self, location, create=False, exclusive=False, lock_wait=None, lock
|
|||
|
||||
try:
|
||||
try:
|
||||
version = self.call('negotiate', {'client_data': {b'client_version': BORG_VERSION}})
|
||||
version = self.call('negotiate', {'client_data': {
|
||||
b'client_version': BORG_VERSION,
|
||||
b'client_supports_log_v3': True,
|
||||
}})
|
||||
except ConnectionClosed:
|
||||
raise ConnectionClosedWithHint('Is borg working on the server?') from None
|
||||
if version == RPC_PROTOCOL_VERSION:
|
||||
|
|
|
@ -724,6 +724,9 @@ class MockArgs:
|
|||
assert self.repository.borg_cmd(args, testing=False) == ['borg', 'serve', '--umask=077', '--info']
|
||||
args.remote_path = 'borg-0.28.2'
|
||||
assert self.repository.borg_cmd(args, testing=False) == ['borg-0.28.2', 'serve', '--umask=077', '--info']
|
||||
args.debug_topics = ['something_client_side', 'repository_compaction']
|
||||
assert self.repository.borg_cmd(args, testing=False) == ['borg-0.28.2', 'serve', '--umask=077', '--info',
|
||||
'--debug-topic=borg.debug.repository_compaction']
|
||||
|
||||
|
||||
class RemoteLegacyFree(RepositoryTestCaseBase):
|
||||
|
|
Loading…
Reference in a new issue