aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjet2tlf <jet2tlf@gmail.com>2024-06-03 05:09:22 +0000
committerjet2tlf <jet2tlf@gmail.com>2024-06-03 05:09:22 +0000
commitd66bf141966877efd877fb674e108f7db4383e66 (patch)
tree7818ed49682328f2b707940997caa31c4edbf476
parent747d0b3ec57e31196922b7a4d512e36621cb67fc (diff)
downloaddns-server-go-d66bf141966877efd877fb674e108f7db4383e66.tar.gz
dns-server-go-d66bf141966877efd877fb674e108f7db4383e66.zip
codecrafters submit [skip ci]
-rw-r--r--app/main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/main.go b/app/main.go
index 46da46d..b9be1e5 100644
--- a/app/main.go
+++ b/app/main.go
@@ -31,7 +31,9 @@ func main() {
receivedData := string(buf[:size])
fmt.Printf("Received %d bytes from %s: %s\n", size, source, receivedData)
- response := []byte{}
+ response := make([]byte, 12)
+ copy(response, buf[:12])
+ response[2] = flipIndicator(response[2])
_, err = udpConn.WriteToUDP(response, source)
if err != nil {
@@ -39,3 +41,7 @@ func main() {
}
}
}
+
+func flipIndicator(b byte) byte {
+ return b | 0b10000000
+}