fix(towercore): bind exported context to session

- Force EXPORT_CONTEXT to use session->UE after both peer selector paths.
- Strip tag 0x09 and 0x0b peer selectors in the protocol guard.
This commit is contained in:
TakuyaYagam1 committed 2026-11-29 15:41:12 +03:00
1 parent ce5eb09db3
commit aba00ab3ed
3 files changed
+23 -7

No files matched your search

+8 -4
View File
@@ -5,8 +5,11 @@ import contextlib
import os
HEADER_SIZE = 16
TARGETED_READ_OPCODES = frozenset((0x21, 0x23))
SUBSCRIBER_TAG = 0x0B
FILTERED_SELECTOR_TAGS = {
0x21: frozenset((0x0B,)),
0x23: frozenset((0x0B,)),
0x40: frozenset((0x09, 0x0B)),
}
BACKEND_HOST = os.environ.get("BACKEND_HOST", "towercore")
BACKEND_PORT = int(os.environ.get("BACKEND_PORT", "7250"))
LISTEN_PORT = int(os.environ.get("LISTEN_PORT", "7250"))
@@ -18,7 +21,8 @@ def sanitize_frame(frame: bytes) -> bytes:
payload_size = int.from_bytes(frame[14:16], "little")
if len(frame) != HEADER_SIZE + payload_size:
raise ValueError("invalid frame length")
if frame[3] not in TARGETED_READ_OPCODES:
filtered_tags = FILTERED_SELECTOR_TAGS.get(frame[3])
if filtered_tags is None:
return frame
payload = frame[HEADER_SIZE:]
@@ -32,7 +36,7 @@ def sanitize_frame(frame: bytes) -> bytes:
end = offset + 4 + size
if end > len(payload):
raise ValueError("truncated TLV value")
if tag == SUBSCRIBER_TAG:
if tag in filtered_tags:
if sanitized is None:
sanitized = bytearray(payload[:offset])
elif sanitized is not None: