gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchnotes9-no-pollc49ce093|||PR WIP remove notes polling and use framework reachabilityAtlasnotes9-no-poll/lib/ratelimit.hl

980 B

  1. // lib/ratelimit.hl — A SMALL RATE LIMIT for the login (notes mission SN): every login attempt asks ident over the network, so a
  2. // flood of wrong codes must be slowed down. Per client IP: the X-Client-IP header nginx sets on Byrodin (nginx overwrites what a
  3. // client sent; X-Forwarded-For & co. are never read, as in ident). No header (dev) = one shared bucket. In memory: a restart forgets it.
  4. import { now } from 'hl:time'
  5. static loginWindowMs = 600000
  6. static loginMax = 30
  7. static tries = {}
  8. // may the client `ip` try a login now? Counts the try. false = too many in the window.
  9. static loginAllowed = (ip) => {
  10. key = ip == null || hlTypeName(ip) != 'String' || ip.trim() == '' ? 'direct' : ip.trim().toLowerCase().slice(0, 64)
  11. t = now()
  12. kept = []
  13. old = tries[key]
  14. if (old != null) { for (x of old) { if (t - x < loginWindowMs) { kept.push(x) } } }
  15. if (kept.length >= loginMax) {
  16. tries[key] = kept
  17. return false
  18. }
  19. kept.push(t)
  20. tries[key] = kept
  21. return true
  22. }

Branches

Latest commits

  • c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
  • c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
  • 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
  • a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
  • 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
  • 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
  • eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
  • 3537cf7eMerge branch 'vendor-day59' into mainAtlas
  • c13d188b|||PR Vendor Hybriel day59Atlas
  • 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
  • ae1075b2Preserve rejected drafts during note ID adoptionAtlas
  • 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
  • 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
  • 649cef37|||PR Vendor Hybriel day56Atlas
  • aadd0abcMerge branch 'hl-standard-2' into mainAtlas
  • 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
  • 617ee8c0Merge branch 'hl-standard' into mainAtlas
  • 452458ee|||PR Type the function parameters of notes' own .hl files (HL-STANDARD L10)Atlas
  • 23758cd6Re-vendor complete Hybriel plugins and runtime to day44mre
  • 5d7cc700Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre