mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Handle one-word replication commands correctly
`REPLICATE` is now a valid command, and it's nice if you can issue it from the console without remembering to call it `REPLICATE ` with a trailing space.
This commit is contained in:
parent
c3e4b4edb2
commit
e13c6c7a96
@ -201,15 +201,23 @@ class BaseReplicationStreamProtocol(LineOnlyReceiver):
|
|||||||
)
|
)
|
||||||
self.send_error("ping timeout")
|
self.send_error("ping timeout")
|
||||||
|
|
||||||
def lineReceived(self, line):
|
def lineReceived(self, line: bytes):
|
||||||
"""Called when we've received a line
|
"""Called when we've received a line
|
||||||
"""
|
"""
|
||||||
if line.strip() == "":
|
if line.strip() == "":
|
||||||
# Ignore blank lines
|
# Ignore blank lines
|
||||||
return
|
return
|
||||||
|
|
||||||
line = line.decode("utf-8")
|
linestr = line.decode("utf-8")
|
||||||
cmd_name, rest_of_line = line.split(" ", 1)
|
|
||||||
|
# split at the first " ", handling one-word commands
|
||||||
|
idx = linestr.index(" ")
|
||||||
|
if idx >= 0:
|
||||||
|
cmd_name = linestr[:idx]
|
||||||
|
rest_of_line = linestr[idx + 1 :]
|
||||||
|
else:
|
||||||
|
cmd_name = linestr
|
||||||
|
rest_of_line = ""
|
||||||
|
|
||||||
if cmd_name not in self.VALID_INBOUND_COMMANDS:
|
if cmd_name not in self.VALID_INBOUND_COMMANDS:
|
||||||
logger.error("[%s] invalid command %s", self.id(), cmd_name)
|
logger.error("[%s] invalid command %s", self.id(), cmd_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user