feat(c-bindings): DNS Discovery (#548)

This commit is contained in:
RichΛrd 2022-10-25 14:24:03 -04:00 committed by GitHub
parent 4c18950e91
commit 50de9e7435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -1035,6 +1035,39 @@ An `error` message otherwise.
}
```
## DNS Discovery
### `extern char* waku_dns_discovery(char* url, char* nameserver, int timeoutMs)`
Returns a list of multiaddress given a url to a DNS discoverable ENR tree
**Parameters**
1. `char* url`: URL containing a discoverable ENR tree
2. `char* nameserver`: The nameserver to resolve the ENR tree url.
If `NULL` or empty, it will automatically use the default system dns.
3. `int timeoutMs`: Timeout value in milliseconds to execute the call.
If the function execution takes longer than this value,
the execution will be canceled and an error returned.
Use `0` for no timeout.
**Returns**
A [`JsonResponse`](#jsonresponse-type).
If the execution is successful, the `result` field contains an array with multiaddresses.
An `error` message otherwise.
```json
{
"result": [
"/ip4/134.209.139.210/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
"/ip4/104.154.239.128/tcp/30303/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS",
"/ip4/47.242.210.73/tcp/30303/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm"
]
}
```
## Utils
### `extern char* waku_utils_base64_encode(char* data)`