forked from arti/vt1200
Isolated-netns test setup (a private tap-mess-0-0 so a second MAME can run without holding the owner's tap), the one-file/one-index TFTP servers, the trace/probe run wrappers, and the two server logs quoted in FONT_STORAGE_REPORT.md.
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""fontwork: drive the font reader with the crafted 25 KB font.
|
|
|
|
Serves baseline.pcf for the path/index names (so the terminal, reading the
|
|
first bytes of the path object as a name, asks for the PCF-magic name) and the
|
|
crafted 25,860-byte font for everything else. That makes the terminal's own
|
|
font reader fetch a many-block file, which is the transfer the crash work needs.
|
|
"""
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
ROOT = "/home/arti/code/k-space/vt1200"
|
|
sys.path.insert(0, os.path.join(ROOT, "tools"))
|
|
import fontgen # noqa: E402
|
|
|
|
host = sys.argv[1] if len(sys.argv) > 1 else "192.168.99.1"
|
|
with open(os.path.join(ROOT, "reference/fonts/baseline.pcf"), "rb") as fh:
|
|
base = fh.read()
|
|
with open(os.path.join(ROOT, "reference/fonts/evil-real.pcf"), "rb") as fh:
|
|
evil = fh.read()
|
|
print(f"path={len(base)}B baseline; font name -> {len(evil)}B evil-real.pcf", flush=True)
|
|
|
|
|
|
def resolve(name):
|
|
if name == "69" or name.endswith("fonts.dir"):
|
|
return base
|
|
return evil
|
|
|
|
|
|
srv = fontgen.TFTPServer((host, 69), {}, timeout=60.0, retries=10,
|
|
resolver=resolve).start()
|
|
try:
|
|
while True:
|
|
time.sleep(0.5)
|
|
while srv.log:
|
|
ts, name, addr = srv.log.pop(0)
|
|
stamp = time.strftime("%H:%M:%S", time.localtime(ts))
|
|
print(f"{stamp} {addr[0]}:{addr[1]} requested {name!r}", flush=True)
|
|
except KeyboardInterrupt:
|
|
pass
|
|
finally:
|
|
srv.stop()
|