Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/community/10msg.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / community / 10msg.om` 697 lines ยท 12630 bytes Raw Blame History 1 note community/10msg.om -- POST /community/api: parse, check and store one ipcc1 message. 2 3 text cmct "text/plain; charset=utf-8" 4 text cmnost "no-store" 5 text cmrok "ipcc1 ok " 6 text cmrref "ipcc1 refused " 7 text cmkreg "registered\n" 8 text cmknone "none\nretry 600\n" 9 text cmkjob "job\n" 10 text cmkcnt "counted\n" 11 text cmkstor "stored\n" 12 text cmkleft "left\n" 13 text cmlnone "none" 14 text cmlcnt "counted" 15 text cmldup "duplicate" 16 text cmlcell "stored-cell" 17 text cmlj "j" 18 text cmll "l" 19 20 note ---- the reply 21 fn cm_reply st long to long 22 fsetct cmct 23 fsetcc cmnost 24 put fkind 0 1 25 put fobl 0 0 26 ret st 27 end 28 29 fn cm_rok k view uchar * to long 30 x = cm_reply 200 31 fput cmrok 32 fput k 33 ret 200 34 end 35 36 note cm_wcp: the reason word for code e into d; its length 37 fn cm_wcp e ulong d edit uchar * to ulong 38 if eq e cmemal 39 ret cm_cp d 0 cmw1 40 end 41 if eq e cmesize 42 ret cm_cp d 0 cmw2 43 end 44 if eq e cmeclk 45 ret cm_cp d 0 cmw3 46 end 47 if eq e cmesig 48 ret cm_cp d 0 cmw4 49 end 50 if eq e cmeunr 51 ret cm_cp d 0 cmw5 52 end 53 if eq e cmeden 54 ret cm_cp d 0 cmw6 55 end 56 if eq e cmejob 57 ret cm_cp d 0 cmw7 58 end 59 if eq e cmemis 60 ret cm_cp d 0 cmw8 61 end 62 if eq e cmedup 63 ret cm_cp d 0 cmw9 64 end 65 if eq e cmeoff 66 ret cm_cp d 0 cmw12 67 end 68 ret cm_cp d 0 cmw13 69 end 70 71 fn cm_status e ulong to long 72 if or eq e cmemal eq e cmeio 73 ret 400 74 end 75 if eq e cmesize 76 ret 413 77 end 78 if eq e cmedup 79 ret 409 80 end 81 if eq e cmeoff 82 ret 503 83 end 84 ret 403 85 end 86 87 note cm_refuse: answer "ipcc1 refused " and append " " to refused 88 fn cm_refuse e ulong to long 89 d = new uchar 256 0 90 w = new uchar 16 0 91 st = cm_status e 92 wl = cm_wcp e w 93 x = cm_reply st 94 fput cmrref 95 fput part w 0 wl 96 fput cmnl 97 k = cm_decput d 0 cm_now 98 k = cm_cp d k cmsp 99 k = cm_cp d k part w 0 wl 100 k = cm_cp d k cmsp 101 k = cm_khex d k 102 k = cm_cp d k cmsp 103 k = cm_shex d k 104 k = cm_cp d k cmnl 105 if eq get cmgv cmon 1 106 cm_p0 107 cm_pa cmtref 108 y = cm_app part d 0 k 109 if ne get cmgv cmlock 0 110 cm_tally cmtrfn cmaref cmtaref 111 end 112 end 113 ret st 114 end 115 116 note cm_khex / cm_shex: the key id / message hash when known, else "-" 117 fn cm_khex d edit uchar * o ulong to ulong 118 if ne get cmgv cmcsec 1 119 ret cm_cp d o cmdash 120 end 121 for i ulong 64 122 put d add o i get cmkid i 123 end 124 ret add o 64 125 end 126 127 fn cm_shex d edit uchar * o ulong to ulong 128 if ne get cmgv cmchub 1 129 ret cm_cp d o cmdash 130 end 131 for i ulong 64 132 put d add o i get cmsha i 133 end 134 ret add o 64 135 end 136 137 note ---- parsing (exact form: docs/PROTOCOL.md) 138 note cm_bodyis: fbody[o, o+len t) is t 139 fn cm_bodyis o ulong t view uchar * to bool 140 if gt add o len t get fbodyl 0 141 ret false 142 end 143 for i ulong len t bound 4096 144 if ne get fbody add o i get t i 145 ret false 146 end 147 end 148 ret true 149 end 150 151 note cm_kw: "ipcc1 " then t then LF at the start of the body 152 fn cm_kw t view uchar * to bool 153 o = len cmtip 154 if not cm_bodyis o t 155 ret false 156 end 157 e = add o len t 158 if ge e get fbodyl 0 159 ret false 160 end 161 if ne get fbody e 10 162 ret false 163 end 164 put cmgv cmcur add e 1 165 ret true 166 end 167 168 fn cm_kind to ulong 169 if not cm_bodyis 0 cmtip 170 ret 0 171 end 172 if cm_kw cmtreg 173 ret 1 174 end 175 if cm_kw cmtnext 176 ret 2 177 end 178 if cm_kw cmtres 179 ret 3 180 end 181 if cm_kw cmtlv 182 ret 4 183 end 184 ret 0 185 end 186 187 note cm_f: the next line must be "nm " with a value of type ty (1 hex of exactly ln 188 note characters, 2 decimal, 3 exit outcome); records the field and moves the cursor 189 fn cm_f i ulong nm view uchar * ty ulong ln ulong to bool 190 c = get cmgv cmcur 191 n = get fbodyl 0 192 if not cm_bodyis c nm 193 ret false 194 end 195 v = add add c len nm 1 196 if gt v n 197 ret false 198 end 199 if ne get fbody sub v 1 32 200 ret false 201 end 202 e = cm_eol v 203 if ge e n 204 ret false 205 end 206 put cmfo i v 207 put cmfn i sub e v 208 if eq i cmfsig 209 put cmgv cmsigo c 210 end 211 put cmgv cmcur add e 1 212 ret cm_vok i ty ln 213 end 214 215 fn cm_eol v ulong to ulong 216 e = v 217 while lt e get fbodyl 0 bound 4096 218 if eq get fbody e 10 219 ret e 220 end 221 e = add e 1 222 end 223 ret e 224 end 225 226 fn cm_vok i ulong ty ulong ln ulong to bool 227 v = new uchar 256 0 228 n = get cmfn i 229 if or eq n 0 gt n 200 230 ret false 231 end 232 o = get cmfo i 233 for j ulong n bound 256 234 put v j get fbody add o j 235 end 236 if eq ty 1 237 if ne n ln 238 ret false 239 end 240 ret cm_ishex part v 0 n 241 end 242 if eq ty 2 243 ret ne cm_dec part v 0 n `18446744073709551615` 244 end 245 ret cm_outok part v 0 n 246 end 247 248 note cm_prenum: s is pre followed by a decimal 1..mx 249 fn cm_prenum s view uchar * pre view uchar * mx ulong to bool 250 if le len s len pre 251 ret false 252 end 253 if not cm_eq part s 0 len pre pre 254 ret false 255 end 256 v = cm_dec part s len pre sub len s len pre 257 ret and ge v 1 le v mx 258 end 259 260 note cm_outok: an exit outcome: 0..255, signalN, timeout, omcK, omcsignalN, omctimeout, cellE 261 fn cm_outok s view uchar * to bool 262 if le cm_dec s 255 263 ret true 264 end 265 if or cm_eq s cmxtmo cm_eq s cmxomct 266 ret true 267 end 268 if or cm_prenum s cmxomcs 127 cm_prenum s cmxsig 127 269 ret true 270 end 271 ret or cm_prenum s cmxomc 255 cm_prenum s cmxcell 4095 272 end 273 274 fn cm_parse to ulong 275 n = get fbodyl 0 276 if gt n cmmaxb 277 ret cmesize 278 end 279 k = cm_kind 280 if eq k 0 281 ret cmemal 282 end 283 put cmgv cmkind k 284 ok = true 285 if eq k 1 286 ok = and cm_f cmfkey cmnpub 1 130 cm_f cmftime cmntime 2 0 287 ok = and ok cm_f cmfthird cmnrate 2 0 288 end 289 if eq k 2 290 ok = and cm_f cmfkey cmnkey 1 64 cm_f cmftime cmntime 2 0 291 ok = and ok cm_f cmfthird cmnnon 1 32 292 end 293 if eq k 3 294 ok = cm_parse3 295 end 296 if eq k 4 297 ok = and cm_f cmfkey cmnkey 1 64 cm_f cmftime cmntime 2 0 298 end 299 if not ok 300 ret cmemal 301 end 302 if not cm_f cmfsig cmnsig 1 128 303 ret cmemal 304 end 305 if ne get cmgv cmcur n 306 ret cmemal 307 end 308 ret 0 309 end 310 311 fn cm_parse3 to bool 312 ok = cm_f cmfkey cmnkey 1 64 313 ok = and ok cm_f cmfjob cmnjob 1 32 314 ok = and ok cm_f cmfpart cmnpart 1 64 315 ok = and ok cm_f cmfcomp cmncomp 1 64 316 ok = and ok cm_f cmfbin cmnbin 1 64 317 ok = and ok cm_f cmfout cmnout 1 64 318 ok = and ok cm_f cmfexit cmnexit 3 0 319 ret and ok cm_f cmftime cmntime 2 0 320 end 321 322 note cm_fget: field i into d (its length must be len d) 323 fn cm_fget i ulong d edit uchar * to bool 324 n = get cmfn i 325 if ne n len d 326 ret false 327 end 328 o = get cmfo i 329 for j ulong n bound 4096 330 put d j get fbody add o j 331 end 332 ret true 333 end 334 335 note cm_fnum: field i as a decimal 336 fn cm_fnum i ulong to ulong 337 v = new uchar 32 0 338 n = get cmfn i 339 if gt n 32 340 ret `18446744073709551615` 341 end 342 o = get cmfo i 343 for j ulong n bound 32 344 put v j get fbody add o j 345 end 346 ret cm_dec part v 0 n 347 end 348 349 fn cm_sha m view uchar * h edit uchar * to void 350 c = new ulong 40 0 351 sha256_init c 352 sha256_update c m 353 sha256_final c h 354 end 355 356 note cm_msha: cmsha = hex SHA-256 of the signed bytes (everything before the sig line). It names the 357 note stored message and is the replay key: ECDSA signatures are malleable ((r, s) and (r, n - s) 358 note both verify), so a key over the whole body would let anyone resend each message once more. 359 fn cm_msha to void 360 m = new uchar 4096 0 361 h = new uchar 32 0 362 x = new uchar 64 0 363 n = get cmgv cmsigo 364 for i ulong n bound 4096 365 put m i get fbody i 366 end 367 cm_sha part m 0 n h 368 cm_tohex h x 369 for i ulong 64 370 put cmsha i get x i 371 end 372 put cmgv cmchub 1 373 end 374 375 note cm_verify: ECDSA P-256 / SHA-256 of every byte before the sig line, by cmpub 376 fn cm_verify to bool 377 m = new uchar 4096 0 378 h = new uchar 32 0 379 hs = new uchar 96 0 380 pub = new uchar 65 0 381 sg = new uchar 128 0 382 n = get cmgv cmsigo 383 for i ulong n bound 4096 384 put m i get fbody i 385 end 386 cm_sha part m 0 n h 387 for i ulong 32 388 put hs i get h i 389 end 390 if not cm_fget cmfsig sg 391 ret false 392 end 393 if not cm_unhex sg part hs 32 64 394 ret false 395 end 396 for i ulong 65 397 put pub i get cmpub i 398 end 399 ret eq ecdsa_verify_raw 256 pub hs 32 0 400 end 401 402 note ---- keys 403 note cm_regkey: register: the public key from the message; cmkid = hex SHA-256 of it 404 fn cm_regkey to ulong 405 p = new uchar 130 0 406 q = new uchar 65 0 407 h = new uchar 32 0 408 x = new uchar 64 0 409 if not cm_fget cmfkey p 410 ret cmemal 411 end 412 if not cm_unhex p q 413 ret cmemal 414 end 415 for i ulong 65 416 put cmpub i get q i 417 end 418 cm_sha q h 419 cm_tohex h x 420 for i ulong 64 421 put cmkid i get x i 422 end 423 put cmgv cmcsec 1 424 ret 0 425 end 426 427 note cm_kload: the key named by the message must be registered and not left. Key file: 428 note "<130 hex pub> \n" 429 fn cm_kload to ulong 430 k = new uchar 64 0 431 b = new uchar 512 0 432 q = new uchar 65 0 433 if not cm_fget cmfkey k 434 ret cmemal 435 end 436 for i ulong 64 437 put cmkid i get k i 438 end 439 put cmgv cmcsec 1 440 cm_p0 441 cm_pa cmtkeys 442 cm_pa k 443 r = cm_rd b 444 if lt r 133 445 ret cmeunr 446 end 447 n = ulong r 448 if or ne get b sub n 1 10 ne get b sub n 2 106 449 ret cmeunr 450 end 451 if not cm_unhex part b 0 130 q 452 ret cmeunr 453 end 454 for i ulong 65 455 put cmpub i get q i 456 end 457 ret 0 458 end 459 460 note cm_kwrite: write the key file with state st (rate from the message on register, else kept) 461 fn cm_kwrite st view uchar * rate ulong to bool 462 d = new uchar 256 0 463 k = cm_kdpub d 464 k = cm_cp d k cmsp 465 k = cm_decput d k rate 466 k = cm_cp d k cmsp 467 k = cm_decput d k cm_now 468 k = cm_cp d k cmsp 469 k = cm_cp d k st 470 k = cm_cp d k cmnl 471 cm_p0 472 cm_pa cmtkeys 473 cm_pkid 474 ret cm_repl part d 0 k 475 end 476 477 fn cm_kdpub d edit uchar * to ulong 478 q = new uchar 65 0 479 x = new uchar 130 0 480 for i ulong 65 481 put q i get cmpub i 482 end 483 cm_tohex q x 484 for i ulong 130 485 put d i get x i 486 end 487 ret 130 488 end 489 490 note cm_krate: the rate in the stored key file (0 when unreadable) 491 fn cm_krate to ulong 492 b = new uchar 512 0 493 cm_p0 494 cm_pa cmtkeys 495 cm_pkid 496 r = cm_rd b 497 if lt r 133 498 ret 0 499 end 500 e = ulong 131 501 while lt e ulong r bound 512 502 if eq get b e 32 503 break 504 end 505 e = add e 1 506 end 507 v = cm_dec part b 131 sub e 131 508 if eq v `18446744073709551615` 509 ret 0 510 end 511 ret v 512 end 513 514 note ---- deny list: deny, lines "key <64 hex>" and "part <64 hex>", read as a stream 515 fn cm_denied pre view uchar * id view uchar * to bool 516 t = new uchar 80 0 517 tl = cm_cp t 0 pre 518 tl = cm_cp t tl id 519 ret cm_dfile part t 0 tl 520 end 521 522 note cm_dfile: the deny file holds a line equal to t 523 fn cm_dfile t view uchar * to bool 524 b = new uchar 65536 0 525 cm_q0 526 cm_pa cmtdeny 527 fd = fopen cmpth 0 get cmgv cmpl 557056 0 528 if lt fd 0 529 ret false 530 end 531 put cmgv cmdj 0 532 put cmgv cmdm 1 533 hit = false 534 while true bound `9223372036854775807` 535 n = read int fd b 0 65536 536 if le n 0 537 break 538 end 539 if cm_dscan part b 0 ulong n t 540 hit = true 541 break 542 end 543 end 544 x = fclose int fd 545 if and eq get cmgv cmdm 1 eq get cmgv cmdj len t 546 hit = true 547 end 548 ret hit 549 end 550 551 note cm_dscan: feed bytes b to the line matcher for t; true at a whole line equal to t 552 fn cm_dscan b view uchar * t view uchar * to bool 553 j = get cmgv cmdj 554 m = eq get cmgv cmdm 1 555 for i ulong len b bound 65536 556 c = get b i 557 if eq c 10 558 if and m eq j len t 559 ret true 560 end 561 j = 0 562 m = true 563 else 564 if and m lt j len t 565 m = eq c get t j 566 j = add j 1 567 else 568 m = false 569 end 570 end 571 end 572 put cmgv cmdj j 573 put cmgv cmdm 0 574 if m 575 put cmgv cmdm 1 576 end 577 ret false 578 end 579 580 note ---- volume alarms (decision 2026-11-11: no app-level caps on the hub; the public edge keeps its 581 note request-rate limiting): rate/ holds " \n", one window per hour. 582 note When a count first passes its threshold in a window, one line goes to alarms naming what, 583 note who and how many; nothing is refused for volume (the deny list is the operator's answer). 584 fn cm_tally nm view uchar * thr ulong what view uchar * to void 585 b = new uchar 64 0 586 d = new uchar 64 0 587 cm_p0 588 cm_pa cmtrate 589 cm_pa nm 590 now = cm_now 591 put cmgv cmrw now 592 put cmgv cmrc 0 593 r = cm_rd b 594 if gt r 2 595 cm_rparse part b 0 ulong r now 596 end 597 cnt = add get cmgv cmrc 1 598 k = cm_decput d 0 get cmgv cmrw 599 k = cm_cp d k cmsp 600 k = cm_decput d k cnt 601 k = cm_cp d k cmnl 602 x = cm_replq part d 0 k 603 if and x eq cnt add thr 1 604 cm_alarm what nm cnt thr 605 end 606 end 607 608 note cm_alarm: " ALARM passed in the hour: \n" appended to alarms 609 fn cm_alarm what view uchar * nm view uchar * cnt ulong thr ulong to void 610 d = new uchar 256 0 611 k = cm_decput d 0 cm_now 612 k = cm_cp d k cmtalw 613 k = cm_cp d k what 614 k = cm_cp d k cmsp 615 k = cm_cp d k nm 616 k = cm_cp d k cmtalp 617 k = cm_decput d k thr 618 k = cm_cp d k cmtalh 619 k = cm_decput d k cnt 620 k = cm_cp d k cmnl 621 cm_p0 622 cm_pa cmtalm 623 x = cm_app part d 0 k 624 end 625 626 note cm_rparse: " \n" still inside its hour: keep both (else a new window) 627 fn cm_rparse b view uchar * now ulong to void 628 s = cm_sp b 629 if ge add s 2 len b 630 ret 631 end 632 w = cm_dec part b 0 s 633 c = cm_dec part b add s 1 sub sub len b s 2 634 if or gt w now eq c `18446744073709551615` 635 ret 636 end 637 if lt sub now w 3600 638 put cmgv cmrw w 639 put cmgv cmrc c 640 end 641 end 642 643 fn cm_sp b view uchar * to ulong 644 for i ulong len b bound 64 645 if eq get b i 32 646 ret i 647 end 648 end 649 ret len b 650 end 651 652 note ---- store 653 note cm_msgp: cmpth = msgs/ 654 fn cm_msgp to void 655 s = new uchar 64 0 656 for i ulong 64 657 put s i get cmsha i 658 end 659 cm_p0 660 cm_pa cmtmsgs 661 cm_pa s 662 end 663 664 fn cm_store to bool 665 m = new uchar 4096 0 666 n = get fbodyl 0 667 for i ulong n bound 4096 668 put m i get fbody i 669 end 670 cm_msgp 671 ret cm_wnew part m 0 n 672 end 673 674 note cm_ledger: " \n" 675 fn cm_ledger kw view uchar * pt bool w view uchar * to bool 676 d = new uchar 512 0 677 p = new uchar 64 0 678 k = cm_decput d 0 cm_now 679 k = cm_cp d k cmsp 680 k = cm_cp d k kw 681 k = cm_cp d k cmsp 682 k = cm_khex d k 683 k = cm_cp d k cmsp 684 k = cm_shex d k 685 k = cm_cp d k cmsp 686 if and pt cm_fget cmfpart p 687 k = cm_cp d k p 688 else 689 k = cm_cp d k cmdash 690 end 691 k = cm_cp d k cmsp 692 k = cm_cp d k w 693 k = cm_cp d k cmnl 694 cm_p0 695 cm_pa cmtled 696 ret cm_app part d 0 k 697 end