interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / server / counts.om

1043 lines · 20148 bytes Raw Blame History
1note forged server/counts.om: real clone, download and seeding counts for the repo home (HTML header
2note and the "counts" object of forge/repo/1). Every number comes from a log or table that exists:
3note source 0 front-door nginx download log: git smart-HTTP info/refs?service=git-upload-pack (and
4note /code/git/<name>.git/info/refs) answered 200 = one git clone or fetch; our own
5note addresses (loopback, LAN, tailnet, the home address of www.aienos.com) and user agents
6note naming bot / crawl / spider are left out
7note source 1 front-door nginx access log: POST /rad/<RID>.git/git-upload-pack answered 200, every
8note client (that log has no client address); a clone is usually two of these
9note source 2 forged's own access log: GET/HEAD of /<o>/<r>/archive/... and /releases/download/...
10note answered 200, our own addresses left out
11note seeds this node's Radicle routing table (rad node routing --rid <RID> --json)
12note Change-driven, no timer: on a repo home request each log is read only when its size or inode
13note changed since the last read, from the saved position (after a rotation the rest of <log>.1
14note first). Counted events are appended to the journal ~/forge-data/counts.log as one write per
15note batch ("e <k> <epoch> <rid>" lines, then "s <src> <epoch>" once, then the cursor "k <src> <ino>
16note <off>"); forged replays it at start and on reload and ignores a torn last batch. Since = the
17note time of the first line of the oldest log read for that source.
18text tfzp0 "/var/log/nginx/aienos-dl.log"
19text tfzp1 "/var/log/nginx/aienos.access.log"
20text tfzlog "logs/forged.log"
21text tfzjn "counts.log"
22text tfzdot1 ".1"
23text tfzrad5 "/rad/"
24text tfzgit4 ".git"
25text tfzinfo "/info/refs?service=git-upload-pack"
26text tfzupk "/git-upload-pack"
27text tfzz6 "/z6Mk"
28text tfzcode "/code/git/"
29text tfzdot "dot-"
30text tfzpost "\"POST /rad/"
31text tfzarch "/archive/"
32text tfzrel "/releases/download/"
33text tfzbot "bot"
34text tfzcrl "crawl"
35text tfzspi "spider"
36text tfzmon "janfebmaraprmayjunjulaugsepoctnovdec"
37text tfzo1 "127."
38text tfzo2 "10."
39text tfzo3 "192.168."
40text tfzo4 "::1"
41text tfzo5 "fe80:"
42text tfzo6 "fd"
43text tfzo7 "100."
44text tfzkind "gpar"
45note Owner-side snapshot mode supplies its isolated journal path; ordinary mode leaves it empty.
46global fzjp uchar 4096
47global fzjpl ulong 1
48global fzbuf uchar 1048576
49global fzst uchar 128
50global fzcin ulong 1
51global fzcsz ulong 1
52global fzino ulong 4
53global fzoff ulong 4
54global fzinit ulong 4
55global fzsnc ulong 4
56global fzsj ulong 4
57global fzspen ulong 4
58global fzz0 ulong 1
59global fzfail ulong 1
60note fzcnt / fzpnd: committed / pending counts, index k*FAMAX + repo, k 0 git fetch 1 upload-pack 2 archive 3 release asset
61global fzcnt ulong 1024
62global fzpnd ulong 1024
63global fznev ulong 1
64global fzjb uchar 131072
65global fzjbl ulong 1
66note fzjend: journal byte offset after the last committed cursor; any later bytes are abandoned.
67global fzjend ulong 1
68global fzhome uchar 64
69global fzhomel ulong 1
70global fzsd ulong 256
71global fzsdk ulong 256
72global fzsdm ulong 256
73global fzsdt ulong 256
74note ---- small readers over fzbuf
75fn fzb i ulong to uchar
76ret get fzbuf i
77end
78fn fzsp a ulong e ulong to ulong
79j = a
80for it ulong sub e a bound 1048576
81if eq fzb j 32
82ret j
83end
84j = add j 1
85end
86ret e
87end
88fn fzch a ulong e ulong c uchar to ulong
89j = a
90for it ulong sub e a bound 1048576
91if eq fzb j c
92ret j
93end
94j = add j 1
95end
96ret e
97end
98fn fznum a ulong e ulong to ulong
99v = ulong 0
100j = a
101for it ulong 20
102if ge j e
103break
104end
105c = fzb j
106if not fisdig c
107break
108end
109v = add mul v 10 ulong sub c 48
110j = add j 1
111end
112ret v
113end
114fn fzpre a ulong e ulong t view uchar * to bool
115if gt add a len t e
116ret false
117end
118for k ulong len t bound 64
119if ne fzb add a k get t k
120ret false
121end
122end
123ret true
124end
125fn fzhasat a ulong t view uchar * to bool
126for k ulong len t bound 64
127if ne flow fzb add a k get t k
128ret false
129end
130end
131ret true
132end
133note fzhas: [a, e) contains t, ignoring ASCII case
134fn fzhas a ulong e ulong t view uchar * to bool
135if gt add a len t e
136ret false
137end
138for s ulong add sub sub e a len t 1 bound 1048576
139if fzhasat add a s t
140ret true
141end
142end
143ret false
144end
145note ---- the repository an event belongs to (public allow-list only)
146fn fzrideq i ulong a ulong n ulong to bool
147if ne get fail i n
148ret false
149end
150for k ulong n bound 64
151if ne fridbyte i k fzb add a k
152ret false
153end
154end
155ret true
156end
157fn fzrix a ulong n ulong to ulong
158for i ulong get fan 0 bound FAMAX
159if fzrideq i a n
160ret i
161end
162end
163ret 9999
164end
165note fznmeq: the repo name of i equals [a, a+n); with dt 1 a leading "dot-" stands for "."
166fn fznmeq i ulong a ulong n ulong dt ulong to bool
167if and eq dt 1 fzpre a add a n tfzdot
168if ne get fanl i sub n 3
169ret false
170end
171if ne frnbyte i 0 46
172ret false
173end
174for k ulong sub n 4 bound 128
175if ne frnbyte i add k 1 fzb add add a 4 k
176ret false
177end
178end
179ret true
180end
181if ne get fanl i n
182ret false
183end
184for k ulong n bound 128
185if ne frnbyte i k fzb add a k
186ret false
187end
188end
189ret true
190end
191fn fznix a ulong n ulong dt ulong to ulong
192for i ulong get fan 0 bound FAMAX
193if fznmeq i a n dt
194ret i
195end
196end
197ret 9999
198end
199note ---- our own addresses: loopback, LAN, tailnet 100.64/10, IPv6 local, the home address
200fn fzhomeq a ulong e ulong to bool
201n = get fzhomel 0
202if or eq n 0 ne sub e a n
203ret false
204end
205for k ulong n bound 64
206if ne fzb add a k get fzhome k
207ret false
208end
209end
210ret true
211end
212fn fzown a ulong e ulong to bool
213if le sub e a 1
214ret true
215end
216if or fzpre a e tfzo1 fzpre a e tfzo2
217ret true
218end
219if or fzpre a e tfzo3 fzpre a e tfzo4
220ret true
221end
222if or fzpre a e tfzo5 fzpre a e tfzo6
223ret true
224end
225if fzpre a e tfzo7
226v = fznum add a 4 e
227if and ge v 64 le v 127
228ret true
229end
230end
231ret fzhomeq a e
232end
233note fzhomeip: the home address = what www.aienos.com resolves to here (getent, argv only)
234text tfzgent "/usr/bin/getent"
235text tfzhosts "hosts"
236text tfzhost "www.aienos.com"
237fn fzhomeip to bool
238put fzhomel 0 0
239fkb
240fka tfzgent
241fka tfzhosts
242fka tfzhost
243st = fexec 5000000000
244if ne st 0
245ret false
246end
247n = ulong 0
248for k ulong hmin get fxol 0 63 bound 64
249c = get fxo k
250if or or eq c 32 eq c 9 eq c 10
251break
252end
253put fzhome k c
254n = add n 1
255end
256put fzhomel 0 n
257ret ge n 3
258end
259note ---- epochs from log times
260fn fzdays y ulong m ulong d ulong to ulong
261yy = y
262if le m 2
263yy = sub y 1
264end
265era = div yy 400
266yoe = sub yy mul era 400
267mm = add m 9
268if gt m 2
269mm = sub m 3
270end
271doy = add div add mul 153 mm 2 5 sub d 1
272q = add mul yoe 365 div yoe 4
273doe = sub add q doy div yoe 100
274ret sub add mul era 146097 doe 719468
275end
276fn fzmon a ulong to ulong
277for m ulong 12
278if fzmoneq a m
279ret add m 1
280end
281end
282ret 0
283end
284fn fzmoneq a ulong m ulong to bool
285for k ulong 3
286if ne flow fzb add a k get tfzmon add mul m 3 k
287ret false
288end
289end
290ret true
291end
292note fzclf: "08/Nov/2026:05:57:35 -0600" at a -> epoch (0 when malformed)
293fn fzn2 a ulong to ulong
294ret add mul ulong sub fzb a 48 10 ulong sub fzb add a 1 48
295end
296fn fzdigs a ulong e ulong to bool
297if or ge a e gt sub e a 19
298ret false
299end
300for k ulong sub e a bound 19
301if not fisdig fzb add a k
302ret false
303end
304end
305ret true
306end
307fn fzclf a ulong e ulong to ulong
308if gt add a 26 e
309ret 0
310end
311if not fzdigs add a 22 add a 26
312ret 0
313end
314m = fzmon add a 3
315if eq m 0
316ret 0
317end
318dd = fzdays fznum add a 7 e m fznum a e
319h = fznum add a 12 e
320mi = fznum add a 15 e
321s = add add mul h 3600 mul mi 60 fznum add a 18 e
322t = add mul dd 86400 s
323o = add mul fzn2 add a 22 3600 mul fzn2 add a 24 60
324if eq fzb add a 21 45
325ret add t o
326end
327ret sub t o
328end
329note ---- events: pending until the batch is in the journal
330fn fzjc c uchar to void
331n = get fzjbl 0
332if lt n len fzjb
333put fzjb n c
334put fzjbl 0 add n 1
335end
336end
337fn fzjn v ulong to void
338d = new uchar 20 0
339i = ulong 20
340x = v
341for it ulong 20
342i = sub i 1
343put d i uchar add rem x 10 48
344x = div x 10
345if eq x 0
346break
347end
348end
349for k ulong sub 20 i bound 20
350fzjc get d add i k
351end
352end
353fn fzev k ulong i ulong ep ulong to void
354if ge i get fan 0
355ret
356end
357j = add mul k FAMAX i
358put fzpnd j add get fzpnd j 1
359put fznev 0 add get fznev 0 1
360fzjc 101
361fzjc 32
362fzjc get tfzkind k
363fzjc 32
364fzjn ep
365fzjc 32
366for q ulong get fail i bound 64
367fzjc fridbyte i q
368end
369fzjc 10
370end
371fn fzsince s ulong ep ulong to void
372if and eq get fzz0 0 1 eq get fzsnc s 0
373if ge ep 1000000000
374put fzsnc s ep
375end
376end
377end
378note ---- source 0: "<msec> <ip> <status> \"<uri>\" \"<user agent>\""
379fn fzl0 a ulong e ulong to void
380p1 = fzsp a e
381ep = fznum a p1
382fzsince 0 ep
383p2 = fzsp add p1 1 e
384p3 = fzsp add p2 1 e
385if ne fznum add p2 1 p3 200
386ret
387end
388if ge add p3 2 e
389ret
390end
391u = add p3 2
392ue = fzch u e 34
393if fzown add p1 1 p2
394ret
395end
396if fzua ue e
397ret
398end
399i = fzuri0 u ue
400if lt i 9999
401fzev 0 i ep
402end
403end
404fn fzua a ulong e ulong to bool
405if fzhas a e tfzbot
406ret true
407end
408if fzhas a e tfzcrl
409ret true
410end
411ret fzhas a e tfzspi
412end
413note fzuri0: /rad/<RID>.git[/z6Mk<nid>]/info/refs?service=git-upload-pack or /code/git/<name>.git/info/refs...
414fn fzuri0 u ulong ue ulong to ulong
415if fzpre u ue tfzrad5
416r = add u 5
417g = fzch r ue 46
418if not fzpre g ue tfzgit4
419ret 9999
420end
421t = add g 4
422if fzpre t ue tfzz6
423t = fzch add t 1 ue 47
424end
425if not fzpre t ue tfzinfo
426ret 9999
427end
428ret fzrix r sub g r
429end
430if fzpre u ue tfzcode
431r = add u 10
432g = fzch r ue 46
433for it ulong 8
434if fzpre g ue tfzgit4
435break
436end
437g = fzch add g 1 ue 46
438end
439if not fzpre add g 4 ue tfzinfo
440ret 9999
441end
442ret fznix r sub g r 1
443end
444ret 9999
445end
446note ---- source 1: combined format, "... [<time>] \"POST /rad/<RID>.git[/z6Mk<nid>]/git-upload-pack HTTP/x\" <status> ..."
447fn fzl1 a ulong e ulong to void
448b = fzch a e 91
449ep = fzclf add b 1 e
450fzsince 1 ep
451q = fzch b e 34
452if not fzpre q e tfzpost
453ret
454end
455u = add q 6
456ue = fzsp u e
457q2 = fzch ue e 34
458if ge add q2 2 e
459ret
460end
461if ne fznum add q2 2 e 200
462ret
463end
464r = add u 5
465g = fzch r ue 46
466if not fzpre g ue tfzgit4
467ret
468end
469t = add g 4
470if fzpre t ue tfzz6
471t = fzch add t 1 ue 47
472end
473if ne sub ue t len tfzupk
474ret
475end
476if not fzpre t ue tfzupk
477ret
478end
479i = fzrix r sub g r
480if lt i 9999
481fzev 1 i ep
482end
483end
484note ---- source 2: forged's access line "<epoch> <ip> <method> <path> <status> <bytes> <ms>"
485fn fzl2 a ulong e ulong to void
486if not fisdig fzb a
487ret
488end
489p1 = fzsp a e
490if not fzdigs a p1
491ret
492end
493ep = fznum a p1
494fzsince 2 ep
495p2 = fzsp add p1 1 e
496p3 = fzsp add p2 1 e
497if ne fznum add p2 1 p3 1
498ret
499end
500p4 = fzsp add p3 1 e
501p5 = fzsp add p4 1 e
502if ne fznum add p4 1 p5 200
503ret
504end
505if fzown add p1 1 p2
506ret
507end
508fzpath2 add p3 1 p4 ep
509end
510fn fzpath2 a ulong e ulong ep ulong to void
511o = add a 1
512if not fzpre o e tfowner
513ret
514end
515r = add o add len tfowner 1
516if ne fzb sub r 1 47
517ret
518end
519g = fzch r e 47
520i = fznix r sub g r 0
521if ge i 9999
522ret
523end
524if fzpre g e tfzarch
525fzev 2 i ep
526ret
527end
528if fzpre g e tfzrel
529fzev 3 i ep
530end
531end
532note ---- journal lines: "e <k> <epoch> <rid>", "s <src> <epoch>", "k <src> <ino> <off>"
533fn fzjl a ulong e ulong to bool
534if lt sub e a 5
535ret false
536end
537c = fzb a
538if eq c 101
539fzjle a e
540ret false
541end
542s = ulong sub fzb add a 2 48
543if gt s 2
544ret false
545end
546if eq c 115
547put fzspen s fznum add a 4 e
548ret false
549end
550if eq c 107
551p = fzsp add a 4 e
552put fzino s fznum add a 4 e
553put fzoff s fznum add p 1 e
554put fzinit s 1
555if ne get fzspen s 0
556put fzsnc s get fzspen s
557put fzsj s 1
558put fzspen s 0
559end
560fzcommit
561ret true
562end
563ret false
564end
565fn fzjle a ulong e ulong to void
566k = fzkix fzb add a 2
567if gt k 3
568ret
569end
570p = fzsp add a 4 e
571i = fzrix add p 1 sub sub e p 1
572if ge i 9999
573ret
574end
575j = add mul k FAMAX i
576put fzpnd j add get fzpnd j 1
577put fznev 0 add get fznev 0 1
578end
579fn fzkix c uchar to ulong
580for k ulong 4
581if eq c get tfzkind k
582ret k
583end
584end
585ret 9
586end
587fn fzcommit to void
588for j ulong mul 4 FAMAX
589put fzcnt j add get fzcnt j get fzpnd j
590put fzpnd j 0
591end
592put fznev 0 0
593end
594fn fzdrop to void
595for j ulong mul 4 FAMAX
596put fzpnd j 0
597end
598for s ulong 4
599put fzspen s 0
600end
601put fznev 0 0
602put fzjbl 0 0
603end
604fn fzline s ulong a ulong e ulong to void
605if eq s 0
606fzl0 a e
607ret
608end
609if eq s 1
610fzl1 a e
611ret
612end
613if eq s 2
614fzl2 a e
615ret
616end
617end
618note ---- paths, stat, journal write
619fn fzpath s ulong rot ulong to void
620fpb
621if eq s 0
622fpt tfzp0
623end
624if eq s 1
625fpt tfzp1
626end
627if eq s 2
628fpt tfdata
629fpt tfzlog
630end
631if eq s 3
632if ne get fzjpl 0 0
633for k ulong get fzjpl 0 bound 4096
634fpc get fzjp k
635end
636else
637fpt tfdata
638fpt tfzjn
639end
640end
641if eq rot 1
642fpt tfzdot1
643end
644end
645fn fzle8 o ulong to ulong
646v = ulong 0
647for i ulong 8
648v = or v shl ulong get fzst add o i mul i 8
649end
650ret v
651end
652note fzstat: inode and size of the source (rot 1: its rotated copy <log>.1); false when missing
653fn fzstat s ulong rot ulong to bool
654fzpath s rot
655r = stat fpth 0 get fpthl 0 fzst 0 128
656if lt r 0
657ret false
658end
659put fzcin 0 fzle8 8
660put fzcsz 0 fzle8 48
661ret true
662end
663fn fzjk s ulong ino ulong ofs ulong to void
664if and eq get fzsj s 0 ne get fzsnc s 0
665fzjc 115
666fzjc 32
667fzjc uchar add s 48
668fzjc 32
669fzjn get fzsnc s
670fzjc 10
671end
672fzjc 107
673fzjc 32
674fzjc uchar add s 48
675fzjc 32
676fzjn ino
677fzjc 32
678fzjn ofs
679fzjc 10
680end
681note fzjopen: discard a torn suffix before appending, including a short write in this process.
682note Refuse a journal that shrank below its committed end; never extend it with invented bytes.
683fn fzjopen to long
684fzpath 3 0
685fd = fopen fpth 0 get fpthl 0 525377 384
686if lt fd 0
687ret fd
688end
689sz = fseek int fd 0 2
690if lt sz 0
691x = fclose int fd
692ret -1
693end
694if lt ulong sz get fzjend 0
695x = fclose int fd
696ret -1
697end
698if gt ulong sz get fzjend 0
699r = ftrunc int fd long get fzjend 0
700if lt r 0
701x = fclose int fd
702ret -1
703end
704end
705ret fd
706end
707note fzflush: write the pending batch and its cursor in one append; commit only when it is all written
708fn fzflush s ulong ino ulong ofs ulong to bool
709if eq get fznev 0 0
710put fzjbl 0 0
711note Save known-source empty-batch cursors across owner invocations.
712note Until a source has a valid epoch, rescan so its first valid record can set since.
713note Ordinary in-process counting retains its existing journal behavior.
714if or eq get fzjpl 0 0 eq get fzsnc s 0
715ret true
716end
717end
718fzjk s ino ofs
719fd = fzjopen
720if lt fd 0
721fzdrop
722ret false
723end
724n = get fzjbl 0
725w = write int fd fzjb 0 n
726x = fclose int fd
727if ne w long n
728fzdrop
729ret false
730end
731put fzjend 0 add get fzjend 0 n
732if eq get fzsnc s 0
733put fzsj s 0
734else
735put fzsj s 1
736end
737put fzjbl 0 0
738fzcommit
739ret true
740end
741note ---- the chunked line reader: complete lines of [from, to) of source s; returns the end of the last line read
742fn fzlines s ulong n ulong pos ulong ino ulong to ulong
743a = ulong 0
744used = ulong 0
745for it ulong n bound 1048576
746if ge a n
747break
748end
749e = fzch a n 10
750if ge e n
751break
752end
753used = add e 1
754if eq s 3
755if fzjl a e
756put fzjend 0 add pos used
757end
758else
759fzline s a e
760end
761a = used
762if gt get fzjbl 0 60000
763if ne s 3
764if not fzflush s ino add pos used
765put fzfail 0 1
766ret used
767end
768end
769end
770end
771ret used
772end
773fn fzscan s ulong rot ulong fr ulong upto ulong ino ulong to bool
774put fzz0 0 0
775if eq fr 0
776put fzz0 0 1
777end
778fzpath s rot
779fd = fopen fpth 0 get fpthl 0 524288 0
780if lt fd 0
781ret false
782end
783pos = fr
784for it ulong 1000000
785if ge pos upto
786break
787end
788n = pread int fd fzbuf 0 hmin sub upto pos len fzbuf long pos
789if le n 0
790break
791end
792u = fzlines s ulong n pos ino
793if ne get fzfail 0 0
794break
795end
796if eq u 0
797if lt ulong n len fzbuf
798break
799end
800u = ulong n
801end
802pos = add pos u
803end
804x = fclose int fd
805if ne get fzfail 0 0
806ret false
807end
808if eq s 3
809ret true
810end
811if not fzflush s ino pos
812ret false
813end
814put fzino s ino
815put fzoff s pos
816put fzinit s 1
817ret true
818end
819note ---- one source, on change only
820fn fzsync s ulong to void
821put fzfail 0 0
822if not fzstat s 0
823ret
824end
825ino = get fzcin 0
826sz = get fzcsz 0
827if and ne get fzinit s 0 and eq ino get fzino s eq sz get fzoff s
828ret
829end
830if ne s 1
831if eq get fzhomel 0 0
832if not fzhomeip
833ret
834end
835end
836end
837if eq get fzinit s 0
838fzfirst s ino sz
839ret
840end
841if eq ino get fzino s
842f = get fzoff s
843if lt sz f
844f = 0
845end
846x = fzscan s 0 f sz ino
847ret
848end
849fzrot s ino sz
850end
851fn fzfirst s ulong ino ulong sz ulong to void
852if fzstat s 1
853i1 = get fzcin 0
854s1 = get fzcsz 0
855if not fzscan s 1 0 s1 i1
856ret
857end
858end
859x = fzscan s 0 0 sz ino
860end
861fn fzrot s ulong ino ulong sz ulong to void
862o = get fzino s
863if fzstat s 1
864i1 = get fzcin 0
865s1 = get fzcsz 0
866f = ulong 0
867if eq i1 o
868f = get fzoff s
869if lt s1 f
870f = 0
871end
872end
873if not fzscan s 1 f s1 i1
874ret
875end
876end
877x = fzscan s 0 0 sz ino
878end
879note fzload: start and reload: forget everything and replay the journal (a torn last batch is dropped)
880fn fzload to void
881if fzboxed
882fzclear
883ret
884end
885for j ulong mul 4 FAMAX
886put fzcnt j 0
887end
888fzdrop
889put fzjend 0 0
890for s ulong 4
891put fzino s 0
892put fzoff s 0
893put fzinit s 0
894put fzsnc s 0
895put fzsj s 0
896end
897for i ulong FAMAX
898put fzsdk i 0
899end
900put fzfail 0 0
901if fzstat 3 0
902x = fzscan 3 0 0 get fzcsz 0 0
903end
904fzdrop
905put fzfail 0 0
906end
907note fzprep: before the repo home (HTML or JSON) of fridx: read what the logs added, read the seeds
908fn fzprep to void
909if fzboxed
910fzsnapshot
911ret
912end
913i = get fridx 0
914if ge i get fan 0
915ret
916end
917put fzhomel 0 0
918fzsync 0
919fzsync 1
920fzsync 2
921fzseeds i
922end
923note fzseeds: the number of nodes seeding repo i from this node's routing table (fradseeds,
924note server/radsrc.om), read again when the node database changed (fradwalk). The store-reading build
925note has no routing table (fradsrc false): nothing runs or is read, and fzsdk stays 0 (not measured).
926fn fzseeds i ulong to void
927if not fradsrc
928ret
929end
930key = fradwalk
931if and ne get fzsdk i 0 and ne key 0 eq key get fzsdm i
932ret
933end
934put fzsdm i key
935n = fradseeds i
936if lt n 0
937put fzsdk i 2
938ret
939end
940put fzsd i ulong n
941put fzsdk i 1
942put fzsdt i div ulong realns 1000000000
943end
944note ---- output: the header lines (HTML) and the counts object (JSON)
945fn fzc k ulong i ulong to ulong
946ret get fzcnt add mul k FAMAX i
947end
948text tfzh1 "\n<p class=\"meta\">Clones and fetches over HTTPS: "
949text tfzh2 " by visitors (git smart-HTTP <code>info/refs</code> requests answered 200 in the front-door download log; our own addresses and bots left out"
950text tfzh3 ") &#183; "
951text tfzh4 " <code>git-upload-pack</code> requests from all clients (the source of this count is retired"
952text tfzh5 ")</p>\n<p class=\"meta\">Downloads: "
953text tfzh6 " by visitors ("
954text tfzh7 " source archives, "
955text tfzh8 " release assets; forged access log; our own addresses left out"
956text tfzh9 ")</p>\n<p class=\"meta\">Seeding: <b>not measured</b> (the source of this count is retired)</p>\n"
957text tfzh9s ")</p>\n"
958text tfzh14 " (forged access log not read yet"
959text tfzsn " since "
960text tfznm "<b>not measured</b>"
961text tfzb1 "<b>"
962text tfzb2 "</b>"
963fn fzhn v ulong s ulong to void
964if eq get fzsnc s 0
965fput tfznm
966ret
967end
968fput tfzb1
969fnum v
970fput tfzb2
971end
972fn fzhs s ulong to void
973if eq get fzsnc s 0
974ret
975end
976fputc 59
977fput tfzsn
978fjday get fzsnc s
979end
980fn fzhtml i ulong to void
981fput tfzh1
982fzhn fzc 0 i 0
983fput tfzh2
984fzhs 0
985fput tfzh3
986fput tfznm
987fput tfzh4
988fput tfzh5
989fzhdl i
990if not fradsrc
991fput tfzh9s
992ret
993end
994fput tfzh9
995end
996fn fzhdl i ulong to void
997if eq get fzsnc 2 0
998fput tfznm
999fput tfzh14
1000ret
1001end
1002fzhn add fzc 2 i fzc 3 i 2
1003fput tfzh6
1004fnum fzc 2 i
1005fput tfzh7
1006fnum fzc 3 i
1007fput tfzh8
1008fzhs 2
1009end
1010text tfzj1 "{\n\"git_fetches\":{\"count\":"
1011text tfzjs "\"since\":"
1012text tfzj2 ",\"source\":\"front-door nginx download log\",\"counts\":\"git smart-HTTP info/refs?service=git-upload-pack requests answered 200 (one per clone or fetch), /code/git/<name>.git and the retired clone path\",\"excludes\":\"our own addresses (loopback, LAN, tailnet, the home address of www.aienos.com) and user agents naming bot, crawl or spider\"},\n\"upload_pack_requests\":{\"count\":null,\"since\":null,\"source\":\"retired\",\"counts\":\"not measured: the source of this count is retired\",\"excludes\":null},\n\"downloads\":{\"count\":"
1013text tfzj4 ",\"archives\":"
1014text tfzj5 ",\"release_assets\":"
1015text tfzj6 ",\"source\":\"forged access log\",\"counts\":\"GET or HEAD of /<owner>/<repo>/archive/... and /releases/download/... answered 200\",\"excludes\":\"our own addresses (loopback, LAN, tailnet, the home address of www.aienos.com)\"},\n\"seeds\":{\"count\":null,\"as_of\":null,\"source\":\"retired\",\"counts\":\"not measured: the source of this count is retired\"}\n}"
1016fn fzjv v ulong s ulong to void
1017if eq get fzsnc s 0
1018fput tfjnull
1019else
1020fnum v
1021end
1022fputc 44
1023fput tfzjs
1024fjiso get fzsnc s
1025end
1026fn fzjson i ulong to void
1027fput tfzj1
1028fzjv fzc 0 i 0
1029fput tfzj2
1030fzjv add fzc 2 i fzc 3 i 2
1031fput tfzj4
1032fzj0 fzc 2 i 2
1033fput tfzj5
1034fzj0 fzc 3 i 2
1035fput tfzj6
1036end
1037fn fzj0 v ulong s ulong to void
1038if eq get fzsnc s 0
1039fput tfjnull
1040ret
1041end
1042fnum v
1043end