|
5 | 5 | #include <stdint.h>
|
6 | 6 | #include <stdlib.h>
|
7 | 7 |
|
8 |
| -typedef struct HashSet_ProxyConfig HashSet_ProxyConfig; |
9 |
| - |
10 |
| -typedef struct EphemeralPeerCancelToken { |
11 |
| - void *context; |
12 |
| -} EphemeralPeerCancelToken; |
| 8 | +typedef struct EncryptedDnsProxyState EncryptedDnsProxyState; |
13 | 9 |
|
14 | 10 | typedef struct ProxyHandle {
|
15 | 11 | void *context;
|
16 | 12 | uint16_t port;
|
17 | 13 | } ProxyHandle;
|
18 | 14 |
|
19 |
| -typedef struct EncryptedDnsProxyState { |
20 |
| - struct HashSet_ProxyConfig configurations; |
21 |
| - bool has_tried_xor; |
22 |
| - struct HashSet_ProxyConfig tried_configurations; |
23 |
| -} EncryptedDnsProxyState; |
| 15 | +typedef struct EphemeralPeerCancelToken { |
| 16 | + void *context; |
| 17 | +} EphemeralPeerCancelToken; |
24 | 18 |
|
25 | 19 | extern const uint16_t CONFIG_SERVICE_PORT;
|
26 | 20 |
|
| 21 | +/** |
| 22 | + * Initializes a valid pointer to an instance of `EncryptedDnsProxyState`. |
| 23 | + */ |
| 24 | +struct EncryptedDnsProxyState *encrypted_dns_proxy_init(void); |
| 25 | + |
| 26 | +/** |
| 27 | + * This must be called only once to deallocate `EncryptedDnsProxyState`. |
| 28 | + * |
| 29 | + * # Safety |
| 30 | + * `ptr` must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized |
| 31 | + * by `encrypted_dns_proxy_init`. This function is not thread safe. |
| 32 | + */ |
| 33 | +void encrytped_dns_proxy_free(struct EncryptedDnsProxyState *ptr); |
| 34 | + |
| 35 | +/** |
| 36 | + * # Safety |
| 37 | + * encrypted_dns_proxy must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized |
| 38 | + * by `encrypted_dns_proxy_init`. This function is not thread safe. |
| 39 | + * `proxy_handle` must be pointing to a valid memory region for the size of a `ProxyHandle` |
| 40 | + * |
| 41 | + * `proxy_handle` will only contain valid values if the return value is zero. It is still valid to |
| 42 | + * deallocate the memory. |
| 43 | + * |
| 44 | + */ |
| 45 | +int32_t encrypted_dns_proxy_start(struct EncryptedDnsProxyState *encrypted_dns_proxy, |
| 46 | + struct ProxyHandle *proxy_handle); |
| 47 | + |
| 48 | +/** |
| 49 | + * SAFETY: |
| 50 | + * `proxy_config` must be a valid pointer to a `ProxyHandle` as initialized by |
| 51 | + * [`encrypted_dns_proxy_start`]. |
| 52 | + */ |
| 53 | +int32_t encrypted_dns_proxy_stop(struct ProxyHandle *proxy_config); |
| 54 | + |
27 | 55 | /**
|
28 | 56 | * Called by the Swift side to signal that the ephemeral peer exchange should be cancelled.
|
29 | 57 | * After this call, the cancel token is no longer valid.
|
@@ -142,16 +170,6 @@ int32_t start_shadowsocks_proxy(const uint8_t *forward_address,
|
142 | 170 | */
|
143 | 171 | int32_t stop_shadowsocks_proxy(struct ProxyHandle *proxy_config);
|
144 | 172 |
|
145 |
| -void fetch_encrypted_dns_configs(void); |
146 |
| - |
147 |
| -void free_encrypted_dns_configs(void); |
148 |
| - |
149 |
| -int32_t init_proxy_configurations(struct EncryptedDnsProxyState *proxy_state); |
150 |
| - |
151 |
| -int32_t start_encrypted_dns_proxy(DnsConfig *dns_config, struct ProxyHandle *proxy_config); |
152 |
| - |
153 |
| -int32_t stop_encrypted_proxy(struct ProxyHandle *proxy_config); |
154 |
| - |
155 | 173 | int32_t start_tunnel_obfuscator_proxy(const uint8_t *peer_address,
|
156 | 174 | uintptr_t peer_address_len,
|
157 | 175 | uint16_t peer_port,
|
|
0 commit comments