2019-06-06 02:13:24 +03:00
|
|
|
/- dns, hall
|
2019-06-05 04:21:42 +03:00
|
|
|
/+ tapp, stdio
|
2018-05-07 19:53:31 +03:00
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
:: tapp types and boilerplate
|
2018-05-07 19:53:31 +03:00
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
=> |%
|
|
|
|
++ collector-app `dock`[~zod %dns-collector]
|
|
|
|
+$ app-state
|
|
|
|
$: %0
|
|
|
|
requested=(unit address:dns)
|
|
|
|
completed=(unit binding:dns)
|
2019-03-28 21:19:35 +03:00
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
+$ peek-data _!!
|
|
|
|
+$ in-poke-data
|
2019-07-03 01:11:03 +03:00
|
|
|
$% [%dns-auto ames-domains=(list turf)]
|
2019-06-05 04:21:42 +03:00
|
|
|
[%dns-address =address:dns]
|
2019-03-28 21:19:35 +03:00
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
+$ out-poke-data
|
|
|
|
$% [%dns-address =address:dns]
|
2019-06-06 02:13:24 +03:00
|
|
|
[%hall-action %phrase audience:hall (list speech:hall)]
|
2019-03-28 21:19:35 +03:00
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
+$ in-peer-data
|
|
|
|
$% [%dns-binding =binding:dns]
|
2019-01-09 23:50:22 +03:00
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
+$ out-peer-data ~
|
2019-06-27 20:03:18 +03:00
|
|
|
++ tapp
|
|
|
|
%: ^tapp
|
|
|
|
app-state
|
|
|
|
peek-data
|
|
|
|
in-poke-data
|
|
|
|
out-poke-data
|
|
|
|
in-peer-data
|
|
|
|
out-peer-data
|
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
++ stdio (^stdio out-poke-data out-peer-data)
|
|
|
|
--
|
|
|
|
::
|
|
|
|
:: monadic helpers (XX move to stdio?)
|
|
|
|
::
|
|
|
|
=> |%
|
|
|
|
:: +backoff: exponential backoff timer
|
|
|
|
::
|
|
|
|
++ backoff
|
2019-06-06 01:21:15 +03:00
|
|
|
|= [try=@ud limit=@dr]
|
2019-06-05 04:21:42 +03:00
|
|
|
=/ m (async:stdio ,~)
|
|
|
|
^- form:m
|
|
|
|
;< eny=@uvJ bind:m get-entropy:stdio
|
|
|
|
;< now=@da bind:m get-time:stdio
|
|
|
|
%- wait:stdio
|
2019-06-06 01:21:15 +03:00
|
|
|
%+ add now
|
|
|
|
%+ min limit
|
2019-06-05 04:21:42 +03:00
|
|
|
?: =(0 try) ~s0
|
|
|
|
%+ add
|
|
|
|
(mul ~s1 (bex (dec try)))
|
|
|
|
(mul ~s0..0001 (~(rad og eny) 1.000))
|
2019-06-06 01:21:15 +03:00
|
|
|
::
|
|
|
|
++ request
|
|
|
|
|= =hiss:eyre
|
2019-06-06 09:45:14 +03:00
|
|
|
=/ m (async:stdio (unit httr:eyre))
|
2019-06-06 01:21:15 +03:00
|
|
|
^- form:m
|
|
|
|
;< ~ bind:m (send-hiss:stdio hiss)
|
2019-06-06 09:45:14 +03:00
|
|
|
take-maybe-sigh:stdio
|
2019-06-06 01:21:15 +03:00
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
:: +self-check-http: confirm our availability at .host on port 80
|
|
|
|
::
|
2019-06-06 09:45:14 +03:00
|
|
|
:: XX needs better success/failure predicates
|
|
|
|
:: XX bind route to self and handle request inside tx?
|
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
++ self-check-http
|
|
|
|
|= [=host:eyre max=@ud]
|
|
|
|
=/ m (async:stdio ?)
|
|
|
|
^- form:m
|
2019-06-07 21:36:12 +03:00
|
|
|
:: XX also scry into eyre
|
|
|
|
:: q:.^(hart:eyre %e /(scot %p our)/host/real)
|
2019-06-06 01:21:15 +03:00
|
|
|
=/ =hiss:eyre
|
2019-06-05 04:21:42 +03:00
|
|
|
=/ url=purl:eyre
|
|
|
|
[[sec=| por=~ host] [ext=`~.udon path=/static] query=~]
|
|
|
|
[url %get ~ ~]
|
|
|
|
=/ try=@ud 0
|
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
|
|
|
?: =(try max)
|
|
|
|
(pure:m |)
|
2019-06-06 09:45:14 +03:00
|
|
|
;< ~ bind:m (backoff try ~h1)
|
|
|
|
;< rep=(unit httr:eyre) bind:m (request hiss)
|
|
|
|
?: ?& ?=(^ rep)
|
|
|
|
|(=(200 p.u.rep) =(307 p.u.rep))
|
|
|
|
==
|
2019-06-05 04:21:42 +03:00
|
|
|
(pure:m &)
|
2019-06-06 09:45:14 +03:00
|
|
|
?. ?| ?=(~ rep)
|
|
|
|
=(504 p.u.rep)
|
|
|
|
==
|
|
|
|
(pure:m |)
|
2019-06-05 04:21:42 +03:00
|
|
|
loop(try +(try))
|
2019-06-06 02:13:24 +03:00
|
|
|
::
|
|
|
|
++ hall-app-message
|
|
|
|
|= [app=term =cord =tang]
|
|
|
|
=/ m (async:stdio ,~)
|
|
|
|
^- form:m
|
|
|
|
=/ msg=speech:hall
|
|
|
|
:+ %app app
|
|
|
|
=/ line [%lin & cord]
|
|
|
|
?~(tang line [%fat [%tank tang] line])
|
|
|
|
;< our=@p bind:m get-identity:stdio
|
|
|
|
=/ act
|
|
|
|
[%phrase (sy [our %inbox] ~) [msg ~]]
|
|
|
|
(poke-app:stdio [our %hall] %hall-action act)
|
2019-06-05 04:21:42 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:: application actions
|
|
|
|
::
|
|
|
|
=> |%
|
|
|
|
:: +turf-confirm-install: self check and install domain
|
|
|
|
::
|
|
|
|
++ turf-confirm-install
|
|
|
|
|= =turf
|
|
|
|
=/ m (async:stdio ?)
|
|
|
|
^- form:m
|
|
|
|
;< good=? bind:m (self-check-http &+turf 5)
|
|
|
|
?. good
|
|
|
|
(pure:m |)
|
|
|
|
;< ~ bind:m (install-domain:stdio turf)
|
|
|
|
(pure:m &)
|
|
|
|
::
|
|
|
|
:: +galaxy-domains
|
|
|
|
::
|
|
|
|
++ galaxy-domains
|
2019-07-03 01:11:03 +03:00
|
|
|
|= ames-domains=(list turf)
|
2019-06-05 04:21:42 +03:00
|
|
|
=/ m (async:stdio ,~)
|
|
|
|
^- form:m
|
|
|
|
;< our=@p bind:m get-identity:stdio
|
2019-07-03 11:19:02 +03:00
|
|
|
:: XX urbit/urbit#1314
|
|
|
|
::
|
2019-07-03 01:11:03 +03:00
|
|
|
:: ;< now=@da bind:m get-time:stdio
|
|
|
|
:: =/ ames-domains=(list turf)
|
|
|
|
:: .^((list turf) %j /(scot %p our)/turf/(scot %da now))
|
2019-06-05 04:21:42 +03:00
|
|
|
|- ^- form:m
|
|
|
|
=* loop $
|
|
|
|
?~ ames-domains
|
|
|
|
(pure:m ~)
|
|
|
|
=/ =turf
|
|
|
|
(weld i.ames-domains /(crip +:(scow %p our)))
|
2019-06-06 02:13:24 +03:00
|
|
|
;< good=? bind:m (turf-confirm-install turf)
|
|
|
|
=/ msg=(pair cord tang)
|
|
|
|
?: good
|
|
|
|
[(cat 3 'confirmed access via ' (en-turf:html turf)) ~]
|
|
|
|
:- (cat 3 'unable to access via ' (en-turf:html turf))
|
|
|
|
:~ leaf+"XX check via nslookup"
|
|
|
|
leaf+"XX confirm port 80"
|
|
|
|
==
|
|
|
|
;< ~ bind:m (hall-app-message %dns msg)
|
2019-06-05 04:21:42 +03:00
|
|
|
loop(ames-domains t.ames-domains)
|
|
|
|
::
|
|
|
|
:: +request-by-ip
|
|
|
|
::
|
|
|
|
++ request-by-ip
|
|
|
|
|= if=@if
|
|
|
|
=/ m (async:stdio ?)
|
|
|
|
^- form:m
|
|
|
|
;< good=? bind:m (self-check-http |+if 5)
|
|
|
|
?. good
|
|
|
|
:: XX details
|
|
|
|
~& %bail-early
|
|
|
|
(pure:m |)
|
|
|
|
;< ~ bind:m (poke-app:stdio collector-app [%dns-address %if if])
|
|
|
|
;< our=@p bind:m get-identity:stdio
|
|
|
|
;< ~ bind:m (peer-app:stdio collector-app /(scot %p our))
|
|
|
|
(pure:m &)
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=* tapp-async tapp-async:tapp
|
|
|
|
=* default-tapp default-tapp:tapp
|
|
|
|
%- create-tapp-all:tapp
|
|
|
|
^- tapp-core-all:tapp
|
|
|
|
|_ [=bowl:gall state=app-state]
|
|
|
|
::
|
|
|
|
++ handle-init handle-init:default-tapp
|
|
|
|
++ handle-peek handle-peek:default-tapp
|
|
|
|
++ handle-peer handle-peer:default-tapp
|
|
|
|
::
|
|
|
|
++ handle-poke
|
|
|
|
|= =in-poke-data
|
|
|
|
=/ m tapp-async
|
|
|
|
^- form:m
|
|
|
|
?. (team:title [our src]:bowl)
|
|
|
|
~| %configure-yoself !!
|
|
|
|
?- -.in-poke-data
|
|
|
|
::
|
|
|
|
:: "automatic" dns binding -- currently only for galaxies
|
|
|
|
::
|
|
|
|
:: XX could be in +handle-init
|
|
|
|
:: XX use ip reflection for other classes
|
|
|
|
::
|
|
|
|
%dns-auto
|
|
|
|
?. ?=(%czar (clan:title our.bowl))
|
|
|
|
:: XX details
|
|
|
|
::
|
|
|
|
~& %galaxy-only
|
|
|
|
(pure:m state)
|
2019-07-03 01:11:03 +03:00
|
|
|
;< ~ bind:m (galaxy-domains ames-domains.in-poke-data)
|
2019-06-05 04:21:42 +03:00
|
|
|
(pure:m state)
|
|
|
|
::
|
|
|
|
:: manual dns binding -- by explicit ipv4
|
|
|
|
::
|
|
|
|
%dns-address
|
2019-06-07 21:36:12 +03:00
|
|
|
=* adr address.in-poke-data
|
|
|
|
=/ rac (clan:title our.bowl)
|
|
|
|
?. ?=(?(%king %duke) rac)
|
|
|
|
~| [%dns-collector-bind-invalid rac] !!
|
|
|
|
?: (reserved:eyre if.adr)
|
|
|
|
~| [%dns-collector-reserved-address if.adr] !!
|
|
|
|
;< requested=? bind:m (request-by-ip if.adr)
|
2019-06-05 04:21:42 +03:00
|
|
|
:: XX save failure?
|
2019-07-19 22:45:20 +03:00
|
|
|
::
|
|
|
|
~? =(requested.state (some address.in-poke-data))
|
|
|
|
%re-requesting
|
2019-06-05 04:21:42 +03:00
|
|
|
=? requested.state requested
|
|
|
|
(some address.in-poke-data)
|
|
|
|
(pure:m state)
|
2019-01-09 21:21:19 +03:00
|
|
|
==
|
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
++ handle-diff
|
|
|
|
|= [=dock =path =in-peer-data]
|
|
|
|
=/ m tapp-async
|
|
|
|
^- form:m
|
|
|
|
?. =(dock collector-app)
|
|
|
|
~| [%unexpected-diff-dock-wat-do dock] !!
|
|
|
|
?. =(path /(scot %p our.bowl))
|
|
|
|
~| [%unexpected-diff-path-wat-do path] !!
|
|
|
|
?- -.in-peer-data
|
|
|
|
%dns-binding
|
|
|
|
=* binding binding.in-peer-data
|
|
|
|
?~ requested.state
|
|
|
|
~| %unexpected-binding-wat-do !!
|
|
|
|
?. =(u.requested.state address.binding)
|
|
|
|
~| %mismatch-binding-wat-do !!
|
2019-06-06 02:13:24 +03:00
|
|
|
;< good=? bind:m (turf-confirm-install turf.binding)
|
|
|
|
=/ msg=(pair cord tang)
|
|
|
|
?: good
|
|
|
|
[(cat 3 'confirmed access via ' (en-turf:html turf.binding)) ~]
|
|
|
|
:- (cat 3 'unable to access via ' (en-turf:html turf.binding))
|
|
|
|
:~ leaf+"XX check via nslookup"
|
|
|
|
leaf+"XX confirm port 80"
|
|
|
|
==
|
|
|
|
;< ~ bind:m (hall-app-message %dns msg)
|
|
|
|
=? completed.state good (some binding)
|
|
|
|
:: XX save failure?s
|
2019-06-05 04:21:42 +03:00
|
|
|
:: XX unsubscribe?
|
|
|
|
(pure:m state)
|
2018-06-19 05:59:50 +03:00
|
|
|
==
|
2019-03-28 21:19:35 +03:00
|
|
|
::
|
2019-06-05 04:21:42 +03:00
|
|
|
++ handle-take
|
|
|
|
|= =sign:tapp
|
|
|
|
=/ m tapp-async
|
|
|
|
^- form:m
|
|
|
|
?+ -.sign
|
|
|
|
~| [%unexpected-sign sign] !!
|
|
|
|
:: print %poke nacks
|
|
|
|
::
|
|
|
|
%coup
|
2019-06-06 02:13:24 +03:00
|
|
|
?. =(collector-app dock.sign)
|
|
|
|
(pure:m state)
|
2019-06-05 04:21:42 +03:00
|
|
|
?~ error.sign
|
2019-06-06 02:13:24 +03:00
|
|
|
=/ msg=cord
|
|
|
|
(cat 3 'request for DNS sent to ' (scot %p p:collector-app))
|
|
|
|
;< ~ bind:m (hall-app-message %dns msg ~)
|
2019-06-05 04:21:42 +03:00
|
|
|
(pure:m state)
|
|
|
|
:: XX details
|
|
|
|
~& %dns-ip-request-failed
|
|
|
|
%- (slog u.error.sign)
|
|
|
|
(pure:m state)
|
|
|
|
:: re-subscribe if (involuntarily) unsubscribed
|
|
|
|
::
|
|
|
|
%quit
|
|
|
|
?. =(path.sign /(scot %p our.bowl))
|
|
|
|
~| [%unexpected-quit-path-wat-do path.sign] !!
|
|
|
|
;< ~ bind:m (peer-app:stdio collector-app /(scot %p our.bowl))
|
|
|
|
(pure:m state)
|
|
|
|
:: print %peer nacks
|
|
|
|
::
|
|
|
|
%reap
|
|
|
|
?. =(path.sign /(scot %p our.bowl))
|
|
|
|
~| [%unexpected-reap-path-wat-do path.sign] !!
|
|
|
|
?~ error.sign
|
2019-06-06 02:13:24 +03:00
|
|
|
=/ msg=cord
|
|
|
|
(cat 3 'awaiting response from ' (scot %p p:collector-app))
|
|
|
|
;< ~ bind:m (hall-app-message %dns msg ~)
|
2019-06-05 04:21:42 +03:00
|
|
|
(pure:m state)
|
|
|
|
:: XX details
|
|
|
|
~& %dns-domain-subscription-failed
|
|
|
|
%- (slog u.error.sign)
|
|
|
|
(pure:m state)
|
2018-10-31 01:19:34 +03:00
|
|
|
==
|
2018-05-07 19:53:31 +03:00
|
|
|
--
|