aboutsummaryrefslogtreecommitdiff
path: root/app/main.go
diff options
context:
space:
mode:
authorjet2tlf <jet2tlf@gmail.com>2024-06-03 05:43:21 +0000
committerjet2tlf <jet2tlf@gmail.com>2024-06-03 05:43:21 +0000
commitddaa6d76691453203459038a35aae5aa086dfad4 (patch)
tree54a651954fa57bd9cdf190ffc9aab4e71fc0e425 /app/main.go
parent57e0aa0ac0c6efd1dd50b354826cc21b6a5ffdc1 (diff)
downloaddns-server-go-ddaa6d76691453203459038a35aae5aa086dfad4.tar.gz
dns-server-go-ddaa6d76691453203459038a35aae5aa086dfad4.zip
codecrafters submit [skip ci]
Diffstat (limited to 'app/main.go')
-rw-r--r--app/main.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/main.go b/app/main.go
index 6831c5c..79e3b82 100644
--- a/app/main.go
+++ b/app/main.go
@@ -30,19 +30,25 @@ func main() {
receivedData := string(buf[:size])
fmt.Printf("Received %d bytes from %s: %s\n", size, source, receivedData)
+ requestHeader := ParseHeader(buf[:size])
+
+ rcode := uint8(4)
+ if requestHeader.OPCODE == 0 {
+ rcode = 0
+ }
header := DNSHeader{
- ID: 1234,
+ ID: requestHeader.ID,
QR: 1,
- OPCODE: 1,
+ OPCODE: requestHeader.OPCODE,
AA: 0,
TC: 0,
- RD: 0,
+ RD: requestHeader.RD,
RA: 0,
Z: 0,
- RCODE: 0,
+ RCODE: rcode,
QDCOUNT: 1,
- ANCOUNT: 1,
+ ANCOUNT: 0,
NSCOUNT: 0,
ARCOUNT: 0,
}