Build to Learn: DNS Server in Zig - Part 14

Опубликовано: 09 Август 2026
на канале: Sourcerer
128
4

Building a DNS Server from Scratch in Zig! After completing Ziglings, I'm taking on the #codecrafters DNS challenge to push deeper into systems programming. Live and unfiltered.

So, finally, in the last session, I managed to solve the compressed question section parsing, caused by the drift on the offsets (I was using header length, while the function wasn't getting the header portion). In today's session, I'm going to continue my progress and resolve the issue of using label format in the response.
I'm sure it'll be fun, so CHALLENGE ACCEPTED 💪🏼🤓.

Related Playlists:
   • Build to Learn: DNS Server in Zig  
   • Ziglings: Livecoding  

Notes:
✅ Session 1: https://sourcery.zone/articles/2025/0...
✅ Session 2: https://sourcery.zone/articles/2025/0...
✅ Session 3: https://sourcery.zone/articles/2025/0...
✅ Session 4: https://sourcery.zone/articles/2025/0...
✅ Session 5: https://sourcery.zone/articles/2025/0...
✅ Session 6, 7, and 8: https://sourcery.zone/articles/2025/0...
✅ Session 9, and 10: https://sourcery.zone/articles/2025/0...
⭐ Sessions 11 to 17: https://sourcery.zone/articles/2025/1...

Reach out and Chat
Matrix: https://matrix.to/#/#sourcery-zone:matrix.org

Timestamps
00:00:00 Stream Warm Up
00:00:52 test still failing with cryptic error
00:01:27 GPT feedback applied, label format dropped
00:02:10 fix: compress answers, tests pass
00:02:58 recap: use pointer not raw label
00:03:16 track label_start per question
00:03:50 write 2-byte pointer in answer
00:04:06 answer size = 12 + data len
00:04:33 note: only low byte of pointer used
00:05:30 refactor plan: single-question only
00:06:11 next: make forwarding DNS server
00:07:20 add caching via TTL
00:07:52 parse CLI args for resolver IP
00:08:43 manual argv scan example
00:09:56 alt parser with optional port
00:10:41 split IPv4, parseInt octets
00:12:04 struct Args { ip, port }
00:12:58 net.Address.initIp4 + defaults
00:13:56 query() → sendto() + recvfrom()
00:15:02 CodeCrafters: A records only
00:15:33 handle multi-Q by split + merge
00:16:14 todo: Question/Answer toBytes()
00:16:56 rename to arguments.zig
00:17:46 learned CLI + UDP socket flow

#zig #lowlevelprogramming #systemprogramming #coding #codinglive