mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
moves +reserved ipv4 address check to zuse, uses in :dns|ip
This commit is contained in:
parent
71641f7b93
commit
ecf24a1345
53
app/dns.hoon
53
app/dns.hoon
@ -56,57 +56,6 @@
|
||||
|= [bas=purl:eyre pat=path]
|
||||
^+ bas
|
||||
bas(q.q (weld q.q.bas pat))
|
||||
:: +reserved: check if an ipv4 address is in a reserved range
|
||||
::
|
||||
++ reserved
|
||||
|= a=@if
|
||||
^- ?
|
||||
=/ b (flop (rip 3 a))
|
||||
:: 0.0.0.0/8 (software)
|
||||
::
|
||||
?. ?=([@ @ @ @ ~] b) &
|
||||
?| :: 10.0.0.0/8 (private)
|
||||
::
|
||||
=(10 i.b)
|
||||
:: 100.64.0.0/10 (carrier-grade NAT)
|
||||
::
|
||||
&(=(100 i.b) (gte i.t.b 64) (lte i.t.b 127))
|
||||
:: 127.0.0.0/8 (localhost)
|
||||
::
|
||||
=(127 i.b)
|
||||
:: 169.254.0.0/16 (link-local)
|
||||
::
|
||||
&(=(169 i.b) =(254 i.t.b))
|
||||
:: 172.16.0.0/12 (private)
|
||||
::
|
||||
&(=(172 i.b) (gte i.t.b 16) (lte i.t.b 31))
|
||||
:: 192.0.0.0/24 (protocol assignment)
|
||||
::
|
||||
&(=(192 i.b) =(0 i.t.b) =(0 i.t.t.b))
|
||||
:: 192.0.2.0/24 (documentation)
|
||||
::
|
||||
&(=(192 i.b) =(0 i.t.b) =(2 i.t.t.b))
|
||||
:: 192.18.0.0/15 (reserved, benchmark)
|
||||
::
|
||||
&(=(192 i.b) |(=(18 i.t.b) =(19 i.t.b)))
|
||||
:: 192.51.100.0/24 (documentation)
|
||||
::
|
||||
&(=(192 i.b) =(51 i.t.b) =(100 i.t.t.b))
|
||||
:: 192.88.99.0/24 (reserved, ex-anycast)
|
||||
::
|
||||
&(=(192 i.b) =(88 i.t.b) =(99 i.t.t.b))
|
||||
:: 192.168.0.0/16 (private)
|
||||
::
|
||||
&(=(192 i.b) =(168 i.t.b))
|
||||
:: 203.0.113/24 (documentation)
|
||||
::
|
||||
&(=(203 i.b) =(0 i.t.b) =(113 i.t.t.b))
|
||||
:: 224.0.0.0/8 (multicast)
|
||||
:: 240.0.0.0/4 (reserved, future)
|
||||
:: 255.255.255.255/32 (broadcast)
|
||||
::
|
||||
(gte i.b 224)
|
||||
==
|
||||
--
|
||||
::
|
||||
:: service providers
|
||||
@ -520,7 +469,7 @@
|
||||
^+ this
|
||||
?> ?=(^ rel)
|
||||
?> ?=(%direct -.tar.u.rel)
|
||||
?: (reserved p.tar.u.rel)
|
||||
?: (reserved:eyre p.tar.u.rel)
|
||||
(fail %reserved-ip)
|
||||
?: (gth try.u.rel 2)
|
||||
(fail %unreachable)
|
||||
|
@ -16,7 +16,10 @@
|
||||
%+ prompt
|
||||
[%& %dns-address "ipv4 address: "]
|
||||
%+ parse
|
||||
`$-(nail (like @if))`;~(pfix dot lip:ag)
|
||||
`$-(nail (like @if))`;~(pfix ;~(pose dot (easy ~)) lip:ag)
|
||||
|= addr=@if
|
||||
?: (reserved:eyre addr)
|
||||
=/ msg "unable to bind reserved ipv4 address {(scow %if addr)}"
|
||||
(print leaf+msg no-product)
|
||||
%- produce
|
||||
[%dns-command %ip %if addr]
|
||||
|
@ -1164,6 +1164,57 @@
|
||||
$% {%& p/purl} :: absolute
|
||||
{%| p/pork q/quay} :: relative
|
||||
== ::
|
||||
:: +reserved: check if an ipv4 address is in a reserved range
|
||||
::
|
||||
++ reserved
|
||||
|= a=@if
|
||||
^- ?
|
||||
=/ b (flop (rip 3 a))
|
||||
:: 0.0.0.0/8 (software)
|
||||
::
|
||||
?. ?=([@ @ @ @ ~] b) &
|
||||
?| :: 10.0.0.0/8 (private)
|
||||
::
|
||||
=(10 i.b)
|
||||
:: 100.64.0.0/10 (carrier-grade NAT)
|
||||
::
|
||||
&(=(100 i.b) (gte i.t.b 64) (lte i.t.b 127))
|
||||
:: 127.0.0.0/8 (localhost)
|
||||
::
|
||||
=(127 i.b)
|
||||
:: 169.254.0.0/16 (link-local)
|
||||
::
|
||||
&(=(169 i.b) =(254 i.t.b))
|
||||
:: 172.16.0.0/12 (private)
|
||||
::
|
||||
&(=(172 i.b) (gte i.t.b 16) (lte i.t.b 31))
|
||||
:: 192.0.0.0/24 (protocol assignment)
|
||||
::
|
||||
&(=(192 i.b) =(0 i.t.b) =(0 i.t.t.b))
|
||||
:: 192.0.2.0/24 (documentation)
|
||||
::
|
||||
&(=(192 i.b) =(0 i.t.b) =(2 i.t.t.b))
|
||||
:: 192.18.0.0/15 (reserved, benchmark)
|
||||
::
|
||||
&(=(192 i.b) |(=(18 i.t.b) =(19 i.t.b)))
|
||||
:: 192.51.100.0/24 (documentation)
|
||||
::
|
||||
&(=(192 i.b) =(51 i.t.b) =(100 i.t.t.b))
|
||||
:: 192.88.99.0/24 (reserved, ex-anycast)
|
||||
::
|
||||
&(=(192 i.b) =(88 i.t.b) =(99 i.t.t.b))
|
||||
:: 192.168.0.0/16 (private)
|
||||
::
|
||||
&(=(192 i.b) =(168 i.t.b))
|
||||
:: 203.0.113/24 (documentation)
|
||||
::
|
||||
&(=(203 i.b) =(0 i.t.b) =(113 i.t.t.b))
|
||||
:: 224.0.0.0/8 (multicast)
|
||||
:: 240.0.0.0/4 (reserved, future)
|
||||
:: 255.255.255.255/32 (broadcast)
|
||||
::
|
||||
(gte i.b 224)
|
||||
==
|
||||
++ rout {p/(list host) q/path r/oryx s/path} :: http route (new)
|
||||
++ sec-move :: driver effect
|
||||
$% {$send p/hiss} :: http out
|
||||
|
Loading…
Reference in New Issue
Block a user