Merge pull request #6163 from urbit/lf/ames-snub

ames: add %snub
This commit is contained in:
Philip Monk 2023-01-17 15:17:33 -07:00 committed by GitHub
commit e262ab4ebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 90 additions and 14 deletions

View File

@ -0,0 +1,10 @@
:: Helm: Set Ames Blocklist
::
/? 310
::
::::
::
:- %say
|= [^ ships=(list ship) ~]
:- %helm-ames-snub
ships

View File

@ -202,6 +202,10 @@
|= ships=(list ship)
abet:(emit %pass /helm/prod %arvo %a %prod ships)
::
++ poke-ames-snub
|= ships=(list ship)
abet:(emit %pass /helm/snub %arvo %a %snub ships)
::
++ poke-atom
|= ato=@
=+ len=(scow %ud (met 3 ato))
@ -273,6 +277,7 @@
==
?+ mark ~|([%poke-helm-bad-mark mark] !!)
%helm-ames-prod =;(f (f !<(_+<.f vase)) poke-ames-prod)
%helm-ames-snub =;(f (f !<(_+<.f vase)) poke-ames-snub)
%helm-ames-sift =;(f (f !<(_+<.f vase)) poke-ames-sift)
%helm-ames-verb =;(f (f !<(_+<.f vase)) poke-ames-verb)
%helm-ames-wake =;(f (f !<(_+<.f vase)) poke-ames-wake)

View File

@ -360,6 +360,7 @@
:: %init: vane boot
:: %prod: re-send a packet per flow, to all peers if .ships is ~
:: %sift: limit verbosity to .ships
:: %snub: set packet blacklist to .ships
:: %spew: set verbosity toggles
:: %trim: release memory
:: %vega: kernel reload notification
@ -375,6 +376,7 @@
$>(%init vane-task)
[%prod ships=(list ship)]
[%sift ships=(list ship)]
[%snub ships=(list ship)]
[%spew veb=(list verb)]
[%stir arg=@t]
$>(%trim vane-task)

View File

