@@ -49,8 +49,8 @@ init_dns_configuration :: proc() {
4949 /*
5050 Resolve %ENVIRONMENT% placeholders in their paths.
5151 */
52- dns_configuration.resolv_conf, _ = replace_environment_path (dns_configuration.resolv_conf)
53- dns_configuration.hosts_file, _ = replace_environment_path (dns_configuration.hosts_file)
52+ dns_configuration.resolv_conf = os. replace_environment_placeholders (dns_configuration.resolv_conf)
53+ dns_configuration.hosts_file = os. replace_environment_placeholders (dns_configuration.hosts_file)
5454}
5555
5656@ (fini, private)
@@ -63,28 +63,6 @@ destroy_dns_configuration :: proc() {
6363
6464dns_configuration := DEFAULT_DNS_CONFIGURATION
6565
66- // Always allocates for consistency.
67- replace_environment_path :: proc (path: string , allocator := context .allocator) -> (res: string , ok: bool ) {
68- // Nothing to replace. Return a clone of the original.
69- if strings.count (path, " %" ) != 2 {
70- return strings.clone (path, allocator), true
71- }
72-
73- left := strings.index (path, " %" ) + 1
74- assert (left > 0 && left <= len (path)) // should be covered by there being two %
75-
76- right := strings.index (path[left:], " %" ) + 1
77- assert (right > 0 && right <= len (path)) // should be covered by there being two %
78-
79- env_key := path[left: right]
80- env_val := os.get_env (env_key, allocator)
81- defer delete (env_val)
82-
83- res, _ = strings.replace (path, path[left - 1 : right + 1 ], env_val, 1 , allocator)
84- return res, true
85- }
86-
87-
8866/*
8967 Resolves a hostname to exactly one IP4 and IP6 endpoint.
9068 It's then up to you which one you use.
0 commit comments