code wiki / _hdl_build / nx_signaling_v2.nx
nx_signaling_v2.nx
buildroot/runtime/_hdl_build/nx_signaling_v2.nx
about
nx_signaling_v2.nx -- bits-up N-party WebSocket signaling daemon for /video.
Generation 2 of bench/nx_signaling.nx (1:1 rooms). What changed and why:
- N-party rooms (NX_SIG2_MAX_PEERS=8 fds per room) -- the family call is
more than two people. Relay = broadcast to every OTHER peer in the
room; the browser JS addresses peers by its own from/to envelope
fields and ignores frames not meant for it (server stays JSON-free,
single responsibility: room membership + relay only).
- Binds 127.0.0.1 ONLY. TLS termination happens in the sites daemon's
fork-per-connection child, which pumps decrypted bytes to this
loopback daemon (wss://nishifamily.com/signal/<room> on :8443) -- so
the plaintext WS port is never exposed off-host.
- Composes the SAME KAT'd primitives as v1: nx_websocket_upgrade
(RFC 6455 4.1), nx_websocket_stream (5.3), nx_websocket_frame (5.7),
nx_poll.
Deploy: nx_sov_build_run nx_signaling_v2 -> push .sov.elf to the NAS.
Gate: nx_signaling_v2_gate.nx (3-peer mesh relay proof over loopback).
license_tier: ORIGINAL
dependencies 10 imports · 0 importers
imports: nx_syscalls.nxnx_signal.nxnx_dgram_media.nxnx_sfu_select.nxnx_room_key.nxnx_websocket_frame.nxnx_websocket_stream.nxnx_websocket_upgrade.nxnx_poll.nxnx_sig2_txq.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 32 | const NX_SIG2_PORT: i64 = 8445 |
| 33 | const NX_SIG2_MAX_ROOMS: i64 = 64 |
| 34 | const NX_SIG2_MAX_PEERS: i64 = 8 |
| 35 | const NX_SIG2_MAX_CONNS: i64 = 128 |
| 36 | const NX_SIG2_HDR_BUF_BYTES: i64 = 4096 |
| 40 | const NX_SIG2_FRAME_BUF_BYTES: i64 = 65536 |
| 41 | const NX_SIG2_ROOM_ID_POOL_BYTES: i64 = 4096 |
| 42 | const NX_SIG2_ACCEPT_BACKLOG: i64 = 32 |
| 46 | const NX_SIG2_ROOM_BYTES: i64 = 96 |
| 52 | const R_ID_OFF: i64 = 0 |
| 53 | const R_ID_LEN: i64 = 1 |
| 54 | const R_USED: i64 = 2 |
| 55 | const R_NPEERS: i64 = 3 |
| 56 | const R_FD0: i64 = 4 // fd[i] at R_FD0 + i |
| 59 | const NX_SIG2_CONN_BYTES: i64 = 16 |
| 153 | const NX_SIG2_TEL_LOG: *u8 = "/volume1/homes/elderwesto/nishihost/room_telemetry.log" |
| 154 | const NX_SIG2_EMIT_US: i64 = 5000000 |
| 155 | const NX_SIG2_TEL_SLOTS: i64 = 1024 // MAX_ROOMS(64) * MAX_PEERS(8) * 2 |
| 164 | const NX_SIG2_UDP_PORT: i64 = 8471 |
| 165 | const NX_SIG2_UDPM: i64 = 16 // UDP members (addr16 | room:i64 | last_us:i64 = 32B each) |
| 166 | const SIG2_DG_JOIN: i64 = 0x4A |
| 167 | const SIG2_DG_ACK: i64 = 0x4B |
| 168 | const SIG2_DG_ROOMFRAME: i64 = 0x4D // payload = a room-protocol BINARY frame (bridged <-> WS binary) |
| 169 | const SIG2_DG_TEXT: i64 = 0x54 // payload = a room-protocol TEXT frame (bridged <-> WS text JSON) |
| 170 | const SIG2_DG_CASCADE: i64 = 0x4E // CASCADE-JOIN (relay-to-relay, Octo-class): enroll the sender as a |
| 536 | const SIG2_DOM_CHECK_US: i64 = 500000 |
functions
| 48 | func sig2_room_ptr(rooms: *u8, idx: i64) -> *i64 |
| 61 | func sig2_conn_ptr(conns: *u8, idx: i64) -> *i64 |
| 66 | func sig2_sockaddr_loopback(addr: *u8, port: i64) -> i64 called by 1: main |
| 76 | func sig2_find_room(rooms: *u8, id_pool: *u8, id: *u8, id_len: i64) -> i64 |
| 95 | func sig2_alloc_room(rooms: *u8, id_pool: *u8, id_pool_off_p: *i64, id: *u8, id_len: i64) -> i64 |
| 119 | func sig2_join(rooms: *u8, ridx: i64, fd: i64) -> i64 |
| 134 | func sig2_leave(rooms: *u8, ridx: i64, fd: i64) -> i64 |
| 174 | func sig2_atoi(s: *u8) -> i64 called by 1: main |
| 179 | func sig2_parse_ip(s: *u8, out: *u8) -> i64 called by 1: main |
| 191 | func sig2_udpm_find(m: *u8, addr: *u8) -> i64 |
| 205 | func sig2_udpm_upsert(m: *u8, addr: *u8, ridx: i64, now: i64) -> i64 |
| 227 | func sig2_udp_fanout(ufd: i64, m: *u8, ridx: i64, except: i64, dkind: i64, body: *u8, blen: i64, |
| 250 | func sig2_telw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 251 | func sig2_teln(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m} let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1} while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1} var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1} sys_write(fd, bb, k); return 0 } |
| 255 | func sig2_emit_tel(rooms: *u8, tel: *i64, now: i64) -> i64 |
| 284 | func sig2_slot_of_fd(conns: *u8, fd: i64) -> i64 |
| 298 | func sig2_memidx(sfu_mem: *i64, mem_ids: *u8, mcount_p: *i64, id: *u8) -> i64 |
| 325 | func sig2_room_cand(conns: *u8, cmx: *i64, ridx: i64, cand: *i64) -> i64 |
| 345 | func sig2_broadcast(rooms: *u8, ridx: i64, from_fd: i64, called by 1: sig2_handle_frame calls 13: sig2_room_ptrsfu_frame_bitssig2_memidxsfu_video_seensys_now_ussig2_lprod_eval+7 |
| 405 | func sig2_room_id_off(path: *u8, path_len: i64) -> i64 called by 1: main |
| 422 | func sig2_udp_enroll(ufd: i64, pkt: *u8, rinfo: *i64, from: *u8, hctx: *i64, cflags: *i64, is_casc: i64) -> i64 called by 1: sig2_udp_handle calls 5: sig2_find_roomsig2_alloc_roomsig2_udpm_upsertdgm_pack_framesys_sendto |
| 449 | func sig2_udp_handle(ufd: i64, pkt: *u8, n: i64, from: *u8, hctx: *i64) -> i64 called by 1: main calls 9: dgm_parse_pktsig2_udp_enrollsig2_udpm_findsys_sendtodgm_rx_addsig2_room_ptr+3 |
| 507 | func sig2_tee_qoe(pp: *u8, plen: i64, ridx: i64) -> i64 called by 1: sig2_handle_frame calls 6: sys_openat_appendsig2_telwsig2_telnsys_now_realtime_mssys_writesys_close |
| 537 | func sig2_audio_activity(fd: i64, ridx: i64, pp: *u8, plen: i64, sfuctx: *i64, midx: i64) -> i64 called by 1: sig2_handle_frame calls 5: sys_now_ussfu_audio_bytessig2_room_candsfu_dominantsig2_broadcast_plain |
| 564 | func sig2_broadcast_plain(sfuctx: *i64, ridx: i64, buf: *u8, n: i64) -> i64 |
| 577 | func sig2_lprod_eval(sfuctx: *i64, smidx: i64) -> i64 called by 2: sig2_broadcastsig2_handle_frame calls 4: sfu_lprod_checksfu_lprod_lastsig2_conn_ptrs2tx_send |
| 602 | func sig2_handle_frame(fd: i64, ridx: i64, rooms: *u8, buf: *u8, buf_cap: i64, tel: *i64, wuctx: *i64, sfuctx: *i64) -> i64 called by 1: main calls 14: nx_ws_read_frame_from_fdnx_ws_send_pongsig2_tee_qoesig2_slot_of_fdsig2_memidxsig2_audio_activity+8 |
| 701 | func sig2_cascade_keepalive(ufd: i64, home_addr: *u8, room: *u8, roomlen: i64, hctx: *i64, cflags: *i64) -> i64 |
| 722 | func main(argc: i64, argv: *i64) -> i64 |