@ -607,19 +607,20 @@
:: life: our $life; how many times we've rekeyed
:: crypto-core: interface for encryption and signing
:: bug: debug printing configuration
:: corks(STALE):wires for cork flows pending publisher update
:: snub: blocklist for incoming packets
::
:: Note: .corks is only still present for unreleased migration reasons
::
::
+$ ames-state
$: peers=(map ship ship-state)
=unix=duct
=life
crypto-core=acru:ames
=bug
corks=(set wire) ::TODO unused, remove in next version of state
corks=(set wire)
snub=(set ship)
==
::
+$ ames-state-4 ames-state-5
+$ ames-state-5
$: peers=(map ship ship-state-5)
@ -686,6 +687,17 @@
crypto-core=acru:ames
=bug
==
::
+$ ames-state-8
$: peers=(map ship ship-state)
=unix=duct
=life
crypto-core=acru:ames
=bug
corks=(set wire)
==
::
:: $bug: debug printing configuration
::
:: veb: verbosity toggles
@ -842,7 +854,14 @@
::
=< =* adult-gate .
=| queued-events=(qeu queued-event)
=| cached-state=(unit $%([%5 ames-state-5] [%6 ames-state-6] [%7 ames-state-7] [%8 ^ames-state]))
=| $= cached-state
%- unit
$% [%5 ames-state-5]
[%6 ames-state-6]
[%7 ames-state-7]
[%8 ames-state-8]
[%9 ^ames-state]
==
::
|= [now=@da eny=@ rof=roof]
=* larval-gate .
@ -964,7 +983,7 @@
:: lifecycle arms; mostly pass-throughs to the contained adult ames
::
++ scry scry:adult-core
++ stay [%8 %larva queued-events ames-state.adult-gate]
++ stay [%9 %larva queued-events ames-state.adult-gate]
++ load
|= $= old
$% $: %4
@ -996,6 +1015,13 @@
[%adult state=ames-state-7]
== ==
$: %8
$% $: %larva
events=(qeu queued-event)
state=ames-state-8
==
[%adult state=ames-state-8]
== ==
$: %9
$% $: %larva
events=(qeu queued-event)
state=_ames-state.adult-gate
@ -1040,12 +1066,22 @@
=. queued-events events.old
larval-gate
::
[%8 %adult *] (load:adult-core %8 state.old)
[%8 %adult *]
=. cached-state `[%8 state.old]
~> %slog.0^leaf/"ames: larva reload"
larval-gate
::
[%8 %larva *]
~> %slog.0^leaf/"ames: larva: load"
=. queued-events events.old
larval-gate
::
[%9 %adult *] (load:adult-core %9 state.old)
::
[%9 %larva *]
~> %slog.1^leaf/"ames: larva: load"
=. queued-events events.old
=. adult-gate (load:adult-core %8 state.old)
=. adult-gate (load:adult-core %9 state.old)
larval-gate
::
==
@ -1064,7 +1100,9 @@
~> %slog.0^leaf/"ames: init daily recork timer"
:- [[/ames]~ %pass /recork %b %wait `@da`(add now ~d1)]~
8+(state-7-to-8:load:adult-core +.u.cached-state)
?> ?=(%8 -.u.cached-state)
=? u.cached-state ?=(%8 -.u.cached-state)
9+(state-8-to-9:load:adult-core +.u.cached-state)
?> ?=(%9 -.u.cached-state)
=. ames-state.adult-gate +.u.cached-state
[moz larval-core(cached-state ~)]
--
@ -1103,6 +1141,7 @@
%jilt (on-jilt:event-core ship.task)
%prod (on-prod:event-core ships.task)
%sift (on-sift:event-core ships.task)
%snub (on-snub:event-core ships.task)
%spew (on-spew:event-core veb.task)
%stir (on-stir:event-core arg.task)
%trim on-trim:event-core
@ -1139,15 +1178,15 @@
[moves ames-gate]
:: +stay: extract state before reload
::
++ stay [%8 %adult ames-state]
++ stay [%9 %adult ames-state]
:: +load: load in old state after reload
::
++ load
=< |= $= old-state
$% [%8 ^ames-state]
$% [%9 ^ames-state]
==
^+ ames-gate
?> ?=(%8 -.old-state)
?> ?=(%9 -.old-state)
ames-gate(ames-state +.old-state)
::
|%
@ -1211,7 +1250,7 @@
::
++ state-7-to-8
|= ames-state=ames-state-7
^- ^^ames-state
^- ames-state-8
:* peers.ames-state
unix-duct.ames-state
life.ames-state
@ -1219,6 +1258,17 @@
bug.ames-state
*(set wire)
==
++ state-8-to-9
|= ames-state=ames-state-8
^- ^^ames-state
:* peers.ames-state
unix-duct.ames-state
life.ames-state
crypto-core.ames-state
bug.ames-state
corks.ames-state
*(set ship)
==
--
:: +scry: dereference namespace
::
@ -1431,6 +1481,13 @@
^+ event-core
=. ships.bug.ames-state (sy ships)
event-core
:: +on-snub: handle request to change ship blacklist
::
++ on-snub
|= ships=(list ship)
^+ event-core
=. snub.ames-state (sy ships)
event-core
:: +on-spew: handle request to set verbosity toggles on debug output
::
++ on-spew
@ -1562,11 +1619,13 @@
~/ %on-hear-packet
|= [=lane =packet dud=(unit goof)]
^+ event-core
%- %^ trace odd.veb sndr.packet
|.("received packet")
%- (trace odd.veb sndr.packet |.("received packet"))
::
?: =(our sndr.packet)
event-core
?: (~(has in snub.ames-state) sndr.packet)
%- (trace rcv.veb sndr.packet |.("snubbed"))
event-core
::
%. +<
::