This is a DNS application server. It executes JavaScript to respond to DNS requests, and provides libraries for caching, global data storage, and outbound DNS/HTTP requests.
You can use this project to build custom DNS services — both authoritative servers and resolvers. It's quicker and easier to do complicated DNS work with Fly than it is to build a DNS service from scratch, especially if you already know JavaScript.
The real power is in running other peoples' code, however. It's designed to be deployed around the world, run untrusted applications built by not-you and make DNS development accessible to more developers.
DNS application code runs in v8 isolates with strict memory limits. The runtime accepts requests, parses them, and hands structured data over to application code.
Download the latest release for your platform, ungzip and put the binary somewhere
Not yet done. Relevant issue: #9
fly-dns --port 8053 relative/path/to/file.js
// Handle an event for a DNS request
addEventListener("resolv", event => {
event.respondWith( // this function responds to the DNS request event
resolv( // the resolv function resolves DNS queries
event.request.name // requested record name
)
)
})
addEventListener("resolv", event => {
event.respondWith(function () { // can respond with a function
return new DNSResponse([ // list of DNS answers
{
name: event.request.queries[0].name, // name of the DNS entry
rrType: DNSRecordType.A, // record type
ttl: 300, // time-to-live for the client
data: {ip: "127.0.0.1"} // data for the record
}
], { authoritative: true })
})
})
The Fly runtime was originally derived from deno and shares some of the same message passing semantics. It has diverged quite a bit, but when possible we'll be contributing code back to deno.
There's an issue: #5
wget -qO- https://github.com/superfly/libv8/releases/download/7.2.502.13/v8-osx-x64.tar.gz | tar xvz -C libfly
cd v8env
yarn install
rollup -c
cd ..
cargo run --bin dns hello-world.js
- Runtime tests:
cargo test
- Javascript tests
cargo run --bin fly test "v8env/tests/**/*.spec.js"