
This looks related to the conversation in #general , so I added my 2 cents over there.

about concurrency trickery

@notjack I’ve got authority
s “working” in axon
.

And some practical insights, hopefully.

The objective was to implement just barely enough of net2
to change this: (define (tcp-client make-codec [remote '("localhost" 3600)])
(define σ (apply-values (apply tcp-connect server-addr) codec-factory))
into this: (define (tcp-client make-codec [remote (authority "localhost.:3600")])
(define host (authority-host remote))
(define port (authority-port remote))
(define σ (apply-values (tcp-connect host port) make-codec))

So now I have regexp parsers for IPv4address
, IP-literal
(except IPvFuture
), and reg-name
, lifted from the grammar in RFC 3986.

and I can create ip4
, ip6
, and dns
instances and package them in an authority

I needed a lot of string->
and ->string
functions internally.

My authority
constructor take a string argument, since it’s convenient. I’d also like the other exported constructors to work the same.

I don’t really understand the point of storing labels as length-prefixed byte strings, or the dns-root-label
.

@dedbox fantastic, hopefully the parsing code can be moved/copied to net2
pretty easily

the labels and root thing is because DNS names are very strange

there’s two specs - one spec defines what names are possible, and the other defines what subset of those names are “well behaved”

basically the URI RFC has a SHOULD rule that says reg-name values should be those well behaved names, but technically any name at all can be included via percent encoding

the possible names are basically “anything at all joined with dots”

you can stick unprintable bytes in dns names…

Where should I stick this code so you can see it?

the axon repo you linked originally seems like a decent place

The axon part is like 4 lines.

Everything else is in net2/data
.

oh! a pull request to net2 then? haven’t set up any CI stuff yet though

I could stick the data.rkt
file in the axon repo

that could also work, at least as a holding place while CI is set up


fantastic

:laughing:

I’m particularly proud of all the regexp gymnastics.

good old regexps - the only reliable way to stick a parser in a spec

For kicks, here’s the actual regexp being generated: (?:^((?:\[(?:(?:(?:(?:(?:[0-9A-F]{1,4}):){6})(?:(?:(?:[0-9A-F]{1,4}):)(?:[0-9A-F]{1,4})\|(?:(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])(?:\.(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])){3}))\|::(?:(?:(?:[0-9A-F]{1,4}):){5})(?:(?:(?:[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4][0-9]\|25[0-5])){3}))\|(?:(?:(?:(?:[0-9A-F]{1,4}):){,4})(?:[0-9A-F]{1,4}))?::(?:(?:(?:[0-9A-F]{1,4}):)(?:[0-9A-F]{1,4})\|(?:(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])(?:\.(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])){3}))\|(?:(?:(?:(?:[0-9A-F]{1,4}):){,5})(?:[0-9A-F]{1,4}))?::(?:[0-9A-F]{1,4})\|(?:(?:(?:(?:[0-9A-F]{1,4}):){,6})(?:[0-9A-F]{1,4}))?::)\|(?:v[0-9A-F]+\.(?:(?:[A-Za-z]\|[0-9]\|[-._~])\|[!$&'()*+,;=]\|:)+))\])\|(?:(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])(?:\.(?:[0-9]\|[1-9][0-9]\|1[0-9][0-9]\|2[0-4][0-9]\|25[0-5])){3})\|(?:(?:(?:[A-Za-z]\|[0-9]\|[-._~])\|(?:%[0-9A-F][0-9A-F])\|[!$&'()*+,;=])+))(?::([0-9]+))?)

dang

1954 characters. I hope Racket can handle that.