1
0
Fork 0
mirror of https://github.com/SamTherapy/dnscrypt.git synced 2024-12-22 00:50:42 +00:00
Fork of a Golang DNSCrypt v2 protocol implementation + a command-line tool
Find a file
2019-01-22 13:29:29 +03:00
xsecretbox fix dependency 2018-12-25 01:39:34 +03:00
.codecov.yml Init 2018-12-17 01:55:58 +03:00
.gitignore Init 2018-12-17 01:55:58 +03:00
.gometalinter.json Fix adjustPayloadSize method 2019-01-22 13:13:41 +03:00
.travis.yml enable modules 2018-12-17 02:07:04 +03:00
dnscrypt.go Remove Proto from ServerInfo 2019-01-22 13:29:29 +03:00
dnscrypt_test.go Fix adjustPayloadSize method 2019-01-22 13:13:41 +03:00
doc.go fix mistake in the doc 2018-12-17 12:04:31 +03:00
go.mod Fix adjustPayloadSize method 2019-01-22 13:13:41 +03:00
go.sum Fix adjustPayloadSize method 2019-01-22 13:13:41 +03:00
LICENSE Init 2018-12-17 01:55:58 +03:00
README.md fix mistake in the doc 2018-12-17 12:04:31 +03:00

Build Status Code Coverage Go Report Card Go Doc

DNSCrypt Client

This is a very simple DNSCrypt client library written in Go.

The idea is to let others use DNSCrypt resolvers in the same manner as we can use regular and DoT resolvers with miekg's DNS library. Unfortunately, I have not found an easy way to use dnscrypt-proxy as a dependency so here's why this library was created.

Usage

    // AdGuard DNS stamp
    stampStr := "sdns://AQIAAAAAAAAAFDE3Ni4xMDMuMTMwLjEzMDo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20"
    
    // Initializing the DNSCrypt client
    c := dnscrypt.Client{Proto: "udp", Timeout: 10 * time.Second}
    
    // Fetching and validating the server certificate
    serverInfo, rtt, err := client.Dial(stampStr)
    
    // Create a DNS request
    req := dns.Msg{}
    req.Id = dns.Id()
    req.RecursionDesired = true
    req.Question = []dns.Question{
        {Name: "google-public-dns-a.google.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET},
    }
    
    // Get the DNS response
    reply, rtt, err := c.Exchange(&req, serverInfo)