package main

import (
	"github.com/cunnie/sslip.io/src/xip"
	"log"
	"net"
)

func main() {
	conn, err := net.ListenUDP("udp", &net.UDPAddr{Port: 53})
	if err != nil {
		log.Fatal(err.Error())
	}

	query := make([]byte, 512)

	for {
		_, addr, err := conn.ReadFromUDP(query)
		if err != nil {
			log.Println(err.Error())
			break
		}

		response, err := xip.QueryResponse(query)
		if err != nil {
			log.Println(err.Error())
			break
		}
		_, err = conn.WriteToUDP(response, addr)
	}
}

package main

import (
	"github.com/cunnie/sslip.io/src/xip"
	"log"
	"net"
)

func main() {
	conn, err := net.ListenUDP("udp", &net.UDPAddr{Port: 53})
	if err != nil {
		log.Fatal(err.Error())
	}

	query := make([]byte, 512)

	for {
		_, addr, err := conn.ReadFromUDP(query)
		if err != nil {
			log.Println(err.Error())
			break
		}

		go func() {
			response, err := xip.QueryResponse(query)
			if err != nil {
				log.Println(err.Error())
				break
			}
			_, err = conn.WriteToUDP(response, addr)
		}()
	}
}

Handle DNS query's processing in a separate thread
Handle DNS query's processing in a separate thread

...because I can. And because it gives me a reason to use `go func()`
