Only 1 command per peer connection should be handled
This commit is contained in:
parent
1a7ce7d386
commit
4f3da58a60
@ -39,7 +39,7 @@ def gossip_server(
|
|||||||
try:
|
try:
|
||||||
cmd = await asyncio.wait_for(reader.read(1), 60)
|
cmd = await asyncio.wait_for(reader.read(1), 60)
|
||||||
except asyncio.exceptions.CancelledError:
|
except asyncio.exceptions.CancelledError:
|
||||||
writer.close()
|
break
|
||||||
|
|
||||||
cmd = int.from_bytes(cmd, 'big')
|
cmd = int.from_bytes(cmd, 'big')
|
||||||
if cmd == b'' or cmd == 0:
|
if cmd == b'' or cmd == 0:
|
||||||
@ -48,7 +48,7 @@ def gossip_server(
|
|||||||
case GossipCommands.PING:
|
case GossipCommands.PING:
|
||||||
writer.write(b'PONG')
|
writer.write(b'PONG')
|
||||||
case GossipCommands.CLOSE:
|
case GossipCommands.CLOSE:
|
||||||
writer.close()
|
pass
|
||||||
case GossipCommands.ANNOUNCE:
|
case GossipCommands.ANNOUNCE:
|
||||||
async def _read_announce():
|
async def _read_announce():
|
||||||
address = await reader.read(56)
|
address = await reader.read(56)
|
||||||
@ -60,8 +60,10 @@ def gossip_server(
|
|||||||
threaded=True)
|
threaded=True)
|
||||||
writer.write(int(1).to_bytes(1, 'big'))
|
writer.write(int(1).to_bytes(1, 'big'))
|
||||||
await asyncio.wait_for(_read_announce(), 10)
|
await asyncio.wait_for(_read_announce(), 10)
|
||||||
|
break
|
||||||
|
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
writer.close()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user