Skip to content

Commit

Permalink
Update the headerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkisemils committed Sep 25, 2024
1 parent 919de1f commit dfe49e8
Showing 1 changed file with 38 additions and 20 deletions.
58 changes: 38 additions & 20 deletions ios/MullvadRustRuntime/include/mullvad_rust_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,53 @@
#include <stdint.h>
#include <stdlib.h>

typedef struct HashSet_ProxyConfig HashSet_ProxyConfig;

typedef struct EphemeralPeerCancelToken {
void *context;
} EphemeralPeerCancelToken;
typedef struct EncryptedDnsProxyState EncryptedDnsProxyState;

typedef struct ProxyHandle {
void *context;
uint16_t port;
} ProxyHandle;

typedef struct EncryptedDnsProxyState {
struct HashSet_ProxyConfig configurations;
bool has_tried_xor;
struct HashSet_ProxyConfig tried_configurations;
} EncryptedDnsProxyState;
typedef struct EphemeralPeerCancelToken {
void *context;
} EphemeralPeerCancelToken;

extern const uint16_t CONFIG_SERVICE_PORT;

/**
* Initializes a valid pointer to an instance of `EncryptedDnsProxyState`.
*/
struct EncryptedDnsProxyState *encrypted_dns_proxy_init(void);

/**
* This must be called only once to deallocate `EncryptedDnsProxyState`.
*
* # Safety
* `ptr` must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized
* by `encrypted_dns_proxy_init`. This function is not thread safe.
*/
void encrytped_dns_proxy_free(struct EncryptedDnsProxyState *ptr);

/**
* # Safety
* encrypted_dns_proxy must be a valid, exclusive pointer to `EncryptedDnsProxyState`, initialized
* by `encrypted_dns_proxy_init`. This function is not thread safe.
* `proxy_handle` must be pointing to a valid memory region for the size of a `ProxyHandle`
*
* `proxy_handle` will only contain valid values if the return value is zero. It is still valid to
* deallocate the memory.
*
*/
int32_t encrypted_dns_proxy_start(struct EncryptedDnsProxyState *encrypted_dns_proxy,
struct ProxyHandle *proxy_handle);

/**
* SAFETY:
* `proxy_config` must be a valid pointer to a `ProxyHandle` as initialized by
* [`encrypted_dns_proxy_start`].
*/
int32_t encrypted_dns_proxy_stop(struct ProxyHandle *proxy_config);

/**
* Called by the Swift side to signal that the ephemeral peer exchange should be cancelled.
* After this call, the cancel token is no longer valid.
Expand Down Expand Up @@ -142,16 +170,6 @@ int32_t start_shadowsocks_proxy(const uint8_t *forward_address,
*/
int32_t stop_shadowsocks_proxy(struct ProxyHandle *proxy_config);

void fetch_encrypted_dns_configs(void);

void free_encrypted_dns_configs(void);

int32_t init_proxy_configurations(struct EncryptedDnsProxyState *proxy_state);

int32_t start_encrypted_dns_proxy(DnsConfig *dns_config, struct ProxyHandle *proxy_config);

int32_t stop_encrypted_proxy(struct ProxyHandle *proxy_config);

int32_t start_tunnel_obfuscator_proxy(const uint8_t *peer_address,
uintptr_t peer_address_len,
uint16_t peer_port,
Expand Down

0 comments on commit dfe49e8

Please sign in to comment.