mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Improve SRV handling in dns_windows.odin
This commit is contained in:
+18
-14
@@ -128,33 +128,37 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
|
|||||||
append(&recs, record)
|
append(&recs, record)
|
||||||
|
|
||||||
case .SRV:
|
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'
|
// NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname'
|
||||||
// The record name is the name of the record.
|
// 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
|
// 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.
|
// 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.
|
service_name, protocol_name: string
|
||||||
// It's already cloned, after all. I wouldn't put them on the temp allocator like this.
|
|
||||||
|
|
||||||
parts := strings.split_n(base_record.record_name, ".", 3, context.temp_allocator)
|
s := base_record.record_name
|
||||||
if len(parts) != 3 {
|
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
|
continue
|
||||||
}
|
}
|
||||||
service_name, protocol_name := parts[0], parts[1]
|
|
||||||
|
|
||||||
append(&recs, DNS_Record_SRV {
|
append(&recs, DNS_Record_SRV {
|
||||||
base = base_record,
|
base = base_record,
|
||||||
target = target,
|
target = strings.clone(string(r.Data.SRV.pNameTarget)), // The target hostname/address that the service can be found on
|
||||||
port = port,
|
port = int(r.Data.SRV.wPort),
|
||||||
service_name = service_name,
|
service_name = service_name,
|
||||||
protocol_name = protocol_name,
|
protocol_name = protocol_name,
|
||||||
priority = priority,
|
priority = int(r.Data.SRV.wPriority),
|
||||||
weight = weight,
|
weight = int(r.Data.SRV.wWeight),
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user