From d66bf141966877efd877fb674e108f7db4383e66 Mon Sep 17 00:00:00 2001 From: jet2tlf Date: Mon, 3 Jun 2024 02:09:22 -0300 Subject: codecrafters submit [skip ci] --- app/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/main.go') 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 +} -- cgit v1.2.3