Files
benchmarks/egress/catcher.py
zeekayandHanzo Dev 4fdedc5f54 Every benchmark in one repository
The measurement lanes lived in hanzoai/cloud/bench, which meant cloning the
thing being measured to run anything — including lanes that measure no binary
at all. They are here now, at the root, beside the load and scale harnesses
that were already here: eleven lanes, MEASURED.md for what each found,
naive.md for what competitors publish and where it was read.

Four lanes still need the cloud source, because they measure a binary rather
than a library. `cloud_src` in host.sh finds it — $CLOUD_SRC, then ../cloud —
or prints how to get one. It does not clone: a benchmark that fetches its own
subject decides which revision you measured.

AND IT SAYS WHICH SOURCE IT FOUND. hanzoai/cloud and hanzo-inc/cloud are
different repositories that both check out as `cloud`, and self/modules.sh
reads 127 modules on one and 55 on the other. Neither is wrong about the tree
it was handed; a lane that does not name its subject is. It prints path, remote
and commit now, the way every timing prints its host.

Fixed on the way: egress reached for bench/egress/catcher.py and transport for
./bench/transport/harness, both paths in the repository they left. The harness
builds from this module now — its only dependency is zap-proto/zip — and
market/bench.mjs and brain/tables.mjs lost a directory level each.

Verified from the new root: fleet reproduces 454.6 MB and 477 bytes per agent,
and self/modules.sh reproduces 127 of 127 when pointed at the tree the figure
came from.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 09:51:20 -07:00

37 lines
1.3 KiB
Python

"""A listener that records what tried to leave, and answers nothing.
Any Go program using net/http honours HTTP_PROXY, HTTPS_PROXY and NO_PROXY, so
a process pointed here reaches this socket instead of the internet. Every
accepted connection is one attempt, written to the log with whatever the client
asked for first — `CONNECT host:443` for TLS, the absolute URL for plain HTTP,
and the raw bytes for anything that is not HTTP at all.
It answers nothing on purpose. A caller that phones home is recorded whether or
not the call would have worked, and a caller that does not phone home is not
kept waiting by a reply it never asked for.
"""
import socket, sys, threading
log = open(sys.argv[2], 'a', buffering=1)
srv = socket.socket()
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(('127.0.0.1', int(sys.argv[1])))
srv.listen(64)
print('ready', flush=True)
def held(conn):
try:
conn.settimeout(2)
first = conn.recv(4096).split(b'\r\n')[0]
log.write((first.decode('utf-8', 'replace') or '(no request line)') + '\n')
except Exception as why:
log.write('(unreadable: %s)\n' % why)
finally:
conn.close()
while True:
c, _ = srv.accept()
threading.Thread(target=held, args=(c,), daemon=True).start()