@amritk/nish-x86_64-linux 0.49.1 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/INSTALL.md +1 -1
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +237 -160
  4. package/package.json +1 -1
  5. package/runtime/gfx/nish-gfx.h +373 -61
  6. package/runtime/nish.d.ts +94 -11
  7. package/runtime/nish.h +5 -0
  8. package/runtime/runtime-host.c +21 -5
  9. package/std/README.md +14 -11
  10. package/std/base64.ts +74 -35
  11. package/std/bytes.ts +207 -97
  12. package/std/cli-args.ts +150 -107
  13. package/std/compress/checksum.ts +68 -10
  14. package/std/compress/deflate.ts +213 -115
  15. package/std/compress/gzip.ts +124 -49
  16. package/std/compress/zlib.ts +57 -15
  17. package/std/crypto/aes.ts +51 -9
  18. package/std/crypto/base64url.ts +93 -66
  19. package/std/crypto/bcrypt.ts +25 -21
  20. package/std/crypto/ed25519.ts +12 -10
  21. package/std/crypto/hkdf.ts +405 -283
  22. package/std/crypto/hmac.ts +484 -149
  23. package/std/crypto/jwt.ts +51 -40
  24. package/std/crypto/p256.ts +14 -19
  25. package/std/crypto/pki-roots.ts +35 -12
  26. package/std/crypto/pki.ts +43 -55
  27. package/std/crypto/rsa-sign.ts +1635 -0
  28. package/std/crypto/rsa.ts +26 -4
  29. package/std/crypto/sha256.ts +212 -90
  30. package/std/crypto/sha512.ts +135 -49
  31. package/std/crypto/x25519.ts +12 -11
  32. package/std/crypto/x509.ts +164 -40
  33. package/std/gpu/sys.ts +490 -0
  34. package/std/json-equal.ts +33 -18
  35. package/std/json-format.ts +39 -8
  36. package/std/json-number.ts +15 -3
  37. package/std/json-tokenizer.ts +4 -3
  38. package/std/json-typed.ts +12 -6
  39. package/std/json-value.ts +236 -119
  40. package/std/json.ts +81 -46
  41. package/std/net/buffer-pool.ts +25 -14
  42. package/std/net/dns-config.ts +18 -5
  43. package/std/net/dns-message.ts +60 -27
  44. package/std/net/dns-resolver.ts +35 -16
  45. package/std/net/dns.ts +3 -2
  46. package/std/net/fetch.ts +224 -61
  47. package/std/net/handler.ts +189 -88
  48. package/std/net/hpack.ts +216 -103
  49. package/std/net/http-compress.ts +104 -42
  50. package/std/net/http-fields.ts +327 -31
  51. package/std/net/http-server.ts +326 -24
  52. package/std/net/http1-client-codec.ts +159 -55
  53. package/std/net/http1-codec.ts +427 -237
  54. package/std/net/http1-server.ts +220 -38
  55. package/std/net/http2-cleartext.ts +10 -4
  56. package/std/net/http2-frame.ts +2 -2
  57. package/std/net/http2-tls.ts +3 -3
  58. package/std/net/http2.ts +69 -15
  59. package/std/net/http3-frame.ts +11 -14
  60. package/std/net/http3-server.ts +139 -60
  61. package/std/net/http3.ts +140 -79
  62. package/std/net/multipart.ts +592 -0
  63. package/std/net/outbound.ts +24 -8
  64. package/std/net/postgres-async.ts +97 -64
  65. package/std/net/postgres-carrier.ts +28 -4
  66. package/std/net/postgres.ts +166 -65
  67. package/std/net/prefork.ts +86 -5
  68. package/std/net/protobuf.ts +6 -2
  69. package/std/net/qpack.ts +147 -40
  70. package/std/net/quic-conn-ack.ts +27 -7
  71. package/std/net/quic-conn-cid.ts +13 -7
  72. package/std/net/quic-datagram.ts +6 -5
  73. package/std/net/quic-frame.ts +67 -23
  74. package/std/net/quic-listener.ts +61 -39
  75. package/std/net/quic-packet.ts +91 -50
  76. package/std/net/quic-recovery.ts +11 -9
  77. package/std/net/quic-stream.ts +36 -27
  78. package/std/net/quic.ts +84 -54
  79. package/std/net/router.ts +136 -24
  80. package/std/net/serve.ts +59 -5
  81. package/std/net/static.ts +86 -36
  82. package/std/net/tls/client.ts +81 -34
  83. package/std/net/tls/codec.ts +3 -4
  84. package/std/net/tls/record.ts +80 -35
  85. package/std/net/tls/schedule.ts +339 -149
  86. package/std/net/tls/ticket.ts +6 -5
  87. package/std/net/tls-tcp.ts +69 -30
  88. package/std/net/tls.ts +194 -50
  89. package/std/net/upstream.ts +83 -38
  90. package/std/net/url.ts +170 -94
  91. package/std/net/websocket.ts +19 -20
  92. package/std/net/webtransport.ts +123 -33
  93. package/std/raster.ts +12 -2
  94. package/std/regex.ts +600 -388
  95. package/std/sqlite.ts +37 -19
  96. package/std/sync/ring.ts +232 -115
  97. package/std/sync/shm.ts +11 -4
  98. package/std/temporal.ts +232 -133
  99. package/std/term-io.ts +12 -6
  100. package/std/term-pixels.ts +176 -24
  101. package/std/term-rate.ts +8 -3
  102. package/std/term.ts +4 -4
  103. package/std/text.ts +38 -16
  104. package/std/yaml-json.ts +238 -106
  105. package/std/yaml-lines.ts +47 -27
  106. package/std/yaml-write.ts +58 -24
  107. package/std/yaml.ts +808 -395
