Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dnslink-std/go
The reference implementation for DNSLink in golang.
https://github.com/dnslink-std/go
decentralized-web dnslink dweb golang p2p
Last synced: about 1 month ago
JSON representation
The reference implementation for DNSLink in golang.
- Host: GitHub
- URL: https://github.com/dnslink-std/go
- Owner: dnslink-std
- License: other
- Created: 2021-06-27T14:12:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-06T08:21:13.000Z (over 2 years ago)
- Last Synced: 2024-06-20T03:45:49.234Z (6 months ago)
- Topics: decentralized-web, dnslink, dweb, golang, p2p
- Language: Go
- Homepage:
- Size: 145 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dnslink-std/go
The reference implementation for DNSLink in golang.
## Usage
You can use dnslink both as code and as an CLI tool.
## Golang API
Getting started with the dnslink in a jiffy:
```go
import {
dnslink "github.com/dnslink-std/go"
}result, error := dnslink.Resolve("dnslink.dev")
if error != nil {
switch e := error.(type) {
default:
// A variety other errors may be returned. Possible causes include, but are not limited to:
// - Invalid input
// - Timeouts / aborts
// - Networking errors
// - Incompatible dns packets provided by server
panic(e)
case dnslink.DNSRCodeError:
err.DNSRCode // Error code number following - https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6
err.Name // Error code name following (same list)
err.Code // "RCODE_%s", err.RCode
err.Domain // Domain lookup that resulted in the error
if e.RCode == 3 {
// NXDomain = Domain not found; most relevant error
}
}
}// `links` property is a map[string][]string containing given links for the different keys, sorted.
result.Links["ipfs"][0] == "QmTg....yomU"// The `log` is always an Array and contains a list of log entries
// that were should help to trace back how the linked data was resolved.
result.Log// The `txtEntries` are a reduced form of the links that contains the namespace
// as part of the value.
result.TxtEntries === [{ value: "/ipfs/QmTg....yomU", ttl: 60 }]
```You can configure the DNS resolution
```go
import {
"net"
"context"
"time"
}resolver := &dnslink.Resolver{
LookupTXT: dnslink.NewUDPLookup("1.1.1.1:53"),
}// The resolver will now use googles 1.1.1.1 dns server.
resolver.Resolve("dnslink.dev")
```## Possible log statements
The `dnslink.LogStatements` in the `log` all follow the [DNSLink specification][log-codes].
[log-codes]: https://github.com/dnslink-std/test/blob/main/LOG_CODES.md
## Command Line
To get the [command line tool](./dnslink) you can either install it using `go get`
```sh
go get -u github.com/dnslink-std/go/dnslink
```Or download a binary asset from the github [release page](https://github.com/dnslink-std/go/releases/latest).
You can get detailed help for the app by passing a `--help` option at the end:
```sh
dnslink --help
```## License
Published under dual-license: [MIT OR Apache-2.0](./LICENSE)