Merge branch 'release-candidate' into keygen-changes

This commit is contained in:
Fang 2018-11-14 16:20:04 -08:00 committed by GitHub
commit 35fe55c701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 25162 additions and 7591 deletions

View File

@ -30,6 +30,10 @@ before_script:
- bash get-or-build-pill.sh
# https://github.com/travis-ci/travis-ci/issues/2570
script:
- ulimit -c unlimited -S
- npm run -s test; bash print-core-backtrace.sh $?
before_deploy: "[ -d piers ] || { mkdir piers && tar cvzSf piers/zod-$TRAVIS_COMMIT.tgz zod/; }"
addons:
@ -50,6 +54,7 @@ addons:
- re2c
- libcurl4-gnutls-dev
- unzip
- gdb
deploy:
- skip_cleanup: true

View File

@ -2,6 +2,9 @@
set -euo pipefail
set -x
# add urbit-runner to $PATH
PATH=./node_modules/.bin/:$PATH
# XX use -s instead of hash pill
HASH=$(git -C .. log -1 HEAD --format=%H -- sys/)
export PILL_NAME="git-${HASH:0:10}"
@ -26,7 +29,7 @@ mkdir prev
: Pilling: trying pinned fakezod
wget -i pin-parent-pill-pier.url -O - | tar xvz -C prev/ &&
: Downloaded prev/zod &&
lsc ./in-urbit.ls -S prev/zod <<' .'
urbit-runner -S prev/zod <<' .'
|autoload |
|mount %
.
@ -37,7 +40,7 @@ mkdir prev
PILL_NAME2="git-${HASH2:0:10}"
wget https://bootstrap.urbit.org/$PILL_NAME2.pill -O prev/urbit.pill &&
([ -d prev/zod ] && rm -r prev/zod || true) &&
lsc ./in-urbit.ls -A .. -B prev/urbit.pill -cSF zod prev/zod <<' .'
urbit-runner -A .. -B prev/urbit.pill -cSF zod prev/zod <<' .'
%booted-prev-zod
.
} || {
@ -46,7 +49,7 @@ mkdir prev
}
: Pier created, soliding actual pill
lsc ./in-urbit.ls -S prev/zod <<.
urbit-runner -S prev/zod <<.
|label %home %$PILL_NAME
.urbit/pill +solid /==/$PILL_NAME/sys, =dub &
.

View File

@ -1,15 +0,0 @@
require! <[ split ]>
{through} = require 'promise-streams'
{Urbit,ERROR} = require './runner.ls'
urbit = new Urbit process.argv[3 to]
urbit.expect ERROR .then -> process.exit 1
<- urbit.expect /dojo> / .then
process.stdin.pipe split!
.pipe through ->
urbit.line it.trim!replace /\$[a-zA-Z0-9_]+/g ->
process.env[it.slice 1] ? '__unknown-var__'
.wait!then -> urbit.exit 0

1438
.travis/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,22 +2,13 @@
"name": "arvo-tests",
"version": "1.0.0",
"description": "Test harness for Urbit arvo distribution",
"main": "test.ls",
"scripts": {
"test": "lsc test.ls"
"test": "node test.js"
},
"private": true,
"author": "~fyr",
"license": "MIT",
"dependencies": {
"colors": "^1.1.2",
"escape-string-regexp": "^1.0.5",
"livescript": "^1.5.0",
"once": "^1.4.0",
"promise-streams": "^2.1.1",
"pty.js": "^0.3.1",
"recursive-copy": "^2.0.7",
"split": "^1.0.1",
"stream-snitch": "0.0.3",
"wait-on": "^2.0.2"
"urbit-runner": "github:urbit/runner-js#ee24550"
}
}

View File

@ -1 +1 @@
32bbb0214068ef606d0fa2f8f4a7b3b14637e929
bd78ea68d9250af46f1fe4d9e2e51477edba438f

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
set -x
RESULT=$1
if [[ ${RESULT} -eq 0 ]]; then
exit 0
else
for i in $(find ./ -maxdepth 1 -name 'core*' -print)
do
gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch
done
fi
echo "build failed with status code $RESULT"
exit $RESULT

View File

@ -1,64 +0,0 @@
require! <[ stream stream-snitch colors escape-string-regexp ]>
pty = require \pty.js
export ERROR = /((ford|warn): |\r\x1b\[K\/~)/
export class Urbit
(args)->
@stdout = process.stdout # overridable
@pty = pty.spawn \urbit args
@pty.on \data ~> @stdout.write it # TODO pipe?
console.log "FIXME Running Ubuntu 14.04, which causes a libtinfo version info warning. Should update to 16.04."
console.log "starting vere with the following arguments:"
console.log args
#
@last-output = Date.now()
@pty.on \data ~> @last-output = Date.now()
#
@reset-listeners!
process.on \exit ~> @pty.write '\04' # send EOF to gracefully checkpoint
@pty.on \exit (code,signal)~>
| code => process.exit code
| signal => process.exit 128 + signal # repack exit code
| _ => #TODO report if unexpected?
#
note: (...args)-> console.log "\n#{'_'*40}\nnode:".blue, ...args
warn: (...args)-> console.log "\n#{'!'*40}\nnode:".red, ...args
wait-silent: ~> # this feels hacky
new Promise (resolve)~>
a = set-interval ~>
if Date.now! > @last-output + 1000
clear-interval a
resolve @last-output
, 200
#
reset-listeners: ~>
@pty.socket.unpipe @listeners
@pty.socket.pipe (@listeners = new stream.PassThrough)
@
every: (re, cb)~>
@listeners.pipe (new stream-snitch re).on "match" cb
expect: (re)~>
new Promise (resolve)~>
@listeners.pipe (new stream-snitch re).once "match" resolve
expect-immediate: (re)->
Promise.race [
@expect re
@wait-silent!then -> throw Error "Expected #re during event"
]
#
line: (s)->
@pty.write s
<~ @wait-silent!then
@stdout.write "\n"
@pty.write "\r"
#
expect-echo: (s)-> #ALT send-and-expect
<~ @line s .then
@expect new RegExp escape-string-regexp s
#
exit: (code)->
@pty.on \exit -> process.exit code #REVIEW just return promise?
# @pty.write "\03" # ^C running event
@pty.write "\05\25" # ^E^U to clear prompt
@pty.write "\04" # ^D to checkpoint
# set-timeout # hard exit

25
.travis/test.js Normal file
View File

@ -0,0 +1,25 @@
'use strict';
var runner = require('urbit-runner')
var Urbit = runner.Urbit;
var ERROR = runner.ERROR;
var actions = runner.actions
var args = ['-B', 'urbit.pill', '-A', '..', '-cSF', 'zod', 'zod'];
var urbit = new Urbit(args);
Promise.resolve(urbit)
.then(actions.safeBoot)
.then(actions.test)
.then(actions.testCores)
.then(actions.testRenderers)
.then(function(){
return urbit.exit(0);
})
.catch(function(err){
return urbit.waitSilent()
.then(function(){
urbit.warn("Test aborted:", err);
return urbit.exit(1);
});
});

View File

@ -1,62 +0,0 @@
{Urbit,ERROR} = require './runner.ls'
urbit = new Urbit <[-B urbit.pill -A .. -cSF zod zod]>
Promise.resolve urbit
.then (urb)->
urb.note "Booting urbit"
Promise.race [
urb.expect ERROR .then ->
urb.warn "Boot error detected"
throw Error "Stack trace while booting"
, do
<- urb.expect /dojo> / .then
<- urb.expect-echo "%dojo-booted" .then
urb.reset-listeners!
]
.then (urb)->
urb.note "Running /===/tests"
errs = "" #REVIEW stream reduce?
urb.every /(\/[ -~]* (FAILED|CRASHED))/, ([_,result])->
if !errs => urb.warn "First error"
errs += "\n #result"
<- urb.line "+test, =defer |, =seed `@uvI`(shaz %reproducible)" .then
<- urb.expect-echo "%ran-tests" .then
if errs => throw Error errs
urb.reset-listeners!
.then (urb)->
urb.note "Testing compilation"
errs = {} #REVIEW stream reduce?
cur = "init"
urb.every />> (\/[ -~]+)/ ([_,path])-> cur := path
urb.every ERROR, ->
unless errs[cur]
errs[cur] = true
urb.warn "Compile error detected"
#
<- urb.line "|start %test" .then
<- urb.line ":test [%cores /]" .then
<- urb.expect-echo "%compilation-tested" .then
errs := Object.keys errs
if errs.length => throw Error "in #errs"
urb.reset-listeners!
.then (urb)->
urb.note "Testing renderers"
errs = {} #REVIEW stream reduce?
cur = "init"
urb.every />> (\[[ -~]+)/ ([_,ren])-> cur := ren
urb.every ERROR, ->
unless errs[cur]
errs[cur] = true
urb.warn "Renderer error detected"
#
<- urb.line ":test [%renders /]" .then
<- urb.expect-echo "%renderers-tested" .then
errs := Object.keys errs
if errs.length => throw Error "in #errs"
urb.reset-listeners!
.then ->
urbit.exit 0
.catch (err)->
<- urbit.wait-silent!then # assumptions?
urbit.warn "Test aborted:" err
urbit.exit 1

File diff suppressed because it is too large Load Diff

View File

@ -24,26 +24,13 @@
=, collections
=, space:userlib
::
|%
+= move [bone card]
+= card
$% [%info wire ship toro:clay]
[%poke wire dock poke]
[%perm wire ship desk path rite:clay]
==
+= poke
$% [%hall-action action:hall]
[%collections-action action:collections]
[%json json]
==
--
::
:: state:
::
:: stores the collection built by above by :cols so that we can compare old
:: and new versions whenever the rendered data changes
::
|_ [bol=bowl:gall state=collection]
~% %collections ..^is ~
|_ [bol=bowl:gall sta=state]
::
:: +this: app core subject
::
@ -57,24 +44,27 @@
:: then update state to store the new collection data
::
++ prep
|= old=(unit *)
~/ %coll-prep
|= old=(unit state)
^- (quip move _this)
?~ old
:_ this
=< ta-done
(ta-hall-create-circle:ta /c 'collections')
=/ old-col ((soft collection) u.old)
?~ old-col
[~ this(state cols)]
=^ mow this
=< ta-done
(ta-update:ta u.old-col)
[mow this(state cols)]
(~(ta-hall-create-circle ta ~ bol) /c 'collections')
?- -.u.old
%0
=/ mow=(list move)
=< ta-done
(~(ta-update ta ~ bol) col.u.old cols)
[mow this(sta [%0 cols])]
==
::
:: +mack:
::
:: recieve acknowledgement for permissions changes, print error if it failed
::
++ mack
~/ %coll-mack
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
@ -84,126 +74,25 @@
:: +coup: recieve acknowledgement for poke, print error if it failed
::
++ coup
~/ %coll-coup
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
(mean u.err)
::
:: +path-to-circle:
::
:: takes a clay path and returns a hall circle
:: for a path /foo/bar it returns a circle with a :name %c-foo-bar
::
++ path-to-circle
|= pax=path
^- circle:hall
=. pax
?: ?=([%web %collections *] pax)
(weld /c (slag 2 `path`pax))
?: ?=([%collections *] pax)
(weld /c (slag 1 `path`pax))
?: ?=([%c *] pax)
`path`pax
`path`(weld /c pax)
=/ nam=term
%+ roll `(list @ta)`pax
|= [seg=@ta out=term]
%^ cat 3
?:(=(%$ out) out (cat 3 out '-'))
((hard @tas) seg)
[our.bol nam]
::
:: +allowed-by: checks if ship :who is allowed by the permission rules in :dic
::
++ allowed-by
|= [who=@p dic=dict:clay]
^- ?
?: =(who our.bol) &
=/ in-list=?
?| (~(has in p.who.rul.dic) who)
::
%- ~(rep by q.who.rul.dic)
|= [[@ta cru=crew:clay] out=_|]
?: out &
(~(has in cru) who)
==
?: =(%black mod.rul.dic)
!in-list
in-list
::
:: +collection-notify: XX
::
++ collection-notify
|= [pax=path conf=config]
^- json
%- pairs:enjs:format
:~ ['owner' [%s (crip (scow %p owner.conf))]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s name.conf]]
['date' [%s (crip (scow %da last-modified.conf))]]
['type' [%s type.conf]]
==
::
:: +item-notify: XX
::
++ item-notify
|= [pax=path raw=raw-item]
^- json
=/ owner (fall (~(get by meta.raw) %owner) ~.anon)
=/ dat (fall (~(get by meta.raw) %last-modified) (scot %da now.bol))
=/ nom (fall (~(get by meta.raw) %name) ~.no-title)
=/ typ (fall (~(get by meta.raw) %type) ~.no-type)
%- pairs:enjs:format
:~ ['owner' [%s owner]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s nom]]
['date' [%s dat]]
['type' [%s typ]]
['content' [%s data.raw]]
==
::
:: +front-to-wain: XX
::
++ front-to-wain
|= a=(map knot cord)
^- wain
=/ entries=wain
%+ turn ~(tap by a)
|= b=[knot cord]
=/ c=[term cord] ((hard ,[term cord]) b)
(crip " [{<-.c>} {<+.c>}]")
::
?~ entries ~
;: weld
[':- :~' ~]
entries
[' ==' ~]
==
::
:: +update-umd-front: XX
::
++ update-umd-front
|= [fro=(map knot cord) umd=@t]
^- @t
%- of-wain:format
=/ tum (trip umd)
=/ id (find ";>" tum)
?~ id
%+ weld (front-to-wain fro)
(to-wain:format (crip (weld ";>\0a" tum)))
%+ weld (front-to-wain fro)
(to-wain:format (crip (slag u.id tum)))
::
:: +poke-collections-action:
::
:: the main interface for creating and deleting collections and items
::
++ poke-collections-action
|= act=action:collections
~/ %coll-poke-collections-action
|= act=action
^- (quip move _this)
?: =(who.act our.bol)
ta-done:(ta-act:ta act)
:_ this
=< ta-done
(~(ta-act ta ~ bol) act)
:: forward poke if its not meant for us
::
:_ this
@ -214,517 +103,17 @@
%collections-action act
==
::
:: +poke-noun
:: +poke-json
::
:: utility for setting whether or not to display the onboarding page
::
++ poke-noun
|= onb=?
++ poke-json
~/ %coll-poke-json
|= jon=json
^- (quip move _this)
=< ta-done
(ta-write:ta /web/landscape/onboard/atom [%atom !>(onb)])
::
:: +ta: main event core for collections
::
++ ta
|_ moves=(list move)
::
:: +ta-this: ta core subject
::
++ ta-this .
::
:: +ta-done:
::
:: flop :moves for finalization, since moves are prepended to the list
::
++ ta-done [(flop moves) this]
::
:: +ta-emit: add a +move to :moves
::
++ ta-emit
|= mov=move
%_ ta-this
moves [mov moves]
==
::
:: +ta-emil: add a list of +move to :moves
::
++ ta-emil
|= mos=(list move)
%_ ta-this
moves (welp (flop mos) moves)
==
::
:: +ta-act: process collection-action
::
++ ta-act
|= act=action:collections
^+ ta-this
::
:: iterate through list of +sub-action of +action
::
|-
?~ acts.act ta-this
=* a i.acts.act
::
=/ sap (en-beam:format [byk.bol (flop (path +<.a))])
=/ now-id=@da (sub now.bol (div (dis now.bol ~s0..fffe) 2))
=/ dat (scot %da now-id)
::
=. ta-this
?- -.a
%write
=/ perms .^([dict:clay dict:clay] %cp sap)
?: (allowed-by src.bol +.perms)
?- -.for.a
%umd (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
%collections-config (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
==
ta-this
::
%delete
=/ perms .^([dict:clay dict:clay] %cp sap)
?: (allowed-by src.bol +.perms)
(ta-remove pax.a)
ta-this
::
%perms
?: =(src.bol our.bol) :: XX admin privileges for other users?
(ta-set-permissions pax.a r.a w.a)
ta-this
::
::
:: XX some of this is redunant
::
%collection
=/ perms
.^([dict:clay dict:clay] %cp (weld sap /[dat]/collections-config))
?. (allowed-by src.bol +.perms)
ta-this
=/ conf=config
:* [byk.bol (flop (weld pax.a /[dat]/collections-config))]
name.a
desc.a
our.bol
now-id
now-id
type.a
comments.a
~
visible.a
==
=. ta-this
%+ ta-write (weld pax.a /[dat]/collections-config)
[%collections-config !>(conf)]
:: restrict permissions on config file
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat]/collections-config)
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
:: open permissions on collection items
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat])
[%black ((set whom:clay) ~)] :: read
[%black ((set whom:clay) ~)] :: write
ta-this
::
%post
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/umd))
?. (allowed-by src.bol +.perms)
ta-this
=. content.a (crip (weld (trip content.a) "\0a"))
=/ front=(map knot cord)
%- my
:~ [%name name.a]
[%comments ?:(comments.a ~..y ~..n)]
[%owner (scot %p src.bol)]
[%date-created dat]
[%last-modified dat]
[%type type.a]
==
=. ta-this
%+ ta-write (weld pax.a /[dat]/umd)
[%umd !>((update-umd-front front content.a))]
:: restrict permissions on umd file
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat]/umd)
[%black ((set whom:clay) ~)] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
:: open permissions on comments
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat])
[%black ((set whom:clay) ~)] :: read
[%black ((set whom:clay) ~)] :: write
ta-this
::
%comment
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/umd))
?. (allowed-by src.bol +.perms)
ta-this
=. content.a (crip (weld (trip content.a) "\0a"))
=/ front=(map knot cord)
%- my
:~ [%owner (scot %p src.bol)]
[%date-created dat]
[%last-modified dat]
[%type %comments]
==
=. ta-this
%+ ta-write (weld pax.a /[dat]/umd)
[%umd !>((update-umd-front front content.a))]
:: restrict permissions on umd file
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat]/umd)
[%black ((set whom:clay) ~)] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
ta-this
::
==
$(acts.act t.acts.act)
::
:: +ta-update:
::
::
::
++ ta-update
|= old=collection
^+ ta-this
?: =(old cols)
ta-this
(ta-update-collection old cols /web/collections)
::
++ ta-insert-item
|= [new=item pax=path]
^+ ta-this
=/ parent-path (scag (dec (lent pax)) pax)
::
?- -.new
::
%collection
=. ta-this
%^ ta-hall-json parent-path 'new collection'
(collection-notify pax meta.col.new)
::
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
=. ta-this
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
ta-this
::
%raw
=. ta-this
(ta-hall-json parent-path 'new item' (item-notify pax raw.new))
?: ?& (~(has by meta.raw.new) %comments)
=('.y' (~(got by meta.raw.new) %comments))
==
(ta-generate-comments pax)
ta-this
::
==
::
++ ta-remove-item
|= [old=item pax=path]
^+ ta-this
:: flush permissions
:: notify parent of deletion
=/ parent (scag (dec (lent pax)) pax)
:: recurse for children
?- -.old
::
%collection
=. ta-this
%^ ta-hall-json parent 'deleted collection'
(collection-notify pax meta.col.old)
=. ta-this (ta-flush-permissions (weld pax /collections-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this (ta-flush-permissions pax)
=. ta-this (ta-flush-permissions (weld pax /collections-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%raw
=. ta-this (ta-flush-permissions pax)
(ta-hall-json parent 'deleted item' (item-notify pax raw.old))
::
==
::
::
::
++ ta-update-item
:: always make sure removals happen first and insertions happen last
:: because removals flush permissions and insertions set them
::
|= [old=item new=item pax=path]
^+ ta-this
?: =(old new)
ta-this
::
:: check for changes in item type
?: &(?=(%collection -.old) ?=(%collection -.new))
(ta-update-collection col.old col.new pax)
?: &(?=(%raw -.old) ?=(%raw -.new))
(ta-update-raw-item raw.old raw.new pax)
?: &(?=(%both -.old) ?=(%both -.new))
:: update raw item
=. ta-this (ta-update-collection col.old col.new pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%collection -.old) ?=(%raw -.new))
:: remove collection
:: insert raw item
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%collection -.old) ?=(%both -.new))
:: insert raw item
:: update-collection
=. ta-this (ta-update-collection col.old col.new pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%collection -.new))
:: remove raw item
:: insert collection
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%both -.new))
:: insert collection
:: update raw item
=. ta-this (ta-update-raw-item raw.old raw.new pax)
(ta-insert-item new pax)
::
?: &(?=(%both -.old) ?=(%raw -.new))
:: remove collection
:: update raw item
=. ta-this (ta-remove-item [%collection col.old] pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%both -.old) ?=(%collection -.new))
:: remove raw item
:: update collection
=. ta-this (ta-remove-item [%raw raw.old] pax)
(ta-update-collection col.old col.new pax)
::
ta-this
::
++ ta-update-raw-item
|= [old=raw-item new=raw-item pax=path]
^+ ta-this
?: =(old new)
ta-this
::
=? ta-this !=(data.old data.new)
=/ parent-path (scag (dec (lent pax)) pax)
(ta-hall-json parent-path 'edited item' (item-notify pax new)) :: XX fil
::
=? ta-this
?& =('.y' (fall (~(get by meta.new) %comments) '.n'))
=('.n' (fall (~(get by meta.old) %comments) '.n'))
==
:: create comments
(ta-generate-comments pax)
::
=? ta-this
?& =('.n' (fall (~(get by meta.new) %comments) '.n'))
=('.y' (fall (~(get by meta.old) %comments) '.n'))
==
:: delete comments
(ta-remove (weld pax /collections-config))
::
:: check if file has been modified
:: and if so update last modified field
=/ told (trip data.old)
=/ newt (trip data.new)
=/ old-con (slag (need (find ";>" told)) told)
=/ new-con (slag (need (find ";>" newt)) newt)
=? ta-this !=(old-con new-con)
=/ contents=@t
%+ update-umd-front
(~(put by meta.new) %last-modified (scot %da now.bol))
data.new
(ta-write (weld pax /umd) %umd !>(contents))
::
ta-this
::
++ ta-update-collection
|= $: old=collection
new=collection
pax=path
==
^+ ta-this
::
=? ta-this !=(meta.old meta.new)
=/ parent-path (scag (dec (lent pax)) pax)
%^ ta-hall-json parent-path 'edited collection'
(collection-notify pax meta.new)
::
?: =(data.old data.new)
ta-this
::
:: new values of all changed items
=/ upd-new (~(dif in (~(int by data.old) data.new)) data.old)
:: old values of all changed items
=/ upd-old (~(dif in (~(int by data.new) data.old)) data.new)
:: all totally new entries
=/ ins-new (~(dif by data.new) data.old)
:: all deleted entries
=/ del-old (~(dif by data.old) data.new)
::
=/ upd-new=(list [nom=knot =item]) ~(tap by upd-new)
=/ upd-old=(list [nom=knot =item]) ~(tap by upd-old)
=/ ins-new=(list [nom=knot =item]) ~(tap by ins-new)
=/ del-old=(list [nom=knot =item]) ~(tap by del-old)
::
=/ lam |=([[a=knot item] out=(list path)] [(weld pax [a ~]) out])
::
=. ta-this |-
?~ upd-new
ta-this
?< ?=(~ upd-old)
=* new-item i.upd-new
=* old-item i.upd-old
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-update-item item.old-item item.new-item new-pax)
::
%= $
upd-new t.upd-new
upd-old t.upd-old
==
::
=. ta-this |-
?~ ins-new
ta-this
=* new-item i.ins-new
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-insert-item +.new-item (weld pax [-.new-item ~]))
$(ins-new t.ins-new)
::
=. ta-this |-
?~ del-old
ta-this
=* old-item i.del-old
=/ old-pax (weld pax [nom.old-item ~])
=. ta-this (ta-remove-item +.old-item (weld pax [-.old-item ~]))
$(del-old t.del-old)
::
ta-this
::
++ ta-generate-comments
|= pax=path
^+ ta-this
=/ sup=path [%collections-config (flop pax)]
=/ pat (en-beam:format [byk.bol sup])
=/ dat=@da (slav %da (snag 0 (flop pax)))
=/ cay=config
:* [byk.bol sup]
'comments'
'comments'
our.bol
dat
dat
%comments
|
~
|
==
(ta-write (flop sup) %collections-config !>(cay))
::
:: writing files
::
++ ta-write
|= [pax=path cay=cage]
^+ ta-this
=. pax (en-beam:format byk.bol (flop pax))
%+ ta-emit ost.bol
[%info (weld /ta-write pax) our.bol (foal pax cay)]
::
++ ta-remove
|= pax=path
=. pax (en-beam:format byk.bol (flop pax))
^+ ta-this
%+ ta-emit ost.bol
[%info (weld /ta-remove pax) our.bol (fray pax)]
::
:: permissions
::
++ ta-set-permissions
|= [pax=path r=rule:clay w=rule:clay]
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw `r `w]]
::
++ ta-flush-permissions
|= pax=path
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw ~ ~]]
::
:: hall
::
++ ta-hall-action
|= act=action:hall
^+ ta-this
%+ ta-emit ost.bol
[%poke /col-hall-action [our.bol %hall] %hall-action act]
::
++ ta-hall-actions
|= act=(list $?(~ action:hall))
^+ ta-this
?~ act ta-this
?~ i.act $(act t.act)
%= $
ta-this (ta-hall-action i.act)
act t.act
==
::
++ ta-hall-create-circle ::
|= [pax=path description=@t]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
=/ parent=circle:hall
?: =(nom.circ %c)
[our.bol %inbox]
(path-to-circle (scag (dec (lent pax)) pax))
%- ta-hall-actions
:~ [%create nom.circ description %journal]
[%source nom.parent & (sy `source:hall`[circ ~] ~)]
==
::
++ ta-hall-lin
|= [pax=path msg=cord]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
%- ta-hall-action
[%phrase [circ ~ ~] [%lin | msg]~]
::
++ ta-hall-json
|= [pax=path header=@t jon=json]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax)
%- ta-hall-action
:+ %phrase [circ ~ ~]
[%fat [%text ~[header]] [%lin | (crip (en-json:html jon))]]~
::
--
?: ?=([%o [[%onboard %b ?] ~ ~]] jon)
:_ this
=< ta-done
(~(ta-write ta ~ bol) /web/landscape/onboard/json [%json !>(jon)])
[~ this]
--

