urbit/pkg/arvo/ted/aqua/ames.hoon

75 lines
1.9 KiB
Plaintext
Raw Normal View History

:: This needs a better SDN solution. Every ship should have an IP
:: address, and we should eventually test changing those IP
:: addresses.
::
:: For now, we broadcast every packet to every ship and rely on them
:: to drop them.
::
2019-11-10 10:27:07 +03:00
/- aquarium, spider
/+ aqua-vane-thread
=, aquarium
|%
++ emit-aqua-events
|= [our=ship aes=(list aqua-event)]
2019-11-19 07:36:21 +03:00
^- (list card:agent:gall)
[%pass /aqua-events %agent [our %aqua] %poke %aqua-events !>(aes)]~
::
++ handle-restore
|= [our=ship who=@p]
2019-11-20 00:40:05 +03:00
^- (list card:agent:gall)
%+ emit-aqua-events our
[%event who [//newt/0v1n.2m9vh %born ~]]~
::
++ handle-send
2019-11-20 00:40:05 +03:00
|= [our=ship now=@da sndr=@p way=wire %send lan=lane:ames pac=@]
^- (list card:agent:gall)
=/ rcvr=ship (lane-to-ship lan)
=/ hear-lane (ship-to-lane sndr)
%+ emit-aqua-events our
2019-11-20 00:40:05 +03:00
[%event rcvr //newt/0v1n.2m9vh %hear hear-lane pac]~
:: +lane-to-ship: decode a ship from an aqua lane
::
2020-12-01 17:59:07 +03:00
:: Special-case one comet, since its address doesn't fit into a lane.
::
++ lane-to-ship
|= =lane:ames
^- ship
::
?- -.lane
%& p.lane
2020-12-01 17:59:07 +03:00
%| =/ s `ship``@`p.lane
?. =(s 0xdead.beef.cafe)
s
~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud
==
:: +ship-to-lane: encode a lane to look like it came from .ship
::
:: Never shows up as a galaxy, because Vere wouldn't know that either.
2020-12-01 17:59:07 +03:00
:: Special-case one comet, since its address doesn't fit into a lane.
::
++ ship-to-lane
|= =ship
^- lane:ames
2020-12-01 17:59:07 +03:00
:- %|
^- address:ames ^- @
?. =(ship ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud)
ship
0xdead.beef.cafe
--
::
%+ aqua-vane-thread ~[%restore %send]
2019-11-10 10:27:07 +03:00
|_ =bowl:spider
+* this .
++ handle-unix-effect
|= [who=@p ue=unix-effect]
2019-11-19 07:36:21 +03:00
^- (quip card:agent:gall _this)
2019-11-20 00:40:05 +03:00
=/ cards
?+ -.q.ue ~
%restore (handle-restore our.bowl who)
%send (handle-send our.bowl now.bowl who ue)
==
[cards this]
::
++ handle-arvo-response _!!
--