@ttsc/win32-arm64 0.33.1 → 0.34.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 (1062) hide show
  1. package/bin/go/VERSION +2 -2
  2. package/bin/go/bin/go.exe +0 -0
  3. package/bin/go/bin/gofmt.exe +0 -0
  4. package/bin/go/lib/time/update.bash +2 -2
  5. package/bin/go/lib/time/zoneinfo.zip +0 -0
  6. package/bin/go/pkg/include/asm_ppc64x.h +0 -16
  7. package/bin/go/pkg/tool/windows_arm64/asm.exe +0 -0
  8. package/bin/go/pkg/tool/windows_arm64/cgo.exe +0 -0
  9. package/bin/go/pkg/tool/windows_arm64/compile.exe +0 -0
  10. package/bin/go/pkg/tool/windows_arm64/cover.exe +0 -0
  11. package/bin/go/pkg/tool/windows_arm64/fix.exe +0 -0
  12. package/bin/go/pkg/tool/windows_arm64/link.exe +0 -0
  13. package/bin/go/pkg/tool/windows_arm64/preprofile.exe +0 -0
  14. package/bin/go/pkg/tool/windows_arm64/vet.exe +0 -0
  15. package/bin/go/src/archive/tar/reader.go +2 -1
  16. package/bin/go/src/archive/zip/reader.go +5 -29
  17. package/bin/go/src/archive/zip/struct.go +5 -6
  18. package/bin/go/src/archive/zip/writer.go +120 -60
  19. package/bin/go/src/bufio/bufio.go +1 -1
  20. package/bin/go/src/bytes/buffer.go +3 -3
  21. package/bin/go/src/bytes/bytes.go +45 -25
  22. package/bin/go/src/compress/flate/deflate.go +512 -363
  23. package/bin/go/src/compress/flate/deflatefast.go +156 -262
  24. package/bin/go/src/compress/flate/dict_decoder.go +1 -4
  25. package/bin/go/src/compress/flate/huffman_bit_writer.go +673 -250
  26. package/bin/go/src/compress/flate/huffman_code.go +164 -92
  27. package/bin/go/src/compress/flate/level1.go +195 -0
  28. package/bin/go/src/compress/flate/level2.go +190 -0
  29. package/bin/go/src/compress/flate/level3.go +228 -0
  30. package/bin/go/src/compress/flate/level4.go +200 -0
  31. package/bin/go/src/compress/flate/level5.go +287 -0
  32. package/bin/go/src/compress/flate/level6.go +297 -0
  33. package/bin/go/src/compress/flate/load_store.go +43 -0
  34. package/bin/go/src/compress/flate/regmask_amd64.go +9 -0
  35. package/bin/go/src/compress/flate/regmask_other.go +11 -0
  36. package/bin/go/src/compress/flate/token.go +238 -26
  37. package/bin/go/src/compress/gzip/gzip.go +8 -0
  38. package/bin/go/src/compress/zlib/writer.go +12 -0
  39. package/bin/go/src/context/context.go +6 -5
  40. package/bin/go/src/crypto/cipher/gcm.go +0 -4
  41. package/bin/go/src/crypto/crypto.go +27 -4
  42. package/bin/go/src/crypto/des/const.go +1 -1
  43. package/bin/go/src/crypto/ecdsa/ecdsa.go +21 -4
  44. package/bin/go/src/crypto/ed25519/ed25519.go +13 -0
  45. package/bin/go/src/crypto/internal/boring/aes.go +2 -3
  46. package/bin/go/src/crypto/internal/cryptotest/aead.go +53 -0
  47. package/bin/go/src/crypto/internal/cryptotest/boundary.go +34 -0
  48. package/bin/go/src/crypto/internal/cryptotest/boundary_compat.go +16 -0
  49. package/bin/go/src/crypto/internal/cryptotest/fetchmodule.go +9 -3
  50. package/bin/go/src/crypto/internal/cryptotest/fips140.go +62 -3
  51. package/bin/go/src/crypto/internal/cryptotest/hash.go +14 -0
  52. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod +19 -0
  53. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum +27 -0
  54. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/schema_gen.go +151 -0
  55. package/bin/go/src/crypto/internal/cryptotest/wycheproof/schema.go +9792 -0
  56. package/bin/go/src/crypto/internal/cryptotest/wycheproof/schemaversion.go +11 -0
  57. package/bin/go/src/crypto/internal/cryptotest/wycheproof/wycheproof.go +165 -0
  58. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/go.mod +14 -0
  59. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/go.sum +25 -0
  60. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/schema_gen.go +125 -0
  61. package/bin/go/src/crypto/internal/cryptotest/x509limbo/schema.go +591 -0
  62. package/bin/go/src/crypto/internal/cryptotest/x509limbo/schemaversion.go +14 -0
  63. package/bin/go/src/crypto/internal/fips140/aes/_asm/ctr/go.mod +1 -1
  64. package/bin/go/src/crypto/internal/fips140/aes/_asm/standard/go.mod +1 -1
  65. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/gcm_amd64_asm.go +36 -32
  66. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/go.mod +5 -5
  67. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/go.sum +8 -6
  68. package/bin/go/src/crypto/internal/fips140/aes/gcm/gcm_amd64.s +29 -17
  69. package/bin/go/src/crypto/internal/fips140/aes/gcm/gcm_arm64.s +73 -72
  70. package/bin/go/src/crypto/internal/fips140/aes/gcm/ghash.go +140 -124
  71. package/bin/go/src/crypto/internal/fips140/bigmod/nat.go +18 -0
  72. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_loong64.s +23 -0
  73. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_none.go +1 -1
  74. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_stub.go +1 -1
  75. package/bin/go/src/crypto/internal/fips140/drbg/rand.go +12 -4
  76. package/bin/go/src/crypto/internal/fips140/ecdsa/ecdsa.go +17 -10
  77. package/bin/go/src/crypto/internal/fips140/edwards25519/field/_asm/fe_amd64_asm.go +0 -90
  78. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe.go +64 -97
  79. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64.go +0 -5
  80. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64.s +0 -167
  81. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64_noasm.go +0 -2
  82. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_generic.go +57 -1
  83. package/bin/go/src/crypto/internal/fips140/edwards25519/scalarmult.go +3 -2
  84. package/bin/go/src/crypto/internal/fips140/mldsa/mldsa.go +31 -25
  85. package/bin/go/src/crypto/internal/fips140/mldsa/semiexpanded.go +2 -2
  86. package/bin/go/src/crypto/internal/fips140/nistec/_asm/go.mod +4 -4
  87. package/bin/go/src/crypto/internal/fips140/nistec/_asm/go.sum +6 -0
  88. package/bin/go/src/crypto/internal/fips140/nistec/_asm/p256_asm.go +1 -613
  89. package/bin/go/src/crypto/internal/fips140/nistec/p256.go +2 -2
  90. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm.go +7 -6
  91. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm_amd64.s +0 -503
  92. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm_arm64.s +4 -429
  93. package/bin/go/src/crypto/internal/fips140/nistec/p256_ordinv.go +511 -47
  94. package/bin/go/src/crypto/internal/fips140/pbkdf2/pbkdf2.go +1 -1
  95. package/bin/go/src/crypto/internal/fips140/rsa/keygen.go +48 -46
  96. package/bin/go/src/crypto/internal/fips140/rsa/largeexponent.go +365 -0
  97. package/bin/go/src/crypto/internal/fips140/rsa/pkcs1v15.go +27 -0
  98. package/bin/go/src/crypto/internal/fips140/sha256/_asm/go.mod +1 -1
  99. package/bin/go/src/crypto/internal/fips140/sha3/_asm/go.mod +1 -1
  100. package/bin/go/src/crypto/internal/fips140/sha512/_asm/go.mod +1 -1
  101. package/bin/go/src/crypto/internal/fips140/subtle/constant_time.go +1 -1
  102. package/bin/go/src/crypto/internal/fips140/subtle/xor_asm.go +1 -1
  103. package/bin/go/src/crypto/internal/fips140/subtle/xor_riscv64.go +18 -0
  104. package/bin/go/src/crypto/internal/fips140/subtle/xor_riscv64.s +33 -2
  105. package/bin/go/src/crypto/internal/fips140deps/cpu/cpu.go +2 -0
  106. package/bin/go/src/crypto/internal/fips140deps/time/time.go +7 -4
  107. package/bin/go/src/crypto/internal/fips140only/fips140only.go +0 -7
  108. package/bin/go/src/crypto/internal/fips140only/random_fips140v1.0.go +17 -0
  109. package/bin/go/src/crypto/internal/fips140only/random_fips140v1.28.go +16 -0
  110. package/bin/go/src/crypto/internal/fips140test/acvp_capabilities_fips140v1.28.json +86 -0
  111. package/bin/go/src/crypto/internal/fips140test/acvp_test_fips140v1.28.config.json +58 -0
  112. package/bin/go/src/crypto/internal/rand/rand.go +14 -14
  113. package/bin/go/src/crypto/internal/rand/random_fips140v1.0.go +20 -0
  114. package/bin/go/src/crypto/internal/rand/random_fips140v1.28.go +19 -0
  115. package/bin/go/src/crypto/mldsa/mldsa.go +97 -0
  116. package/bin/go/src/crypto/mldsa/mldsa_fips140v1.0.go +116 -0
  117. package/bin/go/src/crypto/mldsa/mldsa_fips140v1.26.go +226 -0
  118. package/bin/go/src/crypto/mlkem/mlkem.go +8 -2
  119. package/bin/go/src/crypto/rsa/fips.go +26 -8
  120. package/bin/go/src/crypto/rsa/pkcs1v15.go +2 -2
  121. package/bin/go/src/crypto/rsa/rsa.go +25 -2
  122. package/bin/go/src/crypto/sha1/sha1block_decl.go +1 -1
  123. package/bin/go/src/crypto/sha1/sha1block_generic.go +1 -1
  124. package/bin/go/src/crypto/sha1/sha1block_loong64.s +24 -8
  125. package/bin/go/src/crypto/sha1/sha1block_riscv64.s +225 -0
  126. package/bin/go/src/crypto/sha3/sha3.go +3 -2
  127. package/bin/go/src/crypto/tls/alert.go +2 -0
  128. package/bin/go/src/crypto/tls/auth.go +31 -0
  129. package/bin/go/src/crypto/tls/bogo_config.json +12 -23
  130. package/bin/go/src/crypto/tls/cipher_suites.go +3 -11
  131. package/bin/go/src/crypto/tls/common.go +106 -59
  132. package/bin/go/src/crypto/tls/common_string.go +18 -5
  133. package/bin/go/src/crypto/tls/conn.go +33 -35
  134. package/bin/go/src/crypto/tls/defaults.go +26 -20
  135. package/bin/go/src/crypto/tls/defaults_fips140.go +9 -0
  136. package/bin/go/src/crypto/tls/ech.go +9 -4
  137. package/bin/go/src/crypto/tls/generate_cert.go +8 -2
  138. package/bin/go/src/crypto/tls/handshake_client.go +17 -17
  139. package/bin/go/src/crypto/tls/handshake_client_tls13.go +8 -3
  140. package/bin/go/src/crypto/tls/handshake_server.go +26 -19
  141. package/bin/go/src/crypto/tls/handshake_server_tls13.go +8 -5
  142. package/bin/go/src/crypto/tls/key_agreement.go +5 -1
  143. package/bin/go/src/crypto/tls/key_schedule.go +42 -17
  144. package/bin/go/src/crypto/tls/prf.go +1 -1
  145. package/bin/go/src/crypto/tls/quic.go +6 -7
  146. package/bin/go/src/crypto/tls/tls.go +25 -29
  147. package/bin/go/src/crypto/x509/cert_pool.go +8 -4
  148. package/bin/go/src/crypto/x509/constraints.go +5 -0
  149. package/bin/go/src/crypto/x509/parser.go +101 -15
  150. package/bin/go/src/crypto/x509/pkcs8.go +45 -4
  151. package/bin/go/src/crypto/x509/pkix/pkix.go +33 -9
  152. package/bin/go/src/crypto/x509/root.go +113 -0
  153. package/bin/go/src/crypto/x509/root_darwin.go +8 -4
  154. package/bin/go/src/crypto/x509/root_plan9.go +2 -23
  155. package/bin/go/src/crypto/x509/root_unix.go +0 -97
  156. package/bin/go/src/crypto/x509/root_windows.go +8 -3
  157. package/bin/go/src/crypto/x509/verify.go +43 -4
  158. package/bin/go/src/crypto/x509/x509.go +169 -30
  159. package/bin/go/src/database/sql/closemu.go +119 -0
  160. package/bin/go/src/database/sql/convert.go +63 -4
  161. package/bin/go/src/database/sql/driver/driver.go +26 -0
  162. package/bin/go/src/database/sql/driver/types.go +4 -0
  163. package/bin/go/src/database/sql/internal/sql.go +22 -0
  164. package/bin/go/src/database/sql/sql.go +89 -40
  165. package/bin/go/src/debug/buildinfo/buildinfo.go +0 -13
  166. package/bin/go/src/debug/dwarf/buf.go +7 -1
  167. package/bin/go/src/debug/dwarf/class_string.go +3 -2
  168. package/bin/go/src/debug/elf/file.go +80 -50
  169. package/bin/go/src/debug/elf/reader.go +1 -1
  170. package/bin/go/src/debug/gosym/symtab.go +26 -30
  171. package/bin/go/src/debug/macho/file.go +2 -2
  172. package/bin/go/src/debug/macho/reloctype_string.go +12 -8
  173. package/bin/go/src/debug/pe/file.go +6 -3
  174. package/bin/go/src/encoding/base32/base32.go +29 -31
  175. package/bin/go/src/encoding/base64/base64.go +24 -29
  176. package/bin/go/src/encoding/gob/decode.go +7 -1
  177. package/bin/go/src/encoding/gob/type.go +6 -6
  178. package/bin/go/src/encoding/hex/hex.go +6 -6
  179. package/bin/go/src/encoding/json/decode.go +4 -3
  180. package/bin/go/src/encoding/json/encode.go +1 -2
  181. package/bin/go/src/encoding/json/fold.go +1 -1
  182. package/bin/go/src/encoding/json/internal/internal.go +11 -1
  183. package/bin/go/src/encoding/json/internal/jsonflags/flags.go +17 -9
  184. package/bin/go/src/encoding/json/internal/jsonopts/options.go +52 -37
  185. package/bin/go/src/encoding/json/internal/jsonopts/options_format.go +124 -0
  186. package/bin/go/src/encoding/json/internal/jsontest/_embed/canada_geometry.json.zst +0 -0
  187. package/bin/go/src/encoding/json/internal/jsontest/_embed/citm_catalog.json.zst +0 -0
  188. package/bin/go/src/encoding/json/internal/jsontest/_embed/golang_source.json.zst +0 -0
  189. package/bin/go/src/encoding/json/internal/jsontest/_embed/string_escaped.json.zst +0 -0
  190. package/bin/go/src/encoding/json/internal/jsontest/_embed/string_unicode.json.zst +0 -0
  191. package/bin/go/src/encoding/json/internal/jsontest/_embed/synthea_fhir.json.zst +0 -0
  192. package/bin/go/src/encoding/json/internal/jsontest/_embed/twitter_status.json.zst +0 -0
  193. package/bin/go/src/encoding/json/internal/jsontest/testdata.go +10 -4
  194. package/bin/go/src/encoding/json/internal/jsonwire/decode.go +13 -36
  195. package/bin/go/src/encoding/json/internal/jsonwire/encode.go +7 -7
  196. package/bin/go/src/encoding/json/internal/jsonwire/wire.go +30 -38
  197. package/bin/go/src/encoding/json/jsontext/decode.go +49 -14
  198. package/bin/go/src/encoding/json/jsontext/doc.go +6 -11
  199. package/bin/go/src/encoding/json/jsontext/encode.go +55 -39
  200. package/bin/go/src/encoding/json/jsontext/errors.go +34 -3
  201. package/bin/go/src/encoding/json/jsontext/export.go +14 -0
  202. package/bin/go/src/encoding/json/jsontext/options.go +8 -8
  203. package/bin/go/src/encoding/json/jsontext/quote.go +2 -2
  204. package/bin/go/src/encoding/json/jsontext/state.go +14 -14
  205. package/bin/go/src/encoding/json/jsontext/token.go +246 -101
  206. package/bin/go/src/encoding/json/jsontext/value.go +31 -16
  207. package/bin/go/src/encoding/json/stream.go +14 -2
  208. package/bin/go/src/encoding/json/v2/arshal.go +100 -114
  209. package/bin/go/src/encoding/json/v2/arshal_any.go +6 -5
  210. package/bin/go/src/encoding/json/v2/arshal_default.go +292 -189
  211. package/bin/go/src/encoding/json/v2/{arshal_inlined.go → arshal_embedded.go} +14 -14
  212. package/bin/go/src/encoding/json/v2/arshal_funcs.go +28 -47
  213. package/bin/go/src/encoding/json/v2/arshal_methods.go +98 -29
  214. package/bin/go/src/encoding/json/v2/arshal_time.go +33 -13
  215. package/bin/go/src/encoding/json/v2/doc.go +40 -55
  216. package/bin/go/src/encoding/json/v2/errors.go +29 -9
  217. package/bin/go/src/encoding/json/v2/fields.go +83 -81
  218. package/bin/go/src/encoding/json/v2/intern.go +2 -2
  219. package/bin/go/src/encoding/json/v2/options.go +57 -41
  220. package/bin/go/src/encoding/json/v2_decode.go +21 -9
  221. package/bin/go/src/encoding/json/v2_encode.go +21 -10
  222. package/bin/go/src/encoding/json/v2_indent.go +2 -0
  223. package/bin/go/src/encoding/json/v2_inject.go +7 -4
  224. package/bin/go/src/encoding/json/v2_options.go +37 -30
  225. package/bin/go/src/encoding/json/v2_scanner.go +6 -1
  226. package/bin/go/src/encoding/json/v2_stream.go +49 -14
  227. package/bin/go/src/encoding/pem/pem.go +6 -2
  228. package/bin/go/src/fmt/doc.go +11 -1
  229. package/bin/go/src/fmt/print.go +69 -82
  230. package/bin/go/src/go/ast/ast.go +4 -4
  231. package/bin/go/src/go/ast/filter.go +1 -1
  232. package/bin/go/src/go/ast/scope.go +2 -2
  233. package/bin/go/src/go/build/build.go +1 -1
  234. package/bin/go/src/go/build/constraint/vers.go +4 -1
  235. package/bin/go/src/go/build/read.go +2 -2
  236. package/bin/go/src/go/constant/kind_string.go +3 -2
  237. package/bin/go/src/go/constant/value.go +26 -4
  238. package/bin/go/src/go/doc/comment/std.go +1 -0
  239. package/bin/go/src/go/importer/importer.go +4 -3
  240. package/bin/go/src/go/internal/gccgoimporter/parser.go +2 -0
  241. package/bin/go/src/go/internal/gcimporter/ureader.go +141 -56
  242. package/bin/go/src/go/parser/parser.go +11 -22
  243. package/bin/go/src/go/printer/math.go +28 -0
  244. package/bin/go/src/go/printer/nodes.go +28 -11
  245. package/bin/go/src/go/printer/printer.go +3 -1
  246. package/bin/go/src/go/scanner/errors.go +2 -0
  247. package/bin/go/src/go/scanner/scanner.go +40 -28
  248. package/bin/go/src/go/token/position.go +7 -16
  249. package/bin/go/src/go/types/alias.go +0 -18
  250. package/bin/go/src/go/types/api.go +4 -10
  251. package/bin/go/src/go/types/api_predicates.go +2 -2
  252. package/bin/go/src/go/types/assignments.go +44 -38
  253. package/bin/go/src/go/types/builtins.go +199 -168
  254. package/bin/go/src/go/types/call.go +155 -138
  255. package/bin/go/src/go/types/check.go +0 -83
  256. package/bin/go/src/go/types/const.go +22 -10
  257. package/bin/go/src/go/types/conversions.go +19 -19
  258. package/bin/go/src/go/types/cycles.go +29 -42
  259. package/bin/go/src/go/types/decl.go +33 -81
  260. package/bin/go/src/go/types/expr.go +191 -183
  261. package/bin/go/src/go/types/gotype.go +1 -0
  262. package/bin/go/src/go/types/hash.go +309 -0
  263. package/bin/go/src/go/types/index.go +91 -61
  264. package/bin/go/src/go/types/infer.go +11 -11
  265. package/bin/go/src/go/types/instantiate.go +27 -15
  266. package/bin/go/src/go/types/interface.go +2 -2
  267. package/bin/go/src/go/types/literals.go +56 -32
  268. package/bin/go/src/go/types/lookup.go +31 -14
  269. package/bin/go/src/go/types/named.go +58 -54
  270. package/bin/go/src/go/types/object.go +4 -3
  271. package/bin/go/src/go/types/operand.go +50 -34
  272. package/bin/go/src/go/types/range.go +19 -16
  273. package/bin/go/src/go/types/recording.go +24 -7
  274. package/bin/go/src/go/types/resolver.go +16 -18
  275. package/bin/go/src/go/types/scope.go +1 -15
  276. package/bin/go/src/go/types/selection.go +3 -1
  277. package/bin/go/src/go/types/signature.go +10 -11
  278. package/bin/go/src/go/types/stmt.go +34 -28
  279. package/bin/go/src/go/types/subst.go +82 -5
  280. package/bin/go/src/go/types/trie.go +93 -0
  281. package/bin/go/src/go/types/typelists.go +28 -0
  282. package/bin/go/src/go/types/typestring.go +5 -9
  283. package/bin/go/src/go/types/typexpr.go +17 -28
  284. package/bin/go/src/go/types/unify.go +12 -3
  285. package/bin/go/src/go/types/universe.go +12 -40
  286. package/bin/go/src/go/types/version.go +4 -0
  287. package/bin/go/src/go.mod +5 -5
  288. package/bin/go/src/go.sum +8 -8
  289. package/bin/go/src/hash/maphash/hasher.go +139 -0
  290. package/bin/go/src/hash/maphash/maphash.go +59 -4
  291. package/bin/go/src/html/template/attr_string.go +3 -2
  292. package/bin/go/src/html/template/delim_string.go +3 -2
  293. package/bin/go/src/html/template/element_string.go +3 -2
  294. package/bin/go/src/html/template/jsctx_string.go +3 -2
  295. package/bin/go/src/html/template/state_string.go +3 -2
  296. package/bin/go/src/html/template/template.go +7 -4
  297. package/bin/go/src/html/template/transition.go +1 -1
  298. package/bin/go/src/html/template/urlpart_string.go +3 -2
  299. package/bin/go/src/image/format.go +9 -0
  300. package/bin/go/src/image/gif/reader.go +18 -0
  301. package/bin/go/src/image/jpeg/huffman.go +22 -3
  302. package/bin/go/src/image/jpeg/reader.go +54 -29
  303. package/bin/go/src/image/jpeg/scan.go +68 -38
  304. package/bin/go/src/image/png/writer.go +8 -0
  305. package/bin/go/src/index/suffixarray/suffixarray.go +14 -6
  306. package/bin/go/src/internal/abi/abi_generic.go +1 -1
  307. package/bin/go/src/internal/abi/abi_s390x.go +0 -2
  308. package/bin/go/src/internal/abi/compiletype.go +30 -0
  309. package/bin/go/src/internal/abi/iface.go +13 -1
  310. package/bin/go/src/internal/abi/map.go +21 -3
  311. package/bin/go/src/internal/abi/type.go +136 -27
  312. package/bin/go/src/internal/buildcfg/exp.go +8 -8
  313. package/bin/go/src/internal/buildcfg/zbootstrap.go +1 -1
  314. package/bin/go/src/internal/bytealg/bytealg.go +16 -16
  315. package/bin/go/src/internal/bytealg/compare_s390x.s +0 -24
  316. package/bin/go/src/internal/bytealg/equal_s390x.s +0 -18
  317. package/bin/go/src/internal/bytealg/indexbyte_arm64.s +28 -0
  318. package/bin/go/src/internal/bytealg/indexbyte_s390x.s +0 -33
  319. package/bin/go/src/internal/coverage/encodemeta/encode.go +1 -1
  320. package/bin/go/src/internal/cpu/cpu.go +22 -7
  321. package/bin/go/src/internal/cpu/cpu_arm64.go +8 -1
  322. package/bin/go/src/internal/cpu/cpu_arm64.s +7 -0
  323. package/bin/go/src/internal/cpu/cpu_arm64_darwin.go +2 -0
  324. package/bin/go/src/internal/cpu/cpu_arm64_freebsd.go +2 -1
  325. package/bin/go/src/internal/cpu/cpu_arm64_hwcap.go +2 -0
  326. package/bin/go/src/internal/cpu/cpu_arm64_openbsd.go +6 -1
  327. package/bin/go/src/internal/cpu/cpu_arm64_other.go +1 -1
  328. package/bin/go/src/internal/cpu/cpu_arm64_windows.go +26 -0
  329. package/bin/go/src/internal/cpu/cpu_loong64.go +14 -2
  330. package/bin/go/src/internal/cpu/cpu_riscv64.go +10 -0
  331. package/bin/go/src/internal/cpu/cpu_riscv64_linux.go +21 -0
  332. package/bin/go/src/internal/cpu/cpu_windows.go +20 -0
  333. package/bin/go/src/internal/cpu/cpu_x86.go +2 -0
  334. package/bin/go/src/internal/filepathlite/path_windows.go +30 -17
  335. package/bin/go/src/internal/fuzz/fuzz.go +5 -1
  336. package/bin/go/src/internal/fuzz/mutator.go +2 -2
  337. package/bin/go/src/internal/fuzz/worker.go +1 -1
  338. package/bin/go/src/internal/gate/gate.go +76 -0
  339. package/bin/go/src/internal/godebugs/table.go +29 -10
  340. package/bin/go/src/internal/goexperiment/exp_mapsplitgroup_off.go +8 -0
  341. package/bin/go/src/internal/goexperiment/exp_mapsplitgroup_on.go +8 -0
  342. package/bin/go/src/internal/goexperiment/flags.go +5 -3
  343. package/bin/go/src/internal/goversion/goversion.go +1 -1
  344. package/bin/go/src/internal/lazyregexp/lazyre.go +4 -0
  345. package/bin/go/src/internal/nettest/conn.go +437 -0
  346. package/bin/go/src/internal/nettest/listener.go +148 -0
  347. package/bin/go/src/internal/nettest/packetconn.go +250 -0
  348. package/bin/go/src/internal/nettest/queue.go +33 -0
  349. package/bin/go/src/internal/pkgbits/syncmarker_string.go +4 -4
  350. package/bin/go/src/internal/pkgbits/version.go +27 -1
  351. package/bin/go/src/internal/platform/supported.go +8 -10
  352. package/bin/go/src/internal/platform/zosarch.go +1 -3
  353. package/bin/go/src/internal/poll/fd_mutex.go +49 -10
  354. package/bin/go/src/internal/poll/fd_unix.go +6 -1
  355. package/bin/go/src/internal/poll/fd_windows.go +175 -191
  356. package/bin/go/src/internal/poll/fd_writev_libc.go +1 -1
  357. package/bin/go/src/internal/poll/fd_writev_unix.go +1 -1
  358. package/bin/go/src/internal/poll/file_plan9.go +4 -4
  359. package/bin/go/src/internal/poll/sendfile_windows.go +1 -3
  360. package/bin/go/src/internal/poll/splice_linux.go +1 -1
  361. package/bin/go/src/internal/profile/encode.go +1 -1
  362. package/bin/go/src/internal/profile/profile.go +5 -3
  363. package/bin/go/src/internal/profilerecord/profilerecord.go +2 -2
  364. package/bin/go/src/internal/reflectlite/value.go +1 -15
  365. package/bin/go/src/internal/runtime/atomic/atomic_386.go +0 -6
  366. package/bin/go/src/internal/runtime/atomic/atomic_amd64.go +0 -6
  367. package/bin/go/src/internal/runtime/atomic/atomic_andor_generic.go +0 -11
  368. package/bin/go/src/internal/runtime/atomic/atomic_arm.go +0 -6
  369. package/bin/go/src/internal/runtime/atomic/atomic_loong64.go +2 -2
  370. package/bin/go/src/internal/runtime/atomic/atomic_loong64.s +22 -11
  371. package/bin/go/src/internal/runtime/atomic/atomic_mipsx.go +0 -10
  372. package/bin/go/src/internal/runtime/atomic/atomic_riscv64.s +4 -4
  373. package/bin/go/src/internal/runtime/atomic/atomic_s390x.go +0 -6
  374. package/bin/go/src/internal/runtime/atomic/atomic_wasm.go +0 -31
  375. package/bin/go/src/internal/runtime/atomic/linkname.go +34 -0
  376. package/bin/go/src/internal/runtime/exithook/hooks.go +0 -4
  377. package/bin/go/src/internal/runtime/gc/scan/expand_amd64.s +2285 -2285
  378. package/bin/go/src/internal/runtime/gc/scan/mkasm.go +1 -1
  379. package/bin/go/src/internal/runtime/gc/scan/scan_amd64.go +2 -1
  380. package/bin/go/src/internal/runtime/gc/scan/scan_amd64.s +4 -2
  381. package/bin/go/src/internal/runtime/maps/group.go +22 -13
  382. package/bin/go/src/internal/runtime/maps/map.go +35 -14
  383. package/bin/go/src/internal/runtime/maps/memhash_386.s +408 -0
  384. package/bin/go/src/internal/runtime/maps/memhash_aes.go +38 -0
  385. package/bin/go/src/internal/runtime/maps/memhash_aes_asm.go +24 -0
  386. package/bin/go/src/internal/runtime/maps/memhash_aes_simd.go +49 -0
  387. package/bin/go/src/internal/runtime/maps/memhash_align_check.go +10 -0
  388. package/bin/go/src/internal/runtime/maps/memhash_align_nocheck.go +16 -0
  389. package/bin/go/src/internal/runtime/maps/memhash_amd64.s +426 -0
  390. package/bin/go/src/internal/runtime/maps/memhash_arm64.s +366 -0
  391. package/bin/go/src/internal/runtime/maps/memhash_noaes.go +43 -0
  392. package/bin/go/src/internal/runtime/maps/memhash_nosimd_amd64.s +33 -0
  393. package/bin/go/src/internal/runtime/maps/runtime.go +37 -88
  394. package/bin/go/src/internal/runtime/maps/runtime_alg.go +93 -0
  395. package/bin/go/src/internal/runtime/maps/runtime_fast32.go +111 -97
  396. package/bin/go/src/internal/runtime/maps/runtime_fast64.go +137 -98
  397. package/bin/go/src/internal/runtime/maps/runtime_faststr.go +96 -89
  398. package/bin/go/src/{runtime/hash32.go → internal/runtime/maps/runtime_hash32.go} +8 -10
  399. package/bin/go/src/{runtime/hash64.go → internal/runtime/maps/runtime_hash64.go} +8 -8
  400. package/bin/go/src/internal/runtime/maps/table.go +66 -3
  401. package/bin/go/src/internal/runtime/math/math.go +0 -21
  402. package/bin/go/src/internal/runtime/startlinetest/func_amd64.s +2 -1
  403. package/bin/go/src/internal/runtime/sys/dit_arm64.go +3 -0
  404. package/bin/go/src/internal/runtime/sys/dit_arm64.s +16 -3
  405. package/bin/go/src/internal/runtime/syscall/linux/asm_linux_s390x.s +0 -23
  406. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_386.s +7 -4
  407. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_amd64.s +10 -8
  408. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_arm64.s +0 -1
  409. package/bin/go/src/internal/runtime/syscall/windows/defs_windows.go +4 -0
  410. package/bin/go/src/internal/runtime/syscall/windows/syscall_windows.go +7 -9
  411. package/bin/go/src/internal/strconv/atof.go +69 -42
  412. package/bin/go/src/internal/strconv/atoi.go +1 -0
  413. package/bin/go/src/internal/strconv/ftoa.go +329 -357
  414. package/bin/go/src/internal/strconv/itoa.go +53 -59
  415. package/bin/go/src/internal/strconv/pow10gen.go +15 -3
  416. package/bin/go/src/internal/strconv/pow10tab.go +670 -670
  417. package/bin/go/src/internal/strconv/uscale.go +290 -0
  418. package/bin/go/src/internal/stringslite/strings.go +14 -42
  419. package/bin/go/src/internal/syscall/unix/asm_openbsd.s +0 -2
  420. package/bin/go/src/internal/syscall/unix/at.go +1 -1
  421. package/bin/go/src/internal/syscall/unix/at_fstatat.go +1 -1
  422. package/bin/go/src/internal/syscall/unix/at_libc2.go +1 -1
  423. package/bin/go/src/internal/syscall/unix/at_openbsd.go +0 -2
  424. package/bin/go/src/internal/syscall/unix/faccessat_bsd.go +1 -1
  425. package/bin/go/src/internal/syscall/unix/faccessat_openbsd.go +0 -2
  426. package/bin/go/src/internal/syscall/windows/at_windows.go +5 -5
  427. package/bin/go/src/internal/syscall/windows/net_windows.go +1 -0
  428. package/bin/go/src/internal/syscall/windows/string_windows.go +6 -3
  429. package/bin/go/src/internal/syscall/windows/syscall_windows.go +2 -0
  430. package/bin/go/src/internal/syscall/windows/types_windows.go +89 -4
  431. package/bin/go/src/internal/syscall/windows/zsyscall_windows.go +7 -0
  432. package/bin/go/src/internal/testenv/testenv.go +24 -1
  433. package/bin/go/src/internal/trace/event.go +1 -1
  434. package/bin/go/src/internal/trace/tracev2/events.go +2 -0
  435. package/bin/go/src/internal/trace/traceviewer/pprof.go +1 -0
  436. package/bin/go/src/internal/types/errors/generrordocs.go +1 -1
  437. package/bin/go/src/io/fs/fs.go +4 -1
  438. package/bin/go/src/io/fs/glob.go +1 -1
  439. package/bin/go/src/io/fs/readdir.go +3 -3
  440. package/bin/go/src/io/fs/readfile.go +3 -3
  441. package/bin/go/src/io/fs/stat.go +1 -1
  442. package/bin/go/src/io/fs/sub.go +4 -2
  443. package/bin/go/src/iter/iter.go +2 -2
  444. package/bin/go/src/log/slog/handler.go +0 -1
  445. package/bin/go/src/log/slog/json_handler.go +7 -1
  446. package/bin/go/src/log/slog/logger.go +16 -0
  447. package/bin/go/src/log/slog/text_handler.go +10 -1
  448. package/bin/go/src/log/slog/value.go +1 -1
  449. package/bin/go/src/log/syslog/doc.go +5 -0
  450. package/bin/go/src/math/abs.go +1 -1
  451. package/bin/go/src/math/big/accuracy_string.go +4 -4
  452. package/bin/go/src/math/big/arith.go +1 -1
  453. package/bin/go/src/math/big/arith_loong64.s +2 -4
  454. package/bin/go/src/math/big/float.go +2 -0
  455. package/bin/go/src/math/big/ftoa.go +11 -5
  456. package/bin/go/src/math/big/int.go +84 -1
  457. package/bin/go/src/math/big/intconv.go +19 -4
  458. package/bin/go/src/math/big/internal/asmgen/loong64.go +2 -0
  459. package/bin/go/src/math/big/nat.go +68 -17
  460. package/bin/go/src/math/big/natdiv.go +8 -5
  461. package/bin/go/src/math/big/roundingmode_string.go +3 -2
  462. package/bin/go/src/math/copysign.go +1 -2
  463. package/bin/go/src/math/exp2_asm.go +1 -1
  464. package/bin/go/src/math/exp2_noasm.go +1 -1
  465. package/bin/go/src/math/exp_asm.go +1 -1
  466. package/bin/go/src/math/exp_loong64.s +4 -12
  467. package/bin/go/src/math/exp_noasm.go +1 -1
  468. package/bin/go/src/math/exp_riscv64.s +236 -0
  469. package/bin/go/src/math/nextafter.go +4 -2
  470. package/bin/go/src/math/pow10.go +1 -1
  471. package/bin/go/src/math/rand/v2/rand.go +14 -4
  472. package/bin/go/src/mime/type.go +3 -2
  473. package/bin/go/src/net/dial.go +10 -6
  474. package/bin/go/src/net/dnsclient_unix.go +37 -8
  475. package/bin/go/src/net/dnsconfig.go +6 -0
  476. package/bin/go/src/net/fd_plan9.go +13 -6
  477. package/bin/go/src/net/fd_unix.go +3 -7
  478. package/bin/go/src/net/fd_windows.go +4 -9
  479. package/bin/go/src/net/file_plan9.go +1 -1
  480. package/bin/go/src/net/file_posix.go +1 -5
  481. package/bin/go/src/net/http/client.go +21 -4
  482. package/bin/go/src/net/http/clientconn.go +20 -1
  483. package/bin/go/src/net/http/clone.go +1 -10
  484. package/bin/go/src/net/http/cookie.go +5 -6
  485. package/bin/go/src/net/http/cookiejar/jar.go +6 -4
  486. package/bin/go/src/net/http/fcgi/fcgi.go +1 -2
  487. package/bin/go/src/net/http/fs.go +8 -1
  488. package/bin/go/src/net/http/http.go +29 -12
  489. package/bin/go/src/net/http/http2.go +561 -0
  490. package/bin/go/src/net/http/httptest/server.go +305 -60
  491. package/bin/go/src/net/http/httptrace/trace.go +78 -27
  492. package/bin/go/src/net/http/httputil/reverseproxy.go +0 -30
  493. package/bin/go/src/net/http/internal/common.go +14 -0
  494. package/bin/go/src/net/http/internal/http2/api.go +161 -0
  495. package/bin/go/src/net/http/internal/http2/ascii.go +53 -0
  496. package/bin/go/src/net/http/internal/http2/ciphers.go +641 -0
  497. package/bin/go/src/net/http/internal/http2/client_conn_pool.go +285 -0
  498. package/bin/go/src/net/http/internal/http2/config.go +118 -0
  499. package/bin/go/src/net/http/internal/http2/databuffer.go +146 -0
  500. package/bin/go/src/net/http/internal/http2/errors.go +173 -0
  501. package/bin/go/src/net/http/internal/http2/flow.go +175 -0
  502. package/bin/go/src/net/http/internal/http2/frame.go +1905 -0
  503. package/bin/go/src/net/http/internal/http2/gotrack.go +181 -0
  504. package/bin/go/src/net/http/internal/http2/http2.go +403 -0
  505. package/bin/go/src/net/http/internal/http2/pipe.go +184 -0
  506. package/bin/go/src/net/http/internal/http2/server.go +3238 -0
  507. package/bin/go/src/net/http/internal/http2/transport.go +3267 -0
  508. package/bin/go/src/net/http/internal/http2/write.go +380 -0
  509. package/bin/go/src/net/http/internal/http2/writesched.go +289 -0
  510. package/bin/go/src/net/http/internal/http2/writesched_priority_rfc9218.go +224 -0
  511. package/bin/go/src/net/http/internal/http2/writesched_roundrobin.go +119 -0
  512. package/bin/go/src/net/http/internal/httpcommon/httpcommon.go +8 -0
  513. package/bin/go/src/net/http/internal/httpsfv/httpsfv.go +666 -0
  514. package/bin/go/src/net/http/internal/sniff.go +304 -0
  515. package/bin/go/src/net/http/omithttp2.go +28 -49
  516. package/bin/go/src/net/http/pprof/pprof.go +11 -17
  517. package/bin/go/src/net/http/request.go +30 -3
  518. package/bin/go/src/net/http/response.go +6 -2
  519. package/bin/go/src/net/http/server.go +366 -144
  520. package/bin/go/src/net/http/sniff.go +2 -289
  521. package/bin/go/src/net/http/transfer.go +64 -21
  522. package/bin/go/src/net/http/transport.go +288 -83
  523. package/bin/go/src/net/ip.go +4 -0
  524. package/bin/go/src/net/ipsock_plan9.go +4 -4
  525. package/bin/go/src/net/ipsock_posix.go +8 -2
  526. package/bin/go/src/net/lookup.go +10 -0
  527. package/bin/go/src/net/lookup_windows.go +1 -1
  528. package/bin/go/src/net/mail/message.go +8 -3
  529. package/bin/go/src/net/net.go +2 -0
  530. package/bin/go/src/net/netip/netip.go +68 -61
  531. package/bin/go/src/net/sock_posix.go +1 -4
  532. package/bin/go/src/net/textproto/reader.go +11 -3
  533. package/bin/go/src/net/udpsock_plan9.go +2 -7
  534. package/bin/go/src/net/unixsock.go +11 -3
  535. package/bin/go/src/net/url/url.go +33 -0
  536. package/bin/go/src/os/dir_darwin.go +7 -0
  537. package/bin/go/src/os/exec/exec.go +16 -2
  538. package/bin/go/src/os/exec.go +1 -0
  539. package/bin/go/src/os/file.go +8 -1
  540. package/bin/go/src/os/root_windows.go +5 -1
  541. package/bin/go/src/os/signal/doc.go +3 -2
  542. package/bin/go/src/os/signal/signal.go +18 -6
  543. package/bin/go/src/os/statat_unix.go +5 -1
  544. package/bin/go/src/path/filepath/path.go +4 -0
  545. package/bin/go/src/reflect/asm_s390x.s +0 -10
  546. package/bin/go/src/reflect/iter.go +13 -13
  547. package/bin/go/src/reflect/makefunc.go +2 -1
  548. package/bin/go/src/reflect/map.go +61 -18
  549. package/bin/go/src/reflect/type.go +63 -46
  550. package/bin/go/src/reflect/value.go +59 -16
  551. package/bin/go/src/regexp/exec.go +5 -5
  552. package/bin/go/src/regexp/regexp.go +382 -319
  553. package/bin/go/src/regexp/syntax/parse.go +19 -10
  554. package/bin/go/src/runtime/HACKING.md +19 -0
  555. package/bin/go/src/runtime/_mkmalloc/constants.go +6 -4
  556. package/bin/go/src/runtime/_mkmalloc/go.mod +1 -1
  557. package/bin/go/src/runtime/_mkmalloc/mkmalloc.go +405 -64
  558. package/bin/go/src/runtime/alg.go +21 -53
  559. package/bin/go/src/runtime/asm_386.s +11 -461
  560. package/bin/go/src/runtime/asm_amd64.s +30 -537
  561. package/bin/go/src/runtime/asm_arm.s +4 -39
  562. package/bin/go/src/runtime/asm_arm64.s +15 -428
  563. package/bin/go/src/runtime/asm_loong64.s +37 -47
  564. package/bin/go/src/runtime/asm_mips64x.s +15 -15
  565. package/bin/go/src/runtime/asm_mipsx.s +0 -15
  566. package/bin/go/src/runtime/asm_ppc64x.h +0 -16
  567. package/bin/go/src/runtime/asm_ppc64x.s +13 -59
  568. package/bin/go/src/runtime/asm_riscv64.s +30 -91
  569. package/bin/go/src/runtime/asm_s390x.s +49 -49
  570. package/bin/go/src/runtime/asm_wasm.s +0 -15
  571. package/bin/go/src/runtime/atomic_riscv64.s +1 -1
  572. package/bin/go/src/runtime/cgo/abi_riscv64.h +72 -0
  573. package/bin/go/src/runtime/cgo/asm_riscv64.s +7 -48
  574. package/bin/go/src/runtime/cgo/callbacks.go +0 -42
  575. package/bin/go/src/runtime/cgo/callbacks_unix.go +58 -0
  576. package/bin/go/src/runtime/cgo/cgo.go +6 -3
  577. package/bin/go/src/runtime/cgo/gcc_aix_ppc64.S +21 -9
  578. package/bin/go/src/runtime/cgo/gcc_android.c +0 -26
  579. package/bin/go/src/runtime/cgo/gcc_clearenv.c +1 -1
  580. package/bin/go/src/runtime/cgo/gcc_fatalf.c +14 -3
  581. package/bin/go/src/runtime/cgo/{gcc_libinit.c → gcc_libinit_unix.c} +18 -65
  582. package/bin/go/src/runtime/cgo/gcc_libinit_windows.c +23 -35
  583. package/bin/go/src/runtime/cgo/gcc_linux_ppc64x.S +16 -7
  584. package/bin/go/src/runtime/cgo/gcc_netbsd.c +8 -56
  585. package/bin/go/src/runtime/cgo/gcc_s390x.S +13 -4
  586. package/bin/go/src/runtime/cgo/gcc_sigaction.c +1 -1
  587. package/bin/go/src/runtime/cgo/gcc_unix.c +63 -0
  588. package/bin/go/src/runtime/cgo/gcc_util.c +0 -19
  589. package/bin/go/src/runtime/cgo/handle.go +3 -0
  590. package/bin/go/src/runtime/cgo/libcgo.h +7 -10
  591. package/bin/go/src/runtime/cgo/libcgo_unix.h +2 -10
  592. package/bin/go/src/runtime/cgo/pthread_unix.c +138 -0
  593. package/bin/go/src/runtime/cgo/sigaction.go +1 -1
  594. package/bin/go/src/runtime/cgo/windows.go +18 -1
  595. package/bin/go/src/runtime/cgo_ppc64x.go +1 -1
  596. package/bin/go/src/runtime/cgo_sigaction.go +1 -1
  597. package/bin/go/src/runtime/cgocall.go +10 -2
  598. package/bin/go/src/runtime/chan.go +2 -16
  599. package/bin/go/src/runtime/coro.go +2 -2
  600. package/bin/go/src/runtime/cpuflags.go +4 -3
  601. package/bin/go/src/runtime/debug/garbage.go +6 -6
  602. package/bin/go/src/runtime/debug/mod.go +1 -1
  603. package/bin/go/src/runtime/debug/stack.go +1 -1
  604. package/bin/go/src/runtime/debugcall.go +0 -3
  605. package/bin/go/src/runtime/error.go +6 -0
  606. package/bin/go/src/runtime/extern.go +5 -3
  607. package/bin/go/src/runtime/heapdump.go +1 -1
  608. package/bin/go/src/runtime/iface.go +20 -10
  609. package/bin/go/src/runtime/libinit.go +48 -0
  610. package/bin/go/src/runtime/lock_js.go +4 -2
  611. package/bin/go/src/runtime/lock_spinbit.go +13 -12
  612. package/bin/go/src/runtime/lock_wasip1.go +4 -2
  613. package/bin/go/src/runtime/lockrank.go +24 -21
  614. package/bin/go/src/runtime/lockrank_off.go +5 -2
  615. package/bin/go/src/runtime/lockrank_on.go +8 -7
  616. package/bin/go/src/runtime/malloc.go +10 -26
  617. package/bin/go/src/runtime/malloc_generated.go +819 -8628
  618. package/bin/go/src/runtime/malloc_stubs.go +187 -197
  619. package/bin/go/src/runtime/malloc_tables_generated.go +16 -882
  620. package/bin/go/src/runtime/map.go +4 -4
  621. package/bin/go/src/runtime/mbitmap.go +3 -1
  622. package/bin/go/src/runtime/mem.go +2 -6
  623. package/bin/go/src/runtime/mem_sbrk.go +4 -0
  624. package/bin/go/src/runtime/memclr_s390x.s +0 -5
  625. package/bin/go/src/runtime/memmove_s390x.s +0 -7
  626. package/bin/go/src/runtime/metrics/doc.go +5 -29
  627. package/bin/go/src/runtime/metrics/sample.go +3 -0
  628. package/bin/go/src/runtime/metrics.go +3 -2
  629. package/bin/go/src/runtime/mgc.go +41 -25
  630. package/bin/go/src/runtime/mgcmark.go +5 -0
  631. package/bin/go/src/runtime/mgcmark_greenteagc.go +1 -1
  632. package/bin/go/src/runtime/mgcpacer.go +1 -3
  633. package/bin/go/src/runtime/mgcscavenge.go +1 -1
  634. package/bin/go/src/runtime/mheap.go +1 -10
  635. package/bin/go/src/runtime/mklockrank.go +6 -1
  636. package/bin/go/src/runtime/mkpreempt.go +7 -0
  637. package/bin/go/src/runtime/mprof.go +12 -23
  638. package/bin/go/src/runtime/os2_aix.go +3 -3
  639. package/bin/go/src/runtime/os3_solaris.go +10 -0
  640. package/bin/go/src/runtime/os_aix.go +9 -2
  641. package/bin/go/src/runtime/os_darwin.go +3 -8
  642. package/bin/go/src/runtime/os_dragonfly.go +10 -0
  643. package/bin/go/src/runtime/os_js.go +10 -0
  644. package/bin/go/src/runtime/os_linux32.go +19 -6
  645. package/bin/go/src/runtime/os_netbsd.go +10 -0
  646. package/bin/go/src/runtime/os_openbsd.go +10 -0
  647. package/bin/go/src/runtime/os_plan9.go +10 -0
  648. package/bin/go/src/runtime/os_wasip1.go +10 -0
  649. package/bin/go/src/runtime/os_windows.go +45 -12
  650. package/bin/go/src/runtime/os_workdir_ios_arm64.go +98 -0
  651. package/bin/go/src/runtime/os_workdir_stub.go +9 -0
  652. package/bin/go/src/runtime/panic.go +93 -8
  653. package/bin/go/src/runtime/plugin.go +1 -3
  654. package/bin/go/src/runtime/pprof/pprof.go +11 -14
  655. package/bin/go/src/runtime/pprof/protomem.go +8 -15
  656. package/bin/go/src/runtime/preempt_loong64.s +8 -4
  657. package/bin/go/src/runtime/preempt_noxreg.go +2 -0
  658. package/bin/go/src/runtime/preempt_xreg.go +29 -2
  659. package/bin/go/src/runtime/print.go +9 -1
  660. package/bin/go/src/runtime/proc.go +68 -17
  661. package/bin/go/src/runtime/race_riscv64.s +40 -83
  662. package/bin/go/src/runtime/race_s390x.s +0 -16
  663. package/bin/go/src/runtime/rand.go +40 -12
  664. package/bin/go/src/runtime/{rt0_linux_ppc64le.s → rt0_linux_ppc64x.s} +12 -2
  665. package/bin/go/src/runtime/runtime-gdb.py +13 -2
  666. package/bin/go/src/runtime/runtime1.go +69 -18
  667. package/bin/go/src/runtime/runtime2.go +23 -22
  668. package/bin/go/src/runtime/secret/secret.go +7 -2
  669. package/bin/go/src/runtime/secret.go +27 -9
  670. package/bin/go/src/runtime/secret_nosecret.go +1 -1
  671. package/bin/go/src/runtime/sigaction.go +1 -1
  672. package/bin/go/src/runtime/signal_unix.go +5 -3
  673. package/bin/go/src/runtime/softfloat64.go +7 -2
  674. package/bin/go/src/runtime/string.go +4 -1
  675. package/bin/go/src/runtime/stubs.go +14 -4
  676. package/bin/go/src/runtime/stubs_amd64.go +4 -0
  677. package/bin/go/src/runtime/stubs_arm.go +10 -1
  678. package/bin/go/src/runtime/stubs_arm64.go +13 -0
  679. package/bin/go/src/runtime/stubs_loong64.go +18 -0
  680. package/bin/go/src/runtime/stubs_mips64x.go +9 -0
  681. package/bin/go/src/runtime/stubs_mipsx.go +11 -0
  682. package/bin/go/src/runtime/stubs_ppc64x.go +15 -0
  683. package/bin/go/src/runtime/stubs_riscv64.go +13 -0
  684. package/bin/go/src/runtime/stubs_s390x.go +18 -0
  685. package/bin/go/src/runtime/symtab.go +15 -16
  686. package/bin/go/src/runtime/synctest.go +2 -4
  687. package/bin/go/src/runtime/sys_aix_ppc64.s +9 -0
  688. package/bin/go/src/runtime/sys_darwin.go +2 -20
  689. package/bin/go/src/runtime/sys_darwin_amd64.s +1 -4
  690. package/bin/go/src/runtime/sys_darwin_arm64.s +3 -6
  691. package/bin/go/src/runtime/sys_freebsd_riscv64.s +2 -2
  692. package/bin/go/src/runtime/sys_ios_arm64.go +151 -0
  693. package/bin/go/src/runtime/sys_ios_arm64.s +78 -0
  694. package/bin/go/src/runtime/sys_linux_amd64.s +7 -1
  695. package/bin/go/src/runtime/sys_linux_loong64.s +8 -14
  696. package/bin/go/src/runtime/sys_linux_ppc64x.s +0 -12
  697. package/bin/go/src/runtime/sys_linux_riscv64.s +2 -2
  698. package/bin/go/src/runtime/sys_openbsd.go +1 -1
  699. package/bin/go/src/runtime/sys_openbsd_riscv64.s +16 -16
  700. package/bin/go/src/runtime/syscall_windows.go +2 -6
  701. package/bin/go/src/runtime/time.go +19 -57
  702. package/bin/go/src/runtime/trace/subscribe.go +0 -3
  703. package/bin/go/src/runtime/traceback.go +90 -13
  704. package/bin/go/src/runtime/traceregion.go +3 -3
  705. package/bin/go/src/runtime/tracestring.go +5 -0
  706. package/bin/go/src/runtime/type.go +85 -15
  707. package/bin/go/src/runtime/utf8.go +2 -2
  708. package/bin/go/src/simd/archsimd/_gen/go.mod +2 -2
  709. package/bin/go/src/simd/archsimd/_gen/go.sum +2 -2
  710. package/bin/go/src/simd/archsimd/_gen/main.go +106 -15
  711. package/bin/go/src/simd/archsimd/_gen/midway/comments.yaml +151 -0
  712. package/bin/go/src/simd/archsimd/_gen/midway/intersect_simd_ops.go +836 -0
  713. package/bin/go/src/simd/archsimd/_gen/sgutil/asbits.go +139 -0
  714. package/bin/go/src/simd/archsimd/_gen/sgutil/compare_natural.go +73 -0
  715. package/bin/go/src/simd/archsimd/_gen/sgutil/formatted_files.go +66 -0
  716. package/bin/go/src/simd/archsimd/_gen/sgutil/insert_ordered_map.go +159 -0
  717. package/bin/go/src/simd/archsimd/_gen/sgutil/merge_generic_ops.go +245 -0
  718. package/bin/go/src/simd/archsimd/_gen/simdgen/arch.go +173 -0
  719. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/emit.go +166 -0
  720. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/instruction.go +642 -0
  721. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/load.go +54 -0
  722. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/operands.go +406 -0
  723. package/bin/go/src/simd/archsimd/_gen/simdgen/etetest.sh +1 -1
  724. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdGenericOps.go +19 -52
  725. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdIntrinsics.go +162 -98
  726. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdMachineOps.go +50 -19
  727. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdTypes.go +198 -140
  728. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdrules.go +278 -57
  729. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdssa.go +133 -68
  730. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_utility.go +163 -30
  731. package/bin/go/src/simd/archsimd/_gen/simdgen/go_amd64.yaml +1 -0
  732. package/bin/go/src/simd/archsimd/_gen/simdgen/go_arm64.yaml +1 -0
  733. package/bin/go/src/simd/archsimd/_gen/simdgen/godefs.go +113 -15
  734. package/bin/go/src/simd/archsimd/_gen/simdgen/main.go +62 -17
  735. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/categories.yaml +12 -12
  736. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/{go.yaml → go_amd64.yaml} +12 -12
  737. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/go_arm64.yaml +91 -0
  738. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/categories.yaml +11 -3
  739. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/go_arm64.yaml +43 -0
  740. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Compares/go_arm64.yaml +81 -0
  741. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/categories.yaml +11 -6
  742. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/{go.yaml → go_amd64.yaml} +8 -8
  743. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/go_arm64.yaml +358 -0
  744. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/categories.yaml +5 -5
  745. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/{go.yaml → go_amd64.yaml} +4 -4
  746. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/go_arm64.yaml +52 -0
  747. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/categories.yaml +29 -11
  748. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/{go.yaml → go_amd64.yaml} +1 -0
  749. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/go_arm64.yaml +10 -0
  750. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/categories.yaml +2 -5
  751. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/{go.yaml → go_amd64.yaml} +2 -3
  752. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/go_arm64.yaml +35 -0
  753. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/categories.yaml +5 -8
  754. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/{go.yaml → go_amd64.yaml} +7 -5
  755. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/go_arm64.yaml +31 -0
  756. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MinMax/go_arm64.yaml +61 -0
  757. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/categories.yaml +79 -23
  758. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/{go.yaml → go_amd64.yaml} +213 -104
  759. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/go_arm64.yaml +264 -0
  760. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/categories.yaml +6 -2
  761. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/{go.yaml → go_amd64.yaml} +3 -3
  762. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/go_arm64.yaml +38 -0
  763. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/NegAbs/categories.yaml +7 -0
  764. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/NegAbs/go_arm64.yaml +36 -0
  765. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/categories.yaml +5 -1
  766. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/go_arm64.yaml +19 -0
  767. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Reduce/categories.yaml +16 -0
  768. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Reduce/go_arm64.yaml +71 -0
  769. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/categories.yaml +156 -41
  770. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go_amd64.yaml +299 -0
  771. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go_arm64.yaml +202 -0
  772. package/bin/go/src/simd/archsimd/_gen/simdgen/types.yaml +2 -0
  773. package/bin/go/src/simd/archsimd/_gen/simdgen/xed.go +44 -11
  774. package/bin/go/src/simd/archsimd/_gen/tmplgen/main.go +668 -123
  775. package/bin/go/src/simd/archsimd/_gen/unify/closure.go +1 -1
  776. package/bin/go/src/simd/archsimd/_gen/unify/env.go +35 -3
  777. package/bin/go/src/simd/archsimd/_gen/unify/yaml.go +4 -4
  778. package/bin/go/src/simd/archsimd/_gen/wasmgen/main.go +2064 -0
  779. package/bin/go/src/simd/archsimd/clmul_arm64.go +79 -0
  780. package/bin/go/src/simd/archsimd/clmul_emulated.go +103 -0
  781. package/bin/go/src/simd/archsimd/compare_gen_arm64.go +155 -0
  782. package/bin/go/src/simd/archsimd/cpu.go +1 -1
  783. package/bin/go/src/simd/archsimd/cpu_other.go +21 -0
  784. package/bin/go/src/simd/archsimd/doc.go +0 -2
  785. package/bin/go/src/simd/archsimd/dummy.s +1 -1
  786. package/bin/go/src/simd/archsimd/generate.go +1 -1
  787. package/bin/go/src/simd/archsimd/internal/test_helpers/checkslices.go +2 -2
  788. package/bin/go/src/simd/archsimd/maskmerge_gen_amd64.go +330 -0
  789. package/bin/go/src/simd/archsimd/maskmerge_gen_arm64.go +167 -0
  790. package/bin/go/src/simd/archsimd/ops_amd64.go +4210 -2475
  791. package/bin/go/src/simd/archsimd/ops_arm64.go +2186 -0
  792. package/bin/go/src/simd/archsimd/ops_emulated_amd64.go +205 -0
  793. package/bin/go/src/simd/archsimd/ops_emulated_wasm.go +212 -0
  794. package/bin/go/src/simd/archsimd/ops_internal_amd64.go +500 -56
  795. package/bin/go/src/simd/archsimd/ops_internal_arm64.go +234 -0
  796. package/bin/go/src/simd/archsimd/ops_wasm.go +1795 -0
  797. package/bin/go/src/simd/archsimd/other_gen_amd64.go +576 -72
  798. package/bin/go/src/simd/archsimd/other_gen_arm64.go +519 -0
  799. package/bin/go/src/simd/archsimd/shuffles_amd64.go +217 -76
  800. package/bin/go/src/simd/archsimd/slice_gen_amd64.go +594 -532
  801. package/bin/go/src/simd/archsimd/slice_gen_arm64.go +125 -0
  802. package/bin/go/src/simd/archsimd/slicepart_128.go +302 -0
  803. package/bin/go/src/simd/archsimd/slicepart_amd64.go +36 -235
  804. package/bin/go/src/simd/archsimd/slicepart_arm64.go +217 -0
  805. package/bin/go/src/simd/archsimd/slicepart_wasm.go +217 -0
  806. package/bin/go/src/simd/archsimd/string.go +1 -1
  807. package/bin/go/src/simd/archsimd/types_amd64.go +165 -341
  808. package/bin/go/src/simd/archsimd/types_arm64.go +224 -0
  809. package/bin/go/src/simd/archsimd/types_wasm.go +354 -0
  810. package/bin/go/src/simd/archsimd/unsafe_helpers.go +60 -0
  811. package/bin/go/src/simd/doc.go +91 -0
  812. package/bin/go/src/simd/dummy.s +7 -0
  813. package/bin/go/src/simd/internal/bridge/decls_amd64.go +4085 -0
  814. package/bin/go/src/simd/internal/bridge/decls_arm64.go +1369 -0
  815. package/bin/go/src/simd/internal/bridge/decls_wasm.go +1369 -0
  816. package/bin/go/src/simd/internal/bridge/import_hook.go +13 -0
  817. package/bin/go/src/simd/internal/bridge/simd_emulated.go +3275 -0
  818. package/bin/go/src/simd/internal/bridge/simd_types_emulated.go +95 -0
  819. package/bin/go/src/simd/internal/bridge/tofrom_128.go +65 -0
  820. package/bin/go/src/simd/internal/bridge/tofrom_amd64.go +123 -0
  821. package/bin/go/src/simd/internal/bridge/tofrom_emulated.go +63 -0
  822. package/bin/go/src/simd/midway_amd64.go +34 -0
  823. package/bin/go/src/simd/midway_arm64.go +22 -0
  824. package/bin/go/src/simd/midway_common.go +138 -0
  825. package/bin/go/src/simd/midway_wasm.go +13 -0
  826. package/bin/go/src/simd/simd_emulated.go +3275 -0
  827. package/bin/go/src/simd/simd_stubs.go +1041 -0
  828. package/bin/go/src/simd/simd_types.go +96 -0
  829. package/bin/go/src/simd/tofrom_amd64.go +374 -0
  830. package/bin/go/src/simd/tofrom_arm64.go +290 -0
  831. package/bin/go/src/simd/tofrom_wasm.go +290 -0
  832. package/bin/go/src/slices/slices.go +9 -7
  833. package/bin/go/src/strconv/isprint.go +81 -51
  834. package/bin/go/src/strings/builder.go +1 -1
  835. package/bin/go/src/strings/strings.go +44 -35
  836. package/bin/go/src/sync/atomic/doc.go +7 -0
  837. package/bin/go/src/sync/cond.go +4 -2
  838. package/bin/go/src/sync/pool.go +6 -15
  839. package/bin/go/src/sync/runtime2_lockrank.go +1 -2
  840. package/bin/go/src/syscall/exec_bsd.go +3 -3
  841. package/bin/go/src/syscall/exec_libc2.go +1 -1
  842. package/bin/go/src/syscall/exec_linux.go +7 -2
  843. package/bin/go/src/syscall/fs_js.go +9 -4
  844. package/bin/go/src/syscall/fs_wasip1.go +6 -0
  845. package/bin/go/src/syscall/js/js.go +2 -2
  846. package/bin/go/src/syscall/linkname_bsd.go +8 -0
  847. package/bin/go/src/syscall/linkname_libc.go +1 -1
  848. package/bin/go/src/syscall/linkname_openbsd.go +0 -2
  849. package/bin/go/src/syscall/mkall.sh +6 -17
  850. package/bin/go/src/syscall/syscall_aix.go +5 -0
  851. package/bin/go/src/syscall/syscall_linux_386.go +9 -0
  852. package/bin/go/src/syscall/syscall_linux_amd64.go +5 -0
  853. package/bin/go/src/syscall/syscall_linux_arm.go +4 -0
  854. package/bin/go/src/syscall/syscall_linux_arm64.go +3 -0
  855. package/bin/go/src/syscall/syscall_linux_loong64.go +3 -0
  856. package/bin/go/src/syscall/syscall_linux_mipsx.go +4 -0
  857. package/bin/go/src/syscall/syscall_linux_riscv64.go +3 -0
  858. package/bin/go/src/syscall/syscall_linux_s390x.go +5 -0
  859. package/bin/go/src/syscall/syscall_openbsd.go +77 -2
  860. package/bin/go/src/syscall/syscall_plan9.go +25 -0
  861. package/bin/go/src/syscall/syscall_solaris.go +11 -0
  862. package/bin/go/src/syscall/syscall_unix.go +19 -0
  863. package/bin/go/src/syscall/syscall_windows.go +1 -1
  864. package/bin/go/src/testing/synctest/synctest.go +21 -0
  865. package/bin/go/src/testing/testing.go +211 -52
  866. package/bin/go/src/text/template/parse/lex.go +6 -6
  867. package/bin/go/src/text/template/parse/node.go +21 -16
  868. package/bin/go/src/text/template/parse/parse.go +23 -6
  869. package/bin/go/src/text/template/template.go +5 -3
  870. package/bin/go/src/time/format.go +3 -0
  871. package/bin/go/src/time/sleep.go +0 -33
  872. package/bin/go/src/time/tick.go +3 -2
  873. package/bin/go/src/time/time.go +2 -2
  874. package/bin/go/src/time/tzdata/zzipdata.go +1 -1
  875. package/bin/go/src/time/zoneinfo.go +5 -4
  876. package/bin/go/src/time/zoneinfo_read.go +1 -1
  877. package/bin/go/src/unicode/tables.go +898 -417
  878. package/bin/go/src/uuid/uuid.go +273 -0
  879. package/bin/go/src/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go +3 -3
  880. package/bin/go/src/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s +2066 -6598
  881. package/bin/go/src/vendor/golang.org/x/crypto/hkdf/hkdf.go +100 -0
  882. package/bin/go/src/vendor/golang.org/x/net/dns/dnsmessage/message.go +5 -4
  883. package/bin/go/src/vendor/golang.org/x/net/http/httpproxy/proxy.go +4 -4
  884. package/bin/go/src/vendor/golang.org/x/net/http3/http3.go +46 -0
  885. package/bin/go/src/vendor/golang.org/x/net/idna/{idna10.0.0.go → idna.go} +133 -35
  886. package/bin/go/src/vendor/golang.org/x/net/idna/punycode.go +4 -1
  887. package/bin/go/src/vendor/golang.org/x/net/idna/tables15.0.0.go +1 -1
  888. package/bin/go/src/vendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  889. package/bin/go/src/vendor/golang.org/x/net/internal/http3/body.go +231 -0
  890. package/bin/go/src/vendor/golang.org/x/net/internal/http3/conn.go +131 -0
  891. package/bin/go/src/vendor/golang.org/x/net/internal/http3/doc.go +10 -0
  892. package/bin/go/src/vendor/golang.org/x/net/internal/http3/errors.go +102 -0
  893. package/bin/go/src/vendor/golang.org/x/net/internal/http3/http3.go +95 -0
  894. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack.go +356 -0
  895. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_decode.go +81 -0
  896. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_encode.go +61 -0
  897. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_static.go +142 -0
  898. package/bin/go/src/vendor/golang.org/x/net/internal/http3/quic.go +40 -0
  899. package/bin/go/src/vendor/golang.org/x/net/internal/http3/roundtrip.go +423 -0
  900. package/bin/go/src/vendor/golang.org/x/net/internal/http3/server.go +866 -0
  901. package/bin/go/src/vendor/golang.org/x/net/internal/http3/settings.go +66 -0
  902. package/bin/go/src/vendor/golang.org/x/net/internal/http3/stream.go +260 -0
  903. package/bin/go/src/vendor/golang.org/x/net/internal/http3/transport.go +333 -0
  904. package/bin/go/src/vendor/golang.org/x/net/internal/http3/varint.go +23 -0
  905. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  906. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  907. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/request.go +475 -0
  908. package/bin/go/src/vendor/golang.org/x/net/internal/quic/quicwire/wire.go +150 -0
  909. package/bin/go/src/vendor/golang.org/x/net/quic/ack_delay.go +26 -0
  910. package/bin/go/src/vendor/golang.org/x/net/quic/acks.go +213 -0
  911. package/bin/go/src/vendor/golang.org/x/net/quic/atomic_bits.go +31 -0
  912. package/bin/go/src/vendor/golang.org/x/net/quic/config.go +158 -0
  913. package/bin/go/src/vendor/golang.org/x/net/quic/congestion_reno.go +306 -0
  914. package/bin/go/src/vendor/golang.org/x/net/quic/conn.go +434 -0
  915. package/bin/go/src/vendor/golang.org/x/net/quic/conn_close.go +340 -0
  916. package/bin/go/src/vendor/golang.org/x/net/quic/conn_flow.go +142 -0
  917. package/bin/go/src/vendor/golang.org/x/net/quic/conn_id.go +502 -0
  918. package/bin/go/src/vendor/golang.org/x/net/quic/conn_loss.go +85 -0
  919. package/bin/go/src/vendor/golang.org/x/net/quic/conn_recv.go +631 -0
  920. package/bin/go/src/vendor/golang.org/x/net/quic/conn_send.go +407 -0
  921. package/bin/go/src/vendor/golang.org/x/net/quic/conn_streams.go +483 -0
  922. package/bin/go/src/vendor/golang.org/x/net/quic/crypto_stream.go +157 -0
  923. package/bin/go/src/vendor/golang.org/x/net/quic/dgram.go +53 -0
  924. package/bin/go/src/vendor/golang.org/x/net/quic/doc.go +50 -0
  925. package/bin/go/src/vendor/golang.org/x/net/quic/endpoint.go +478 -0
  926. package/bin/go/src/vendor/golang.org/x/net/quic/errors.go +129 -0
  927. package/bin/go/src/vendor/golang.org/x/net/quic/frame_debug.go +730 -0
  928. package/bin/go/src/vendor/golang.org/x/net/quic/gate.go +86 -0
  929. package/bin/go/src/vendor/golang.org/x/net/quic/idle.go +168 -0
  930. package/bin/go/src/vendor/golang.org/x/net/quic/log.go +67 -0
  931. package/bin/go/src/vendor/golang.org/x/net/quic/loss.go +521 -0
  932. package/bin/go/src/{runtime/cgo/gcc_stack_windows.c → vendor/golang.org/x/net/quic/math.go} +7 -2
  933. package/bin/go/src/vendor/golang.org/x/net/quic/pacer.go +129 -0
  934. package/bin/go/src/vendor/golang.org/x/net/quic/packet.go +267 -0
  935. package/bin/go/src/vendor/golang.org/x/net/quic/packet_number.go +72 -0
  936. package/bin/go/src/vendor/golang.org/x/net/quic/packet_parser.go +519 -0
  937. package/bin/go/src/vendor/golang.org/x/net/quic/packet_protection.go +539 -0
  938. package/bin/go/src/vendor/golang.org/x/net/quic/packet_writer.go +566 -0
  939. package/bin/go/src/vendor/golang.org/x/net/quic/path.go +87 -0
  940. package/bin/go/src/vendor/golang.org/x/net/quic/ping.go +14 -0
  941. package/bin/go/src/vendor/golang.org/x/net/quic/pipe.go +173 -0
  942. package/bin/go/src/vendor/golang.org/x/net/quic/qlog.go +272 -0
  943. package/bin/go/src/vendor/golang.org/x/net/quic/queue.go +63 -0
  944. package/bin/go/src/vendor/golang.org/x/net/quic/quic.go +221 -0
  945. package/bin/go/src/vendor/golang.org/x/net/quic/race_disabled.go +10 -0
  946. package/bin/go/src/vendor/golang.org/x/net/quic/race_enabled.go +27 -0
  947. package/bin/go/src/vendor/golang.org/x/net/quic/rangeset.go +193 -0
  948. package/bin/go/src/vendor/golang.org/x/net/quic/retry.go +240 -0
  949. package/bin/go/src/vendor/golang.org/x/net/quic/rtt.go +71 -0
  950. package/bin/go/src/vendor/golang.org/x/net/quic/sent_packet.go +119 -0
  951. package/bin/go/src/vendor/golang.org/x/net/quic/sent_packet_list.go +93 -0
  952. package/bin/go/src/vendor/golang.org/x/net/quic/sent_val.go +103 -0
  953. package/bin/go/src/vendor/golang.org/x/net/quic/skip.go +62 -0
  954. package/bin/go/src/vendor/golang.org/x/net/quic/stateless_reset.go +59 -0
  955. package/bin/go/src/vendor/golang.org/x/net/quic/stream.go +1106 -0
  956. package/bin/go/src/vendor/golang.org/x/net/quic/stream_limits.go +138 -0
  957. package/bin/go/src/vendor/golang.org/x/net/quic/tls.go +123 -0
  958. package/bin/go/src/vendor/golang.org/x/net/quic/transport_params.go +283 -0
  959. package/bin/go/src/vendor/golang.org/x/net/quic/udp.go +28 -0
  960. package/bin/go/src/vendor/golang.org/x/net/quic/udp_darwin.go +45 -0
  961. package/bin/go/src/vendor/golang.org/x/net/quic/udp_linux.go +39 -0
  962. package/bin/go/src/vendor/golang.org/x/net/quic/udp_msg.go +245 -0
  963. package/bin/go/src/vendor/golang.org/x/net/quic/udp_other.go +62 -0
  964. package/bin/go/src/vendor/golang.org/x/net/quic/udp_packetconn.go +67 -0
  965. package/bin/go/src/vendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  966. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu.go +12 -7
  967. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_arm64.go +3 -6
  968. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  969. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  970. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +1 -0
  971. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +2 -0
  972. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_loong64.go +14 -2
  973. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +4 -2
  974. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +1 -0
  975. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  976. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  977. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_x86.go +124 -50
  978. package/bin/go/src/vendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  979. package/bin/go/src/vendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  980. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule.go +4 -0
  981. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +1 -1
  982. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  983. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/forminfo.go +18 -8
  984. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go +1410 -1410
  985. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/{tables13.0.0.go → tables17.0.0.go} +3530 -3186
  986. package/bin/go/src/vendor/modules.txt +14 -8
  987. package/bin/ttsc-cache.exe +0 -0
  988. package/bin/ttsc.exe +0 -0
  989. package/bin/ttscserver.exe +0 -0
  990. package/package.json +1 -1
  991. package/bin/go/src/crypto/internal/fips140/nistec/p256_ordinv_noasm.go +0 -13
  992. package/bin/go/src/go/internal/scannerhooks/hooks.go +0 -11
  993. package/bin/go/src/hash/maphash/maphash_purego.go +0 -200
  994. package/bin/go/src/hash/maphash/maphash_runtime.go +0 -64
  995. package/bin/go/src/internal/goexperiment/exp_goroutineleakprofile_off.go +0 -8
  996. package/bin/go/src/internal/goexperiment/exp_goroutineleakprofile_on.go +0 -8
  997. package/bin/go/src/internal/strconv/atofeisel.go +0 -166
  998. package/bin/go/src/internal/strconv/ftoadbox.go +0 -349
  999. package/bin/go/src/internal/strconv/ftoafixed.go +0 -184
  1000. package/bin/go/src/internal/strconv/math.go +0 -179
  1001. package/bin/go/src/net/http/h2_bundle.go +0 -12371
  1002. package/bin/go/src/net/http/h2_error.go +0 -37
  1003. package/bin/go/src/runtime/cgo/gcc_darwin_amd64.c +0 -61
  1004. package/bin/go/src/runtime/cgo/gcc_darwin_arm64.c +0 -148
  1005. package/bin/go/src/runtime/cgo/gcc_dragonfly_amd64.c +0 -61
  1006. package/bin/go/src/runtime/cgo/gcc_freebsd.c +0 -72
  1007. package/bin/go/src/runtime/cgo/gcc_freebsd_amd64.c +0 -72
  1008. package/bin/go/src/runtime/cgo/gcc_linux.c +0 -67
  1009. package/bin/go/src/runtime/cgo/gcc_linux_amd64.c +0 -92
  1010. package/bin/go/src/runtime/cgo/gcc_linux_arm64.c +0 -88
  1011. package/bin/go/src/runtime/cgo/gcc_linux_s390x.c +0 -64
  1012. package/bin/go/src/runtime/cgo/gcc_openbsd.c +0 -62
  1013. package/bin/go/src/runtime/cgo/gcc_ppc64x.c +0 -68
  1014. package/bin/go/src/runtime/cgo/gcc_signal2_ios_arm64.c +0 -11
  1015. package/bin/go/src/runtime/cgo/gcc_signal_ios_arm64.c +0 -213
  1016. package/bin/go/src/runtime/cgo/gcc_signal_ios_nolldb.c +0 -10
  1017. package/bin/go/src/runtime/cgo/gcc_solaris_amd64.c +0 -83
  1018. package/bin/go/src/runtime/cgo/gcc_stack_darwin.c +0 -25
  1019. package/bin/go/src/runtime/cgo/gcc_stack_unix.c +0 -48
  1020. package/bin/go/src/runtime/cgo/gcc_windows_386.c +0 -55
  1021. package/bin/go/src/runtime/cgo/gcc_windows_amd64.c +0 -54
  1022. package/bin/go/src/runtime/cgo/gcc_windows_arm64.c +0 -42
  1023. package/bin/go/src/runtime/cgo/libcgo_windows.h +0 -6
  1024. package/bin/go/src/runtime/cgo/signal_ios_arm64.go +0 -10
  1025. package/bin/go/src/runtime/cgo/signal_ios_arm64.s +0 -56
  1026. package/bin/go/src/runtime/rt0_linux_ppc64.s +0 -28
  1027. package/bin/go/src/runtime/stubs_ppc64.go +0 -12
  1028. package/bin/go/src/simd/archsimd/_gen/simdgen/go.yaml +0 -1
  1029. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go.yaml +0 -172
  1030. package/bin/go/src/syscall/asm_openbsd_mips64.s +0 -129
  1031. package/bin/go/src/syscall/syscall_openbsd1.go +0 -12
  1032. package/bin/go/src/syscall/syscall_openbsd_libc.go +0 -84
  1033. package/bin/go/src/syscall/syscall_openbsd_mips64.go +0 -43
  1034. package/bin/go/src/syscall/zerrors_openbsd_mips64.go +0 -1682
  1035. package/bin/go/src/syscall/zsyscall_openbsd_mips64.go +0 -1289
  1036. package/bin/go/src/syscall/zsysnum_openbsd_mips64.go +0 -218
  1037. package/bin/go/src/syscall/ztypes_openbsd_mips64.go +0 -443
  1038. package/bin/go/src/vendor/golang.org/x/net/idna/go118.go +0 -13
  1039. package/bin/go/src/vendor/golang.org/x/net/idna/idna9.0.0.go +0 -717
  1040. package/bin/go/src/vendor/golang.org/x/net/idna/pre_go118.go +0 -11
  1041. package/bin/go/src/vendor/golang.org/x/net/idna/tables10.0.0.go +0 -4559
  1042. package/bin/go/src/vendor/golang.org/x/net/idna/tables11.0.0.go +0 -4653
  1043. package/bin/go/src/vendor/golang.org/x/net/idna/tables12.0.0.go +0 -4733
  1044. package/bin/go/src/vendor/golang.org/x/net/idna/tables13.0.0.go +0 -4959
  1045. package/bin/go/src/vendor/golang.org/x/net/idna/tables9.0.0.go +0 -4486
  1046. package/bin/go/src/vendor/golang.org/x/net/idna/trie12.0.0.go +0 -30
  1047. package/bin/go/src/vendor/golang.org/x/net/idna/trie13.0.0.go +0 -30
  1048. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go +0 -11
  1049. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go +0 -14
  1050. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go +0 -1815
  1051. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go +0 -1887
  1052. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go +0 -1923
  1053. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go +0 -1955
  1054. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go +0 -1781
  1055. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go +0 -7657
  1056. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go +0 -7693
  1057. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go +0 -7710
  1058. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go +0 -7637
  1059. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/{go.yaml → go_amd64.yaml} +0 -0
  1060. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Compares/{go.yaml → go_amd64.yaml} +0 -0
  1061. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MinMax/{go.yaml → go_amd64.yaml} +0 -0
  1062. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/{go.yaml → go_amd64.yaml} +0 -0
