urbit/pkg/arvo/ted/dns/address.hoon

62 lines
1.9 KiB
Plaintext
Raw Normal View History

2019-11-26 08:30:41 +03:00
/- spider, dns
/+ strandio, libdns=dns
=, strand=strand:spider
^- thread:spider
|= arg=vase
|^
=/ m (strand ,vase)
^- form:m
=+ !< [~ adr=address:dns] arg
2019-11-26 08:30:41 +03:00
::
;< our=ship bind:m get-our:strandio
=/ rac (clan:title our)
?. ?=(?(%king %duke) rac)
%+ strand-fail:strandio %ship-type-fail
[>"can only set DNS for planets and stars"< ~]
2019-11-26 08:30:41 +03:00
::
?: (reserved:eyre if.adr)
%+ strand-fail:strandio %reserved-address
[>"ip address {<if.adr>} is reserved"< ~]
2019-11-26 08:30:41 +03:00
;< ~ bind:m (request-by-ip if.adr)
;< ~ bind:m take-fact
(pure:m *vase)
::
++ request-by-ip
|= if=@if
=/ m (strand ,~)
^- form:m
=/ collector-app `dock`[~deg %dns-collector]
2019-11-26 08:30:41 +03:00
;< good=? bind:m (self-check-http:libdns |+if 2)
?. good
%+ strand-fail:strandio %bail-early-self-check
[>"couldn't access ship on port 80"< ~]
2022-08-17 14:08:33 +03:00
;< our=@p bind:m get-our:strandio
2022-08-18 14:22:57 +03:00
;< ~ bind:m (watch:strandio /response collector-app /(scot %p our))
2019-11-26 08:30:41 +03:00
;< ~ bind:m (poke:strandio collector-app %dns-address !>([%if if]))
=/ msg=cord
(cat 3 'request for DNS sent to ' (scot %p p:collector-app))
;< ~ bind:m (app-message:strandio %dns msg ~)
=/ msg=cord
(cat 3 'awaiting response from ' (scot %p p:collector-app))
;< ~ bind:m (app-message:strandio %dns msg ~)
(pure:m ~)
::
++ take-fact
=/ m (strand ,~)
^- form:m
;< our=ship bind:m get-our:strandio
2022-08-18 14:22:57 +03:00
;< =cage bind:m (take-fact:strandio /response)
2019-11-26 08:30:41 +03:00
?> ?=(%dns-binding p.cage)
=/ =binding:dns !<(binding:dns q.cage)
;< good=? bind:m (turf-confirm-install:libdns 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 (app-message:strandio %dns msg)
(pure:m ~)
--