code wiki / (root) / nx_turn_relay.nx

nx_turn_relay.nx

buildroot/runtime/nx_turn_relay.nx

38219 B883 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_turn_relay.nx -- Sovereign TURN relay foundation (RFC 5766/8656). Arc 4 Phase A.1 per [[NISHI_BITS_UP_EXCEED_INDUSTRY]]. Closes the openrelay.metered.ca dependency that's currently `slow-lane-grandfathered` in web_assets/video.js. Once nx_turn_relay ships on Texas Synology + Hetzner Frankfurt VPS, the slow-lane audit grader can flag any remaining openrelay reference as a real violation per [[feedback-no-slow-lane-no-paid-priority]]. This file provides the message FRAMING layer: - nx_turn_parse_allocate: parse a TURN ALLOCATE request - nx_turn_build_allocate_success: build a 0x0103 success response - nx_turn_build_allocate_error: build a 0x0113 error response Future phases (per [[NISHI_S_CLASS_ROUTING_ROADMAP]] Q1): - Phase A.2: SEND indication forwarding (relay → peer) - Phase A.3: DATA indication (peer → relay → client) - Phase A.4: CREATE-PERMISSION (allow specific peer IPs) - Phase A.5: REFRESH (extend allocation lifetime) - Phase A.6: CHANNEL-BIND (compact data channel) - Phase B: short-term credentials (HMAC-SHA1 MESSAGE-INTEGRITY) - Phase C: multi-egress + QUIC-on-443 fingerprint (slow-lane cardinal) Patent-clean math: TURN is an IETF standard, royalty-free per IETF IPR policy. We implement the wire format; no proprietary extensions.

dependencies 0 imports · 1 importers

nx_turn_relay.nx nx_turn_msgintegrity.nx

imports: none

imported by: nx_turn_msgintegrity.nx

structs

none

consts

39const NX_TURN_TYPE_ALLOCATE_REQUEST: i64 = 0x0003
40const NX_TURN_TYPE_ALLOCATE_SUCCESS: i64 = 0x0103
41const NX_TURN_TYPE_ALLOCATE_ERROR: i64 = 0x0113
42const NX_TURN_TYPE_REFRESH_REQUEST: i64 = 0x0004
43const NX_TURN_TYPE_SEND_INDICATION: i64 = 0x0016
44const NX_TURN_TYPE_DATA_INDICATION: i64 = 0x0017
45const NX_TURN_TYPE_CREATE_PERM_REQUEST: i64 = 0x0008
46const NX_TURN_TYPE_CHANNEL_BIND_REQUEST: i64 = 0x0009
49const NX_TURN_ATTR_MAPPED_ADDR: i64 = 0x0001
50const NX_TURN_ATTR_USERNAME: i64 = 0x0006
51const NX_TURN_ATTR_MESSAGE_INTEGRITY: i64 = 0x0008
52const NX_TURN_ATTR_ERROR_CODE: i64 = 0x0009
53const NX_TURN_ATTR_REALM: i64 = 0x0014
54const NX_TURN_ATTR_NONCE: i64 = 0x0015
55const NX_TURN_ATTR_XOR_RELAYED_ADDR: i64 = 0x0016
56const NX_TURN_ATTR_REQUESTED_TRANSPORT: i64 = 0x0019
57const NX_TURN_ATTR_DONT_FRAGMENT: i64 = 0x001A
58const NX_TURN_ATTR_LIFETIME: i64 = 0x000D
59const NX_TURN_ATTR_XOR_MAPPED_ADDR: i64 = 0x0020
60const NX_TURN_ATTR_SOFTWARE: i64 = 0x8022
63const NX_STUN_MAGIC: i64 = 0x2112A442
66const NX_TURN_TRANSPORT_UDP: i64 = 17
67const NX_TURN_TRANSPORT_TCP: i64 = 6
70const NX_TURN_FAMILY_IPV4: i64 = 0x01
71const NX_TURN_FAMILY_IPV6: i64 = 0x02
74const NX_TURN_VERDICT_OK_ALLOCATE: i64 = 1
75const NX_TURN_VERDICT_BAD_MAGIC: i64 = 2
76const NX_TURN_VERDICT_TOO_SHORT: i64 = 3
77const NX_TURN_VERDICT_UNKNOWN_TYPE: i64 = 4
78const NX_TURN_VERDICT_MISSING_TRANSPORT: i64 = 5
79const NX_TURN_VERDICT_UNSUPP_TRANSPORT: i64 = 6
349const NX_TURN_ATTR_XOR_PEER_ADDR: i64 = 0x0012
350const NX_TURN_ATTR_DATA: i64 = 0x0013
582const NX_TURN_TYPE_REFRESH_SUCCESS: i64 = 0x0104
583const NX_TURN_TYPE_REFRESH_ERROR: i64 = 0x0114
584const NX_TURN_TYPE_CREATE_PERM_SUCCESS: i64 = 0x0108
585const NX_TURN_TYPE_CREATE_PERM_ERROR: i64 = 0x0118
586const NX_TURN_TYPE_CHANNEL_BIND_SUCCESS: i64 = 0x0109
587const NX_TURN_TYPE_CHANNEL_BIND_ERROR: i64 = 0x0119
588const NX_TURN_ATTR_CHANNEL_NUMBER: i64 = 0x000C

functions

84func _turn_read_be16(buf: *u8, off: i64) -> i64
90func _turn_write_be16(buf: *u8, off: i64, v: i64) -> i64
96func _turn_write_be32(buf: *u8, off: i64, v: i64) -> i64
130func nx_turn_parse_allocate(buf: *u8, n: i64,
192func _turn_write_xor_address(buf: *u8, off: i64, attr_type: i64,
212func _turn_write_lifetime(buf: *u8, off: i64, lifetime_sec: i64) -> i64
229func nx_turn_build_allocate_success(out_buf: *u8, tx_id: *u8,
272func nx_turn_build_allocate_error(out_buf: *u8, tx_id: *u8,
314func nx_turn_allocate_roundtrip_test(scratch: *u8) -> i64
355func _turn_write_data_attr(buf: *u8, off: i64,
389func nx_turn_build_send_indication(out_buf: *u8, tx_id: *u8,
413func nx_turn_build_data_indication(out_buf: *u8, tx_id: *u8,
442func nx_turn_parse_indication(buf: *u8, n: i64,
520func nx_turn_send_data_roundtrip_test(scratch: *u8) -> i64
593func nx_turn_build_refresh_request(out_buf: *u8, tx_id: *u8,
607func nx_turn_parse_refresh(buf: *u8, n: i64,
651func nx_turn_build_refresh_success(out_buf: *u8, tx_id: *u8,
669func nx_turn_build_create_perm_request(out_buf: *u8, tx_id: *u8,
683func nx_turn_build_create_perm_success(out_buf: *u8, tx_id: *u8) -> i64
698func nx_turn_build_channel_bind_request(out_buf: *u8, tx_id: *u8,
721func nx_turn_build_channel_bind_success(out_buf: *u8, tx_id: *u8) -> i64
737func nx_turn_build_channel_data(out_buf: *u8,
760func nx_turn_parse_channel_data(buf: *u8, n: i64,
784func nx_turn_phase_a3_smoke(scratch: *u8) -> i64
861func nx_turn_build_success_test(scratch: *u8) -> i64