diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-06-13 17:49:05 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-06-13 17:49:05 +0200 |
| commit | 3862555153611cf53b1f0fec72889d4dae64fde2 (patch) | |
| tree | f83b4e29d6dceb096204c43e65ef39e7ef2b2424 /core/net | |
| parent | fe9f74f7a2d4a73d59020357e81ed8ebadeeae1f (diff) | |
Replace core:posix usage in core:os/os2
Diffstat (limited to 'core/net')
| -rw-r--r-- | core/net/dns.odin | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/core/net/dns.odin b/core/net/dns.odin index 7eb543db3..a54242549 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -49,8 +49,8 @@ init_dns_configuration :: proc() { /* Resolve %ENVIRONMENT% placeholders in their paths. */ - dns_configuration.resolv_conf, _ = replace_environment_path(dns_configuration.resolv_conf) - dns_configuration.hosts_file, _ = replace_environment_path(dns_configuration.hosts_file) + dns_configuration.resolv_conf = os.replace_environment_placeholders(dns_configuration.resolv_conf) + dns_configuration.hosts_file = os.replace_environment_placeholders(dns_configuration.hosts_file) } @(fini, private) @@ -63,28 +63,6 @@ destroy_dns_configuration :: proc() { dns_configuration := DEFAULT_DNS_CONFIGURATION -// Always allocates for consistency. -replace_environment_path :: proc(path: string, allocator := context.allocator) -> (res: string, ok: bool) { - // Nothing to replace. Return a clone of the original. - if strings.count(path, "%") != 2 { - return strings.clone(path, allocator), true - } - - left := strings.index(path, "%") + 1 - assert(left > 0 && left <= len(path)) // should be covered by there being two % - - right := strings.index(path[left:], "%") + 1 - assert(right > 0 && right <= len(path)) // should be covered by there being two % - - env_key := path[left: right] - env_val := os.get_env(env_key, allocator) - defer delete(env_val) - - res, _ = strings.replace(path, path[left - 1: right + 1], env_val, 1, allocator) - return res, true -} - - /* Resolves a hostname to exactly one IP4 and IP6 endpoint. It's then up to you which one you use. |