tangled
alpha
login
or
join now
rockorager.dev
/
ourio
6
fork
atom
An asynchronous IO runtime
6
fork
atom
overview
issues
pulls
pipelines
dns: add SRV
rockorager.dev
10 months ago
6ed0e45a
510c7448
verified
This commit was signed with the committer's
known signature
.
rockorager.dev
SSH Key Fingerprint:
SHA256:qn/Fjy7CpbcogGEPB14Y53hLnQleZNFY9lkQnuudFLs=
+39
-1
1 changed file
expand all
collapse all
unified
split
src
stda
net
dns.zig
+39
-1
src/stda/net/dns.zig
···
250
250
// MX = 15,
251
251
// TXT = 16,
252
252
AAAA = 28,
253
253
-
// SRV = 33,
253
253
+
SRV = 33,
254
254
// OPT = 41,
255
255
};
256
256
257
257
pub const Answer = union(ResourceType) {
258
258
A: [4]u8,
259
259
AAAA: [16]u8,
260
260
+
SRV: struct {
261
261
+
priority: u16,
262
262
+
weight: u16,
263
263
+
port: u16,
264
264
+
target: []const u8,
265
265
+
},
260
266
};
261
267
262
268
pub const Response = struct {
···
347
353
self.bytes[self.offset + 13],
348
354
self.bytes[self.offset + 14],
349
355
self.bytes[self.offset + 15],
356
356
+
} };
357
357
+
},
358
358
+
359
359
+
.SRV => {
360
360
+
assert(rd_len > 6);
361
361
+
const rdata = self.bytes[self.offset..];
362
362
+
const priority = std.mem.readInt(u16, rdata[0..2], .big);
363
363
+
const weight = std.mem.readInt(u16, rdata[2..4], .big);
364
364
+
const port = std.mem.readInt(u16, rdata[4..6], .big);
365
365
+
366
366
+
var buf: [256]u8 = undefined;
367
367
+
var idx: usize = 0;
368
368
+
var offset: usize = 6;
369
369
+
while (true) {
370
370
+
const len = rdata[offset];
371
371
+
if (len == 0x00) break;
372
372
+
373
373
+
if (idx > 0) {
374
374
+
buf[idx] = '.';
375
375
+
idx += 1;
376
376
+
}
377
377
+
offset += 1;
378
378
+
@memcpy(buf[idx .. idx + len], rdata[offset .. offset + len]);
379
379
+
offset += len;
380
380
+
idx += len;
381
381
+
}
382
382
+
383
383
+
return .{ .SRV = .{
384
384
+
.priority = priority,
385
385
+
.weight = weight,
386
386
+
.port = port,
387
387
+
.target = buf[0..idx],
350
388
} };
351
389
},
352
390
}