diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2024-08-24 18:43:25 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2024-08-24 18:43:25 +0200 |
| commit | 0a825fc44d8923a8e5977d5f233db4a387f1faef (patch) | |
| tree | 6cefa2425babded0a3d4783bc819002149258c49 /core/net/dns_windows.odin | |
| parent | aa659a637a70af21feb60ee08c11c46718defa30 (diff) | |
Improve SRV handling in dns_windows.odin
Diffstat (limited to 'core/net/dns_windows.odin')
| -rw-r--r-- | core/net/dns_windows.odin | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/core/net/dns_windows.odin b/core/net/dns_windows.odin index b7af050b1..1b7fe7196 100644 --- a/core/net/dns_windows.odin +++ b/core/net/dns_windows.odin @@ -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 + + 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 + } - parts := strings.split_n(base_record.record_name, ".", 3, context.temp_allocator) - if len(parts) != 3 { + 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), }) } |