@@ -12,7 +12,7 @@
12
12
  * import { QuicServerConfig } from "nish/net/quic";
13
13
  * import { QUIC_LISTENER_ENTROPY_SIZE } from "nish/net/quic-listener";
14
14
  *
15
- * // `quicConfig.alpn` is ["h3"]; `privateKey` is the P-256 key of its certificate.
15
+ * // `quicConfig.alpn` is ["h3"]; `privateKey` is its certificate's key, P-256 or RSA.
16
16
  * const run = (quicConfig: QuicServerConfig, privateKey: u8[], rounds: i32): void => {
17
17
  * const fd: i32 = udpBind("0.0.0.0", 4433, 0);
18
18
  * const listenerEntropy: u8[] = new Array<u8>(QUIC_LISTENER_ENTROPY_SIZE);
@@ -149,7 +149,7 @@ import {
149
149
  quicListenerFlightTime,
150
150
  quicListenerTakeFlight,
151
151
  } from "nish/net/quic-listener"
152
- import { TlsP256Signer } from "nish/net/tls"
152
+ import { TlsKeySigner } from "nish/net/tls"
153
153
 
154
154
  /** The timer wheel's buckets, one millisecond each: its horizon. */
155
155
  export const H3_SERVER_WHEEL: i32 = 2048
@@ -743,13 +743,14 @@ export class Http3Server {
743
743
  private from: u8[]
744
744
  private meta: i32[]
745
745
  /**
746
- * `QUIC_CONN_ENTROPY_SIZE` bytes of scratch, refilled from `crypto.getRandomValues` for each slot built
747
- * and each connection accepted; it holds the last one's until the next, and `stop` zeroes it.
746
+ * `QUIC_CONN_ENTROPY_SIZE` bytes of scratch, filled from `crypto.tryGetRandomValues` for each
747
+ * connection accepted and zeroed by the connection that copies it, so it holds zeros between
748
+ * accepts; `stop` zeroes it too.
748
749
  */
749
750
  entropy: u8[]
750
751
  private flight: QuicFlight
751
752
  /** Signs every slot's CertificateVerify in `serve`, one for the server, keeping nothing per signature. */
752
- private signer: TlsP256Signer
753
+ private signer: TlsKeySigner
753
754
  /** Each slot's connection-ID index signature, so it is refiled only when its IDs changed. */
754
755
  private signatures: i64[]
755
756
  private state: i32[]
@@ -793,6 +794,11 @@ export class Http3Server {
793
794
  accepted: i32 = 0
794
795
  /** Initials dropped because no slot was free, saturating at 2^31 - 1. */
795
796
  refused: i32 = 0
797
+ /**
798
+ * Initials dropped because the entropy source failed (`crypto.tryGetRandomValues`
799
+ * answered false) before a slot was taken, saturating at 2^31 - 1; the slot stays free.
800
+ */
801
+ starved: i32 = 0
796
802
  /** Datagrams no slot owns dropped past the answer budget before the listener read them, saturating. */
797
803
  limited: i32 = 0
798
804
  private sendErrors: i32 = 0
@@ -821,22 +827,15 @@ export class Http3Server {
821
827
  * @param quicConfig The QUIC configuration, kept by reference and shared by the listener and every slot.
822
828
  * @param config The HTTP/3 configuration, kept by reference; its `bodyChunk` and `maxFieldSectionSize`
823
829
  * size the shared buffer pools.
830
+ * An `idleTimeout` or `headTimeout` under 1 panics here, before a peer's first Initial reaches a slot;
831
+ * `openHttp3Server` answers it and a `size` out of range as an `Err` instead.
824
832
  * @param fd The bound UDP socket, kept; the server does not close it.
825
- * @param size How many slots, 1 to 65536; any other panics, as does an `idleTimeout` or `headTimeout`
826
- * under 1.
833
+ * @param size How many slots, 1 to 65536; any other panics, a contract of this constructor.
827
834
  * @param listenerEntropy `QUIC_LISTENER_ENTROPY_SIZE` random bytes, copied and then zeroed in this array.
828
835
  */
829
836
  constructor(quicConfig: QuicServerConfig, config: Http3Config, fd: i32, size: i32, listenerEntropy: u8[]) {
830
- if (size < 1 || size > 65536) {
831
- panic(`Http3Server: ${size} slots, outside 1 to 65536`)
832
- }
833
- // Checked here as well as by each slot's connection, which is built only on its first Initial.
834
- if (config.idleTimeout < 1) {
835
- panic(`Http3Server: idleTimeout of ${config.idleTimeout}, outside 1 to 2147483647`)
836
- }
837
- if (config.headTimeout < 1) {
838
- panic(`Http3Server: headTimeout of ${config.headTimeout}, outside 1 to 2147483647`)
839
- }
837
+ http3ServerCheckSize(size)
838
+ http3ServerCheckTimeouts(config)
840
839
  this.quicConfig = quicConfig
841
840
  this.config = config
842
841
  this.fd = fd
@@ -886,7 +885,7 @@ export class Http3Server {
886
885
  this.from = new Array<u8>(H3_SERVER_ADDRESS)
887
886
  this.meta = [H3_SERVER_ZERO, H3_SERVER_ZERO]
888
887
  this.flight = new QuicFlight()
889
- this.signer = new TlsP256Signer()
888
+ this.signer = new TlsKeySigner(quicConfig.signatureScheme)
890
889
  this.signatures = http3ServerZeroTimes(size)
891
890
  this.state = http3ServerFilled(size, H3_SERVER_ZERO)
892
891
  this.readyRing = http3ServerFilled(size, H3_SERVER_ZERO)
@@ -897,13 +896,16 @@ export class Http3Server {
897
896
  }
898
897
 
899
898
  /**
900
- * Builds the next slot, `quics.length`: its QUIC connection under fresh
901
- * entropy, sharing `streamPools` when its stream table is the one they
902
- * were made for, its HTTP/3 connection on the pool's buffers and `date`,
903
- * and its address.
899
+ * Builds the next slot, `quics.length`: its QUIC connection, sharing
900
+ * `streamPools` when its stream table is the one they were made for, its
901
+ * HTTP/3 connection on the pool's buffers and `date`, and its address.
902
+ * The QUIC connection is made from `entropy` as it stands, zeros (each
903
+ * connection zeroes it once copied): a built slot meets no peer and its
904
+ * connection IDs are not indexed until an accept takes it, and the accept
905
+ * seeds it again with `reset` from bytes the source gave, so no
906
+ * connection a peer reaches runs on these.
904
907
  */
905
908
  private build(): void {
906
- crypto.getRandomValues(this.entropy)
907
909
  const quic = new QuicConnection(this.quicConfig, this.entropy)
908
910
  quic.ecnMarking = this.ecn
909
911
  this.quics.push(quic)
@@ -1092,7 +1094,7 @@ export class Http3Server {
1092
1094
  /**
1093
1095
  * Reads every datagram waiting on the socket, in at most
1094
1096
  * `H3_SERVER_RECEIVE_BURST` receives, and hands each to its slot or the listener,
1095
- * signing a handshake's CertificateVerify with `key` (ECDSA P-256) when one
1097
+ * signing a handshake's CertificateVerify with `key` (in `signatureScheme`) when one
1096
1098
  * asks. A GRO receive is cut into its datagrams in place. Answers how many
1097
1099
  * datagrams it read.
1098
1100
  * @param now The current millisecond on the caller's monotonic clock.
@@ -1102,18 +1104,15 @@ export class Http3Server {
1102
1104
  */
1103
1105
  receive(now: i64, key: Secret<u8[]>): i32 {
1104
1106
  let count: i32 = 0
1107
+ // The whole of `rx`, which is `H3_SERVER_RECEIVE_SIZE` bytes: read through
1108
+ // a local so the bounds prover sees the window is its own length.
1109
+ const rx: u8[] = this.rx
1105
1110
  for (let burst: i32 = 0; burst < H3_SERVER_RECEIVE_BURST; burst++) {
1106
- const n: i32 = udpRecvFrom(
1107
- this.fd,
1108
- this.rx,
1109
- H3_SERVER_ZERO,
1110
- H3_SERVER_RECEIVE_SIZE,
1111
- this.from,
1112
- this.meta
1113
- )
1111
+ const n: i32 = udpRecvFrom(this.fd, rx, 0, toI32(rx.length), this.from, this.meta)
1114
1112
  const meta: i32[] = this.meta
1115
1113
  // Past the first term, never taken: `udpRecvFrom` reads at most the
1116
- // `H3_SERVER_RECEIVE_SIZE` it is given, and `meta` is the constructor's two words.
1114
+ // length of `rx` it is given, `H3_SERVER_RECEIVE_SIZE`, and `meta` is the
1115
+ // constructor's two words.
1117
1116
  if (n < 0 || n > 65536 || toI32(meta.length) < 2) {
1118
1117
  return count
1119
1118
  }
@@ -1124,7 +1123,7 @@ export class Http3Server {
1124
1123
  while (at >= 0 && at < n && segment > 0) {
1125
1124
  const left: i32 = n - at
1126
1125
  const length: i32 = left < segment ? left : segment
1127
- this.datagram(this.rx, at, length, this.from, now, key)
1126
+ this.datagram(rx, at, length, this.from, now, key)
1128
1127
  count = h3Count(count)
1129
1128
  if (length < left) {
1130
1129
  at = at + length
@@ -1193,7 +1192,7 @@ export class Http3Server {
1193
1192
  if (this.listener.handleWindow(buf, at, len, address, now, answer) !== QUIC_LISTEN_ACCEPT) {
1194
1193
  const reply: i32 = toI32(answer.reply.length)
1195
1194
  if (reply > 0) {
1196
- this.send(answer.reply, H3_SERVER_ZERO, reply, address, H3_SERVER_ZERO, H3_SERVER_ZERO)
1195
+ this.send(answer.reply, reply, address, H3_SERVER_ZERO, H3_SERVER_ZERO)
1197
1196
  }
1198
1197
  return
1199
1198
  }
@@ -1227,7 +1226,13 @@ export class Http3Server {
1227
1226
  const addresses: u8[][] = this.addresses
1228
1227
  const state: i32[] = this.state
1229
1228
  const signatures: i64[] = this.signatures
1230
- crypto.getRandomValues(this.entropy)
1229
+ // A source that fails drops the Initial before the slot is taken; the peer may send it again.
1230
+ // The fill may have written a prefix, which is zeroed with the rest.
1231
+ if (!crypto.tryGetRandomValues(this.entropy)) {
1232
+ secureZero(this.entropy)
1233
+ this.starved = h3Count(this.starved)
1234
+ return
1235
+ }
1231
1236
  // Never taken: a released slot was built, `slotAt` builds the one it answers, and
1232
1237
  // `state` and `signatures` are `size` long.
1233
1238
  if (
@@ -1446,11 +1451,16 @@ export class Http3Server {
1446
1451
  }
1447
1452
 
1448
1453
  /**
1449
- * Sends `buf[at .. at + len)` to `to` with the ECN codepoint `ecn`, cut
1450
- * into `segment`-byte datagrams when it is above 0; answers whether it went.
1454
+ * Sends `buf[0 .. len)` to `to` with the ECN codepoint `ecn`, cut into
1455
+ * `segment`-byte datagrams when it is above 0; answers whether it went.
1451
1456
  */
1452
- private send(buf: u8[], at: i32, len: i32, to: u8[], segment: i32, ecn: i32): boolean {
1453
- const sent: i32 = udpSendTo(this.fd, buf, at, len, to, segment, ecn)
1457
+ private send(buf: u8[], len: i32, to: u8[], segment: i32, ecn: i32): boolean {
1458
+ if (len < 0 || len > toI32(buf.length)) {
1459
+ // Never taken: every caller sends the first `len` bytes of `buf`, a
1460
+ // count its writer answered for the buffer it wrote into.
1461
+ return false
1462
+ }
1463
+ const sent: i32 = udpSendTo(this.fd, buf, 0, len, to, segment, ecn)
1454
1464
  if (sent >= 0) {
1455
1465
  return true
1456
1466
  }
@@ -1466,34 +1476,37 @@ export class Http3Server {
1466
1476
  mark = H3_SERVER_ZERO
1467
1477
  }
1468
1478
  const step: i32 = segment > 0 ? segment : len
1469
- if (at < 0 || len < 0) {
1470
- // Never taken: `udpSendTo` above took `buf[at .. at + len)`.
1471
- return false
1472
- }
1473
- let p: i32 = at
1474
- let left: i32 = len
1475
- while (left > 0) {
1476
- const n: i32 = left < step ? left : step
1477
- let one: i32 = udpSendTo(this.fd, buf, p, n, to, H3_SERVER_ZERO, mark)
1479
+ if (step <= 0 || len > toI32(buf.length)) {
1480
+ // Never taken past an empty send: `len` was checked above and
1481
+ // `udpSendTo` does not resize `buf`.
1482
+ return len === 0
1483
+ }
1484
+ let p: i32 = 0
1485
+ while (p >= 0 && p < len) {
1486
+ // The datagram's end: `p + step` when that is short of `len`, so it fits an i32.
1487
+ const q: i32 = p < len - step ? toI32(toI64(p) + toI64(step)) : len
1488
+ if (q < p || q > toI32(buf.length)) {
1489
+ // Never taken: `p <= q <= len`, and `len` fits `buf`.
1490
+ return false
1491
+ }
1492
+ let one: i32 = udpSendTo(this.fd, buf, p, q - p, to, H3_SERVER_ZERO, mark)
1478
1493
  if (one === H3_SERVER_UNSUPPORTED && mark !== 0) {
1479
1494
  // No ECN here: this datagram and the rest go unmarked and no slot
1480
1495
  // marks again. The packets just counted as marked fail their
1481
1496
  // connection's validation.
1482
1497
  this.unmark()
1483
1498
  mark = H3_SERVER_ZERO
1484
- one = udpSendTo(this.fd, buf, p, n, to, H3_SERVER_ZERO, mark)
1499
+ if (q > toI32(buf.length)) {
1500
+ // Never taken: `unmark` does not resize `buf`.
1501
+ return false
1502
+ }
1503
+ one = udpSendTo(this.fd, buf, p, q - p, to, H3_SERVER_ZERO, mark)
1485
1504
  }
1486
1505
  if (one < 0) {
1487
1506
  this.sendErrors = h3Count(this.sendErrors)
1488
1507
  return false
1489
1508
  }
1490
- if (n < 0 || n > left) {
1491
- // Never taken: `n` is the smaller of `left` and a positive `step`.
1492
- return false
1493
- }
1494
- left = left - n
1495
- // `p + n`, at most `at + len`, which `udpSendTo` took, so it fits an i32.
1496
- p = toI32(toI64(p) + toI64(n))
1509
+ p = q
1497
1510
  }
1498
1511
  return true
1499
1512
  }
@@ -1564,7 +1577,7 @@ export class Http3Server {
1564
1577
  // the flight below picks where it goes.
1565
1578
  const probe: i32 = quic.takeProbeInto(this.tx, H3_SERVER_ZERO, now)
1566
1579
  if (probe > 0) {
1567
- this.send(this.tx, H3_SERVER_ZERO, probe, quic.probeAddress, H3_SERVER_ZERO, H3_SERVER_ZERO)
1580
+ this.send(this.tx, probe, quic.probeAddress, H3_SERVER_ZERO, H3_SERVER_ZERO)
1568
1581
  }
1569
1582
  if (quic.pathKnown) {
1570
1583
  const current: u8[] = quic.sendAddress()
@@ -1592,7 +1605,7 @@ export class Http3Server {
1592
1605
  break
1593
1606
  }
1594
1607
  const segment: i32 = this.flight.count > 1 ? this.flight.segment : H3_SERVER_ZERO
1595
- if (!this.send(this.tx, H3_SERVER_ZERO, n, to, segment, this.flight.ecn)) {
1608
+ if (!this.send(this.tx, n, to, segment, this.flight.ecn)) {
1596
1609
  break
1597
1610
  }
1598
1611
  retried = false
@@ -1601,7 +1614,7 @@ export class Http3Server {
1601
1614
  // The CONNECTION_CLOSE goes whatever the pacer says: nothing follows it.
1602
1615
  const n: i32 = quic.takeDatagramInto(this.tx, H3_SERVER_ZERO, now)
1603
1616
  if (n > 0) {
1604
- this.send(this.tx, H3_SERVER_ZERO, n, to, H3_SERVER_ZERO, quic.datagramEcn)
1617
+ this.send(this.tx, n, to, H3_SERVER_ZERO, quic.datagramEcn)
1605
1618
  }
1606
1619
  this.release(slot)
1607
1620
  return
@@ -1794,3 +1807,69 @@ export class Http3Server {
1794
1807
  return this.wheel.next(now)
1795
1808
  }
1796
1809
  }
1810
+
1811
+ /** Why `config`'s timeouts cannot make a server, or `""` when they can: an `idleTimeout` or `headTimeout` under 1. */
1812
+ const http3ServerTimeoutFault = (config: Http3Config): string => {
1813
+ if (config.idleTimeout < 1) {
1814
+ return `Http3Server: idleTimeout of ${config.idleTimeout}, outside 1 to 2147483647`
1815
+ }
1816
+ if (config.headTimeout < 1) {
1817
+ return `Http3Server: headTimeout of ${config.headTimeout}, outside 1 to 2147483647`
1818
+ }
1819
+ return ""
1820
+ }
1821
+
1822
+ /** Why `size` cannot be a server's slot count, or `""` when it can. */
1823
+ const http3ServerSizeFault = (size: i32): string => {
1824
+ if (size < 1 || size > 65536) {
1825
+ return `Http3Server: ${size} slots, outside 1 to 65536`
1826
+ }
1827
+ return ""
1828
+ }
1829
+
1830
+ /** Panics unless `config`'s timeouts can make a server, at its construction: a timeout under 1 is the program's mistake. */
1831
+ const http3ServerCheckTimeouts = (config: Http3Config): void => {
1832
+ const fault: string = http3ServerTimeoutFault(config)
1833
+ if (fault.length > 0) {
1834
+ panic(fault)
1835
+ }
1836
+ }
1837
+
1838
+ /** Panics unless `size` can be a server's slot count: a count out of range is the program's mistake. */
1839
+ const http3ServerCheckSize = (size: i32): void => {
1840
+ const fault: string = http3ServerSizeFault(size)
1841
+ if (fault.length > 0) {
1842
+ panic(fault)
1843
+ }
1844
+ }
1845
+
1846
+ /**
1847
+ * A server as `new Http3Server(quicConfig, config, fd, size, listenerEntropy)`
1848
+ * makes one, with a slot count out of range and an `idleTimeout` or
1849
+ * `headTimeout` under 1, which that constructor panics on, answered as an
1850
+ * `Err` before anything is built or `listenerEntropy` is touched.
1851
+ * @param quicConfig The QUIC configuration, as the constructor keeps it.
1852
+ * @param config The HTTP/3 configuration, as the constructor keeps it.
1853
+ * @param fd The bound UDP socket, kept; the server does not close it.
1854
+ * @param size How many slots, 1 to 65536.
1855
+ * @param listenerEntropy `QUIC_LISTENER_ENTROPY_SIZE` random bytes, copied and then zeroed in this array
1856
+ * when the server is built.
1857
+ * @returns `Ok` with the server, or `Err` saying which of `size`, `idleTimeout` and `headTimeout` is out of range.
1858
+ */
1859
+ export const openHttp3Server = (
1860
+ quicConfig: QuicServerConfig,
1861
+ config: Http3Config,
1862
+ fd: i32,
1863
+ size: i32,
1864
+ listenerEntropy: u8[]
1865
+ ): Result<Http3Server, string> => {
1866
+ const timeouts: string = http3ServerTimeoutFault(config)
1867
+ if (timeouts.length > 0) {
1868
+ return Err(timeouts)
1869
+ }
1870
+ const fault: string = http3ServerSizeFault(size)
1871
+ if (fault.length > 0) {
1872
+ return Err(fault)
1873
+ }
1874
+ return Ok(new Http3Server(quicConfig, config, fd, size, listenerEntropy))
1875
+ }