fix(towercore): return protocol errors for denied reads

- replace malformed empty read responses with native not-found frames
This commit is contained in:
TakuyaYagam1 committed 2026-11-29 16:44:30 +03:00
1 parent 903d8872c2
commit b16b42b0fa
2 files changed
+10 -9

No files matched your search

+6 -3
View File
@@ -44,8 +44,11 @@ def should_block(frame: bytes) -> bool:
return frame[3] in READ_OPCODES and tlv_tags(frame).count(SUBSCRIBER_TAG) > 1
def empty_response(frame: bytes) -> bytes:
return frame[:14] + b"\0\0"
def denied_response(frame: bytes) -> bytes:
message = b"not found"
payload = (0x22).to_bytes(2, "little") + len(message).to_bytes(2, "little") + message
return b"LT\x01\xfe" + frame[4:14] + len(payload).to_bytes(2, "little") + payload
@@ -92,7 +95,7 @@ async def client_frames(
payload = await reader.readexactly(payload_size)
frame = header + payload
if guard.should_block(frame):
client_writer.write(empty_response(frame))
client_writer.write(denied_response(frame))
await client_writer.drain()
continue
backend_writer.write(frame)