Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zevv/janet-dns
Asynchronous DNS resolver library for the Janet language.
https://github.com/zevv/janet-dns
async dns janet resolver
Last synced: about 1 month ago
JSON representation
Asynchronous DNS resolver library for the Janet language.
- Host: GitHub
- URL: https://github.com/zevv/janet-dns
- Owner: zevv
- License: mit
- Created: 2023-05-13T13:46:49.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-14T20:33:18.000Z (over 1 year ago)
- Last Synced: 2024-12-16T01:37:24.180Z (about 1 month ago)
- Topics: async, dns, janet, resolver
- Language: Janet
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Introduction
This is a proof-of-concept async DNS resolver library for the Janet programming
language. This code is not at all production ready, as it only implements the
happy path and has virtually no error handling.## Description
Address resolution is a complicated task that is usually performed by the libc
standard library using `getaddrinfo()` or similar calls. The Janet standard
library also uses this call for resolving when calling `net/address`; this can
be problematic because `getaddrinfo()` can potentially block for several
seconds, effectively blocking the current Janet thread and it's event loop as
well.This library implements a very simply DNS resolver that does not rely on the
libc standard library functions; instead it communicates directly with DNS
servers to perform the lookup, allowing for proper async behavior that will not
block the event loop.Note that the resolving behavior of this library is by no means standard and
might differ from the underlying libc implementation; also, it will only use
DNS for resolution and does not implement any other source like a local hosts
file.## Example
```janet
(import ./resolver)# Create resolver instance
(def res (resolver/new "8.8.4.4"))
# Call the :resolve method to perform a DNS lookup
(defn test[]
(ev/sleep 0.1)
(pp (:resolve res "nyt.com"))
(ev/sleep 0.1)
(pp (:resolve res "google.com" :AAAA)))(ev/call test)
```## TODO and Open questions
- Improve error handling
- Acquire DNS server IPs from system resolver configuration
- Cache resceived answers with proper time-to-live
- Implement TCP/53
- Primary/secondary server fallback