gitoria
All repositories: gitoria
2.3 KB
// lib/transport-helpers.hl — what lib/transport.hl looks up: the Basic password of a request, the plain-text answers,// the protocol version a client asks for, git's pkt-line. Statics only.import { Response } from 'hl:http1'import { run } from 'hl:proc'import { NL } from './util.hl'static isBase64 = (s) => {if (s.length == 0 || s.length > 600) { return false }let i = 0while (i < s.length) {let c = s.charCodeAt(i)if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c == 43 || c == 47 || c == 61)) { return false }i = i + 1}return true}// the password of a Basic `Authorization` header ('user:password' → 'password'); null without one.// Hybriel has no base64 decoder (hybriel ticket candidate), so `base64 -d` decodes it — the text goes in as an// argument, after a check that it only holds base64 characters.static passwordOf = (header) => {if (header == null || hlTypeName(header) != 'String') { return null }h = header.trim()if (h.length < 7 || h.slice(0, 6).toLowerCase() != 'basic ') { return null }b = h.slice(6).trim()if (!isBase64(b)) { return null }r = run(['sh', '-c', 'printf %s "$1" | base64 -d 2>/dev/null', 'sh', b], { timeout = 10 })if (r == null || r.exit != 0 || r.lines.length == 0) { return null }text = r.lines[0]colon = text.indexOf(':')return colon < 0 ? null : text.slice(colon + 1)}static plain = (status, text, extra) => {let headers = { 'Content-Type' = 'text/plain; charset=utf-8' 'Cache-Control' = 'no-store' }if (extra != null) { for (k of extra.keys()) { headers[k] = extra[k] } }return new Response(text + NL, { status = status headers = headers })}// git speaks protocol v2 when the client says so: `Git-Protocol: version=2` (only that shape is passed on)static protocolEnv = (req) => {v = req.headers['git-protocol']if (v == null || hlTypeName(v) != 'String' || v.length > 40) { return {} }let ok = v.length > 0let i = 0while (i < v.length) {let c = v.charCodeAt(i)if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 122) || c == 61 || c == 58)) { ok = false }i = i + 1}return ok ? { GIT_PROTOCOL = v } : {}}// pkt-line: 4 hex digits of the length (itself included), then the textstatic pktLine = (text) => {let n = text.length + 4hex = '0123456789abcdef'let out = ''let i = 0while (i < 4) {let d = n % 16out = hex[d] + outn = (n - d) / 16i = i + 1}return out + text}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- cd99d2feWIP gitoria#22: always render the repo level's slot (missing-repo boot hang), pages render nothing without a repo; hydration diagnosis in reports/G2-hydrate.mdmre
- e5404b9breport: commit idsmre
- 63cfa21ereports/G2-repotabs.mdmre
- 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
- 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
- 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
- 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
- f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
- 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
- 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
- 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre
- 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
- 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
- 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
- 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
- e6dff0cbgitoria#23: report 005, STATUS, LOGmre