@@ -0,0 +1,1905 @@
1
+ // Copyright 2014 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package http2
6
+
7
+ import (
8
+ "bytes"
9
+ "encoding/binary"
10
+ "errors"
11
+ "fmt"
12
+ "io"
13
+ "log"
14
+ "slices"
15
+ "strings"
16
+ "sync"
17
+
18
+ "net/http/internal/httpsfv"
19
+
20
+ "golang.org/x/net/http2/hpack"
21
+
22
+ "golang.org/x/net/http/httpguts"
23
+ )
24
+
25
+ const frameHeaderLen = 9
26
+
27
+ var padZeros = make([]byte, 255) // zeros for padding
28
+
29
+ // A FrameType is a registered frame type as defined in
30
+ // https://httpwg.org/specs/rfc7540.html#rfc.section.11.2 and other future
31
+ // RFCs.
32
+ type FrameType uint8
33
+
34
+ const (
35
+ FrameData FrameType = 0x0
36
+ FrameHeaders FrameType = 0x1
37
+ FramePriority FrameType = 0x2
38
+ FrameRSTStream FrameType = 0x3
39
+ FrameSettings FrameType = 0x4
40
+ FramePushPromise FrameType = 0x5
41
+ FramePing FrameType = 0x6
42
+ FrameGoAway FrameType = 0x7
43
+ FrameWindowUpdate FrameType = 0x8
44
+ FrameContinuation FrameType = 0x9
45
+ FramePriorityUpdate FrameType = 0x10
46
+ )
47
+
48
+ var frameNames = [...]string{
49
+ FrameData: "DATA",
50
+ FrameHeaders: "HEADERS",
51
+ FramePriority: "PRIORITY",
52
+ FrameRSTStream: "RST_STREAM",
53
+ FrameSettings: "SETTINGS",
54
+ FramePushPromise: "PUSH_PROMISE",
55
+ FramePing: "PING",
56
+ FrameGoAway: "GOAWAY",
57
+ FrameWindowUpdate: "WINDOW_UPDATE",
58
+ FrameContinuation: "CONTINUATION",
59
+ FramePriorityUpdate: "PRIORITY_UPDATE",
60
+ }
61
+
62
+ func (t FrameType) String() string {
63
+ if int(t) < len(frameNames) {
64
+ return frameNames[t]
65
+ }
66
+ return fmt.Sprintf("UNKNOWN_FRAME_TYPE_%d", t)
67
+ }
68
+
69
+ // Flags is a bitmask of HTTP/2 flags.
70
+ // The meaning of flags varies depending on the frame type.
71
+ type Flags uint8
72
+
73
+ // Has reports whether f contains all (0 or more) flags in v.
74
+ func (f Flags) Has(v Flags) bool {
75
+ return (f & v) == v
76
+ }
77
+
78
+ // Frame-specific FrameHeader flag bits.
79
+ const (
80
+ // Data Frame
81
+ FlagDataEndStream Flags = 0x1
82
+ FlagDataPadded Flags = 0x8
83
+
84
+ // Headers Frame
85
+ FlagHeadersEndStream Flags = 0x1
86
+ FlagHeadersEndHeaders Flags = 0x4
87
+ FlagHeadersPadded Flags = 0x8
88
+ FlagHeadersPriority Flags = 0x20
89
+
90
+ // Settings Frame
91
+ FlagSettingsAck Flags = 0x1
92
+
93
+ // Ping Frame
94
+ FlagPingAck Flags = 0x1
95
+
96
+ // Continuation Frame
97
+ FlagContinuationEndHeaders Flags = 0x4
98
+
99
+ FlagPushPromiseEndHeaders Flags = 0x4
100
+ FlagPushPromisePadded Flags = 0x8
101
+ )
102
+
103
+ var flagName = map[FrameType]map[Flags]string{
104
+ FrameData: {
105
+ FlagDataEndStream: "END_STREAM",
106
+ FlagDataPadded: "PADDED",
107
+ },
108
+ FrameHeaders: {
109
+ FlagHeadersEndStream: "END_STREAM",
110
+ FlagHeadersEndHeaders: "END_HEADERS",
111
+ FlagHeadersPadded: "PADDED",
112
+ FlagHeadersPriority: "PRIORITY",
113
+ },
114
+ FrameSettings: {
115
+ FlagSettingsAck: "ACK",
116
+ },
117
+ FramePing: {
118
+ FlagPingAck: "ACK",
119
+ },
120
+ FrameContinuation: {
121
+ FlagContinuationEndHeaders: "END_HEADERS",
122
+ },
123
+ FramePushPromise: {
124
+ FlagPushPromiseEndHeaders: "END_HEADERS",
125
+ FlagPushPromisePadded: "PADDED",
126
+ },
127
+ }
128
+
129
+ // a frameParser parses a frame given its FrameHeader and payload
130
+ // bytes. The length of payload will always equal fh.Length (which
131
+ // might be 0).
132
+ type frameParser func(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error)
133
+
134
+ var frameParsers = [...]frameParser{
135
+ FrameData: parseDataFrame,
136
+ FrameHeaders: parseHeadersFrame,
137
+ FramePriority: parsePriorityFrame,
138
+ FrameRSTStream: parseRSTStreamFrame,
139
+ FrameSettings: parseSettingsFrame,
140
+ FramePushPromise: parsePushPromise,
141
+ FramePing: parsePingFrame,
142
+ FrameGoAway: parseGoAwayFrame,
143
+ FrameWindowUpdate: parseWindowUpdateFrame,
144
+ FrameContinuation: parseContinuationFrame,
145
+ FramePriorityUpdate: parsePriorityUpdateFrame,
146
+ }
147
+
148
+ func typeFrameParser(t FrameType) frameParser {
149
+ if int(t) < len(frameParsers) {
150
+ if f := frameParsers[t]; f != nil {
151
+ return f
152
+ }
153
+ }
154
+ return parseUnknownFrame
155
+ }
156
+
157
+ // A FrameHeader is the 9 byte header of all HTTP/2 frames.
158
+ //
159
+ // See https://httpwg.org/specs/rfc7540.html#FrameHeader
160
+ type FrameHeader struct {
161
+ valid bool // caller can access []byte fields in the Frame
162
+
163
+ // Type is the 1 byte frame type. There are ten standard frame
164
+ // types, but extension frame types may be written by WriteRawFrame
165
+ // and will be returned by ReadFrame (as UnknownFrame).
166
+ Type FrameType
167
+
168
+ // Flags are the 1 byte of 8 potential bit flags per frame.
169
+ // They are specific to the frame type.
170
+ Flags Flags
171
+
172
+ // Length is the length of the frame, not including the 9 byte header.
173
+ // The maximum size is one byte less than 16MB (uint24), but only
174
+ // frames up to 16KB are allowed without peer agreement.
175
+ Length uint32
176
+
177
+ // StreamID is which stream this frame is for. Certain frames
178
+ // are not stream-specific, in which case this field is 0.
179
+ StreamID uint32
180
+ }
181
+
182
+ // Header returns h. It exists so FrameHeaders can be embedded in other
183
+ // specific frame types and implement the Frame interface.
184
+ func (h FrameHeader) Header() FrameHeader { return h }
185
+
186
+ func (h FrameHeader) String() string {
187
+ var buf bytes.Buffer
188
+ buf.WriteString("[FrameHeader ")
189
+ h.writeDebug(&buf)
190
+ buf.WriteByte(']')
191
+ return buf.String()
192
+ }
193
+
194
+ func (h FrameHeader) writeDebug(buf *bytes.Buffer) {
195
+ buf.WriteString(h.Type.String())
196
+ if h.Flags != 0 {
197
+ buf.WriteString(" flags=")
198
+ set := 0
199
+ for i := range uint8(8) {
200
+ if h.Flags&(1<<i) == 0 {
201
+ continue
202
+ }
203
+ set++
204
+ if set > 1 {
205
+ buf.WriteByte('|')
206
+ }
207
+ name := flagName[h.Type][Flags(1<<i)]
208
+ if name != "" {
209
+ buf.WriteString(name)
210
+ } else {
211
+ fmt.Fprintf(buf, "0x%x", 1<<i)
212
+ }
213
+ }
214
+ }
215
+ if h.StreamID != 0 {
216
+ fmt.Fprintf(buf, " stream=%d", h.StreamID)
217
+ }
218
+ fmt.Fprintf(buf, " len=%d", h.Length)
219
+ }
220
+
221
+ func (h *FrameHeader) checkValid() {
222
+ if !h.valid {
223
+ panic("Frame accessor called on non-owned Frame")
224
+ }
225
+ }
226
+
227
+ func (h *FrameHeader) invalidate() { h.valid = false }
228
+
229
+ // frame header bytes.
230
+ // Used only by ReadFrameHeader.
231
+ var fhBytes = sync.Pool{
232
+ New: func() any {
233
+ buf := make([]byte, frameHeaderLen)
234
+ return &buf
235
+ },
236
+ }
237
+
238
+ func invalidHTTP1LookingFrameHeader() FrameHeader {
239
+ fh, _ := readFrameHeader(make([]byte, frameHeaderLen), strings.NewReader("HTTP/1.1 "))
240
+ return fh
241
+ }
242
+
243
+ // ReadFrameHeader reads 9 bytes from r and returns a FrameHeader.
244
+ // Most users should use Framer.ReadFrame instead.
245
+ func ReadFrameHeader(r io.Reader) (FrameHeader, error) {
246
+ bufp := fhBytes.Get().(*[]byte)
247
+ defer fhBytes.Put(bufp)
248
+ return readFrameHeader(*bufp, r)
249
+ }
250
+
251
+ func readFrameHeader(buf []byte, r io.Reader) (FrameHeader, error) {
252
+ _, err := io.ReadFull(r, buf[:frameHeaderLen])
253
+ if err != nil {
254
+ return FrameHeader{}, err
255
+ }
256
+ return FrameHeader{
257
+ Length: (uint32(buf[0])<<16 | uint32(buf[1])<<8 | uint32(buf[2])),
258
+ Type: FrameType(buf[3]),
259
+ Flags: Flags(buf[4]),
260
+ StreamID: binary.BigEndian.Uint32(buf[5:]) & (1<<31 - 1),
261
+ valid: true,
262
+ }, nil
263
+ }
264
+
265
+ // A Frame is the base interface implemented by all frame types.
266
+ // Callers will generally type-assert the specific frame type:
267
+ // *HeadersFrame, *SettingsFrame, *WindowUpdateFrame, etc.
268
+ //
269
+ // Frames are only valid until the next call to Framer.ReadFrame.
270
+ type Frame interface {
271
+ Header() FrameHeader
272
+
273
+ // invalidate is called by Framer.ReadFrame to make this
274
+ // frame's buffers as being invalid, since the subsequent
275
+ // frame will reuse them.
276
+ invalidate()
277
+ }
278
+
279
+ // A Framer reads and writes Frames.
280
+ type Framer struct {
281
+ r io.Reader
282
+ lastFrame Frame
283
+ errDetail error
284
+
285
+ // countError is a non-nil func that's called on a frame parse
286
+ // error with some unique error path token. It's initialized
287
+ // from Transport.CountError or Server.CountError.
288
+ countError func(errToken string)
289
+
290
+ // lastHeaderStream is non-zero if the last frame was an
291
+ // unfinished HEADERS/CONTINUATION.
292
+ lastHeaderStream uint32
293
+ // lastFrameType holds the type of the last frame for verifying frame order.
294
+ lastFrameType FrameType
295
+
296
+ maxReadSize uint32
297
+ headerBuf [frameHeaderLen]byte
298
+
299
+ // TODO: let getReadBuf be configurable, and use a less memory-pinning
300
+ // allocator in server.go to minimize memory pinned for many idle conns.
301
+ // Will probably also need to make frame invalidation have a hook too.
302
+ getReadBuf func(size uint32) []byte
303
+ readBuf []byte // cache for default getReadBuf
304
+
305
+ maxWriteSize uint32 // zero means unlimited; TODO: implement
306
+
307
+ w io.Writer
308
+ wbuf []byte
309
+
310
+ // AllowIllegalWrites permits the Framer's Write methods to
311
+ // write frames that do not conform to the HTTP/2 spec. This
312
+ // permits using the Framer to test other HTTP/2
313
+ // implementations' conformance to the spec.
314
+ // If false, the Write methods will prefer to return an error
315
+ // rather than comply.
316
+ AllowIllegalWrites bool
317
+
318
+ // AllowIllegalReads permits the Framer's ReadFrame method
319
+ // to return non-compliant frames or frame orders.
320
+ // This is for testing and permits using the Framer to test
321
+ // other HTTP/2 implementations' conformance to the spec.
322
+ // It is not compatible with ReadMetaHeaders.
323
+ AllowIllegalReads bool
324
+
325
+ // ReadMetaHeaders if non-nil causes ReadFrame to merge
326
+ // HEADERS and CONTINUATION frames together and return
327
+ // MetaHeadersFrame instead.
328
+ ReadMetaHeaders *hpack.Decoder
329
+
330
+ // MaxHeaderListSize is the http2 MAX_HEADER_LIST_SIZE.
331
+ // It's used only if ReadMetaHeaders is set; 0 means a sane default
332
+ // (currently 16MB)
333
+ // If the limit is hit, MetaHeadersFrame.Truncated is set true.
334
+ MaxHeaderListSize uint32
335
+
336
+ // MaxHeaderValueCount is the maximum permitted number of
337
+ // header values.
338
+ // It's used only if ReadMetaHeaders is set; 0 means no limit.
339
+ // If the limit is hit, MetaHeadersFrame.Truncated is set true.
340
+ MaxHeaderValueCount int
341
+
342
+ // TODO: track which type of frame & with which flags was sent
343
+ // last. Then return an error (unless AllowIllegalWrites) if
344
+ // we're in the middle of a header block and a
345
+ // non-Continuation or Continuation on a different stream is
346
+ // attempted to be written.
347
+
348
+ logReads, logWrites bool
349
+
350
+ debugFramer *Framer // only use for logging written writes
351
+ debugFramerBuf *bytes.Buffer
352
+ debugReadLoggerf func(string, ...any)
353
+ debugWriteLoggerf func(string, ...any)
354
+
355
+ frameCache *frameCache // nil if frames aren't reused (default)
356
+ }
357
+
358
+ func (fr *Framer) maxHeaderListSize() uint32 {
359
+ if fr.MaxHeaderListSize == 0 {
360
+ return 16 << 20 // sane default, per docs
361
+ }
362
+ return fr.MaxHeaderListSize
363
+ }
364
+
365
+ func (fr *Framer) maxHeaderValueCount() int {
366
+ return fr.MaxHeaderValueCount
367
+ }
368
+
369
+ func (f *Framer) startWrite(ftype FrameType, flags Flags, streamID uint32) {
370
+ // Write the FrameHeader.
371
+ f.wbuf = append(f.wbuf[:0],
372
+ 0, // 3 bytes of length, filled in endWrite
373
+ 0,
374
+ 0,
375
+ byte(ftype),
376
+ byte(flags),
377
+ byte(streamID>>24),
378
+ byte(streamID>>16),
379
+ byte(streamID>>8),
380
+ byte(streamID))
381
+ }
382
+
383
+ func (f *Framer) endWrite() error {
384
+ // Now that we know the final size, fill in the FrameHeader in
385
+ // the space previously reserved for it. Abuse append.
386
+ length := len(f.wbuf) - frameHeaderLen
387
+ if length >= (1 << 24) {
388
+ return ErrFrameTooLarge
389
+ }
390
+ _ = append(f.wbuf[:0],
391
+ byte(length>>16),
392
+ byte(length>>8),
393
+ byte(length))
394
+ if f.logWrites {
395
+ f.logWrite()
396
+ }
397
+
398
+ n, err := f.w.Write(f.wbuf)
399
+ if err == nil && n != len(f.wbuf) {
400
+ err = io.ErrShortWrite
401
+ }
402
+ return err
403
+ }
404
+
405
+ func (f *Framer) logWrite() {
406
+ if f.debugFramer == nil {
407
+ f.debugFramerBuf = new(bytes.Buffer)
408
+ f.debugFramer = NewFramer(nil, f.debugFramerBuf)
409
+ f.debugFramer.logReads = false // we log it ourselves, saying "wrote" below
410
+ // Let us read anything, even if we accidentally wrote it
411
+ // in the wrong order:
412
+ f.debugFramer.AllowIllegalReads = true
413
+ }
414
+ f.debugFramerBuf.Write(f.wbuf)
415
+ fr, err := f.debugFramer.ReadFrame()
416
+ if err != nil {
417
+ f.debugWriteLoggerf("http2: Framer %p: failed to decode just-written frame", f)
418
+ return
419
+ }
420
+ f.debugWriteLoggerf("http2: Framer %p: wrote %v", f, summarizeFrame(fr))
421
+ }
422
+
423
+ func (f *Framer) writeByte(v byte) { f.wbuf = append(f.wbuf, v) }
424
+ func (f *Framer) writeBytes(v []byte) { f.wbuf = append(f.wbuf, v...) }
425
+ func (f *Framer) writeUint16(v uint16) { f.wbuf = append(f.wbuf, byte(v>>8), byte(v)) }
426
+ func (f *Framer) writeUint32(v uint32) {
427
+ f.wbuf = append(f.wbuf, byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
428
+ }
429
+
430
+ const (
431
+ minMaxFrameSize = 1 << 14
432
+ maxFrameSize = 1<<24 - 1
433
+ )
434
+
435
+ // SetReuseFrames allows the Framer to reuse Frames.
436
+ // If called on a Framer, Frames returned by calls to ReadFrame are only
437
+ // valid until the next call to ReadFrame.
438
+ func (fr *Framer) SetReuseFrames() {
439
+ if fr.frameCache != nil {
440
+ return
441
+ }
442
+ fr.frameCache = &frameCache{}
443
+ }
444
+
445
+ type frameCache struct {
446
+ dataFrame DataFrame
447
+ }
448
+
449
+ func (fc *frameCache) getDataFrame() *DataFrame {
450
+ if fc == nil {
451
+ return &DataFrame{}
452
+ }
453
+ return &fc.dataFrame
454
+ }
455
+
456
+ // NewFramer returns a Framer that writes frames to w and reads them from r.
457
+ func NewFramer(w io.Writer, r io.Reader) *Framer {
458
+ fr := &Framer{
459
+ w: w,
460
+ r: r,
461
+ countError: func(string) {},
462
+ logReads: logFrameReads,
463
+ logWrites: logFrameWrites,
464
+ debugReadLoggerf: log.Printf,
465
+ debugWriteLoggerf: log.Printf,
466
+ }
467
+ fr.getReadBuf = func(size uint32) []byte {
468
+ if cap(fr.readBuf) >= int(size) {
469
+ return fr.readBuf[:size]
470
+ }
471
+ fr.readBuf = make([]byte, size)
472
+ return fr.readBuf
473
+ }
474
+ fr.SetMaxReadFrameSize(maxFrameSize)
475
+ return fr
476
+ }
477
+
478
+ // SetMaxReadFrameSize sets the maximum size of a frame
479
+ // that will be read by a subsequent call to ReadFrame.
480
+ // It is the caller's responsibility to advertise this
481
+ // limit with a SETTINGS frame.
482
+ func (fr *Framer) SetMaxReadFrameSize(v uint32) {
483
+ if v > maxFrameSize {
484
+ v = maxFrameSize
485
+ }
486
+ fr.maxReadSize = v
487
+ }
488
+
489
+ // ErrorDetail returns a more detailed error of the last error
490
+ // returned by Framer.ReadFrame. For instance, if ReadFrame
491
+ // returns a StreamError with code PROTOCOL_ERROR, ErrorDetail
492
+ // will say exactly what was invalid. ErrorDetail is not guaranteed
493
+ // to return a non-nil value and like the rest of the http2 package,
494
+ // its return value is not protected by an API compatibility promise.
495
+ // ErrorDetail is reset after the next call to ReadFrame.
496
+ func (fr *Framer) ErrorDetail() error {
497
+ return fr.errDetail
498
+ }
499
+
500
+ // ErrFrameTooLarge is returned from Framer.ReadFrame when the peer
501
+ // sends a frame that is larger than declared with SetMaxReadFrameSize.
502
+ var ErrFrameTooLarge = errors.New("http2: frame too large")
503
+
504
+ // terminalReadFrameError reports whether err is an unrecoverable
505
+ // error from ReadFrame and no other frames should be read.
506
+ func terminalReadFrameError(err error) bool {
507
+ if _, ok := err.(StreamError); ok {
508
+ return false
509
+ }
510
+ return err != nil
511
+ }
512
+
513
+ // ReadFrameHeader reads the header of the next frame.
514
+ // It reads the 9-byte fixed frame header, and does not read any portion of the
515
+ // frame payload. The caller is responsible for consuming the payload, either
516
+ // with ReadFrameForHeader or directly from the Framer's io.Reader.
517
+ //
518
+ // If the frame is larger than previously set with SetMaxReadFrameSize, it
519
+ // returns the frame header and ErrFrameTooLarge.
520
+ //
521
+ // If the returned FrameHeader.StreamID is non-zero, it indicates the stream
522
+ // responsible for the error.
523
+ func (fr *Framer) ReadFrameHeader() (FrameHeader, error) {
524
+ fr.errDetail = nil
525
+ fh, err := readFrameHeader(fr.headerBuf[:], fr.r)
526
+ if err != nil {
527
+ return fh, err
528
+ }
529
+ if fh.Length > fr.maxReadSize {
530
+ if fh == invalidHTTP1LookingFrameHeader() {
531
+ return fh, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", ErrFrameTooLarge)
532
+ }
533
+ return fh, ErrFrameTooLarge
534
+ }
535
+ if err := fr.checkFrameOrder(fh); err != nil {
536
+ return fh, err
537
+ }
538
+ return fh, nil
539
+ }
540
+
541
+ // ReadFrameForHeader reads the payload for the frame with the given FrameHeader.
542
+ //
543
+ // It behaves identically to ReadFrame, other than not checking the maximum
544
+ // frame size.
545
+ func (fr *Framer) ReadFrameForHeader(fh FrameHeader) (Frame, error) {
546
+ if fr.lastFrame != nil {
547
+ fr.lastFrame.invalidate()
548
+ }
549
+ payload := fr.getReadBuf(fh.Length)
550
+ if _, err := io.ReadFull(fr.r, payload); err != nil {
551
+ if fh == invalidHTTP1LookingFrameHeader() {
552
+ return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", err)
553
+ }
554
+ return nil, err
555
+ }
556
+ f, err := typeFrameParser(fh.Type)(fr.frameCache, fh, fr.countError, payload)
557
+ if err != nil {
558
+ if ce, ok := err.(connError); ok {
559
+ return nil, fr.connError(ce.Code, ce.Reason)
560
+ }
561
+ return nil, err
562
+ }
563
+ fr.lastFrame = f
564
+ if fr.logReads {
565
+ fr.debugReadLoggerf("http2: Framer %p: read %v", fr, summarizeFrame(f))
566
+ }
567
+ if fh.Type == FrameHeaders && fr.ReadMetaHeaders != nil {
568
+ return fr.readMetaFrame(f.(*HeadersFrame))
569
+ }
570
+ return f, nil
571
+ }
572
+
573
+ // ReadFrame reads a single frame. The returned Frame is only valid
574
+ // until the next call to ReadFrame or ReadFrameBodyForHeader.
575
+ //
576
+ // If the frame is larger than previously set with SetMaxReadFrameSize, the
577
+ // returned error is ErrFrameTooLarge. Other errors may be of type
578
+ // ConnectionError, StreamError, or anything else from the underlying
579
+ // reader.
580
+ //
581
+ // If ReadFrame returns an error and a non-nil Frame, the Frame's StreamID
582
+ // indicates the stream responsible for the error.
583
+ func (fr *Framer) ReadFrame() (Frame, error) {
584
+ fh, err := fr.ReadFrameHeader()
585
+ if err != nil {
586
+ return nil, err
587
+ }
588
+ return fr.ReadFrameForHeader(fh)
589
+ }
590
+
591
+ // connError returns ConnectionError(code) but first
592
+ // stashes away a public reason to the caller can optionally relay it
593
+ // to the peer before hanging up on them. This might help others debug
594
+ // their implementations.
595
+ func (fr *Framer) connError(code ErrCode, reason string) error {
596
+ fr.errDetail = errors.New(reason)
597
+ return ConnectionError(code)
598
+ }
599
+
600
+ // checkFrameOrder reports an error if f is an invalid frame to return
601
+ // next from ReadFrame. Mostly it checks whether HEADERS and
602
+ // CONTINUATION frames are contiguous.
603
+ func (fr *Framer) checkFrameOrder(fh FrameHeader) error {
604
+ lastType := fr.lastFrameType
605
+ fr.lastFrameType = fh.Type
606
+ if fr.AllowIllegalReads {
607
+ return nil
608
+ }
609
+
610
+ if fr.lastHeaderStream != 0 {
611
+ if fh.Type != FrameContinuation {
612
+ return fr.connError(ErrCodeProtocol,
613
+ fmt.Sprintf("got %s for stream %d; expected CONTINUATION following %s for stream %d",
614
+ fh.Type, fh.StreamID,
615
+ lastType, fr.lastHeaderStream))
616
+ }
617
+ if fh.StreamID != fr.lastHeaderStream {
618
+ return fr.connError(ErrCodeProtocol,
619
+ fmt.Sprintf("got CONTINUATION for stream %d; expected stream %d",
620
+ fh.StreamID, fr.lastHeaderStream))
621
+ }
622
+ } else if fh.Type == FrameContinuation {
623
+ return fr.connError(ErrCodeProtocol, fmt.Sprintf("unexpected CONTINUATION for stream %d", fh.StreamID))
624
+ }
625
+
626
+ switch fh.Type {
627
+ case FrameHeaders, FrameContinuation:
628
+ if fh.Flags.Has(FlagHeadersEndHeaders) {
629
+ fr.lastHeaderStream = 0
630
+ } else {
631
+ fr.lastHeaderStream = fh.StreamID
632
+ }
633
+ }
634
+
635
+ return nil
636
+ }
637
+
638
+ // A DataFrame conveys arbitrary, variable-length sequences of octets
639
+ // associated with a stream.
640
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.1
641
+ type DataFrame struct {
642
+ FrameHeader
643
+ data []byte
644
+ }
645
+
646
+ func (f *DataFrame) StreamEnded() bool {
647
+ return f.FrameHeader.Flags.Has(FlagDataEndStream)
648
+ }
649
+
650
+ // Data returns the frame's data octets, not including any padding
651
+ // size byte or padding suffix bytes.
652
+ // The caller must not retain the returned memory past the next
653
+ // call to ReadFrame.
654
+ func (f *DataFrame) Data() []byte {
655
+ f.checkValid()
656
+ return f.data
657
+ }
658
+
659
+ func parseDataFrame(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) {
660
+ if fh.StreamID == 0 {
661
+ // DATA frames MUST be associated with a stream. If a
662
+ // DATA frame is received whose stream identifier
663
+ // field is 0x0, the recipient MUST respond with a
664
+ // connection error (Section 5.4.1) of type
665
+ // PROTOCOL_ERROR.
666
+ countError("frame_data_stream_0")
667
+ return nil, connError{ErrCodeProtocol, "DATA frame with stream ID 0"}
668
+ }
669
+ f := fc.getDataFrame()
670
+ f.FrameHeader = fh
671
+
672
+ var padSize byte
673
+ if fh.Flags.Has(FlagDataPadded) {
674
+ var err error
675
+ payload, padSize, err = readByte(payload)
676
+ if err != nil {
677
+ countError("frame_data_pad_byte_short")
678
+ return nil, err
679
+ }
680
+ }
681
+ if int(padSize) > len(payload) {
682
+ // If the length of the padding is greater than the
683
+ // length of the frame payload, the recipient MUST
684
+ // treat this as a connection error.
685
+ // Filed: https://github.com/http2/http2-spec/issues/610
686
+ countError("frame_data_pad_too_big")
687
+ return nil, connError{ErrCodeProtocol, "pad size larger than data payload"}
688
+ }
689
+ f.data = payload[:len(payload)-int(padSize)]
690
+ return f, nil
691
+ }
692
+
693
+ var (
694
+ errStreamID = errors.New("invalid stream ID")
695
+ errDepStreamID = errors.New("invalid dependent stream ID")
696
+ errPadLength = errors.New("pad length too large")
697
+ errPadBytes = errors.New("padding bytes must all be zeros unless AllowIllegalWrites is enabled")
698
+ )
699
+
700
+ func validStreamIDOrZero(streamID uint32) bool {
701
+ return streamID&(1<<31) == 0
702
+ }
703
+
704
+ func validStreamID(streamID uint32) bool {
705
+ return streamID != 0 && streamID&(1<<31) == 0
706
+ }
707
+
708
+ // WriteData writes a DATA frame.
709
+ //
710
+ // It will perform exactly one Write to the underlying Writer.
711
+ // It is the caller's responsibility not to violate the maximum frame size
712
+ // and to not call other Write methods concurrently.
713
+ func (f *Framer) WriteData(streamID uint32, endStream bool, data []byte) error {
714
+ return f.WriteDataPadded(streamID, endStream, data, nil)
715
+ }
716
+
717
+ // WriteDataPadded writes a DATA frame with optional padding.
718
+ //
719
+ // If pad is nil, the padding bit is not sent.
720
+ // The length of pad must not exceed 255 bytes.
721
+ // The bytes of pad must all be zero, unless f.AllowIllegalWrites is set.
722
+ //
723
+ // It will perform exactly one Write to the underlying Writer.
724
+ // It is the caller's responsibility not to violate the maximum frame size
725
+ // and to not call other Write methods concurrently.
726
+ func (f *Framer) WriteDataPadded(streamID uint32, endStream bool, data, pad []byte) error {
727
+ if err := f.startWriteDataPadded(streamID, endStream, data, pad); err != nil {
728
+ return err
729
+ }
730
+ return f.endWrite()
731
+ }
732
+
733
+ // startWriteDataPadded is WriteDataPadded, but only writes the frame to the Framer's internal buffer.
734
+ // The caller should call endWrite to flush the frame to the underlying writer.
735
+ func (f *Framer) startWriteDataPadded(streamID uint32, endStream bool, data, pad []byte) error {
736
+ if !validStreamID(streamID) && !f.AllowIllegalWrites {
737
+ return errStreamID
738
+ }
739
+ if len(pad) > 0 {
740
+ if len(pad) > 255 {
741
+ return errPadLength
742
+ }
743
+ if !f.AllowIllegalWrites {
744
+ for _, b := range pad {
745
+ if b != 0 {
746
+ // "Padding octets MUST be set to zero when sending."
747
+ return errPadBytes
748
+ }
749
+ }
750
+ }
751
+ }
752
+ var flags Flags
753
+ if endStream {
754
+ flags |= FlagDataEndStream
755
+ }
756
+ if pad != nil {
757
+ flags |= FlagDataPadded
758
+ }
759
+ f.startWrite(FrameData, flags, streamID)
760
+ if pad != nil {
761
+ f.wbuf = append(f.wbuf, byte(len(pad)))
762
+ }
763
+ f.wbuf = append(f.wbuf, data...)
764
+ f.wbuf = append(f.wbuf, pad...)
765
+ return nil
766
+ }
767
+
768
+ // A SettingsFrame conveys configuration parameters that affect how
769
+ // endpoints communicate, such as preferences and constraints on peer
770
+ // behavior.
771
+ //
772
+ // See https://httpwg.org/specs/rfc7540.html#SETTINGS
773
+ type SettingsFrame struct {
774
+ FrameHeader
775
+ p []byte
776
+ }
777
+
778
+ func parseSettingsFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
779
+ if fh.Flags.Has(FlagSettingsAck) && fh.Length > 0 {
780
+ // When this (ACK 0x1) bit is set, the payload of the
781
+ // SETTINGS frame MUST be empty. Receipt of a
782
+ // SETTINGS frame with the ACK flag set and a length
783
+ // field value other than 0 MUST be treated as a
784
+ // connection error (Section 5.4.1) of type
785
+ // FRAME_SIZE_ERROR.
786
+ countError("frame_settings_ack_with_length")
787
+ return nil, ConnectionError(ErrCodeFrameSize)
788
+ }
789
+ if fh.StreamID != 0 {
790
+ // SETTINGS frames always apply to a connection,
791
+ // never a single stream. The stream identifier for a
792
+ // SETTINGS frame MUST be zero (0x0). If an endpoint
793
+ // receives a SETTINGS frame whose stream identifier
794
+ // field is anything other than 0x0, the endpoint MUST
795
+ // respond with a connection error (Section 5.4.1) of
796
+ // type PROTOCOL_ERROR.
797
+ countError("frame_settings_has_stream")
798
+ return nil, ConnectionError(ErrCodeProtocol)
799
+ }
800
+ if len(p)%6 != 0 {
801
+ countError("frame_settings_mod_6")
802
+ // Expecting even number of 6 byte settings.
803
+ return nil, ConnectionError(ErrCodeFrameSize)
804
+ }
805
+ f := &SettingsFrame{FrameHeader: fh, p: p}
806
+ if v, ok := f.Value(SettingInitialWindowSize); ok && v > (1<<31)-1 {
807
+ countError("frame_settings_window_size_too_big")
808
+ // Values above the maximum flow control window size of 2^31 - 1 MUST
809
+ // be treated as a connection error (Section 5.4.1) of type
810
+ // FLOW_CONTROL_ERROR.
811
+ return nil, ConnectionError(ErrCodeFlowControl)
812
+ }
813
+ return f, nil
814
+ }
815
+
816
+ func (f *SettingsFrame) IsAck() bool {
817
+ return f.FrameHeader.Flags.Has(FlagSettingsAck)
818
+ }
819
+
820
+ func (f *SettingsFrame) Value(id SettingID) (v uint32, ok bool) {
821
+ f.checkValid()
822
+ for i := 0; i < f.NumSettings(); i++ {
823
+ if s := f.Setting(i); s.ID == id {
824
+ return s.Val, true
825
+ }
826
+ }
827
+ return 0, false
828
+ }
829
+
830
+ // Setting returns the setting from the frame at the given 0-based index.
831
+ // The index must be >= 0 and less than f.NumSettings().
832
+ func (f *SettingsFrame) Setting(i int) Setting {
833
+ buf := f.p
834
+ return Setting{
835
+ ID: SettingID(binary.BigEndian.Uint16(buf[i*6 : i*6+2])),
836
+ Val: binary.BigEndian.Uint32(buf[i*6+2 : i*6+6]),
837
+ }
838
+ }
839
+
840
+ func (f *SettingsFrame) NumSettings() int { return len(f.p) / 6 }
841
+
842
+ // HasDuplicates reports whether f contains any duplicate setting IDs.
843
+ func (f *SettingsFrame) HasDuplicates() bool {
844
+ num := f.NumSettings()
845
+ if num == 0 {
846
+ return false
847
+ }
848
+ // If it's small enough (the common case), just do the n^2
849
+ // thing and avoid a map allocation.
850
+ if num < 10 {
851
+ for i := range num {
852
+ idi := f.Setting(i).ID
853
+ for j := i + 1; j < num; j++ {
854
+ idj := f.Setting(j).ID
855
+ if idi == idj {
856
+ return true
857
+ }
858
+ }
859
+ }
860
+ return false
861
+ }
862
+ seen := map[SettingID]bool{}
863
+ for i := range num {
864
+ id := f.Setting(i).ID
865
+ if seen[id] {
866
+ return true
867
+ }
868
+ seen[id] = true
869
+ }
870
+ return false
871
+ }
872
+
873
+ // ForeachSetting runs fn for each setting.
874
+ // It stops and returns the first error.
875
+ func (f *SettingsFrame) ForeachSetting(fn func(Setting) error) error {
876
+ f.checkValid()
877
+ for i := 0; i < f.NumSettings(); i++ {
878
+ if err := fn(f.Setting(i)); err != nil {
879
+ return err
880
+ }
881
+ }
882
+ return nil
883
+ }
884
+
885
+ // WriteSettings writes a SETTINGS frame with zero or more settings
886
+ // specified and the ACK bit not set.
887
+ //
888
+ // It will perform exactly one Write to the underlying Writer.
889
+ // It is the caller's responsibility to not call other Write methods concurrently.
890
+ func (f *Framer) WriteSettings(settings ...Setting) error {
891
+ f.startWrite(FrameSettings, 0, 0)
892
+ for _, s := range settings {
893
+ f.writeUint16(uint16(s.ID))
894
+ f.writeUint32(s.Val)
895
+ }
896
+ return f.endWrite()
897
+ }
898
+
899
+ // WriteSettingsAck writes an empty SETTINGS frame with the ACK bit set.
900
+ //
901
+ // It will perform exactly one Write to the underlying Writer.
902
+ // It is the caller's responsibility to not call other Write methods concurrently.
903
+ func (f *Framer) WriteSettingsAck() error {
904
+ f.startWrite(FrameSettings, FlagSettingsAck, 0)
905
+ return f.endWrite()
906
+ }
907
+
908
+ // A PingFrame is a mechanism for measuring a minimal round trip time
909
+ // from the sender, as well as determining whether an idle connection
910
+ // is still functional.
911
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.7
912
+ type PingFrame struct {
913
+ FrameHeader
914
+ Data [8]byte
915
+ }
916
+
917
+ func (f *PingFrame) IsAck() bool { return f.Flags.Has(FlagPingAck) }
918
+
919
+ func parsePingFrame(_ *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) {
920
+ if len(payload) != 8 {
921
+ countError("frame_ping_length")
922
+ return nil, ConnectionError(ErrCodeFrameSize)
923
+ }
924
+ if fh.StreamID != 0 {
925
+ countError("frame_ping_has_stream")
926
+ return nil, ConnectionError(ErrCodeProtocol)
927
+ }
928
+ f := &PingFrame{FrameHeader: fh}
929
+ copy(f.Data[:], payload)
930
+ return f, nil
931
+ }
932
+
933
+ func (f *Framer) WritePing(ack bool, data [8]byte) error {
934
+ var flags Flags
935
+ if ack {
936
+ flags = FlagPingAck
937
+ }
938
+ f.startWrite(FramePing, flags, 0)
939
+ f.writeBytes(data[:])
940
+ return f.endWrite()
941
+ }
942
+
943
+ // A GoAwayFrame informs the remote peer to stop creating streams on this connection.
944
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.8
945
+ type GoAwayFrame struct {
946
+ FrameHeader
947
+ LastStreamID uint32
948
+ ErrCode ErrCode
949
+ debugData []byte
950
+ }
951
+
952
+ // DebugData returns any debug data in the GOAWAY frame. Its contents
953
+ // are not defined.
954
+ // The caller must not retain the returned memory past the next
955
+ // call to ReadFrame.
956
+ func (f *GoAwayFrame) DebugData() []byte {
957
+ f.checkValid()
958
+ return f.debugData
959
+ }
960
+
961
+ func parseGoAwayFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
962
+ if fh.StreamID != 0 {
963
+ countError("frame_goaway_has_stream")
964
+ return nil, ConnectionError(ErrCodeProtocol)
965
+ }
966
+ if len(p) < 8 {
967
+ countError("frame_goaway_short")
968
+ return nil, ConnectionError(ErrCodeFrameSize)
969
+ }
970
+ return &GoAwayFrame{
971
+ FrameHeader: fh,
972
+ LastStreamID: binary.BigEndian.Uint32(p[:4]) & (1<<31 - 1),
973
+ ErrCode: ErrCode(binary.BigEndian.Uint32(p[4:8])),
974
+ debugData: p[8:],
975
+ }, nil
976
+ }
977
+
978
+ func (f *Framer) WriteGoAway(maxStreamID uint32, code ErrCode, debugData []byte) error {
979
+ f.startWrite(FrameGoAway, 0, 0)
980
+ f.writeUint32(maxStreamID & (1<<31 - 1))
981
+ f.writeUint32(uint32(code))
982
+ f.writeBytes(debugData)
983
+ return f.endWrite()
984
+ }
985
+
986
+ // An UnknownFrame is the frame type returned when the frame type is unknown
987
+ // or no specific frame type parser exists.
988
+ type UnknownFrame struct {
989
+ FrameHeader
990
+ p []byte
991
+ }
992
+
993
+ // Payload returns the frame's payload (after the header). It is not
994
+ // valid to call this method after a subsequent call to
995
+ // Framer.ReadFrame, nor is it valid to retain the returned slice.
996
+ // The memory is owned by the Framer and is invalidated when the next
997
+ // frame is read.
998
+ func (f *UnknownFrame) Payload() []byte {
999
+ f.checkValid()
1000
+ return f.p
1001
+ }
1002
+
1003
+ func parseUnknownFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
1004
+ return &UnknownFrame{fh, p}, nil
1005
+ }
1006
+
1007
+ // A WindowUpdateFrame is used to implement flow control.
1008
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.9
1009
+ type WindowUpdateFrame struct {
1010
+ FrameHeader
1011
+ Increment uint32 // never read with high bit set
1012
+ }
1013
+
1014
+ func parseWindowUpdateFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
1015
+ if len(p) != 4 {
1016
+ countError("frame_windowupdate_bad_len")
1017
+ return nil, ConnectionError(ErrCodeFrameSize)
1018
+ }
1019
+ inc := binary.BigEndian.Uint32(p[:4]) & 0x7fffffff // mask off high reserved bit
1020
+ if inc == 0 {
1021
+ // A receiver MUST treat the receipt of a
1022
+ // WINDOW_UPDATE frame with an flow control window
1023
+ // increment of 0 as a stream error (Section 5.4.2) of
1024
+ // type PROTOCOL_ERROR; errors on the connection flow
1025
+ // control window MUST be treated as a connection
1026
+ // error (Section 5.4.1).
1027
+ if fh.StreamID == 0 {
1028
+ countError("frame_windowupdate_zero_inc_conn")
1029
+ return nil, ConnectionError(ErrCodeProtocol)
1030
+ }
1031
+ countError("frame_windowupdate_zero_inc_stream")
1032
+ return nil, streamError(fh.StreamID, ErrCodeProtocol)
1033
+ }
1034
+ return &WindowUpdateFrame{
1035
+ FrameHeader: fh,
1036
+ Increment: inc,
1037
+ }, nil
1038
+ }
1039
+
1040
+ // WriteWindowUpdate writes a WINDOW_UPDATE frame.
1041
+ // The increment value must be between 1 and 2,147,483,647, inclusive.
1042
+ // If the Stream ID is zero, the window update applies to the
1043
+ // connection as a whole.
1044
+ func (f *Framer) WriteWindowUpdate(streamID, incr uint32) error {
1045
+ // "The legal range for the increment to the flow control window is 1 to 2^31-1 (2,147,483,647) octets."
1046
+ if (incr < 1 || incr > 2147483647) && !f.AllowIllegalWrites {
1047
+ return errors.New("illegal window increment value")
1048
+ }
1049
+ f.startWrite(FrameWindowUpdate, 0, streamID)
1050
+ f.writeUint32(incr)
1051
+ return f.endWrite()
1052
+ }
1053
+
1054
+ // A HeadersFrame is used to open a stream and additionally carries a
1055
+ // header block fragment.
1056
+ type HeadersFrame struct {
1057
+ FrameHeader
1058
+
1059
+ // Priority is set if FlagHeadersPriority is set in the FrameHeader.
1060
+ Priority PriorityParam
1061
+
1062
+ headerFragBuf []byte // not owned
1063
+ }
1064
+
1065
+ func (f *HeadersFrame) HeaderBlockFragment() []byte {
1066
+ f.checkValid()
1067
+ return f.headerFragBuf
1068
+ }
1069
+
1070
+ func (f *HeadersFrame) HeadersEnded() bool {
1071
+ return f.FrameHeader.Flags.Has(FlagHeadersEndHeaders)
1072
+ }
1073
+
1074
+ func (f *HeadersFrame) StreamEnded() bool {
1075
+ return f.FrameHeader.Flags.Has(FlagHeadersEndStream)
1076
+ }
1077
+
1078
+ func (f *HeadersFrame) HasPriority() bool {
1079
+ return f.FrameHeader.Flags.Has(FlagHeadersPriority)
1080
+ }
1081
+
1082
+ func parseHeadersFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) {
1083
+ hf := &HeadersFrame{
1084
+ FrameHeader: fh,
1085
+ }
1086
+ if fh.StreamID == 0 {
1087
+ // HEADERS frames MUST be associated with a stream. If a HEADERS frame
1088
+ // is received whose stream identifier field is 0x0, the recipient MUST
1089
+ // respond with a connection error (Section 5.4.1) of type
1090
+ // PROTOCOL_ERROR.
1091
+ countError("frame_headers_zero_stream")
1092
+ return nil, connError{ErrCodeProtocol, "HEADERS frame with stream ID 0"}
1093
+ }
1094
+ var padLength uint8
1095
+ if fh.Flags.Has(FlagHeadersPadded) {
1096
+ if p, padLength, err = readByte(p); err != nil {
1097
+ countError("frame_headers_pad_short")
1098
+ return
1099
+ }
1100
+ }
1101
+ if fh.Flags.Has(FlagHeadersPriority) {
1102
+ var v uint32
1103
+ p, v, err = readUint32(p)
1104
+ if err != nil {
1105
+ countError("frame_headers_prio_short")
1106
+ return nil, err
1107
+ }
1108
+ hf.Priority.StreamDep = v & 0x7fffffff
1109
+ hf.Priority.Exclusive = (v != hf.Priority.StreamDep) // high bit was set
1110
+ p, hf.Priority.Weight, err = readByte(p)
1111
+ if err != nil {
1112
+ countError("frame_headers_prio_weight_short")
1113
+ return nil, err
1114
+ }
1115
+ }
1116
+ if len(p)-int(padLength) < 0 {
1117
+ countError("frame_headers_pad_too_big")
1118
+ return nil, streamError(fh.StreamID, ErrCodeProtocol)
1119
+ }
1120
+ hf.headerFragBuf = p[:len(p)-int(padLength)]
1121
+ return hf, nil
1122
+ }
1123
+
1124
+ // HeadersFrameParam are the parameters for writing a HEADERS frame.
1125
+ type HeadersFrameParam struct {
1126
+ // StreamID is the required Stream ID to initiate.
1127
+ StreamID uint32
1128
+ // BlockFragment is part (or all) of a Header Block.
1129
+ BlockFragment []byte
1130
+
1131
+ // EndStream indicates that the header block is the last that
1132
+ // the endpoint will send for the identified stream. Setting
1133
+ // this flag causes the stream to enter one of "half closed"
1134
+ // states.
1135
+ EndStream bool
1136
+
1137
+ // EndHeaders indicates that this frame contains an entire
1138
+ // header block and is not followed by any
1139
+ // CONTINUATION frames.
1140
+ EndHeaders bool
1141
+
1142
+ // PadLength is the optional number of bytes of zeros to add
1143
+ // to this frame.
1144
+ PadLength uint8
1145
+
1146
+ // Priority, if non-zero, includes stream priority information
1147
+ // in the HEADER frame.
1148
+ Priority PriorityParam
1149
+ }
1150
+
1151
+ // WriteHeaders writes a single HEADERS frame.
1152
+ //
1153
+ // This is a low-level header writing method. Encoding headers and
1154
+ // splitting them into any necessary CONTINUATION frames is handled
1155
+ // elsewhere.
1156
+ //
1157
+ // It will perform exactly one Write to the underlying Writer.
1158
+ // It is the caller's responsibility to not call other Write methods concurrently.
1159
+ func (f *Framer) WriteHeaders(p HeadersFrameParam) error {
1160
+ if !validStreamID(p.StreamID) && !f.AllowIllegalWrites {
1161
+ return errStreamID
1162
+ }
1163
+ var flags Flags
1164
+ if p.PadLength != 0 {
1165
+ flags |= FlagHeadersPadded
1166
+ }
1167
+ if p.EndStream {
1168
+ flags |= FlagHeadersEndStream
1169
+ }
1170
+ if p.EndHeaders {
1171
+ flags |= FlagHeadersEndHeaders
1172
+ }
1173
+ if !p.Priority.IsZero() {
1174
+ flags |= FlagHeadersPriority
1175
+ }
1176
+ f.startWrite(FrameHeaders, flags, p.StreamID)
1177
+ if p.PadLength != 0 {
1178
+ f.writeByte(p.PadLength)
1179
+ }
1180
+ if !p.Priority.IsZero() {
1181
+ v := p.Priority.StreamDep
1182
+ if !validStreamIDOrZero(v) && !f.AllowIllegalWrites {
1183
+ return errDepStreamID
1184
+ }
1185
+ if p.Priority.Exclusive {
1186
+ v |= 1 << 31
1187
+ }
1188
+ f.writeUint32(v)
1189
+ f.writeByte(p.Priority.Weight)
1190
+ }
1191
+ f.wbuf = append(f.wbuf, p.BlockFragment...)
1192
+ f.wbuf = append(f.wbuf, padZeros[:p.PadLength]...)
1193
+ return f.endWrite()
1194
+ }
1195
+
1196
+ // A PriorityFrame specifies the sender-advised priority of a stream.
1197
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.3
1198
+ type PriorityFrame struct {
1199
+ FrameHeader
1200
+ PriorityParam
1201
+ }
1202
+
1203
+ // defaultRFC9218Priority determines what priority we should use as the default
1204
+ // value.
1205
+ //
1206
+ // According to RFC 9218, by default, streams should be given an urgency of 3
1207
+ // and should be non-incremental. However, making streams non-incremental by
1208
+ // default would be a huge change to our historical behavior where we would
1209
+ // round-robin writes across streams. When streams are non-incremental, we
1210
+ // would process streams of the same urgency one-by-one to completion instead.
1211
+ //
1212
+ // To avoid such a sudden change which might break some HTTP/2 users, this
1213
+ // function allows the caller to specify whether they can actually use the
1214
+ // default value as specified in RFC 9218. If not, this function will return a
1215
+ // priority value where streams are incremental by default instead: effectively
1216
+ // a round-robin between stream of the same urgency.
1217
+ //
1218
+ // As an example, a server might not be able to use the RFC 9218 default value
1219
+ // when it's not sure that the client it is serving is aware of RFC 9218.
1220
+ func defaultRFC9218Priority(canUseDefault bool) PriorityParam {
1221
+ if canUseDefault {
1222
+ return PriorityParam{
1223
+ urgency: 3,
1224
+ incremental: 0,
1225
+ }
1226
+ }
1227
+ return PriorityParam{
1228
+ urgency: 3,
1229
+ incremental: 1,
1230
+ }
1231
+ }
1232
+
1233
+ // Note that HTTP/2 has had two different prioritization schemes, and
1234
+ // PriorityParam struct below is a superset of both schemes. The exported
1235
+ // symbols are from RFC 7540 and the non-exported ones are from RFC 9218.
1236
+
1237
+ // PriorityParam are the stream prioritization parameters.
1238
+ type PriorityParam struct {
1239
+ // StreamDep is a 31-bit stream identifier for the
1240
+ // stream that this stream depends on. Zero means no
1241
+ // dependency.
1242
+ StreamDep uint32
1243
+
1244
+ // Exclusive is whether the dependency is exclusive.
1245
+ Exclusive bool
1246
+
1247
+ // Weight is the stream's zero-indexed weight. It should be
1248
+ // set together with StreamDep, or neither should be set. Per
1249
+ // the spec, "Add one to the value to obtain a weight between
1250
+ // 1 and 256."
1251
+ Weight uint8
1252
+
1253
+ // "The urgency (u) parameter value is Integer (see Section 3.3.1 of
1254
+ // [STRUCTURED-FIELDS]), between 0 and 7 inclusive, in descending order of
1255
+ // priority. The default is 3."
1256
+ urgency uint8
1257
+
1258
+ // "The incremental (i) parameter value is Boolean (see Section 3.3.6 of
1259
+ // [STRUCTURED-FIELDS]). It indicates if an HTTP response can be processed
1260
+ // incrementally, i.e., provide some meaningful output as chunks of the
1261
+ // response arrive."
1262
+ //
1263
+ // We use uint8 (i.e. 0 is false, 1 is true) instead of bool so we can
1264
+ // avoid unnecessary type conversions and because either type takes 1 byte.
1265
+ incremental uint8
1266
+ }
1267
+
1268
+ func (p PriorityParam) IsZero() bool {
1269
+ return p == PriorityParam{}
1270
+ }
1271
+
1272
+ func parsePriorityFrame(_ *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) {
1273
+ if fh.StreamID == 0 {
1274
+ countError("frame_priority_zero_stream")
1275
+ return nil, connError{ErrCodeProtocol, "PRIORITY frame with stream ID 0"}
1276
+ }
1277
+ if len(payload) != 5 {
1278
+ countError("frame_priority_bad_length")
1279
+ return nil, connError{ErrCodeFrameSize, fmt.Sprintf("PRIORITY frame payload size was %d; want 5", len(payload))}
1280
+ }
1281
+ v := binary.BigEndian.Uint32(payload[:4])
1282
+ streamID := v & 0x7fffffff // mask off high bit
1283
+ return &PriorityFrame{
1284
+ FrameHeader: fh,
1285
+ PriorityParam: PriorityParam{
1286
+ Weight: payload[4],
1287
+ StreamDep: streamID,
1288
+ Exclusive: streamID != v, // was high bit set?
1289
+ },
1290
+ }, nil
1291
+ }
1292
+
1293
+ // WritePriority writes a PRIORITY frame.
1294
+ //
1295
+ // It will perform exactly one Write to the underlying Writer.
1296
+ // It is the caller's responsibility to not call other Write methods concurrently.
1297
+ func (f *Framer) WritePriority(streamID uint32, p PriorityParam) error {
1298
+ if !validStreamID(streamID) && !f.AllowIllegalWrites {
1299
+ return errStreamID
1300
+ }
1301
+ if !validStreamIDOrZero(p.StreamDep) {
1302
+ return errDepStreamID
1303
+ }
1304
+ f.startWrite(FramePriority, 0, streamID)
1305
+ v := p.StreamDep
1306
+ if p.Exclusive {
1307
+ v |= 1 << 31
1308
+ }
1309
+ f.writeUint32(v)
1310
+ f.writeByte(p.Weight)
1311
+ return f.endWrite()
1312
+ }
1313
+
1314
+ // PriorityUpdateFrame is a PRIORITY_UPDATE frame as described in
1315
+ // https://www.rfc-editor.org/rfc/rfc9218.html#name-the-priority_update-frame.
1316
+ type PriorityUpdateFrame struct {
1317
+ FrameHeader
1318
+ Priority string
1319
+ PrioritizedStreamID uint32
1320
+ }
1321
+
1322
+ func parseRFC9218Priority(s string, canUseDefault bool) (p PriorityParam, ok bool) {
1323
+ p = defaultRFC9218Priority(canUseDefault)
1324
+ ok = httpsfv.ParseDictionary(s, func(key, val, _ string) {
1325
+ switch key {
1326
+ case "u":
1327
+ if u, ok := httpsfv.ParseInteger(val); ok && u >= 0 && u <= 7 {
1328
+ p.urgency = uint8(u)
1329
+ }
1330
+ case "i":
1331
+ if i, ok := httpsfv.ParseBoolean(val); ok {
1332
+ if i {
1333
+ p.incremental = 1
1334
+ } else {
1335
+ p.incremental = 0
1336
+ }
1337
+ }
1338
+ }
1339
+ })
1340
+ if !ok {
1341
+ return defaultRFC9218Priority(canUseDefault), ok
1342
+ }
1343
+ return p, true
1344
+ }
1345
+
1346
+ func parsePriorityUpdateFrame(_ *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) {
1347
+ if fh.StreamID != 0 {
1348
+ countError("frame_priority_update_non_zero_stream")
1349
+ return nil, connError{ErrCodeProtocol, "PRIORITY_UPDATE frame with non-zero stream ID"}
1350
+ }
1351
+ if len(payload) < 4 {
1352
+ countError("frame_priority_update_bad_length")
1353
+ return nil, connError{ErrCodeFrameSize, fmt.Sprintf("PRIORITY_UPDATE frame payload size was %d; want at least 4", len(payload))}
1354
+ }
1355
+ v := binary.BigEndian.Uint32(payload[:4])
1356
+ streamID := v & 0x7fffffff // mask off high bit
1357
+ if streamID == 0 {
1358
+ countError("frame_priority_update_prioritizing_zero_stream")
1359
+ return nil, connError{ErrCodeProtocol, "PRIORITY_UPDATE frame with prioritized stream ID of zero"}
1360
+ }
1361
+ return &PriorityUpdateFrame{
1362
+ FrameHeader: fh,
1363
+ PrioritizedStreamID: streamID,
1364
+ Priority: string(payload[4:]),
1365
+ }, nil
1366
+ }
1367
+
1368
+ // WritePriorityUpdate writes a PRIORITY_UPDATE frame.
1369
+ //
1370
+ // It will perform exactly one Write to the underlying Writer.
1371
+ // It is the caller's responsibility to not call other Write methods concurrently.
1372
+ func (f *Framer) WritePriorityUpdate(streamID uint32, priority string) error {
1373
+ if !validStreamID(streamID) && !f.AllowIllegalWrites {
1374
+ return errStreamID
1375
+ }
1376
+ f.startWrite(FramePriorityUpdate, 0, 0)
1377
+ f.writeUint32(streamID)
1378
+ f.writeBytes([]byte(priority))
1379
+ return f.endWrite()
1380
+ }
1381
+
1382
+ // A RSTStreamFrame allows for abnormal termination of a stream.
1383
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.4
1384
+ type RSTStreamFrame struct {
1385
+ FrameHeader
1386
+ ErrCode ErrCode
1387
+ }
1388
+
1389
+ func parseRSTStreamFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
1390
+ if len(p) != 4 {
1391
+ countError("frame_rststream_bad_len")
1392
+ return nil, ConnectionError(ErrCodeFrameSize)
1393
+ }
1394
+ if fh.StreamID == 0 {
1395
+ countError("frame_rststream_zero_stream")
1396
+ return nil, ConnectionError(ErrCodeProtocol)
1397
+ }
1398
+ return &RSTStreamFrame{fh, ErrCode(binary.BigEndian.Uint32(p[:4]))}, nil
1399
+ }
1400
+
1401
+ // WriteRSTStream writes a RST_STREAM frame.
1402
+ //
1403
+ // It will perform exactly one Write to the underlying Writer.
1404
+ // It is the caller's responsibility to not call other Write methods concurrently.
1405
+ func (f *Framer) WriteRSTStream(streamID uint32, code ErrCode) error {
1406
+ if !validStreamID(streamID) && !f.AllowIllegalWrites {
1407
+ return errStreamID
1408
+ }
1409
+ f.startWrite(FrameRSTStream, 0, streamID)
1410
+ f.writeUint32(uint32(code))
1411
+ return f.endWrite()
1412
+ }
1413
+
1414
+ // A ContinuationFrame is used to continue a sequence of header block fragments.
1415
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.10
1416
+ type ContinuationFrame struct {
1417
+ FrameHeader
1418
+ headerFragBuf []byte
1419
+ }
1420
+
1421
+ func parseContinuationFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) {
1422
+ if fh.StreamID == 0 {
1423
+ countError("frame_continuation_zero_stream")
1424
+ return nil, connError{ErrCodeProtocol, "CONTINUATION frame with stream ID 0"}
1425
+ }
1426
+ return &ContinuationFrame{fh, p}, nil
1427
+ }
1428
+
1429
+ func (f *ContinuationFrame) HeaderBlockFragment() []byte {
1430
+ f.checkValid()
1431
+ return f.headerFragBuf
1432
+ }
1433
+
1434
+ func (f *ContinuationFrame) HeadersEnded() bool {
1435
+ return f.FrameHeader.Flags.Has(FlagContinuationEndHeaders)
1436
+ }
1437
+
1438
+ // WriteContinuation writes a CONTINUATION frame.
1439
+ //
1440
+ // It will perform exactly one Write to the underlying Writer.
1441
+ // It is the caller's responsibility to not call other Write methods concurrently.
1442
+ func (f *Framer) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error {
1443
+ if !validStreamID(streamID) && !f.AllowIllegalWrites {
1444
+ return errStreamID
1445
+ }
1446
+ var flags Flags
1447
+ if endHeaders {
1448
+ flags |= FlagContinuationEndHeaders
1449
+ }
1450
+ f.startWrite(FrameContinuation, flags, streamID)
1451
+ f.wbuf = append(f.wbuf, headerBlockFragment...)
1452
+ return f.endWrite()
1453
+ }
1454
+
1455
+ // A PushPromiseFrame is used to initiate a server stream.
1456
+ // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.6
1457
+ type PushPromiseFrame struct {
1458
+ FrameHeader
1459
+ PromiseID uint32
1460
+ headerFragBuf []byte // not owned
1461
+ }
1462
+
1463
+ func (f *PushPromiseFrame) HeaderBlockFragment() []byte {
1464
+ f.checkValid()
1465
+ return f.headerFragBuf
1466
+ }
1467
+
1468
+ func (f *PushPromiseFrame) HeadersEnded() bool {
1469
+ return f.FrameHeader.Flags.Has(FlagPushPromiseEndHeaders)
1470
+ }
1471
+
1472
+ func parsePushPromise(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) {
1473
+ pp := &PushPromiseFrame{
1474
+ FrameHeader: fh,
1475
+ }
1476
+ if pp.StreamID == 0 {
1477
+ // PUSH_PROMISE frames MUST be associated with an existing,
1478
+ // peer-initiated stream. The stream identifier of a
1479
+ // PUSH_PROMISE frame indicates the stream it is associated
1480
+ // with. If the stream identifier field specifies the value
1481
+ // 0x0, a recipient MUST respond with a connection error
1482
+ // (Section 5.4.1) of type PROTOCOL_ERROR.
1483
+ countError("frame_pushpromise_zero_stream")
1484
+ return nil, ConnectionError(ErrCodeProtocol)
1485
+ }
1486
+ // The PUSH_PROMISE frame includes optional padding.
1487
+ // Padding fields and flags are identical to those defined for DATA frames
1488
+ var padLength uint8
1489
+ if fh.Flags.Has(FlagPushPromisePadded) {
1490
+ if p, padLength, err = readByte(p); err != nil {
1491
+ countError("frame_pushpromise_pad_short")
1492
+ return
1493
+ }
1494
+ }
1495
+
1496
+ p, pp.PromiseID, err = readUint32(p)
1497
+ if err != nil {
1498
+ countError("frame_pushpromise_promiseid_short")
1499
+ return
1500
+ }
1501
+ pp.PromiseID = pp.PromiseID & (1<<31 - 1)
1502
+
1503
+ if int(padLength) > len(p) {
1504
+ // like the DATA frame, error out if padding is longer than the body.
1505
+ countError("frame_pushpromise_pad_too_big")
1506
+ return nil, ConnectionError(ErrCodeProtocol)
1507
+ }
1508
+ pp.headerFragBuf = p[:len(p)-int(padLength)]
1509
+ return pp, nil
1510
+ }
1511
+
1512
+ // PushPromiseParam are the parameters for writing a PUSH_PROMISE frame.
1513
+ type PushPromiseParam struct {
1514
+ // StreamID is the required Stream ID to initiate.
1515
+ StreamID uint32
1516
+
1517
+ // PromiseID is the required Stream ID which this
1518
+ // Push Promises
1519
+ PromiseID uint32
1520
+
1521
+ // BlockFragment is part (or all) of a Header Block.
1522
+ BlockFragment []byte
1523
+
1524
+ // EndHeaders indicates that this frame contains an entire
1525
+ // header block and is not followed by any
1526
+ // CONTINUATION frames.
1527
+ EndHeaders bool
1528
+
1529
+ // PadLength is the optional number of bytes of zeros to add
1530
+ // to this frame.
1531
+ PadLength uint8
1532
+ }
1533
+
1534
+ // WritePushPromise writes a single PushPromise Frame.
1535
+ //
1536
+ // As with Header Frames, This is the low level call for writing
1537
+ // individual frames. Continuation frames are handled elsewhere.
1538
+ //
1539
+ // It will perform exactly one Write to the underlying Writer.
1540
+ // It is the caller's responsibility to not call other Write methods concurrently.
1541
+ func (f *Framer) WritePushPromise(p PushPromiseParam) error {
1542
+ if !validStreamID(p.StreamID) && !f.AllowIllegalWrites {
1543
+ return errStreamID
1544
+ }
1545
+ var flags Flags
1546
+ if p.PadLength != 0 {
1547
+ flags |= FlagPushPromisePadded
1548
+ }
1549
+ if p.EndHeaders {
1550
+ flags |= FlagPushPromiseEndHeaders
1551
+ }
1552
+ f.startWrite(FramePushPromise, flags, p.StreamID)
1553
+ if p.PadLength != 0 {
1554
+ f.writeByte(p.PadLength)
1555
+ }
1556
+ if !validStreamID(p.PromiseID) && !f.AllowIllegalWrites {
1557
+ return errStreamID
1558
+ }
1559
+ f.writeUint32(p.PromiseID)
1560
+ f.wbuf = append(f.wbuf, p.BlockFragment...)
1561
+ f.wbuf = append(f.wbuf, padZeros[:p.PadLength]...)
1562
+ return f.endWrite()
1563
+ }
1564
+
1565
+ // WriteRawFrame writes a raw frame. This can be used to write
1566
+ // extension frames unknown to this package.
1567
+ func (f *Framer) WriteRawFrame(t FrameType, flags Flags, streamID uint32, payload []byte) error {
1568
+ f.startWrite(t, flags, streamID)
1569
+ f.writeBytes(payload)
1570
+ return f.endWrite()
1571
+ }
1572
+
1573
+ func readByte(p []byte) (remain []byte, b byte, err error) {
1574
+ if len(p) == 0 {
1575
+ return nil, 0, io.ErrUnexpectedEOF
1576
+ }
1577
+ return p[1:], p[0], nil
1578
+ }
1579
+
1580
+ func readUint32(p []byte) (remain []byte, v uint32, err error) {
1581
+ if len(p) < 4 {
1582
+ return nil, 0, io.ErrUnexpectedEOF
1583
+ }
1584
+ return p[4:], binary.BigEndian.Uint32(p[:4]), nil
1585
+ }
1586
+
1587
+ type streamEnder interface {
1588
+ StreamEnded() bool
1589
+ }
1590
+
1591
+ type headersEnder interface {
1592
+ HeadersEnded() bool
1593
+ }
1594
+
1595
+ type headersOrContinuation interface {
1596
+ headersEnder
1597
+ HeaderBlockFragment() []byte
1598
+ }
1599
+
1600
+ // A MetaHeadersFrame is the representation of one HEADERS frame and
1601
+ // zero or more contiguous CONTINUATION frames and the decoding of
1602
+ // their HPACK-encoded contents.
1603
+ //
1604
+ // This type of frame does not appear on the wire and is only returned
1605
+ // by the Framer when Framer.ReadMetaHeaders is set.
1606
+ type MetaHeadersFrame struct {
1607
+ *HeadersFrame
1608
+
1609
+ // Fields are the fields contained in the HEADERS and
1610
+ // CONTINUATION frames. The underlying slice is owned by the
1611
+ // Framer and must not be retained after the next call to
1612
+ // ReadFrame.
1613
+ //
1614
+ // Fields are guaranteed to be in the correct http2 order and
1615
+ // not have unknown pseudo header fields or invalid header
1616
+ // field names or values. Required pseudo header fields may be
1617
+ // missing, however. Use the MetaHeadersFrame.Pseudo accessor
1618
+ // method access pseudo headers.
1619
+ Fields []hpack.HeaderField
1620
+
1621
+ // Truncated is whether the max header list size limit was hit
1622
+ // and Fields is incomplete. The hpack decoder state is still
1623
+ // valid, however.
1624
+ Truncated bool
1625
+ }
1626
+
1627
+ // PseudoValue returns the given pseudo header field's value.
1628
+ // The provided pseudo field should not contain the leading colon.
1629
+ func (mh *MetaHeadersFrame) PseudoValue(pseudo string) string {
1630
+ for _, hf := range mh.Fields {
1631
+ if !hf.IsPseudo() {
1632
+ return ""
1633
+ }
1634
+ if hf.Name[1:] == pseudo {
1635
+ return hf.Value
1636
+ }
1637
+ }
1638
+ return ""
1639
+ }
1640
+
1641
+ // RegularFields returns the regular (non-pseudo) header fields of mh.
1642
+ // The caller does not own the returned slice.
1643
+ func (mh *MetaHeadersFrame) RegularFields() []hpack.HeaderField {
1644
+ for i, hf := range mh.Fields {
1645
+ if !hf.IsPseudo() {
1646
+ return mh.Fields[i:]
1647
+ }
1648
+ }
1649
+ return nil
1650
+ }
1651
+
1652
+ // PseudoFields returns the pseudo header fields of mh.
1653
+ // The caller does not own the returned slice.
1654
+ func (mh *MetaHeadersFrame) PseudoFields() []hpack.HeaderField {
1655
+ for i, hf := range mh.Fields {
1656
+ if !hf.IsPseudo() {
1657
+ return mh.Fields[:i]
1658
+ }
1659
+ }
1660
+ return mh.Fields
1661
+ }
1662
+
1663
+ func (mh *MetaHeadersFrame) rfc9218Priority(priorityAware bool) (p PriorityParam, priorityAwareAfter, hasIntermediary bool) {
1664
+ var s string
1665
+ for _, field := range mh.Fields {
1666
+ if field.Name == "priority" {
1667
+ s = field.Value
1668
+ priorityAware = true
1669
+ }
1670
+ if slices.Contains([]string{"via", "forwarded", "x-forwarded-for"}, field.Name) {
1671
+ hasIntermediary = true
1672
+ }
1673
+ }
1674
+ // No need to check for ok. parseRFC9218Priority will return a default
1675
+ // value if there is no priority field or if the field cannot be parsed.
1676
+ p, _ = parseRFC9218Priority(s, priorityAware && !hasIntermediary)
1677
+ return p, priorityAware, hasIntermediary
1678
+ }
1679
+
1680
+ func (mh *MetaHeadersFrame) checkPseudos() error {
1681
+ var isRequest, isResponse bool
1682
+ pf := mh.PseudoFields()
1683
+ for i, hf := range pf {
1684
+ switch hf.Name {
1685
+ case ":method", ":path", ":scheme", ":authority", ":protocol":
1686
+ isRequest = true
1687
+ case ":status":
1688
+ isResponse = true
1689
+ default:
1690
+ return pseudoHeaderError(hf.Name)
1691
+ }
1692
+ // Check for duplicates.
1693
+ // This would be a bad algorithm, but N is 5.
1694
+ // And this doesn't allocate.
1695
+ for _, hf2 := range pf[:i] {
1696
+ if hf.Name == hf2.Name {
1697
+ return duplicatePseudoHeaderError(hf.Name)
1698
+ }
1699
+ }
1700
+ }
1701
+ if isRequest && isResponse {
1702
+ return errMixPseudoHeaderTypes
1703
+ }
1704
+ return nil
1705
+ }
1706
+
1707
+ func (fr *Framer) maxHeaderStringLen() int {
1708
+ v := int(fr.maxHeaderListSize())
1709
+ if v < 0 {
1710
+ // If maxHeaderListSize overflows an int, use no limit (0).
1711
+ return 0
1712
+ }
1713
+ return v
1714
+ }
1715
+
1716
+ // readMetaFrame returns 0 or more CONTINUATION frames from fr and
1717
+ // merge them into the provided hf and returns a MetaHeadersFrame
1718
+ // with the decoded hpack values.
1719
+ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (Frame, error) {
1720
+ if fr.AllowIllegalReads {
1721
+ return nil, errors.New("illegal use of AllowIllegalReads with ReadMetaHeaders")
1722
+ }
1723
+ mh := &MetaHeadersFrame{
1724
+ HeadersFrame: hf,
1725
+ }
1726
+ type headerBudget struct {
1727
+ remainSize uint32
1728
+ count int
1729
+ }
1730
+ headers := headerBudget{remainSize: fr.maxHeaderListSize()}
1731
+ trailers := headerBudget{remainSize: fr.maxHeaderListSize()}
1732
+ var sawRegular bool
1733
+
1734
+ var invalid error // pseudo header field errors
1735
+ hdec := fr.ReadMetaHeaders
1736
+ hdec.SetEmitEnabled(true)
1737
+ hdec.SetMaxStringLength(fr.maxHeaderStringLen())
1738
+ hdec.SetEmitFunc(func(hf hpack.HeaderField) {
1739
+ if VerboseLogs && fr.logReads {
1740
+ fr.debugReadLoggerf("http2: decoded hpack field %+v", hf)
1741
+ }
1742
+ if !httpguts.ValidHeaderFieldValue(hf.Value) {
1743
+ // Don't include the value in the error, because it may be sensitive.
1744
+ invalid = headerFieldValueError(hf.Name)
1745
+ }
1746
+ isPseudo := strings.HasPrefix(hf.Name, ":")
1747
+ if isPseudo {
1748
+ if sawRegular {
1749
+ invalid = errPseudoAfterRegular
1750
+ }
1751
+ } else {
1752
+ sawRegular = true
1753
+ if !validWireHeaderFieldName(hf.Name) {
1754
+ invalid = headerFieldNameError(hf.Name)
1755
+ }
1756
+ }
1757
+
1758
+ if invalid != nil {
1759
+ hdec.SetEmitEnabled(false)
1760
+ return
1761
+ }
1762
+
1763
+ var budget *headerBudget
1764
+ var size uint32
1765
+ if hf.Name == "trailer" {
1766
+ budget = &trailers
1767
+ fieldCount := strings.Count(hf.Value, ",") + 1
1768
+ budget.count += fieldCount
1769
+ // Rather than actually constructing hpack.HeaderField for each
1770
+ // trailer field and cumulatively adding its Size, just do the math
1771
+ // manually to avoid unnecessary work. This does make it so
1772
+ // whitespaces after comma are counted against the budget, but that
1773
+ // should be innocuous.
1774
+ size = uint32(len(hf.Value)-fieldCount+1) + uint32(fieldCount)*hpack.HeaderField{}.Size()
1775
+ } else {
1776
+ budget = &headers
1777
+ budget.count++
1778
+ size = hf.Size()
1779
+ }
1780
+ if countLimit := fr.maxHeaderValueCount(); (countLimit > 0 && budget.count > countLimit) || size > budget.remainSize {
1781
+ hdec.SetEmitEnabled(false)
1782
+ mh.Truncated = true
1783
+ headers.remainSize = 0
1784
+ trailers.remainSize = 0
1785
+ return
1786
+ }
1787
+ budget.remainSize -= size
1788
+
1789
+ mh.Fields = append(mh.Fields, hf)
1790
+ })
1791
+ // Lose reference to MetaHeadersFrame:
1792
+ defer hdec.SetEmitFunc(func(hf hpack.HeaderField) {})
1793
+
1794
+ var hc headersOrContinuation = hf
1795
+ for {
1796
+ frag := hc.HeaderBlockFragment()
1797
+
1798
+ // Avoid parsing large amounts of headers that we will then discard.
1799
+ // If the sender exceeds the max header list size by too much,
1800
+ // skip parsing the fragment and close the connection.
1801
+ //
1802
+ // "Too much" is either any CONTINUATION frame after we've already
1803
+ // exceeded the max header list size (if so, both budgets are 0), or a
1804
+ // frame whose encoded size is more than twice the remaining header
1805
+ // list bytes we're willing to accept.
1806
+ if int64(len(frag)) > 2*int64(headers.remainSize+trailers.remainSize) {
1807
+ if VerboseLogs {
1808
+ log.Printf("http2: header list too large")
1809
+ }
1810
+ // It would be nice to send a RST_STREAM before sending the GOAWAY,
1811
+ // but the structure of the server's frame writer makes this difficult.
1812
+ return mh, ConnectionError(ErrCodeProtocol)
1813
+ }
1814
+
1815
+ // Also close the connection after any CONTINUATION frame following an
1816
+ // invalid header, since we stop tracking the size of the headers after
1817
+ // an invalid one.
1818
+ if invalid != nil {
1819
+ if VerboseLogs {
1820
+ log.Printf("http2: invalid header: %v", invalid)
1821
+ }
1822
+ // It would be nice to send a RST_STREAM before sending the GOAWAY,
1823
+ // but the structure of the server's frame writer makes this difficult.
1824
+ return mh, ConnectionError(ErrCodeProtocol)
1825
+ }
1826
+
1827
+ if _, err := hdec.Write(frag); err != nil {
1828
+ return mh, ConnectionError(ErrCodeCompression)
1829
+ }
1830
+
1831
+ if hc.HeadersEnded() {
1832
+ break
1833
+ }
1834
+ if f, err := fr.ReadFrame(); err != nil {
1835
+ return nil, err
1836
+ } else {
1837
+ hc = f.(*ContinuationFrame) // guaranteed by checkFrameOrder
1838
+ }
1839
+ }
1840
+
1841
+ mh.HeadersFrame.headerFragBuf = nil
1842
+ mh.HeadersFrame.invalidate()
1843
+
1844
+ if err := hdec.Close(); err != nil {
1845
+ return mh, ConnectionError(ErrCodeCompression)
1846
+ }
1847
+ if invalid != nil {
1848
+ fr.errDetail = invalid
1849
+ if VerboseLogs {
1850
+ log.Printf("http2: invalid header: %v", invalid)
1851
+ }
1852
+ return nil, StreamError{mh.StreamID, ErrCodeProtocol, invalid}
1853
+ }
1854
+ if err := mh.checkPseudos(); err != nil {
1855
+ fr.errDetail = err
1856
+ if VerboseLogs {
1857
+ log.Printf("http2: invalid pseudo headers: %v", err)
1858
+ }
1859
+ return nil, StreamError{mh.StreamID, ErrCodeProtocol, err}
1860
+ }
1861
+ return mh, nil
1862
+ }
1863
+
1864
+ func summarizeFrame(f Frame) string {
1865
+ var buf bytes.Buffer
1866
+ f.Header().writeDebug(&buf)
1867
+ switch f := f.(type) {
1868
+ case *SettingsFrame:
1869
+ n := 0
1870
+ f.ForeachSetting(func(s Setting) error {
1871
+ n++
1872
+ if n == 1 {
1873
+ buf.WriteString(", settings:")
1874
+ }
1875
+ fmt.Fprintf(&buf, " %v=%v,", s.ID, s.Val)
1876
+ return nil
1877
+ })
1878
+ if n > 0 {
1879
+ buf.Truncate(buf.Len() - 1) // remove trailing comma
1880
+ }
1881
+ case *DataFrame:
1882
+ data := f.Data()
1883
+ const max = 256
1884
+ if len(data) > max {
1885
+ data = data[:max]
1886
+ }
1887
+ fmt.Fprintf(&buf, " data=%q", data)
1888
+ if len(f.Data()) > max {
1889
+ fmt.Fprintf(&buf, " (%d bytes omitted)", len(f.Data())-max)
1890
+ }
1891
+ case *WindowUpdateFrame:
1892
+ if f.StreamID == 0 {
1893
+ buf.WriteString(" (conn)")
1894
+ }
1895
+ fmt.Fprintf(&buf, " incr=%v", f.Increment)
1896
+ case *PingFrame:
1897
+ fmt.Fprintf(&buf, " ping=%q", f.Data[:])
1898
+ case *GoAwayFrame:
1899
+ fmt.Fprintf(&buf, " LastStreamID=%v ErrCode=%v Debug=%q",
1900
+ f.LastStreamID, f.ErrCode, f.debugData)
1901
+ case *RSTStreamFrame:
1902
+ fmt.Fprintf(&buf, " ErrCode=%v", f.ErrCode)
1903
+ }
1904
+ return buf.String()
1905
+ }