oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1import Foundation
2
3/// For the gate only: a connection's ICE made to fail, as a path that
4/// stops carrying anything does (2026-10-21's incident, a peer whose
5/// connection never came up).
6///
7/// While the block lasts every ICE candidate this app sends or receives —
8/// trickled, or written into a description — has its port replaced by 9,
9/// the discard port, which nothing on the gate's Mac listens on. Both ends
10/// then hold only candidates that lead nowhere, neither receives a check
11/// from the other (so neither can learn a peer-reflexive address), and ICE
12/// runs to `failed`. When the block lifts nothing is undone: the candidates
13/// already exchanged stay wrong, and only an ICE restart (new candidates)
14/// or a new connection gets the pair talking. That is the incident's shape.
15///
16/// Inert unless the interop harness sets `until`; the apps never do.
17enum ICETestBlock {
18 /// Until when (system uptime) candidates are mangled; 0 is never.
19 @MainActor static var until: Double = 0
20 /// Candidates mangled so far, for the gate.
21 @MainActor static var mangled: UInt64 = 0
22
23 @MainActor static var active: Bool { until > 0 && ProcessInfo.processInfo.systemUptime < until }
24
25 /// One candidate line, `candidate:…` or `a=candidate:…`, with its port
26 /// replaced. Anything that is not a candidate line comes back as it was.
27 static func mangle(candidate line: String) -> String {
28 var fields = line.split(separator: " ", omittingEmptySubsequences: false).map(String.init)
29 guard fields.count > 7, fields[0].hasPrefix("candidate:") || fields[0].hasPrefix("a=candidate:"),
30 fields[6] == "typ"
31 else { return line }
32 fields[5] = "9"
33 return fields.joined(separator: " ")
34 }
35
36 /// A description with every candidate line in it mangled.
37 static func mangle(sdp: String) -> String {
38 let lines = sdp.components(separatedBy: "\r\n")
39 return lines.map { $0.hasPrefix("a=candidate:") ? mangle(candidate: $0) : $0 }.joined(separator: "\r\n")
40 }
41}
42