mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-17 08:34:08 +00:00
Improve SRV handling in dns_windows.odin
This commit is contained in:
@@ -128,33 +128,37 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
|
||||
append(&recs, record)
|
||||
|
||||
case .SRV:
|
||||
target := strings.clone(string(r.Data.SRV.pNameTarget)) // The target hostname/address that the service can be found on
|
||||
priority := int(r.Data.SRV.wPriority)
|
||||
weight := int(r.Data.SRV.wWeight)
|
||||
port := int(r.Data.SRV.wPort)
|
||||
|
||||
// NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname'
|
||||
// The record name is the name of the record.
|
||||
// Not to be confused with the _target_ of the record, which is--in combination with the port--what we're looking up
|
||||
// by making this request in the first place.
|
||||
|
||||
// NOTE(Jeroen): Service Name and Protocol Name can probably just be string slices into the record name.
|
||||
// It's already cloned, after all. I wouldn't put them on the temp allocator like this.
|
||||
service_name, protocol_name: string
|
||||
|
||||
parts := strings.split_n(base_record.record_name, ".", 3, context.temp_allocator)
|
||||
if len(parts) != 3 {
|
||||
s := base_record.record_name
|
||||
i := strings.index_byte(s, '.')
|
||||
if i > -1 {
|
||||
service_name = s[:i]
|
||||
s = s[len(service_name) + 1:]
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
i = strings.index_byte(s, '.')
|
||||
if i > -1 {
|
||||
protocol_name = s[:i]
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
service_name, protocol_name := parts[0], parts[1]
|
||||
|
||||
append(&recs, DNS_Record_SRV {
|
||||
base = base_record,
|
||||
target = target,
|
||||
port = port,
|
||||
target = strings.clone(string(r.Data.SRV.pNameTarget)), // The target hostname/address that the service can be found on
|
||||
port = int(r.Data.SRV.wPort),
|
||||
service_name = service_name,
|
||||
protocol_name = protocol_name,
|
||||
priority = priority,
|
||||
weight = weight,
|
||||
priority = int(r.Data.SRV.wPriority),
|
||||
weight = int(r.Data.SRV.wWeight),
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user