View File

@ -1,28 +1,26 @@
/- dns
=, dns
/- *dns
!:
::
:: moves and state
:: moves and state
::
|%
+= move (pair bone card)
+= poke
$% [%dns-bind for=ship him=ship target]
[%dns-bond for=ship him=ship turf]
[%dns-authority authority]
:: XX some other notification channel?
=> |%
+$ move (pair bone card)
+$ poke
$% [%dns-command command]
:: XX find some other notification channel?
::
[%helm-send-hi ship (unit tape)]
==
+= card
$% [%tend wire ~]
[%wait wire @da]
+$ card
$% [%flog wire flog:dill]
[%hiss wire [~ ~] %httr %hiss hiss:eyre]
[%poke wire dock poke]
[%rule wire %turf %put turf]
[%hiss wire [~ ~] %httr %hiss hiss:eyre]
[%wait wire @da]
==
:: +state: complete app state
:: +state: complete app state
::
+= state
+$ state
$: :: dom: the set of our bindings
::
dom=(set turf)
@ -33,7 +31,12 @@
::
nem=(unit nameserver)
==
:: +join: dedup with :acme
--
::
:: helpers
::
=> |%
:: +join: dedup with lib/pkcs (reversed)
::
++ join
|= [sep=@t hot=(list @t)]
@ -43,69 +46,23 @@
|- ^- (list @t)
?~ t.hot hot
[i.hot sep $(hot t.hot)]
:: +name: fully-qualified domain name
:: +name: fully-qualified domain name
::
++ name
|= [him=ship dom=turf]
(cat 3 (join '.' [(crip +:(scow %p him)) (flop dom)]) '.')
:: +endpoint: append path to purl
:: +endpoint: append path to purl
::
++ endpoint
|= [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)
==
:: |gcloud: provider-specific functions
:: service providers
::
=> |%
:: |gcloud: provider-specific functions
::
++ gcloud
|_ aut=authority
@ -113,12 +70,12 @@
::
++ base
(need (de-purl:html 'https://www.googleapis.com/dns/v1/projects'))
:: +record: JSON-formatted provider-specific dns record
:: +record: JSON-formatted provider-specific dns record
::
++ record
|= [him=ship tar=target]
^- json
:: ?> ?=([%gcloud *] pro.aut)
:: ?> ?=([%gcloud *] pro.aut)
=+ ^- [typ=cord dat=cord]
?: ?=(%direct -.tar)
['A' (crip +:(scow %if p.tar))]
@ -130,13 +87,13 @@
ttl+n+~.300
rrdatas+a+[s+dat ~]
==
:: +request: provider-specific record-creation request
:: +create: provider-specific record-creation request
::
++ request
++ create
=, eyre
|= [him=ship tar=target pre=(unit target)]
^- hiss
:: ?> ?=([%gcloud *] pro.aut)
:: ?> ?=([%gcloud *] pro.aut)
=/ url=purl
%+ endpoint base
/[project.pro.aut]/['managedZones']/[zone.pro.aut]/changes
@ -150,65 +107,203 @@
?~ pre ~
[deletions+a+[(record him u.pre) ~] ~]
[url %post hed `bod]
:: +list: list existing records stored by provider
::
++ list
=, eyre
|= page=(unit @t)
^- hiss
:: ?> ?=([%gcloud *] pro.aut)
=/ url=purl
%+ endpoint base
/[project.pro.aut]/['managedZones']/[zone.pro.aut]/rrsets
=/ hed=math
?~ page ~
(~(put by *math) 'pageToken' [u.page]~)
[url %get hed ~]
:: +parse existing records stored by provider
::
++ parse
=< |= bod=octs
=/ jon (de-json:html q.bod)
?~ jon [~ ~]
(response u.jon)
::
=, dejs:format
|%
++ response
^- $- json
(pair (list (pair ship target)) (unit @t))
%- ou :~
:: 'kind'^(su (jest "dns#resourceRecordSetsListResponse'))
::
'rrsets'^(uf ~ record-set)
'nextPageToken'^(uf ~ (mu so))
==
::
++ record-set
%+ cu
|= a=(list (unit (pair ship target)))
?~ a ~
?: ?| ?=(~ i.a)
?=(%czar (clan:title p.u.i.a))
==
$(a t.a)
[u.i.a $(a t.a)]
(ar record)
::
++ record
%+ cu
|= [typ=@t nam=@t dat=(list @t)]
^- (unit (pair ship target))
=/ him (name nam)
?: ?| ?=(~ him)
?=(~ dat)
?=(^ t.dat)
==
~
?+ typ
~
::
%'A'
=/ adr (rush i.dat lip:ag)
?~ adr ~
`[u.him %direct %if u.adr]
::
%'CNAME'
=/ for (name i.dat)
?~ for ~
`[u.him %indirect u.for]
==
::
%- ot :~
:: 'kind'^(su (jest "dns#resourceRecordSet'))
::
'type'^so
'name'^so
'rrdatas'^(ar so)
==
::
++ name
|= nam=@t
^- (unit ship)
=/ dom=(unit host:eyre)
(rush nam ;~(sfix thos:de-purl:html dot))
?: ?| ?=(~ dom)
?=(%| -.u.dom)
?=(~ p.u.dom)
==
~
=/ who
(rush (head (flop p.u.dom)) fed:ag)
?~ who ~
?. =(dom.aut (flop (tail (flop p.u.dom))))
~
`u.who
--
--
--
::
:: the app itself
::
|_ [bow=bowl:gall state]
:: +this: is sparta
::
++ this .
:: +poke-noun: debugging
:: +request: generic http request
::
++ request
|= [wir=wire req=hiss:eyre]
^- card
[%hiss wir [~ ~] %httr %hiss req]
:: +poke-noun: debugging
::
++ poke-noun
|= a=*
^- (quip move _this)
~& +<+:this
[~ this]
:: +sigh-httr: accept http response
:: +sigh-httr: accept http response
::
++ sigh-httr
|= [wir=wire rep=httr:eyre]
^- (quip move _this)
?- wir
[%authority %confirm ~]
?~ nem
~& [%strange-authority wire=wir response=rep]
[~ this]
?. =(200 p.rep)
~& [%authority-confirm-fail rep]
[~ this(nem ~)]
:: XX anything to do here? parse body?
:: at least two segments in every wire
::
?. ?=([@ @ *] wir)
~& [%strange-http-response wire=wir response=rep]
[~ this]
?+ i.wir
:: print and ignore unrecognized responses
::
~& [%strange-http-response wire=wir response=rep]
[~ this]
:: responses for a nameserver
::
[%authority %create @ %for @ ~]
%authority
?~ nem
~& [%strange-authority wire=wir response=rep]
[~ this]
?. =(200 p.rep)
~& [%authority-create-fail wire=wir response=rep]
[~ this]
=/ him=ship (slav %p i.t.t.wir)
=/ for=ship (slav %p i.t.t.t.t.wir)
abet:(~(confirm bind u.nem) for him)
?+ i.t.wir
!!
:: response confirming a valid nameserver config
::
%confirm
?. =(200 p.rep)
~& [%authority-confirm-fail rep]
[~ this(nem ~)]
abet:(~(update bind u.nem) ~)
:: response to a binding creation request
::
%create
?> ?=([@ %for @ ~] t.t.wir)
?. =(200 p.rep)
:: XX set a retry timeout?
::
~& [%authority-create-fail wire=wir response=rep]
[~ this]
=/ him=ship (slav %p i.t.t.wir)
=/ for=ship (slav %p i.t.t.t.t.wir)
abet:(~(confirm bind u.nem) for him)
:: response to an existing-binding retrieval request
::
%update
?. =(200 p.rep)
:: XX retry
::
[~ this]
?~ r.rep
[~ this]
abet:(~(restore bind u.nem) u.r.rep)
==
:: responses for a relay validating a binding target
::
[%check @ ~]
%check
=/ him=ship (slav %p i.t.wir)
?: =(200 p.rep)
abet:~(bind tell [him (~(get by per) him)])
:: cttp timeout
abet:bind:(tell him)
:: cttp timeout
:: XX backoff, refactor
::
?: =(504 p.rep)
:: XX backoff, refactor
:_ this :_ ~
[ost.bow %wait wir (add now.bow ~m10)]
:: XX specific messages per status code
:: XX specific messages per status code
::
~& %direct-confirm-fail
abet:(~(fail tell [him (~(get by per) him)]) %failed-request)
abet:(fail:(tell him) %failed-request)
:: responses for a relay validating an established binding
::
*
~& +<
[~ this]
%check-bond
=/ him=ship (slav %p i.t.wir)
?: =(200 p.rep)
abet:bake:(tell him)
:: XX backoff, refactor
::
:_ this :_ ~
[ost.bow %wait wir (add now.bow ~m5)]
==
:: +sigh-tang: failed to make http request
:: +sigh-tang: failed to make http request
::
++ sigh-tang
|= [wir=wire saw=tang]
@ -220,123 +315,159 @@
[%authority %confirm ~]
~& %authority-confirm-fail
[((slog saw) ~) this(nem ~)]
::
[%authority %create ~]
~& %authority-create-fail
:: XX retry pending bindings
::
[((slog saw) ~) this]
::
[%authority %update ~]
~& %authority-update-fail
:: XX retry binding retrieval
::
[((slog saw) ~) this]
::
[%check @ ~]
~& %direct-confirm-fail
=/ him=ship (slav %p i.t.wir)
%- (slog saw)
abet:(~(fail tell [him (~(get by per) him)]) %crash)
abet:(fail:(tell him) %crash)
::
[%check-bond @ ~]
~& check-bond-fail+wir
:: XX backoff, refactor
::
:_ this :_ ~
[ost.bow %wait wir (add now.bow ~m10)]
==
:: +wake: timer callback
:: +wake: timer callback
::
++ wake
|= [wir=wire ~]
^- (quip move _this)
?. ?=([%check @ ~] wir)
~& [%strange-wake wir]
[~ this]
=/ him=ship (slav %p i.t.wir)
abet:~(check tell [him (~(get by per) him)])
::
:: +poke-dns-authority: configure self as an authority
::
++ poke-dns-authority
|= aut=authority
^- (quip move _this)
~| %authority-reset-wat-do
?< ?=(^ nem)
abet:(init:bind aut)
:: +poke-dns-bind: create binding (if authority), forward request
::
++ poke-dns-bind
|= [for=ship him=ship tar=target]
^- (quip move _this)
~& [%bind src=src.bow +<.$]
=/ lan (clan:title him)
?: ?=(%czar lan)
~|(%bind-galazy !!)
?: =(for him)
~|(%bind-yoself !!)
?: ?& ?=(%king lan)
?=(%indirect -.tar)
==
~|(%bind-indirect-star !!)
:: always forward, there may be multiple authorities
?+ wir
~& [%strange-wake wir]
[~ this]
::
=^ zom=(list move) ..this
abet:(~(forward tell [him (~(get by per) him)]) for tar)
=^ zam=(list move) ..this
?~ nem [~ this]
abet:(~(create bind u.nem) for him tar)
[(weld zom zam) this]
:: +poke-dns-bond: process established dns binding
[%check @ ~]
=/ him=ship (slav %p i.t.wir)
abet:check:(tell him)
::
[%check-bond @ ~]
=/ him=ship (slav %p i.t.wir)
abet:recheck-bond:(tell him)
==
:: +poke-dns-command: act on command
::
++ poke-dns-bond
|= [for=ship him=ship dom=turf]
++ poke-dns-command
|= com=command
^- (quip move _this)
?: =(for him)
~|(%bond-yoself !!)
?: =(our.bow him)
~& [%bound-us dom]
:- [[ost.bow %rule /bound %turf %put dom] ~]
this(dom (~(put in ^dom) dom))
?: =(our.bow for)
~& [%bound-him him dom]
=< abet
(~(bake tell [him (~(get by per) him)]) dom)
~& [%strange-bond +<]
[~ this]
:: +coup: general poke acknowledgement or error
?- -.com
:: configure self as an authority
::
:: [%authority authority]
::
%authority
~| %authority-reset-wat-do
?< ?=(^ nem)
~! com
abet:(init:bind aut.com)
:: create binding (if authority) and forward request
::
:: [%bind for=ship him=ship target]
::
%bind
=/ rac (clan:title him.com)
?: ?=(%czar rac)
~|(%bind-galazy !!)
?: ?& ?=(%king rac)
?=(%indirect -.tar.com)
==
~|(%bind-indirect-star !!)
:: always forward, there may be multiple authorities
::
=^ zom=(list move) ..this
abet:(forward:(tell him.com) [for tar]:com)
=^ zam=(list move) ..this
?~ nem [~ this]
abet:(~(create bind u.nem) [for him tar]:com)
[(weld zom zam) this]
:: process established dns binding
::
:: [%bond for=ship him=ship turf]
::
%bond
?: ?& =(our.bow for.com)
!=(our.bow src.bow)
==
abet:(check-bond:(tell him.com) dom.com)
::
?: =(our.bow him.com)
=/ msg=tape
"new dns binding established at {(trip (join '.' (flop dom.com)))}"
:_ this(dom (~(put in dom) dom.com))
:~ [ost.bow %flog / %text msg]
[ost.bow %rule /bound %turf %put dom.com]
==
::
~& [%strange-bond com]
[~ this]
:: manually set our ip, request direct binding
::
:: [%ip %if addr=@if]
::
%ip
?. =(our.bow src.bow)
~& %dns-ip-no-foreign
[~ this]
abet:(hear:(tell our.bow) `addr.com)
:: meet sponsee, request indirect binding
::
:: [%meet him=ship]
::
%meet
?. =(our.bow (sein:title our.bow now.bow him.com))
~& %dns-meet-not-sponsored
[~ this]
abet:(hear:(tell him.com) ~)
==
:: +coup: general poke acknowledgement or error
::
++ coup
|= [wir=wire saw=(unit tang)]
?~ saw [~ this]
~& [%coup-fallthru wir]
[((slog u.saw) ~) this]
:: +rove: hear %ames +lane change for child ships
:: +prep: adapt state
::
++ rove
|= [wir=wire p=ship q=lane:ames]
^- (quip move _this)
:: XX move to %ames
?: =(our.bow p)
[~ this]
?. =(our.bow (sein:title our.bow now.bow p))
~& [%rove-false p]
[~ this]
~& [%rove wir p q]
:: XX assert that we intend to be listening?
=< abet
(~(hear tell [p (~(get by per) p)]) q)
:: +prep: adapt state
::
:: ++ prep _[~ this]
:: ++ prep _[~ this]
++ prep
|= old=(unit state)
^- (quip move _this)
?^ old
[~ this(+<+ u.old)]
?: ?=(?(%czar %king) (clan:title our.bow))
abet:listen:tell
:: XX print :dns|ip config instructions for stars?
::
[~ this]
:: |bind: acting as zone authority
:: |bind: acting as zone authority
::
++ bind
=| moz=(list move)
|_ nam=nameserver
++ this .
:: +abet: finalize state changes, produce moves
:: +abet: finalize state changes, produce moves
::
++ abet
^- (quip move _^this)
[(flop moz) ^this(nem `nam)]
:: +emit: emit a move
:: +emit: emit a move
::
++ emit
|= car=card
^+ this
this(moz [[ost.bow car] moz])
:: +init: establish zone authority (request confirmation)
:: +init: establish zone authority (request confirmation)
::
++ init
|= aut=authority
@ -345,17 +476,51 @@
=/ url=purl:eyre
%+ endpoint base:gcloud
/[project.pro.aut]/['managedZones']/[zone.pro.aut]
~& url
%- emit(nam [aut ~ ~])
[%hiss wir [~ ~] %httr %hiss url %get ~ ~]
:: +create: bind :him, on behalf of :for
%- emit(nam [aut ~ ~ ~])
(request wir url %get ~ ~)
:: +update: retrieve existing remote nameserver records
::
++ update
|= page=(unit @t)
^+ this
(emit (request /authority/update (~(list gcloud aut.nam) page)))
:: +restore: restore existing remove nameserver records
::
++ restore
|= bod=octs
=+ ^- [dat=(list (pair ship target)) page=(unit @t)]
(~(parse gcloud aut.nam) bod)
|- ^+ this
?~ dat
?~(page this (update page))
=/ nob=bound [now.bow q.i.dat ~]
$(dat t.dat, bon.nam (~(put by bon.nam) p.i.dat nob))
:: +create: bind :him, on behalf of :for
::
++ create
|= [for=ship him=ship tar=target]
:: XX defer %indirect where target isn't yet bound
?> ?| ?=(%direct -.tar)
(~(has by bon.nam) p.tar)
?: ?& ?=(%indirect -.tar)
!(~(has by bon.nam) p.tar)
==
:: defer %indirect where target isn't yet bound
::
this(dep.nam (~(add ja dep.nam) p.tar [him tar]))
:: ignore if binding is pending
::
=/ pending (~(get by pen.nam) him)
?: ?& ?=(^ pending)
=(tar u.pending)
==
this
:: re-notify if binding already exists
::
=/ existing (~(get by bon.nam) him)
?: ?& ?=(^ existing)
=(tar cur.u.existing)
==
(bond for him)
:: create new or replace existing binding
::
=/ wir=wire
/authority/create/(scot %p him)/for/(scot %p for)
=/ pre=(unit target)
@ -363,10 +528,25 @@
?~(bon ~ `cur.u.bon)
:: ?> ?=(%gcloud pro.aut.nam)
=/ req=hiss:eyre
(~(request gcloud aut.nam) him tar pre)
%- emit(pen.nam (~(put by pen.nam) him tar)) :: XX save for
[%hiss wir [~ ~] %httr %hiss req]
:: +confirm: successfully bound
(~(create gcloud aut.nam) him tar pre)
:: XX save :for relay state?
::
%- emit(pen.nam (~(put by pen.nam) him tar))
(request wir req)
:: +dependants: process stored dependant bindings
::
++ dependants
|= for=ship
^+ this
=/ dep (~(get ja dep.nam) for)
=. ..this
|- ^+ ..this
?~ dep ..this
=* him p.i.dep
=* tar q.i.dep
$(dep t.dep, ..this (create for him tar))
this(dep.nam (~(del by dep.nam) for))
:: +confirm: successfully bound
::
++ confirm
|= [for=ship him=ship]
@ -377,66 +557,77 @@
[now.bow tar ?~(bon ~ [[wen.u.bon cur.u.bon] hit.u.bon])]
=. pen.nam (~(del by pen.nam) him)
=. bon.nam (~(put by bon.nam) him nob)
(dependants:(bond for him) him)
:: +bond: send binding confirmation
::
++ bond
|= [for=ship him=ship]
=/ wir=wire
/bound/(scot %p him)/for/(scot %p for)
=/ dom=turf
(weld dom.aut.nam /(crip +:(scow %p him)))
%- emit
[%poke wir [for dap.bow] %dns-bond for him dom]
=/ com=command
[%bond for him dom]
(emit [%poke wir [for dap.bow] %dns-command com])
--
:: |tell: acting as planet parent or relay
:: |tell: acting as planet parent or relay
::
++ tell
|= him=ship
=| moz=(list move)
|_ [him=ship rel=(unit relay)]
=/ rel=(unit relay) (~(get by per) him)
|%
++ this .
:: +abet: finalize state changes, produce moves
:: +abet: finalize state changes, produce moves
::
++ abet
^- (quip move _^this)
:- (flop moz)
?~ rel
^this
^this(per (~(put by per) him u.rel))
:: +emit: emit a move
=? per ?=(^ rel)
(~(put by per) him u.rel)
^this
:: +emit: emit a move
::
++ emit
|= car=card
^+ this
this(moz [[ost.bow car] moz])
:: +listen: subscribe to %ames +lane changes for child ships
::
++ listen
^+ this
(emit [%tend /tend ~])
:: +hear: hear +lane change, maybe emit binding request
:: +hear: hear ip address, maybe emit binding request
::
++ hear
|= lan=lane:ames
|= addr=(unit @if)
^+ this
=/ adr=(unit @if)
?.(?=([%if *] lan) ~ `r.lan)
=/ tar=target
?: ?| ?=(~ adr)
?=(%duke (clan:title him))
==
?: |(?=(~ addr) ?=(%duke (clan:title him)))
[%indirect our.bow]
[%direct %if u.adr]
?. ?| ?=(~ rel)
!=(tar tar.u.rel)
!bon.u.rel
[%direct %if u.addr]
:: re-notify if binding already exists
::
:: XX deduplicate with +confirm
::
?: ?& ?=(^ rel)
?=(^ dom.u.rel)
=(tar tar.u.rel)
==
this
=. rel `[wen=now.bow adr bon=| try=0 tar]
=/ wir=wire
/bound/(scot %p him)/for/(scot %p our.bow)
=/ com=command
[%bond our.bow him u.dom.u.rel]
(emit [%poke wir [him dap.bow] %dns-command com])
:: check binding target validity, store and forward
::
=. rel `[wen=now.bow addr dom=~ try=0 tar]
?:(?=(%indirect -.tar) bind check)
:: +check: confirm %direct target is accessible
:: +check: confirm %direct target is accessible
::
++ check
^+ this
?> ?=(^ rel)
?> ?=(%direct -.tar.u.rel)
?: (reserved p.tar.u.rel)
?: (reserved:eyre p.tar.u.rel)
(fail %reserved-ip)
:: XX confirm max retries
::
?: (gth try.u.rel 2)
(fail %unreachable)
=. try.u.rel +(try.u.rel)
@ -444,11 +635,9 @@
/check/(scot %p him)
=/ url=purl:eyre
:- [sec=| por=~ host=[%| `@if`p.tar.u.rel]]
[[ext=`~.md path=~] query=~]
:: XX state mgmt
%- emit
[%hiss wir [~ ~] %httr %hiss url %get ~ ~]
:: +fail: %direct target is invalid or inaccessible
[[ext=`~.umd path=/static] query=~]
(emit (request wir url %get ~ ~))
:: +fail: %direct target is invalid or inaccessible
::
++ fail
|= err=@tas
@ -457,58 +646,89 @@
~& [%fail err him tar.u.rel]
=/ wir=wire
/fail/(scot %p him)
:: XX add failure-specific messages
:: XX use a better notification channel?
::
=/ msg=tape
?+ err
"dns binding failed"
"dns binding failed"
::
%reserved-ip
?> ?=(%direct -.tar.u.rel)
"unable to create dns binding reserved address {(scow %if p.tar.u.rel)}"
=/ addr=tape (scow %if p.tar.u.rel)
"unable to create dns binding reserved address {addr}"
==
:: XX state mgmt
%- emit
[%poke wir [our.bow %hood] %helm-send-hi him `msg]
:: +bind: request binding for target
:: XX save failure state?
::
(emit [%poke wir [our.bow %hood] %helm-send-hi him `msg])
:: +bind: request binding for target
::
:: Since we may be an authority, we poke ourselves.
:: Since we may be an authority, we poke ourselves.
::
++ bind
^+ this
?> ?=(^ rel)
:: XX state mgmt
:: XX save binding request state?
::
=/ wir=wire
/bind/(scot %p him)/for/(scot %p our.bow)
%- emit
[%poke wir [our.bow dap.bow] %dns-bind our.bow him tar.u.rel]
:: +bake: successfully bound
=/ com=command
[%bind our.bow him tar.u.rel]
(emit [%poke wir [our.bow dap.bow] %dns-command com])
:: +check-bond: confirm binding propagation
::
++ bake
++ check-bond
|= dom=turf
~& [%bake dom]
^+ this
?> ?=(^ rel)
=/ wir=wire
/check-bond/(scot %p him)
=/ url=purl:eyre
:- [sec=| por=~ host=[%& dom]]
[[ext=`~.umd path=/static] query=~]
:: XX track bound-state per-domain
::
%- emit(dom.u.rel `dom)
(request wir url %get ~ ~)
:: +recheck-bond: re-attempt to confirm binding propagation
::
++ recheck-bond
^+ this
?> ?& ?=(^ rel)
?=(^ dom.u.rel)
==
(check-bond u.dom.u.rel)
:: +bake: successfully bound
::
++ bake
^+ this
?> ?=(^ rel)
?> ?=(^ dom.u.rel)
=/ wir=wire
/forward/bound/(scot %p him)/for/(scot %p our.bow)
:: XX save domain, track bound-state per-domain
%- emit(bon.u.rel &)
[%poke wir [him dap.bow] %dns-bond our.bow him dom]
:: +forward: sending binding request up the network
=* dom u.dom.u.rel
=/ com=command
[%bond our.bow him dom]
=/ msg=tape
"relaying new dns binding: {(trip (join '.' (flop dom)))}"
:: XX save notification state?
::
%- emit:(emit %flog / %text msg)
[%poke wir [him dap.bow] %dns-command com]
:: +forward: sending binding request up the network
::
++ forward
|= [for=ship tar=target]
~& [%forward tar]
^+ this
?: ?=(%~zod our.bow) :: ~zod don't forward
~& [%zod-no-forward him tar]
?: ?=(%~zod our.bow)
this
=/ to=ship
?- (clan:title our.bow)
%czar ~zod
* (sein:title [our now our]:bow)
==
=/ wir=wire
/forward/bind/(scot %p him)/for/(scot %p for)
%- emit :: XX for
[%poke wir [to dap.bow] %dns-bind for him tar]
=/ com=command
[%bind for him tar]
=/ to=ship
?: ?=(%czar (clan:title our.bow)) ~zod
(sein:title [our now our]:bow)
(emit [%poke wir [to dap.bow] %dns-command com])
--
--

File diff suppressed because it is too large Load Diff

View File

@ -2,16 +2,14 @@
::
:::: /hoon/authority/dns/gen
::
/- dns, sole
/+ generators
=, dns
=, generators
/- *dns, *sole
/+ *generators
:- %ask
|= $: [now=@da eny=@uvJ bec=beak]
[arg=$@(~ [dom=path ~])]
[arg=$@(~ [dom=turf ~])]
~
==
^- (sole-result:sole [%dns-authority authority])
^- (sole-result [%dns-command %authority authority])
=- ?~ arg -
(fun.q.q [%& dom.arg])
%+ prompt
@ -28,5 +26,5 @@
[%& %zone "dns zone: "]
%+ parse urs:ab
|= zone=@ta
%+ produce %dns-authority
[p.hot %gcloud project zone]
%- produce
[%dns-command %authority [p.hot %gcloud project zone]]

25
gen/dns/ip.hoon Normal file
View File

@ -0,0 +1,25 @@
:: DNS: configure ip address
::
:::: /hoon/authority/dns/gen
::
/- *dns, *sole
/+ *generators
:- %ask
|= $: [now=@da eny=@uvJ bec=beak]
[arg=$@(~ [addr=@if ~])]
~
==
^- (sole-result [%dns-command command])
=* our p.bec
=- ?~ arg -
(fun.q.q addr.arg)
%+ prompt
[%& %dns-address "ipv4 address: "]
%+ parse
`$-(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]

View File

@ -2,19 +2,38 @@
:::: /hoon/collections/lib
::
/? 309
/+ cram
::
/- hall
/+ cram, elem-to-react-json
::
::
~% %collections-lib ..is ~
|%
+= move [bone card]
+= card
$% [%info wire ship toro:clay]
[%poke wire dock poke]
[%perm wire ship desk path rite:clay]
==
+= poke
$% [%hall-action action:hall]
[%collections-action action]
[%json json]
==
+= state
$% [%0 col=collection]
==
::
::
+= collection [meta=config data=(map nom=knot =item)]
+= item
$~ [%raw %umd ~ %$]
$~ [%error ~]
$% [%collection col=collection]
[%raw raw=raw-item]
[%both col=collection raw=raw-item]
[%error ~]
==
+= raw-item
$% [%umd meta=(map knot cord) data=@t]
$% [%udon meta=(map knot cord) data=@t]
==
::
+= config
@ -45,13 +64,850 @@
[%perms pax=path r=rule:clay w=rule:clay]
::
[%collection pax=path name=@t desc=@t comments=? visible=? type=@tas]
[%post pax=path name=@t type=@tas comments=? content=@t]
[%post pax=path name=@t type=@tas comments=? content=@t edit=?]
[%comment pax=path content=@t]
==
::
+= form
$% [%umd @t]
$% [%udon @t]
[%collections-config config]
==
::
++ collection-error
~/ %coll-collection-error
|= col=collection
^- ?
|-
=/ vals=(list item) ~(val by data.col)
%+ roll vals
|= [i=item out=_|]
^- ?
?: out out
?+ -.i
%.n
%error %.y
%collection ^$(col col.i)
%both ^$(col col.i)
==
::::
:::: /mar/snip
::::
++ words 1
++ hedtal
=| met/marl
|= a/marl ^- {hed/marl tal/marl}
?~ a [~ ~]
:: looks like it only terminates if it finds an h1?
?. ?=($h1 n.g.i.a)
?: ?=($meta n.g.i.a)
$(a t.a, met [i.a met])
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
[c.i.a (weld (flop met) (limit words t.a))]
::
::
++ limit
~/ %coll-limit
|= {lim/@u mal/marl}
=< res
|- ^- {rem/@u res/marl}
?~ mal [lim ~]
?~ lim [0 ~]
=+ ^- {lam/@u hed/manx}
?: ?=(_;/(**) i.mal)
[lim ;/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
~/ %coll-deword
|= {lim/@u tay/tape} ^- {lim/@u tay/tape}
?~ tay [lim tay]
?~ lim [0 ~]
=+ wer=(dot 1^1 tay)
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
[-.nex [(wonk wer) +.nex]]
::
:: json
::
++ item-to-json
~/ %coll-item-to-json
|= itm=item
^- json
?- -.itm
%error (frond:enjs:format %error ~)
::
%collection
%+ frond:enjs:format
%collection (collection-to-json col.itm)
::
%raw
%- frond:enjs:format
[%item (raw-to-json raw.itm)]
::
%both
%- pairs:enjs:format
:~ [%item (raw-to-json raw.itm)]
[%collection (collection-to-json col.itm)]
==
==
::
++ collection-to-json
~/ %coll-collection-to-json
|= col=collection
^- json
%- pairs:enjs:format
:~ [%meta (config-to-json meta.col)]
:+ %data %a
%+ turn ~(tap by data.col)
|= [nom=knot ite=item]
^- json
%- pairs:enjs:format
:~ [%filename %s nom]
[%item (item-to-json ite)]
==
==
::
++ raw-to-json
~/ %coll-raw-to-json
|= raw=raw-item
^- json
=/ elm=manx elm:(static:cram (ream data.raw))
=/ rec=json (elem-to-react-json elm)
%- pairs:enjs:format
:~ [%data rec]
[%meta (meta-to-json meta.raw)]
==
::
++ config-to-json
~/ %coll-config-to-json
|= con=config
^- json
?: =(con *config)
~
%- pairs:enjs:format
:~ :- %full-path
:- %a
%+ turn (en-beam:format full-path.con)
|= a=@ta
[%s a]
:- %name [%s name.con]
:- %desc [%s description.con]
:- %owner (ship:enjs:format owner.con)
:- %date-created (time:enjs:format date-created.con)
:- %last-modified (time:enjs:format last-modified.con)
:- %type [%s type.con]
:- %comments [%b comments.con]
:- %sort-key ?~(sort-key.con ~ (numb:enjs:format u.sort-key.con))
:- %visible [%b visible.con]
==
::
++ meta-to-json
~/ %coll-meta-to-json
|= meta=(map knot cord)
^- json
%- pairs:enjs:format
%+ turn ~(tap by meta)
|= [key=@t val=@t]
^- [@t json]
[key [%s val]]
::
++ udon-to-front
~/ %coll-udon-to-front
|= u=@t
^- (map knot cord)
%- ~(run by inf:(static:cram (ream u)))
|= a=dime ^- cord
?+ (end 3 1 p.a) (scot a)
%t q.a
==
::
:: +path-to-circle:
::
:: takes a clay path and returns a hall circle
:: for a path /foo/bar it returns a circle with a :name %c-foo-bar
::
++ path-to-circle
~/ %coll-path-to-circle
|= [pax=path our=@p]
^- circle:hall
=. pax
?: ?=([%web %collections *] pax)
(weld /c (slag 2 `path`pax))
?: ?=([%collections *] pax)
(weld /c (slag 1 `path`pax))
?: ?=([%c *] pax)
`path`pax
`path`(weld /c pax)
=/ nam=term
%+ roll `(list @ta)`pax
|= [seg=@ta out=term]
%^ cat 3
?:(=(%$ out) out (cat 3 out '-'))
((hard @tas) seg)
[our nam]
::
:: +allowed-by: checks if ship :who is allowed by the permission rules in :dic
::
++ allowed-by
~/ %coll-allowed-by
|= [who=@p dic=dict:clay our=@p]
^- ?
?: =(who our) &
=/ in-list=?
?| (~(has in p.who.rul.dic) who)
::
%- ~(rep by q.who.rul.dic)
|= [[@ta cru=crew:clay] out=_|]
?: out &
(~(has in cru) who)
==
?: =(%black mod.rul.dic)
!in-list
in-list
::
:: +collection-notify: XX
::
++ collection-notify
~/ %coll-collection-notify
|= [pax=path conf=config]
^- json
%- pairs:enjs:format
:~ ['owner' [%s (crip (scow %p owner.conf))]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s name.conf]]
['date' [%s (crip (scow %da last-modified.conf))]]
['type' [%s type.conf]]
==
::
:: +item-notify: XX
::
++ item-notify
~/ %coll-item-notify
|= [pax=path raw=raw-item now=@da byk=beak]
^- json
=/ owner (fall (~(get by meta.raw) %owner) ~.anon)
=/ dat (fall (~(get by meta.raw) %last-modified) (scot %da now))
=/ nom (fall (~(get by meta.raw) %name) ~.no-title)
=/ typ (fall (~(get by meta.raw) %type) ~.no-type)
::
=/ elm=manx elm:(static:cram (ream data.raw))
=/ snip=marl tal:(hedtal +.elm)
=/ inner
?~ snip
(crip (en-xml:html elm))
(crip (en-xml:html i.snip)) :: inner html
::
=/ parent-spur (slag 1 (flop pax))
=/ bek=beak byk(r [%da now])
=/ parent-path (en-beam:format [bek parent-spur])
=/ parent-dir .^(arch %cy parent-path)
::
=/ parent-conf=json
?: (~(has in dir.parent-dir) ~.udon ~)
%- meta-to-json
%- udon-to-front
.^(@t %cx (weld parent-path /udon))
?: (~(has in dir.parent-dir) ~.collections-config ~)
%- config-to-json
.^(config %cx (weld parent-path /collections-config))
~
::
%- pairs:enjs:format
:~ ['owner' [%s owner]]
['path' [%a (turn pax |=(a=@ta `json`[%s a]))]]
['name' [%s nom]]
['date' [%s dat]]
['type' [%s typ]]
['content' [%s data.raw]]
['snip' [%s inner]]
['parent-config' parent-conf]
==
::
:: +front-to-wain: XX
::
++ front-to-wain
~/ %coll-front-to-wain
|= a=(map knot cord)
^- wain
=/ entries=wain
%+ turn ~(tap by a)
|= b=[knot cord]
=/ c=[term cord] ((hard ,[term cord]) b)
(crip " [{<-.c>} {<+.c>}]")
::
?~ entries ~
;: weld
[':- :~' ~]
entries
[' ==' ~]
==
::
:: +update-udon-front: XX
::
++ update-udon-front
~/ %coll-update-udon-front
|= [fro=(map knot cord) udon=@t]
^- @t
%- of-wain:format
=/ tum (trip udon)
=/ id (find ";>" tum)
?~ id
%+ weld (front-to-wain fro)
(to-wain:format (crip (weld ";>\0a" tum)))
%+ weld (front-to-wain fro)
(to-wain:format (crip (slag u.id tum)))
::
:: _ta: main event core for collections
::
++ ta
~/ %coll-ta
|_ $: moves=(list move)
bol=bowl:gall
==
::
:: +ta-this: ta core subject
::
++ ta-this .
::
:: +ta-done:
::
:: flop :moves for finalization, since moves are prepended to the list
::
++ ta-done (flop moves)
::
:: +ta-emit: add a +move to :moves
::
++ ta-emit
~/ %coll-ta-emit
|= mov=move
%_ ta-this
moves [mov moves]
==
::
:: +ta-emil: add a list of +move to :moves
::
++ ta-emil
~/ %coll-ta-emil
|= mos=(list move)
%_ ta-this
moves (welp (flop mos) moves)
==
::
:: +ta-act: process collection-action
::
++ ta-act
~/ %coll-ta-act
|= act=action
^+ ta-this
::
:: iterate through list of +sub-action of +action
::
|-
?~ acts.act ta-this
=* a i.acts.act
::
=/ now-id=@da (sub now.bol (div (dis now.bol ~s0..fffe) 2))
=/ dat (scot %da now-id)
=/ bek=beak byk.bol(r [%da now-id])
=/ sap (en-beam:format [bek (flop (path +<.a))])
::
=. ta-this
?- -.a
%write
=/ perms .^([dict:clay dict:clay] %cp sap)
?: (allowed-by src.bol +.perms our.bol)
?- -.for.a
%udon (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
%collections-config (ta-write pax.a `cage`[-.for.a !>(+.for.a)])
==
ta-this
::
%delete
=/ perms .^([dict:clay dict:clay] %cp sap)
?: (allowed-by src.bol +.perms our.bol)
(ta-remove pax.a)
ta-this
::
%perms
?: =(src.bol our.bol) :: XX admin privileges for other users?
(ta-set-permissions pax.a r.a w.a)
ta-this
::
::
:: XX some of this is redunant
::
%collection
=/ perms
.^([dict:clay dict:clay] %cp (weld sap /[dat]/collections-config))
?. (allowed-by src.bol +.perms our.bol)
ta-this
=/ conf=config
:* [bek (flop (weld pax.a /[dat]/collections-config))]
name.a
desc.a
our.bol
now-id
now-id
type.a
comments.a
~
visible.a
==
=. ta-this
%+ ta-write (weld pax.a /[dat]/collections-config)
[%collections-config !>(conf)]
:: restrict permissions on config file
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat]/collections-config)
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
:: open permissions on collection items
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat])
[%black ((set whom:clay) ~)] :: read
[%black ((set whom:clay) ~)] :: write
ta-this
::
%post
=? pax.a !edit.a
(weld pax.a /[dat])
=? sap !edit.a
(en-beam:format [bek (flop pax.a)])
=/ perms .^([dict:clay dict:clay] %cp (weld sap /udon))
?. (allowed-by src.bol +.perms our.bol)
ta-this
=. content.a (crip (weld (trip content.a) "\0a"))
=/ front=(map knot cord)
%- my
:~ [%name name.a]
[%comments ?:(comments.a ~..y ~..n)]
[%owner (scot %p src.bol)]
[%date-created (snag 0 (flop pax.a))]
[%last-modified dat]
[%type type.a]
==
=. ta-this
%+ ta-write (weld pax.a /udon)
[%udon !>((update-udon-front front content.a))]
:: restrict permissions on udon file
=. ta-this
%^ ta-set-permissions (weld pax.a /udon)
[%black ((set whom:clay) ~)] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
:: open permissions on comments
=. ta-this
%^ ta-set-permissions pax.a
[%black ((set whom:clay) ~)] :: read
[%black ((set whom:clay) ~)] :: write
ta-this
::
%comment
=/ perms .^([dict:clay dict:clay] %cp (weld sap /[dat]/udon))
?. (allowed-by src.bol +.perms our.bol)
ta-this
=. content.a (crip (weld (trip content.a) "\0a"))
=/ front=(map knot cord)
%- my
:~ [%owner (scot %p src.bol)]
[%date-created dat]
[%last-modified dat]
[%type %comments]
==
=. ta-this
%+ ta-write (weld pax.a /[dat]/udon)
[%udon !>((update-udon-front front content.a))]
:: restrict permissions on udon file
=. ta-this
%^ ta-set-permissions (weld pax.a /[dat]/udon)
[%black ((set whom:clay) ~)] :: read
[%white ((set whom:clay) [[& src.bol] ~ ~])] :: write
ta-this
::
==
$(acts.act t.acts.act)
::
:: +ta-update:
::
::
::
++ ta-update
~/ %coll-ta-update
|= [old=collection new=collection]
^+ ta-this
?: =(old new)
ta-this
(ta-update-collection old new /web/collections)
::
++ ta-insert-item
~/ %coll-ta-insert-item
|= [new=item pax=path]
^+ ta-this
=/ parent-path (scag (dec (lent pax)) pax)
::
?- -.new
::
%error
(ta-hall-lin parent-path 'error')
::
%collection
=. ta-this
%^ ta-hall-json parent-path 'new collection'
(collection-notify pax meta.col.new)
::
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
=. ta-this
|-
?~ items ta-this
=. ta-this (ta-insert-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
ta-this
::
%raw
=. ta-this
%^ ta-hall-json
parent-path
'new item'
(item-notify pax raw.new now.bol byk.bol)
?: ?& (~(has by meta.raw.new) %comments)
=('.y' (~(got by meta.raw.new) %comments))
==
(ta-generate-comments pax)
ta-this
::
==
::
++ ta-remove-item
~/ %coll-ta-remove-item
|= [old=item pax=path]
^+ ta-this
:: flush permissions
:: notify parent of deletion
=/ parent (scag (dec (lent pax)) pax)
:: recurse for children
?- -.old
::
%error
(ta-hall-lin parent 'error')
::
%collection
=. ta-this
%^ ta-hall-json parent 'deleted collection'
(collection-notify pax meta.col.old)
=. ta-this (ta-flush-permissions (weld pax /collections-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%both
=. ta-this (ta-flush-permissions pax)
=. ta-this (ta-flush-permissions (weld pax /collections-config))
=/ items=(list [nom=@ta =item]) ~(tap by data.col.old)
|-
?~ items ta-this
=. ta-this (ta-remove-item item.i.items (weld pax [nom.i.items ~]))
$(items t.items)
::
%raw
=. ta-this (ta-flush-permissions pax)
%^ ta-hall-json
parent
'deleted item'
(item-notify pax raw.old now.bol byk.bol)
::
==
::
::
::
++ ta-update-item
:: always make sure removals happen first and insertions happen last
:: because removals flush permissions and insertions set them
::
~/ %coll-ta-update-item
|= [old=item new=item pax=path]
^+ ta-this
?: =(old new)
ta-this
::
:: check for changes in item type
?: &(?=(%collection -.old) ?=(%collection -.new))
(ta-update-collection col.old col.new pax)
?: &(?=(%raw -.old) ?=(%raw -.new))
(ta-update-raw-item raw.old raw.new pax)
?: &(?=(%both -.old) ?=(%both -.new))
:: update raw item
=. ta-this (ta-update-collection col.old col.new pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%collection -.old) ?=(%raw -.new))
:: remove collection
:: insert raw item
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%collection -.old) ?=(%both -.new))
:: insert raw item
:: update-collection
=. ta-this (ta-update-collection col.old col.new pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%collection -.new))
:: remove raw item
:: insert collection
=. ta-this (ta-remove-item old pax)
(ta-insert-item new pax)
::
?: &(?=(%raw -.old) ?=(%both -.new))
:: insert collection
:: update raw item
=. ta-this (ta-update-raw-item raw.old raw.new pax)
(ta-insert-item new pax)
::
?: &(?=(%both -.old) ?=(%raw -.new))
:: remove collection
:: update raw item
=. ta-this (ta-remove-item [%collection col.old] pax)
(ta-update-raw-item raw.old raw.new pax)
::
?: &(?=(%both -.old) ?=(%collection -.new))
:: remove raw item
:: update collection
=. ta-this (ta-remove-item [%raw raw.old] pax)
(ta-update-collection col.old col.new pax)
::
::
?: &(?=(%error -.old) ?=(%error -.new))
ta-this
?: &(?=(%error -.old) ?=(%collection -.new))
(ta-insert-item new pax)
?: &(?=(%error -.old) ?=(%raw -.new))
(ta-insert-item new pax)
?: &(?=(%error -.old) ?=(%both -.new))
(ta-insert-item new pax)
?: ?=(%error -.new)
(ta-hall-lin pax 'error')
::
ta-this
::
++ ta-update-raw-item
~/ %coll-ta-update-raw-item
|= [old=raw-item new=raw-item pax=path]
^+ ta-this
?: =(old new)
ta-this
::
=? ta-this !=(data.old data.new)
=/ parent-path (scag (dec (lent pax)) pax)
%^ ta-hall-json
parent-path
'edited item'
(item-notify pax new now.bol byk.bol)
::
=? ta-this
?& =('.y' (fall (~(get by meta.new) %comments) '.n'))
=('.n' (fall (~(get by meta.old) %comments) '.n'))
==
:: create comments
(ta-generate-comments pax)
::
=? ta-this
?& =('.n' (fall (~(get by meta.new) %comments) '.n'))
=('.y' (fall (~(get by meta.old) %comments) '.n'))
==
:: delete comments
(ta-remove (weld pax /collections-config))
::
ta-this
::
++ ta-update-collection
~/ %coll-ta-update-collection
|= $: old=collection
new=collection
pax=path
==
^+ ta-this
::
=? ta-this !=(meta.old meta.new)
=/ parent-path (scag (dec (lent pax)) pax)
%^ ta-hall-json parent-path 'edited collection'
(collection-notify pax meta.new)
::
?: =(data.old data.new)
ta-this
::
:: new values of all changed items
=/ upd-new (~(dif in (~(int by data.old) data.new)) data.old)
:: old values of all changed items
=/ upd-old (~(dif in (~(int by data.new) data.old)) data.new)
:: all totally new entries
=/ ins-new (~(dif by data.new) data.old)
:: all deleted entries
=/ del-old (~(dif by data.old) data.new)
::
=/ upd-new=(list [nom=knot =item]) ~(tap by upd-new)
=/ upd-old=(list [nom=knot =item]) ~(tap by upd-old)
=/ ins-new=(list [nom=knot =item]) ~(tap by ins-new)
=/ del-old=(list [nom=knot =item]) ~(tap by del-old)
::
=/ lam |=([[a=knot item] out=(list path)] [(weld pax [a ~]) out])
::
=. ta-this |-
?~ upd-new
ta-this
?< ?=(~ upd-old)
=* new-item i.upd-new
=* old-item i.upd-old
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-update-item item.old-item item.new-item new-pax)
::
%= $
upd-new t.upd-new
upd-old t.upd-old
==
::
=. ta-this |-
?~ ins-new
ta-this
=* new-item i.ins-new
=/ new-pax (weld pax [nom.new-item ~])
=. ta-this (ta-insert-item +.new-item (weld pax [-.new-item ~]))
$(ins-new t.ins-new)
::
=. ta-this |-
?~ del-old
ta-this
=* old-item i.del-old
=/ old-pax (weld pax [nom.old-item ~])
=. ta-this (ta-remove-item +.old-item (weld pax [-.old-item ~]))
$(del-old t.del-old)
::
ta-this
::
++ ta-generate-comments
~/ %coll-ta-generate-comments
|= pax=path
^+ ta-this
=/ sup=path [%collections-config (flop pax)]
=/ bek byk.bol(r [%da now.bol])
=/ pat (en-beam:format [bek sup])
=/ dat=@da (slav %da (snag 0 (flop pax)))
=/ cay=config
:* [bek sup]
'comments'
'comments'
our.bol
dat
dat
%comments
|
~
|
==
(ta-write (flop sup) %collections-config !>(cay))
::
:: writing files
::
++ ta-write
~/ %coll-ta-write
=, space:userlib
|= [pax=path cay=cage]
^+ ta-this
=/ bek byk.bol(r [%da now.bol])
=. pax (en-beam:format bek (flop pax))
%+ ta-emit ost.bol
[%info (weld /ta-write pax) our.bol (foal pax cay)]
::
++ ta-remove
=, space:userlib
~/ %coll-ta-remove
|= pax=path
=/ bek byk.bol(r [%da now.bol])
=. pax (en-beam:format bek (flop pax))
^+ ta-this
%+ ta-emit ost.bol
[%info (weld /ta-remove pax) our.bol (fray pax)]
::
:: permissions
::
++ ta-set-permissions
~/ %coll-ta-set-permissions
|= [pax=path r=rule:clay w=rule:clay]
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw `r `w]]
::
++ ta-flush-permissions
~/ %coll-ta-flush-permissions
|= pax=path
^+ ta-this
%+ ta-emit ost.bol
[%perm (weld /perms pax) our.bol q.byk.bol pax [%rw ~ ~]]
::
:: hall
::
++ ta-hall-action
~/ %coll-ta-hall-action
|= act=action:hall
^+ ta-this
%+ ta-emit ost.bol
[%poke /col-hall-action [our.bol %hall] %hall-action act]
::
++ ta-hall-actions
~/ %coll-ta-hall-actions
|= act=(list $?(~ action:hall))
^+ ta-this
?~ act ta-this
?~ i.act $(act t.act)
%= $
ta-this (ta-hall-action i.act)
act t.act
==
::
++ ta-hall-create-circle
~/ %coll-ta-hall-create-circle
|= [pax=path description=@t]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax our.bol)
=/ parent=circle:hall
?: =(nom.circ %c)
[our.bol %inbox]
(path-to-circle (scag (dec (lent pax)) pax) our.bol)
%- ta-hall-actions
:~ [%create nom.circ description %journal]
[%source nom.parent & (sy `source:hall`[circ ~] ~)]
==
::
++ ta-hall-lin
~/ %coll-ta-hall-lin
|= [pax=path msg=cord]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax our.bol)
%- ta-hall-action
[%phrase [circ ~ ~] [%lin | msg]~]
::
++ ta-hall-json
~/ %coll-ta-hall-json
|= [pax=path header=@t jon=json]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax our.bol)
%- ta-hall-action
:+ %phrase [circ ~ ~]
[%fat [%text ~[header]] [%lin | (crip (en-json:html jon))]]~
::
--
--

View File

@ -1,165 +0,0 @@
=, eyre
|%
:: sort knots by date
:: TODO when we change the write path to have trailing sig, remove here before sort
++ dor
|= [a=knot b=knot]
(gth (unt:chrono:userlib (slav %da a)) (unt:chrono:userlib (slav %da b)))
:: checks if authorized
++ authed
|= gas/epic
^- ?
%+ lien
~(tap in (~(get ju aut.ced.gas) %$))
|= b/knot
=((scot %p p.bem.gas) b)
++ no-title
|= wat/wain
^- wain
?: =((scag 2 (trip -:wat)) "# ")
+:wat
wat
++ esoo
|= d/@d
^- tape
=/ t (yore d)
;: welp
(scag 1 (scow %ud y.t))
(swag [2 3] (scow %ud y.t))
"-"
(double m.t)
"-"
(double d.t.t)
"T"
(double h.t.t)
":"
(double m.t.t)
":"
(double s.t.t)
"Z"
==
:: ud to leading zero tape
++ double
|= a/@ud
^- tape
=/ x (scow %ud a)
?: (lth a 10)
(welp "0" x)
x
:: takes a map of knot * where knot is a serialized @da and returns the newest
++ latest
|* a/(map knot *)
^- (pair knot *)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(dor p.b p.c)
?~ sa
*(pair knot *)
i.sa
++ latest-post
'''
/- collections
/+ colls
/= gas /$ fuel:html
/= configs /: /===/web/collections
/^ (map knot config:collections) /_ /collections-config/
:: tried to pull this func into a lib, but couldn't get the gill working correctly. grr.
/= metawcom /; |= a/(map knot topicful:collections)
^- (pair knot topicful:collections)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(gth (unt:chrono:userlib (slav %da p.b)) (unt:chrono:userlib (slav %da p.c)))
?~ sa
*(pair knot topicful:collections)
i.sa
/: /%%/
/^ (map knot topicful:collections) /_ /collections-topic-full/
/= content /; |= a/(map knot manx)
^- (pair knot manx)
=/ sa
%+ sort
~(tap by a)
|= [b=(pair knot *) c=(pair knot *)]
(gth (unt:chrono:userlib (slav %da p.b)) (unt:chrono:userlib (slav %da p.c)))
?~ sa
*(pair knot manx)
i.sa
/: /%%/
/^ (map knot manx) /_
/&elem&md&/collections-topic/
=/ config (~(get by configs) +<:s.bem.gas)
~& metawcom
::
^- manx
;div.container
;div.row
;input(type "hidden", name "urb-header", value "collection-index", title "{(trip desc:(need config))}", id "{(trip +<:s.bem.gas)}", ship "{(scow %p p.bem.gas)}");
;div.col-sm-10.col-sm-offset-2
;div.post.collection-post-page
;div.row.collection-date
;span.mr-2.text-black.text-500(urb-component "Elapsed", urb-timestring "{(esoo:colls mod.info.q.metawcom)}");
;span: {(trip -:s.bem.gas)}
==
::
;div#show
;div.row.tit.mt-6.collection-title
;h3: {(trip tit.info.q.metawcom)}
==
;* ?: (authed:colls gas)
;=
;a(href ".collections-edit")
;button#edit-btn.btn.btn-primary.mb-4
; Edit →
==
==
==
;=
;div;
==
;div.row.content.mb-18.mt-6
;div: +{q.content}
==
;* ?: comm:(need config)
;=
;div
;div.mb-2
;span(urb-component "IconComment");
;span: {<~(wyt by coms.q.metawcom)>}
==
;ul
;* %+ turn
%+ sort
~(tap by coms.q.metawcom)
|= [a=[c=@da d=[mod=@da who=@p wat=wain]] b=[c=@da d=[mod=@da who=@p wat=wain]]]
(lth (unt c.a) (unt c.b))
::
|= [c=@da d=[mod=@da who=@p wat=wain]]
;li.collection-comment
;div.collection-comment-avatar
;div(urb-component "AvatarSample1");
==
;div
;div
;a.collection-comment-author.text-mono(href "/~~/pages/nutalk/profile"): {(trip (scot %p who.d))}
==
;p: {(trip (of-wain:format wat.d))}
==
;span.collection-date.text-black.mr-2(urb-component "Elapsed", urb-timestring "{(esoo:colls mod.d)}");
;span.collection-date: {(esoo:colls mod.d)}
==
==
;div(urb-component "CommentCreate", urb-coll "{(trip +<:s.bem.gas)}", urb-top "{(trip -:s.bem.gas)}");
==
==
~
==
==
==
==
==
'''
--

View File

@ -202,7 +202,8 @@
::
++ sign
|= [protect=cord payload=cord]
=/ sig=@ud (~(sign rs256 k) (rap 3 ~[protect '.' payload]))
=/ msg=@t (rap 3 ~[protect '.' payload])
=/ sig=@ud (~(sign rs256 k) (met 3 msg) msg)
=/ len=@ud (met 3 n.pub.k)
(en-base64url len (rev 3 len sig))
--

View File

@ -26,12 +26,12 @@
:: Padded, DER encoded sha-256 hash (EMSA-PKCS1-v1_5).
::
++ emsa
|= m=@
|= m=byts
=/ emlen (met 3 n.pub.k)
=/ pec=spec:asn1
:~ %seq
[%seq [%obj sha-256:obj:asn1] [%nul ~] ~]
[%oct 32 (shax m)]
[%oct 32 (shay wid.m dat.m)]
==
:: note: this asn.1 digest is rendered raw here, as we require
:: big-endian bytes, and the product of +en:der is little-endian
@ -48,14 +48,14 @@
:: An RSA signature is the primitive decryption of the message hash.
::
++ sign
|=(m=@ (de:rsa (emsa m) k))
|=(m=byts (de:rsa (emsa m) k))
:: +verify:rs256: verify signature
::
:: RSA signature verification confirms that the primitive encryption
:: of the signature matches the message hash.
::
++ verify
|= [s=@ m=@]
|= [s=@ m=byts]
=((emsa m) (en:rsa s k))
--
:: |pem: generic PEM implementation (rfc7468)
@ -334,7 +334,7 @@
::
:+ %bit
(met 0 n.pub.key)
(swp 3 (~(sign rs256 key) +:(en:^der dat)))
(swp 3 (~(sign rs256 key) (en:^der dat)))
==
:: +info:en:spec:pkcs10: certificate request info
::

View File

@ -25,6 +25,16 @@
(~(dunk ut p.expected) %expected)
== ==
result
:: +expect-fail: kicks a trap, expecting crash. pretty-prints if succeeds
::
++ expect-fail
|= a=(trap)
^- tang
=/ b (mule a)
?- -.b
%| ~
%& [leaf+"expected failure - succeeded" ~]
==
:: +category: prepends a name to an error result; passes successes unchanged
::
++ category

View File

@ -90,6 +90,7 @@
type+(su:dejs sym)
comments+bo:dejs
content+so:dejs
edit+bo:dejs
==
::
++ comment

View File

@ -1,11 +0,0 @@
::
:::: /mar/dns/bind/hoon
::
/- dns
=, dns
|_ [for=ship him=ship target]
++ grab
|%
++ noun ,[for=ship him=ship target]
--
--

View File

@ -1,11 +0,0 @@
::
:::: /mar/dns/bond/hoon
::
/- dns
=, dns
|_ [for=ship him=ship turf]
++ grab
|%
++ noun ,[for=ship him=ship turf]
--
--

10
mar/dns/command.hoon Normal file
View File

@ -0,0 +1,10 @@
::
:::: /mar/dns/bind/hoon
::
/- *dns
|_ command
++ grab
|%
++ noun command
--
--

View File

@ -1,5 +1,5 @@
::
:::: /hoon/umd/mar
:::: /hoon/udon/mar
::
/+ cram
::
@ -26,7 +26,7 @@
++ mime |=({p/mite:eyre q/octs:eyre} q.q)
++ noun @t
++ txt of-wain:format
--
--
++ grad %txt
++ garb /down
--

View File

@ -8,59 +8,98 @@
::
::
/= collection-post
:: /^ $-(raw-item:collections manx)
/: /===/web/landscape/collections/post /!noun/
::/= collection-details
:: /^ manx
:: /: /===/web/landscape/collections/details /% /!hymn/
::
::
=< (item-to-elem itm)
|%
++ item-to-elem
!:
|= itm=item:collections
^- manx
?< =(/collections/web s.bem.gas)
=/ sho (fall (~(get by qix.gas) %show) %default)
;div.container
;div.row
;div.col-sm-10.col-sm-offset-2
;div.collection-index.mt-12
;+ (meta-to-elem itm sho)
;+
?- -.itm
;+
?+ -.itm !!
%error ;div: 404
::
%collection
?+ sho !!
%default (collection-to-elem col.itm)
%post (collection-post ~ (flop s.bem.gas))
%edit !!
%collection
?+ sho !!
::
%default
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm sho)
;+ (collection-to-elem col.itm)
==
==
;+ ?: =(type.meta.col.itm %blog)
;div.flex-col-5;
?: =(type.meta.col.itm %fora)
;div.flex-col-4;
;div.flex-col-4;
==
::
%raw
?+ sho !!
%default (raw-to-elem raw.itm)
%post !!
%edit (collection-post `raw.itm (flop s.bem.gas))
%post
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm sho)
;+ (collection-post ~ (flop s.bem.gas))
==
==
;div.flex-col-2;
==
::
%both
?+ sho !!
%default (both-to-elem col.itm raw.itm)
%post !!
%edit (collection-post `raw.itm (flop s.bem.gas))
==
::
==
==
==
==
:: %raw
::
%both
?+ sho !!
::
%default
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm sho)
;+ (both-to-elem col.itm raw.itm)
==
==
;div.flex-col-3;
==
::
%edit
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm sho)
;+ (collection-post `raw.itm (flop s.bem.gas))
==
==
;div.flex-col-2;
==
==
==
==
++ collection-to-elem
|= col=collection:collections
^- manx
;ul.vanilla
;* %+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
;* %+ roll
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lth a-dat b-dat)
|= [[nom=knot ite=item:collections] out=marl]
^- marl
?: ?=(%error -.ite)
out
:_ out
^- manx
;li.collection-post.mt-6
;+ (item-to-snip nom ite)
@ -71,29 +110,13 @@
|= raw=raw-item:collections
^- manx
=/ elm elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=/ ht (hedtal:collections +.elm)
=/ title (fall (~(get by meta.raw) %name) -.s.bem.gas)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ owner (fall (~(get by meta.raw) %owner) 'anonymous')
::
;div
;div.collection-date: {(trip date)}
::
;div#show
;div.row.tit.mt-6.collection-title
;+ ?~ hed.ht
;h3: {(trip title)}
;h3: *{hed.ht}
==
==
::
;div.who.text-mono.text-600: {(trip owner)}
;div.row.content.mb-18.mt-6
;+ elm
==
::
:: if comments are enabled it should be a %both not a %raw
:: XX REVIEW ^^ not robust enough?
;div.mb-18.mt-4
;+ elm
==
::
++ both-to-elem
@ -103,32 +126,43 @@
;+ (raw-to-elem raw)
::
;div
;div.mb-2
;span(urb-component "IconComment");
;span: {<~(wyt by data.col)>}
;div.flex.align-center.mb-5
;div(urb-component "IconComment");
;div.ml-2.text-small.text-mono.text-600: {<~(wyt by data.col)>}
==
::
;ul
;* %+ turn ~(tap by data.col) :: XX TODO: sort
;ul.vanilla
;* %+ turn
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lte a-dat b-dat)
|= [nom=knot ite=item:collections]
^- manx
:: XX TODO: accept types other than comments
?> ?=(%raw -.ite)
:: ?> =(%comments (~(got by meta.raw.ite) %type))
=/ owner (fall (~(get by meta.raw.ite) %owner) 'anonymous')
=/ date (fall (~(get by meta.raw.ite) %date-created) 'missing date')
;li.collection-comment
;div.collection-comment-avatar
;div(urb-component "AvatarSample1");
==
;div
;a.collection-comment-author.text-mono
=href "/~~/landscape/profile"
; {(trip owner)}
;li.mb-6
;div.flex.align-center
;div.mr-2
=urb-component "Sigil"
=urb-ship "{(trip owner)}"
=urb-size "18"
=urb-suffix "true";
;div
;a.vanilla.text-mono.text-small.text-700.mr-4
=href "/~~/landscape/profile"
; {(trip owner)}
==
==
;div.text-host-breadcrumb
=urb-component "Elapsed"
=urb-timestring "{(trip date)}";
==
;div.collection-comment-content
;+ elm:(static:cram (ream data.raw.ite))
==
;span.collection-date: {(trip date)}
==
==
::
@ -139,11 +173,24 @@
==
==
::
++ extract-date-created
|= i=item:collections
^- @da
?- -.i
%error *@da
%collection date-created.meta.col.i
%both date-created.meta.col.i
%raw (slav %da (~(got by meta.raw.i) %date-created))
==
::
::
::
++ item-to-snip
|= [nom=knot itm=item:collections]
^- manx
?- -.itm
%error
;div: 404
%collection
(collection-to-snip nom col.itm)
%raw
@ -159,7 +206,7 @@
"/~~/{(scow %p p.full-path.meta.col)}/=={(spud (flop (slag 1 s.full-path.meta.col)))}"
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;h2.mt-0.mb-0
;a(href lnk): {(trip name.meta.col)}
==
;div.who.text-mono.text-600: {<owner.meta.col>}
@ -174,7 +221,7 @@
|= [nom=knot raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=/ ht (hedtal:collections +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
@ -185,7 +232,7 @@
::
;div
;div.collection-date: {(trip date)}
;h3
;h2
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
@ -200,7 +247,7 @@
|= [nom=knot col=collection:collections raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal +.elm)
=/ ht (hedtal:collections +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
@ -209,16 +256,18 @@
::
;div
;div.collection-date: {<date-created.meta.col>}
;h3
;h2.mt-0.mb-0.text-500
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
==
;div.who.text-mono.text-600: {<owner.meta.col>}
;div.snippet: *{tal.ht}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
;div.text-mono.text-small.text-300.mt-1.mb-1: {<owner.meta.col>}
;div
;div.icon-label.justify-start
;div(urb-component "IconComment");
;div.ml-2
; {(trip (scot %ud ~(wyt by data.col)))}
==
==
==
==
@ -237,6 +286,7 @@
%+ weld mat
^- mart
?- -.itm
%error ~
%collection
=* met meta.col.itm
:~ [%urb-name (trip name.met)]
@ -265,46 +315,4 @@
[%urb-structure-type "collection-post"]
==
==
::::
:::: /mar/snip
::::
++ words 1
++ hedtal
=| met/marl
|= a/marl ^- {hed/marl tal/marl}
?~ a [~ ~]
:: looks like it only terminates if it finds an h1?
?. ?=($h1 n.g.i.a)
?: ?=($meta n.g.i.a)
$(a t.a, met [i.a met])
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
[c.i.a (weld (flop met) (limit words t.a))]
::
::
++ limit
|= {lim/@u mal/marl}
=< res
|- ^- {rem/@u res/marl}
?~ mal [lim ~]
?~ lim [0 ~]
=+ ^- {lam/@u hed/manx}
?: ?=(_;/(**) i.mal)
[lim ;/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
|= {lim/@u tay/tape} ^- {lim/@u tay/tape}
?~ tay [lim tay]
?~ lim [0 ~]
=+ wer=(dot 1^1 tay)
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
[-.nex [(wonk wer) +.nex]]
::
::
::
--

View File

@ -24,7 +24,7 @@
==
?~ raw
?~ col
!!
[%error ~]
[%collection col]
?~ col
[%raw raw]
@ -32,7 +32,7 @@
::
:: run a pair of renderers
::
:: 1. get a .umd file together with its frontmatter, or else return ~
:: 1. get a .udon file together with its frontmatter, or else return ~
::
:: 2. run the collections renderer, if it fails return ~
:: (it fails if .collections-config file does not exist at this path)
@ -40,9 +40,9 @@
/.
::
/| /; |= [a=(map knot cord) b=@t ~]
[%umd a b]
[%udon a b]
/. /front/
/umd/
/udon/
==
/~ ~
==

View File

@ -1,88 +1,9 @@
/? 309
/+ collections, cram, elem-to-react-json
/+ collections
/= gas /$ fuel:html
/= jon
/^ json
/; =< item-to-json
|%
::
++ item-to-json
|= itm=item:collections
^- json
?- -.itm
::
%collection
%+ frond:enjs:format
%collection (collection-to-json col.itm)
::
%raw
%- frond:enjs:format
[%item (raw-to-json raw.itm)]
::
%both
%- pairs:enjs:format
:~ [%item (raw-to-json raw.itm)]
[%collection (collection-to-json col.itm)]
==
==
::
++ collection-to-json
|= col=collection:collections
^- json
%- pairs:enjs:format
:~ [%meta (config-to-json meta.col)]
:+ %data %a
%+ turn ~(tap by data.col)
|= [nom=knot ite=item:collections]
^- json
%- pairs:enjs:format
:~ [%filename %s nom]
[%item (item-to-json ite)]
==
==
::
++ raw-to-json
|= raw=raw-item:collections
^- json
=/ elm=manx elm:(static:cram (ream data.raw))
=/ rec=json (elem-to-react-json elm)
%- pairs:enjs:format
:~ [%data rec]
[%meta (meta-to-json meta.raw)]
==
::
++ config-to-json
|= con=config:collections
^- json
?: =(con *config:collections)
~
%- pairs:enjs:format
:~ :- %full-path
:- %a
%+ turn (en-beam:format full-path.con)
|= a=@ta
[%s a]
:- %name [%s name.con]
:- %desc [%s description.con]
:- %owner (ship:enjs:format owner.con)
:- %date-created (time:enjs:format date-created.con)
:- %last-modified (time:enjs:format last-modified.con)
:- %type [%s type.con]
:- %comments [%b comments.con]
:- %sort-key ?~(sort-key.con ~ (numb:enjs:format u.sort-key.con))
:- %visible [%b visible.con]
==
::
++ meta-to-json
|= meta=(map knot cord)
^- json
%- pairs:enjs:format
%+ turn ~(tap by meta)
|= [key=@t val=@t]
^- [@t json]
[key [%s val]]
::
--
/; item-to-json:collections
::
/collections-web-item/
::

View File

@ -4,9 +4,9 @@
/^ $@(~ raw-item:collections)
/| /; |= [a=(map knot cord) b=@t ~]
^- raw-item:collections
[%umd a b]
[%udon a b]
/. /front/
/umd/
/udon/
==
::
/~ ~
@ -34,7 +34,7 @@
^- item:collections
?~ col
?~ raw
!!
[%error ~]
[%raw raw]
::
?: ?=(%no-config -.col)
@ -43,7 +43,7 @@
[%collection *config:collections items.col]
[%both [*config:collections items.col] raw]
?~ raw
!!
[%error ~]
[%raw raw]
?~ raw
[%collection config.col items.col]

View File

@ -3,12 +3,12 @@
::
/? 309
/= inner
/^ manx
/, /web/landscape /!hymn/
/web/collections /collections-elem/
/
/| /!hymn/
:: /&hymn&/elem/
==
/^ manx
/|
/, /web/collections /collections-elem/
/ /!hymn/
==
::
/: /===/web/404 /!hymn/
==
inner

View File

@ -1,16 +1,16 @@
::
:: no snip view for collections, only items
::
/= snipped-umd
/= snipped-udon
/& snip
/& elem
/umd/
/udon/
^- manx
;div
;h1
;* hed.snipped-umd
;* hed.snipped-udon
==
;* tal.snipped-umd
;* tal.snipped-udon
==

View File

@ -3,12 +3,12 @@
::
/? 309
/= inner
/^ manx
/, /web/landscape /!hymn/
/web/collections /collections-elem/
/
/| /!hymn/
:: /&hymn&/elem/
==
/^ manx
/|
/, /web/collections /collections-elem/
/ /!hymn/
==
::
/: /===/web/404 /!hymn/
==
inner

View File

@ -5,6 +5,8 @@
/? 309
/+ landscape
/= wrapped
/^ $-(inr=manx out=manx)
/~ landscape
/^ $-(inr=manx out=manx)
/, /web/pages /~ |=(manx +<)
/ /~ landscape
==
wrapped

View File

@ -1,12 +1,12 @@
|%
:: +provider: DNS service provider (gcloud only for now)
:: +provider: DNS service provider (gcloud only for now)
::
+= provider
+$ provider
$% [%gcloud project=@ta zone=@ta]
==
:: +authority: responsibility for a DNS zone
:: +authority: responsibility for a DNS zone
::
+= authority
+$ authority
$: :: dom: authority over a fully-qualified domain
::
dom=turf
@ -14,9 +14,9 @@
::
pro=provider
==
:: +target: a ship is bound to a ...
:: +target: a ship is bound to a ...
::
+= target
+$ target
$% :: %direct: an A record
::
[%direct %if p=@if]
@ -24,9 +24,9 @@
::
[%indirect p=ship]
==
:: +bound: an established binding, plus history
:: +bound: an established binding, plus history
::
+= bound
+$ bound
$: :: wen: established
::
wen=@da
@ -37,20 +37,32 @@
::
hit=(list (pair @da target))
==
:: +nameserver: a b s o l u t e p o w e r
:: +nameserver: a b s o l u t e p o w e r
::
+= nameserver
+$ nameserver
$: aut=authority
pen=(map ship target)
bon=(map ship bound)
dep=(jar ship (pair ship target))
pen=(map ship target)
==
:: +relay: a good parent keeps track
:: +relay: a good parent keeps track
::
+= relay
+$ relay
$: wen=@da
wer=(unit @if)
bon=?
:: XX track bound state per domain
::
dom=(unit turf)
try=@ud
tar=target
==
:: +command: top-level app actions
::
+$ command
$% [%authority aut=authority]
[%bind for=ship him=ship tar=target]
[%bond for=ship him=ship dom=turf]
[%ip %if addr=@if]
[%meet him=ship]
==
--

View File

@ -5299,6 +5299,7 @@
++ dem (bass 10 (most gon dit)) :: decimal to atom
++ dit (cook |=(a/@ (sub a '0')) (shim '0' '9')) :: decimal digit
++ dog ;~(plug dot gay) :: . number separator
++ dof ;~(plug hep gay) :: - @q separator
++ doh ;~(plug ;~(plug hep hep) gay) :: -- phon separator
++ dun (cold ~ ;~(plug hep hep)) :: -- (stop) to ~
++ duz (cold ~ ;~(plug tis tis)) :: == (stet) to ~
@ -5486,6 +5487,11 @@
haf:ab :: star
tiq:ab :: galaxy
==
++ feq %+ cook |=(a=(list @) (rep 4 (flop a)))
;~ plug
;~(pose hif:ab tiq:ab)
(star ;~(pfix dof hif:ab))
==
++ fim (sear den:fa (bass 58 (plus fem:ab)))
++ hex (ape (bass 0x1.0000 ;~(plug qex:ab (star ;~(pfix dog qix:ab)))))
++ lip =+ tod=(ape ted:ab)
@ -5604,6 +5610,20 @@
rep
==
==
::
$q
=* val q.p.lot
:+ '.' '~'
=- =.(rep (weld - rep) rep)
%- tail
%+ roll ?:(=(0 val) ~[0] (rip 3 val))
|= [q=@ s=? r=tape]
:- !s
;: weld
(trip (?:(s tod:po tos:po) q))
?:(&(s !=(r "")) "-" ~)
r
==
::
$r
?+ hay (z-co q.p.lot)
@ -5902,6 +5922,7 @@
(stag %if lip:ag)
royl
(stag %f ;~(pose (cold & (just 'y')) (cold | (just 'n'))))
(stag %q ;~(pfix sig feq:ag))
==
--
::
@ -12572,6 +12593,14 @@
==
::
::
++ calf :: cash but for tec tec
|* tem=rule
%- star
;~ pose
whit
;~(pfix bas tem)
;~(less tem prn)
==
++ cash :: escaped fence
|* tem/rule
%- echo
@ -12676,7 +12705,7 @@
::
:: `classic markdown quote`
::
(stag %code (ifix [tec tec] (cash tec)))
(stag %code (ifix [tec tec] (calf tec)))
::
:: ++arm
::

View File

@ -70,7 +70,6 @@
++ as :: as:go
|_ [our=ship saf=sufi] :: per server
++ lax :: lax:as:go
=| rov=(unit lane) :: maybe lane change
|_ [her=ship dur=dore] :: per client
++ cluy :: cluy:lax:as:go
^- [lyf=life cub=acru] :: client crypto
@ -139,26 +138,6 @@
[~ ryn]
lun.wod.dur
[~ ryn]
::
rov
|- ^- (unit lane)
:: XX jael scry
::
?: ?| !=(our (^sein:title her))
?=(?(%earl %pawn) (clan:title her))
==
~
?- ryn
[%if *] ?. ?=([~ %if *] lun.wod.dur)
`ryn
?:(=(r.u.lun.wod.dur r.ryn) ~ `ryn)
::
[%ix *] ?. ?=([~ %ix *] lun.wod.dur)
`ryn
?:(=(r.u.lun.wod.dur r.ryn) ~ `ryn)
::
[%is *] ?~(q.ryn ~ $(ryn u.q.ryn))
==
==
::
++ wist :: wist:lax:as:go
@ -858,7 +837,6 @@
?| ?=(~ fod)
?=(~ lew.wod.u.fod)
== == == ==
~& [%chew-no-will %drop her]
(emit %beer our ?:(?=(%earl rac) seg her))
=/ oub bust:puz
=/ neg =(~ yed.caq.dur.diz)
@ -1162,10 +1140,8 @@
==
::
++ zank :: zank:ho:um:am
=? bin ?=(^ rov.diz)
[[%maze her u.rov.diz] bin]
%= +>.$ :: resolve
gus (nux:gus diz(rov ~))
gus (nux:gus diz)
wab.weg (~(put by wab.weg) her bah(sop abet:puz))
==
::
@ -1304,11 +1280,6 @@
:_ fox
:~ [s.bon %give %woot q.p.bon r.bon]
==
::
%maze
:_ fox
%+ turn ~(tap in ten.fox)
|=(hen=duct [hen %give %rove p.bon q.bon])
::
%mead :_(fox [[hen [%give %hear p.bon q.bon]] ~])
%milk
@ -1324,7 +1295,20 @@
[[gad.fox [%give %send p.bon q.bon]] ~]
::
%raki
:_ fox [hen [%pass / %j %meet p.p.bon q.p.bon q.bon r.bon]]~
=* our p.p.bon
=* her q.p.bon
=/ moz=(list move)
[hen [%pass / %j %meet our her life=q.bon pass=r.bon]]~
:: poke :dns with an indirect binding if her is a planet we're spnsoring
::
=? moz ?& ?=(%duke (clan:title her))
?=(%king (clan:title our))
=(our (~(sein am [now fox ski]) our now her))
==
=/ cmd [%meet her]
=/ pok [%dns %poke `cage`[%dns-command !>(cmd)]]
:_ moz [hen [%pass / %g %deal [our our] pok]]
[moz fox]
::
%sake
=/ wir=wire
@ -1362,7 +1346,6 @@
?. ?=([%our @ %her @ ~] tea)
~& [%strange-pubs tea]
[~ +>]
~& [%hear-pubs tea sih]
=/ our=ship (slav %p i.t.tea)
=/ her=ship (slav %p i.t.t.t.tea)
=/ gus (need (~(us go ton.fox) our))
@ -1387,7 +1370,6 @@
?. ?=([%our @ ~] tea)
~& [%strange-vein tea]
[~ +>]
~& [%hear-vein tea sih]
=/ our=ship (slav %p i.t.tea)
=. fox (~(vein am [now fox ski]) our life.sih vein.sih)
[~ +>.$]
@ -1452,14 +1434,6 @@
::
%kick
(~(kick am [now fox(hop p.kyz) ski]) hen)
::
%tend
:: XX exclude comets and moons? and planets?
:: ?> &(?=(^ hen) ?=([@ @ *] i.hen))
:: =/ who=@p (slav %p i.t.i.hen)
:: ?: ?=((%earl %pawn) (clan:title who))
:: [~ fox]
[~ fox(ten (~(put in ten.fox) hen))]
::
%nuke
:- ~

View File

@ -678,9 +678,45 @@
=. our ?~(hov our u.hov) :: XX
=. p.top our :: XX necessary?
?- -.kyz
:: new unix process - learn of first boot or a restart.
::
$born
:: XX capture IPs too
:: XX continue to support turf in %born? (currently unused)
:: save outgoing duct
::
=. ged hen
:: give %form to start servers
::
=. mow :_(mow [hen [%give %form fig]])
:: kill active incoming requests
::
=. +>.$
=/ fok=(list duct) ~(tap in ~(key by lyv))
|- ^+ +>.^$
?~ fok +>.^$
%= $
fok t.fok
+>.^$ ^$(hen i.fok, kyz [%thud ~])
==
:: kill active outgoing requests
::
=. +>.$
=/ fok=(list duct) ~(tap in ~(key by kes))
|- ^+ +>.^$
?~ fok +>.^$
%= $
fok t.fok
+>.^$ ^$(hen i.fok, kyz [%them ~])
==
:: if galaxy, request %ames domain from %jael
::
:: %jael response handled in $turf branch of +axon.
::
=? mow ?=(%czar (clan:title our)) :_(mow [hen %pass / %j %turf ~])
:: learn externally known domain names
::
:: If any are new, request certificate. XX currently unused. remove?
:: XX %born card also includes locally-known IPs. use for DNS?
::
::
=/ mod/(set turf)
%- ~(gas in *(set turf))
@ -692,12 +728,7 @@
=? mow ?=(^ dif)
=/ cmd [%acme %poke `cage`[%acme-order !>(dom)]]
:_(mow [hen %pass /acme/order %g %deal [our our] cmd])
=? mow ?=(%czar (clan:title our))
:_(mow [hen %pass / %j %turf ~])
%= +>.$
ged hen :: register external
mow :_(mow [hen [%give %form fig]])
==
+>.$
::
$live
+>.$(clr.por p.kyz, sek.por q.kyz)
@ -1406,7 +1437,7 @@
:_ pok(q t.but)
?+ i.but (slav %p i.but)
$anon anon
$own (fall (ship-from-cookies maf) our)
$own our
==
::
$on
@ -1824,12 +1855,12 @@
(pass-note:abet [%of ire (gsig a)] b)
::
++ init
=. die (add ~d1 now)
=. die (add ~h2 now)
abet(mow :_(mow [`/ %pass ow+/[ire] [%b %wait die]]))
::
++ refresh
=. mow :_(mow [`/ %pass ow+/[ire] [%b %rest die]])
=. die (add ~d1 now)
=. die (add ~h2 now)
done(mow :_(mow [`/ %pass ow+/[ire] [%b %wait die]]))
::
++ add-even
@ -1885,7 +1916,9 @@
::
++ get-quit
|= a/whir-of ^+ ..ix
(get-even [%quit [[(slav %p p.a) q.a] s.a]])
=/ doc=dock [(slav %p p.a) q.a]
=. sus (~(del in sus) [doc %json s.a s.a])
(get-even [%quit [doc s.a]])
::
++ get-ack
|= {a/whir-of b/(unit {term tang})} ^+ ..ix

View File

@ -2063,8 +2063,9 @@
:: dependencies between builds here. For now, though, run them serially.
::
++ run-builds
=< $
~% %run-builds + ~
|-
|.
^- [(list build-receipt) _..execute]
::
=/ build-receipts=(list build-receipt)

View File

@ -143,6 +143,7 @@
%_(+> moz :_(moz [hen %give git]))
::
++ mo-okay :: valid agent core
~/ %mo-okay
|= vax/vase
^- ?
=+ bol=(slew 12 vax)
@ -151,6 +152,7 @@
:: +mo-receive-core: receives an app core built by ford-turbo
::
++ mo-receive-core
~/ %mo-receive-core
|= [dap=dude byk=beak made-result=made-result:ford]
^+ +>
::
@ -210,6 +212,7 @@
[%f %build our live=%.y [%core [[p q]:byk [%hoon dap %app ~]]]]
::
++ mo-away :: foreign request
~/ %mo-away
|= {him/ship caz/cush} ::
^+ +>
:: ~& [%mo-away him caz]
@ -303,6 +306,7 @@
[(slav %p i.pax) i.t.pax da+(slav %da i.t.t.pax)]
::
++ mo-cyst :: take in /sys
~/ %mo-cyst
|= {pax/path sih/sign-arvo}
^+ +>
?+ -.pax !!
@ -428,6 +432,7 @@
==
::
++ mo-cook :: take in /use
~/ %mo-cook
|= {pax/path hin/(hypo sign-arvo)}
^+ +>
?. ?=({@ @ $?($inn $out $cay) *} pax)
@ -472,6 +477,7 @@
byk:(~(got by bum) dap)
::
++ mo-peek
~/ %mo-peek
|= {dap/dude pry/prey ren/@tas tyl/path}
^- (unit (unit cage))
(ap-peek:(ap-abed:ap dap pry) ren tyl)
@ -541,6 +547,7 @@
==
::
++ ap-abed :: initialize
~/ %ap-abed
|= {dap/dude pry/prey}
^+ +>
=: ^dap dap
@ -564,7 +571,7 @@
++ ap-abet :: resolve
^+ +>
=> ap-abut
%_ +>
%_ +>
bum (~(put by bum) dap +<+)
moz :(weld (turn zip ap-aver) (turn dub ap-avid) moz)
==
@ -587,6 +594,7 @@
ap-kill(q.q.pry p.u.tib)
::
++ ap-aver :: cove to move
~/ %ap-aver
|= cov/cove
^- move
:- (~(got by r.zam) p.cov)
@ -627,6 +635,7 @@
(ap-sake p.zem)
::
++ ap-peek
~/ %ap-peek
|= {ren/@tas tyl/path}
^- (unit (unit cage))
=+ ?. ?=($x ren)
@ -668,6 +677,7 @@
==
::
++ ap-diff :: pour a diff
~/ %ap-diff
|= {her/ship pax/path cag/cage}
:: =. q.cag (sped q.cag)
=+ cug=(ap-find [%diff p.cag +.pax])
@ -685,6 +695,7 @@
(ap-pump & her pax)
::
++ ap-pump :: update subscription
~/ %ap-pump
|= {oak/? her/ship pax/path}
=+ way=[(scot %p her) %out pax]
?: oak
@ -796,6 +807,7 @@
==
::
++ ap-move-quit :: give quit move
~/ %quit
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
:_ +>(sup.ged (~(del by sup.ged) sto))
@ -803,6 +815,7 @@
[%& `cove`[sto %give `cuft`[%quit ~]]]
::
++ ap-move-diff :: give diff move
~/ %diff
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
=^ pec vel (~(sped wa vel) vax)
@ -812,6 +825,7 @@
:_(+>.$ [%& sto %give %diff `cage`[-.q.pec tel]])
::
++ ap-move-hiss :: pass %hiss
~/ %hiss
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
?. &(?=({p/* q/* r/@ s/{p/@ *}} q.vax) ((sane %tas) r.q.vax))
@ -835,6 +849,7 @@
[%hiss u.usr r.q.vax [p.q.gaw paw]]
::
++ ap-move-mess :: extract path, target
~/ %mess
|= vax/vase
^- {(each (trel path ship term) tang) _+>}
:_ +>.$
@ -848,6 +863,7 @@
[%& [(scot %p q.q.vax) %out r.q.vax u.pux] q.q.vax r.q.vax]
::
++ ap-move-pass :: pass general move
~/ %pass
|= {sto/bone wut/* vax/vase}
^- {(each cove tang) _+>}
?. &(?=(@ wut) ((sane %tas) wut))
@ -864,6 +880,7 @@
[%meta u.huj (slop (ap-term %tas wut) tel)]
::
++ ap-move-poke :: pass %poke
~/ %poke
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
=^ yep +>.$ (ap-move-mess vax)
@ -878,6 +895,7 @@
[%send q.p.yep r.p.yep %poke p.q.gaw paw]
::
++ ap-move-peel :: pass %peel
~/ %peel
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
=^ yep +>.$ (ap-move-mess vax)
@ -899,6 +917,7 @@
[%send q.p.yep r.p.yep %peel u.mar u.pux]
::
++ ap-move-peer :: pass %peer
~/ %peer
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
=^ yep +>.$ (ap-move-mess vax)
@ -917,6 +936,7 @@
[%send q.p.yep r.p.yep %peer u.pux]
::
++ ap-move-pull :: pass %pull
~/ %pull
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
=^ yep +>.$ (ap-move-mess vax)
@ -929,6 +949,7 @@
[%send q.p.yep r.p.yep %pull ~]
::
++ ap-move-send :: pass gall action
~/ %send
|= {sto/bone vax/vase}
^- {(each cove tang) _+>}
?. ?& ?=({p/* {q/@ r/@} {s/@ t/*}} q.vax)
@ -969,6 +990,7 @@
+>(zip :_(zip [ost %pass pax coh]))
::
++ ap-peep :: reinstall
~/ %ap-peep
|= vax/vase
^+ +>
=+ pep=(ap-prep(hav vax) `hav)
@ -982,6 +1004,7 @@
(ap-peer pax)
::
++ ap-peer :: apply %peer
~/ %ap-peer
|= pax/path
^+ +>
=. sup.ged (~(put by sup.ged) ost [q.q.pry pax])
@ -996,6 +1019,7 @@
?^(cam ap-pule +>.$)
::
++ ap-poke :: apply %poke
~/ %ap-poke
|= cag/cage
^+ +>
=+ cug=(ap-find %poke p.cag ~)
@ -1031,6 +1055,7 @@
+>(misvale (~(put in misvale) wir))
::
++ ap-pour :: generic take
~/ %ap-pour
|= {pax/path vax/vase}
^+ +>
?. &(?=({@ *} q.vax) ((sane %tas) -.q.vax))
@ -1050,6 +1075,7 @@
+>.$
::
++ ap-purr :: unwrap take
~/ %ap-purr
|= {wha/term pax/path cag/cage}
^+ +>
=+ cug=(ap-find [wha p.cag pax])
@ -1089,6 +1115,7 @@
==
::
++ ap-prop :: install
~/ %ap-prop
|= vux/(unit vase)
^- {(unit tang) _+>}
?. (ap-fond %prep)
@ -1132,6 +1159,7 @@
(ap-give:ap-pull %quit ~)
::
++ ap-take :: non-diff gall take
~/ %ap-take
|= {her/ship cog/term pax/path vux/(unit vase)}
^+ +>
=+ cug=(ap-find cog pax)
@ -1146,6 +1174,7 @@
+>.$
::
++ ap-safe :: process move list
~/ %ap-safe
|= vax/vase
^- {(each (list cove) tang) _+>}
?~ q.vax :_(+>.$ [%& ~])
@ -1160,6 +1189,7 @@
[%& p.sud p.res]
::
++ ap-sake :: handle result
~/ %ap-sake
|= vax/vase
^- {(unit tang) _+>}
?: ?=(@ q.vax)
@ -1177,6 +1207,7 @@
==
::
++ ap-save :: verify core
~/ %ap-save
|= vax/vase
^- {(each vase tang) _+>}
=^ gud vel (~(nest wa vel) p.hav p.vax)
@ -1241,7 +1272,6 @@
$perm `%c
$rule `%e
$serv `%e
$tend `%a
$them `%e
$wait `%b
$want `%a
@ -1323,6 +1353,7 @@
==
::
++ scry
~/ %gall-scry
|= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path}
^- (unit (unit cage))
?. ?=(%& -.why) ~
@ -1348,6 +1379,7 @@
`axle`all
::
++ take :: response
~/ %gall-take
|= {tea/wire hen/duct hin/(hypo sign-arvo)}
^+ [p=*(list move) q=..^$]
~| [%gall-take tea]

View File

@ -921,7 +921,6 @@
:: [%vent ~]
::
%vent
~& %west-vent
$(tac [%vent our])
::
::
@ -949,7 +948,7 @@
=* wir t.tea
?- hin
[%a %woot *]
?~ q.hin ~&(%coop-fine +>.$)
?~ q.hin +>.$
?~ u.q.hin ~&(%ares-fine +>.$)
~& [%woot-bad p.u.u.q.hin]
~_ q.u.u.q.hin
@ -1187,7 +1186,7 @@
:: update public key store and notify subscribers
:: of the new state
::
~& [%sending-pubs-about who life.pub live.pub]
:: ~& [%sending-pubs-about who life.pub live.pub]
%+ exec(kyz.puk (~(put by kyz.puk) who pub))
(~(get ju yen.puk) who)
[%give %pubs pub]

View File

@ -494,7 +494,6 @@
$% {$hear p/lane q/@} :: receive packet
{$mack p/(unit tang)} ::
{$mass p/mass} :: memory usage
{$rove p/ship q/lane} :: lane change
{$send p/lane q/@} :: transmit packet
{$turf p/(list turf)} :: bind to domains
{$woot p/ship q/coop} :: reaction message
@ -526,7 +525,6 @@
{$kick p/@da} :: wake up
{$nuke p/@p} :: toggle auto-block
{$sunk p=ship q=life} :: report death
{$tend ~} :: watch lane changes
{$wake ~} :: timer activate
{$wegh ~} :: report memory
{$west p/sack q/path r/*} :: network request
@ -570,7 +568,6 @@
{$bock ~} :: bind to domains
{$brew ~} :: request domains
{$cake p/sock q/soap r/coop s/duct} :: e2e message result
{$maze p/ship q/lane} :: lane change
{$mead p/lane q/rock} :: accept packet
{$milk p/sock q/soap r/*} :: e2e pass message
{$ouzo p/lane q/rock} :: transmit packet
@ -613,7 +610,6 @@
bad/(set @p) :: bad ships
ton/town :: security
zac/(map ship corn) :: flows by server
ten/(set duct) :: watch lanes
== ::
++ hand @uvH :: 128-bit hash
++ lane :: packet route
@ -1168,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

49
tests/app/acme.hoon Normal file
View File

@ -0,0 +1,49 @@
/+ *test
::
/= app /: /===/app/acme
/!noun/
::
|%
:: tests that acme preps without moves
::
++ test-prep
=^ moves app (~(prep app *bowl:gall *acme:app) ~)
%+ expect-eq
!> *(list move:app)
!> moves
:: tests that acme inits on first order
::
++ test-first-order
=/ dom=(set turf) (sy /org/urbit/zod ~)
=^ moves app (~(poke-acme-order app *bowl:gall *acme:app) dom)
=/ msg "requesting an https certificate for zod.urbit.org"
;: weld
%+ expect-eq
!> :~ [ost.bow.app %wait /acme/directory +(now.bow.app)]
[ost.bow.app %flog / %text msg]
==
!> moves
::
%+ expect-eq
!> [~ dom]
!> pen.app
::
%+ expect-eq
!> &
!> !=(*key:rsa:app key.act.app)
::
%+ expect-eq
!> &
!> !=(*key:rsa:app cey.app)
==
:: tests that acme requests service directory on %wake
::
++ test-first-order-wake
=^ moves app (~(wake app *bowl:gall *acme:app) /acme/directory ~)
=/ url
=- (need (de-purl:html -))
'https://acme-staging-v02.api.letsencrypt.org/directory'
%+ expect-eq
!> ~[[ost.bow.app [%hiss /acme/directory/~zod [~ ~] %httr %hiss url %get ~ ~]]]
!> moves
--

14
tests/app/dns.hoon Normal file
View File

@ -0,0 +1,14 @@
/+ *test
::
/= app /: /===/app/dns
/!noun/
::
|%
:: tests that :dns preps without moves
::
++ test-prep
=^ moves app (~(prep app *bowl:gall *state:app) ~)
%+ expect-eq
!> *(list move:app)
!> moves
--

13
tests/bug/gh-703.hoon Normal file
View File

@ -0,0 +1,13 @@
:: list addressing bugs: &33:~ bails out
::
/+ *test
|%
::
++ test-addr-no-hang
%- expect-fail
|. &33:~[[%leaf p="syntax error"] [%leaf p="\{1 11}"]]
::
++ test-addr-no-bail
%- expect-fail
|. &33:~
--

View File

@ -128,7 +128,7 @@
::
%+ expect-eq
!> exp-ws
!> (en-base64url (en:octn (~(sign rs256 k) inp-ws)))
!> (en-base64url (en:octn (~(sign rs256 k) (met 3 inp-ws) inp-ws)))
==
::
++ test-jws-2

View File

@ -301,23 +301,23 @@
'Q8EDWlbDcbjrheZgw6QotIr3wW99fYfMA22ussdXMPXxlMkNa7ReXPlfjigPvF+0shrm'
'/g=='
==
=/ sig=@ux (~(sign rs256 k2) inp2)
=/ sig=@ux (~(sign rs256 k2) (met 3 inp2) inp2)
;: weld
%+ expect-eq
!> exp1
!> (~(sign rs256 k1) inp1)
!> (~(sign rs256 k1) (met 3 inp1) inp1)
::
%+ expect-eq
!> &
!> (~(verify rs256 k1) exp1 inp1)
!> (~(verify rs256 k1) exp1 (met 3 inp1) inp1)
::
%+ expect-eq
!> emsa1
!> `@ux`(~(emsa rs256 k1) inp1)
!> `@ux`(~(emsa rs256 k1) (met 3 inp1) inp1)
::
%+ expect-eq
!> &
!> (~(verify rs256 k2) sig inp2)
!> (~(verify rs256 k2) sig (met 3 inp2) inp2)
::
%+ expect-eq
!> exp2

42
tests/sys/hoon/auras.hoon Normal file
View File

@ -0,0 +1,42 @@
/+ *test
|%
++ test-parse-q
;: weld
%+ expect-eq
!> .~zod
!> `@q`0x0
::
%+ expect-eq
!> .~marbud
!> `@q`0x102
::
%+ expect-eq
!> .~nec-marbud
!> `@q`0x1.0102
::
%+ expect-eq
!> .~marnec-marnec-marnec-marnec-marbud
!> `@q`0x101.0101.0101.0101.0102
::
==
::
++ test-render-q
;: weld
%+ expect-eq
!> '.~zod'
!> (scot %q 0x0)
::
%+ expect-eq
!> '.~marbud'
!> (scot %q 0x102)
::
%+ expect-eq
!> '.~nec-marbud'
!> (scot %q 0x1.0102)
::
%+ expect-eq
!> '.~marnec-marnec-marnec-marnec-marbud'
!> (scot %q 0x101.0101.0101.0101.0102)
::
==
--

View File

@ -1,2 +1,6 @@
^- manx
;div(urb-component "InboxPage");
;div
;div(urb-component "InboxPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "header-inbox");
==

View File

@ -1,5 +1,4 @@
::
:::: /hoon/404/web
::
/? 310
;list(data-source "default", is404 "true");
;div.urb-404-page: 404

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"onboard":true}

View File

@ -1,7 +1,5 @@
/+ collections, colls
/+ collections
/= gas /$ fuel:html
::/= all-colls /: /===/web/collections
:: /collection-web-item/
|%
:: is this collection on the profile?
++ is-pro
@ -9,35 +7,33 @@
visible.meta.col
--
^- manx
;div.profile-page
;input(type "hidden", name "urb-header", value "profile", ship "{(scow %p p.bem.gas)}");
;div
;input(type "hidden", name "urb-metadata", urb-structure-type "header-profile", urb-owner "{(scow %p p.bem.gas)}");
;div.container
;div.row
;div.col-sm-offset-2.col-sm-10
;div.flex-col-2;
;div.flex-col-x
;div.profile-avatar
;div(urb-component "AvatarLg", urb-ship "{(scow %p p.bem.gas)}");
;div(urb-component "Sigil", urb-size "320", urb-ship "{(scow %p p.bem.gas)}", urb-suffix "false");
;div(urb-component "ProfileMsgBtn", urb-ship "{(scow %p p.bem.gas)}");
==
==
==
;div.row
;div.col-sm-offset-2.col-sm-10
;div(urb-component "ChatList", urb-hostship "{(scow %p p.bem.gas)}");
;div.text-600.mt-8: Meta
;div.mt-2.text-500.row
;span.col-sm-2: Started:
;span.col-sm-10.text-mono: ~2018.4.12..6.45.12
==
;div.mt-2.text-500.row
;span.col-sm-2: Issued:
;span.col-sm-10.text-mono
;a(href "/~~/{(scow %p (sein:title p.bem.gas))}/==/web/landscape/profile"): {(scow %p (sein:title p.bem.gas))}
==
==
;div.mt-2.text-500.row
;span.col-sm-2: Events:
;span.col-sm-10.text-mono: 852.129.320
==
;div.row.mt-9
;div.flex-offset-special.flex-col-x
;h2.text-500: Meta
==
==
;div.row.mt-4.align-center
;div.flex-col-2;
;h3.text-500.flex-col-1.mt-0: Started:
;div.flex-col-x.text-mono: ~2018.4.12..6.45.12
==
;div.row.mt-3.align-center
;div.flex-col-2;
;h3.text-500.flex-col-1.mt-0: Issued:
;div.flex-col-x
;a.text-mono(href "/~~/{(scow %p (^sein:title p.bem.gas))}/==/web/landscape/profile"): {(scow %p (^sein:title p.bem.gas))}
==
==
==

View File

@ -0,0 +1,48 @@
/= gas /$ fuel:html
=/ cod=tape
%+ slag 1
%+ scow %p
.^(@p %j /(scot %p p.bem.gas)/code/(scot r.bem.gas)/(scot %p p.bem.gas))
^- manx
;div
;input(type "hidden", name "urb-metadata", urb-structure-type "header-profile", urb-owner "{(scow %p p.bem.gas)}");
;div.container(urb-devices "")
;div.row.mt-4
;div.flex-col-2;
;div.flex-col-x
;a.vanilla.btn.btn-primary(href (trip 'javascript:(function(){document.querySelectorAll("[urb-devices]")[0].classList.add("hide"); document.querySelectorAll("[urb-qr]")[0].classList.remove("hide");})()')): Connect device
;h2.mt-6: Devices
;h3.text-mono.mt-4: 108.208.53.121
;div: Current session
;h3.text-mono.mt-4: 67.188.43.52
;div: Chrome on OS X 10.12.6
;div
;span.mr-3: Last login:
;span.text-mono: 2018.4.21
==
;h3.text-mono.mt-4: 43.222.12.64
;div: iOS 14.11
;div
;span.mr-3: Last login:
;span.text-mono: 2018.3.12
==
;div.mt-6
;a.h3.vanilla.text-red(href "javascript:void(0)"): Log Out ↓
==
==
==
==
;div.container.hide(urb-qr "")
;div.row.mt-4
;div.flex-col-2;
;div.flex-col-x
;div
=urb-component "QRCodeComponent"
=urb-ship "{(scow %p p.bem.gas)}"
=urb-code "{cod}";
;h2.mt-8.mt-0.text-500.profile-qr-desc: Scan this code to connect your device
;a.mt-4.vanilla.btn.btn-primary(href (trip 'javascript:(function(){document.querySelectorAll("[urb-qr]")[0].classList.add("hide"); document.querySelectorAll("[urb-devices]")[0].classList.remove("hide");})()')): Done
==
==
==
==

View File

@ -2,5 +2,5 @@
;div
;div(urb-component "ChatPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "stream");
;input(type "hidden", name "urb-metadata", urb-structure-type "stream-chat");
==

View File

@ -1,6 +1,6 @@
^- manx
;div
;div(urb-component "InboxPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "inbox");
;div(urb-component "WelcomePage");
;input(type "hidden", name "urb-metadata", urb-structure-type "welcome");
==