gitoria
All repositories: gitoria
2.4 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' 'X-Content-Type-Options' = 'nosniff' }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
- a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
- 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
- 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
- 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
- a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
- 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
- c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
- e307d69agitoria: say what is per process during the hand-overmre
- f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
- 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
- 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
- 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
- bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
- 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
- 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
- 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
- 2a2fdd77gs: C2 check before cookie experimentsmre
- 76e0587aWIP gs 2mre
- a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
- 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre