Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
/ rawdns Public archive
forked from cirocosta/rawdns

[W.I.P] DNS messages (un)marshaller

License

Notifications You must be signed in to change notification settings

0x2E/rawdns

 
 

Repository files navigation

rawdns

DNS messages (un)marshaller

Overview

This project is forked from cirocosta/rawdns and has been modified to make it more suitable for constructing and parsing the UDP packet of DNS.

For complete DNS functionality, see miekg/dns.

Example

package main

import (
	"github.com/0x2E/rawdns"
	"net"
)

func main() {
	// create socket
	conn, _ := net.Dial("udp", "8.8.8.8:53")
	defer conn.Close()

	// construct DNS packet content
	payload, _ := rawdns.Marshal(33, 1, "github.com", rawdns.QTypeA)

	// send UDP packet
	_, _ = conn.Write(payload)

	// receive UDP packet
	buf := make([]byte, 0, 1024)
	n, _ := conn.Read(buf)

	// parse
	resp, _ := rawdns.Unmarshal(buf[:n])
}

About

[W.I.P] DNS messages (un)marshaller

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%