|
1 | 1 |
|
2 | 2 | interface ip-name-lookup { |
3 | | - use wasi:io/poll.{pollable}; |
4 | | - use network.{network, error-code, ip-address, ip-address-family}; |
| 3 | + use wasi:io/poll.{pollable}; |
| 4 | + use network.{network, error-code, ip-address, ip-address-family}; |
5 | 5 |
|
6 | 6 |
|
7 | | - /// Resolve an internet host name to a list of IP addresses. |
8 | | - /// |
9 | | - /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. |
10 | | - /// |
11 | | - /// # Parameters |
12 | | - /// - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted |
13 | | - /// to ASCII using IDNA encoding. |
14 | | - /// - `address-family`: If provided, limit the results to addresses of this specific address family. |
15 | | - /// - `include-unavailable`: When set to true, this function will also return addresses of which the runtime |
16 | | - /// thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on |
17 | | - /// systems without an active IPv6 interface. Notes: |
18 | | - /// - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address. |
19 | | - /// - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged. |
20 | | - /// |
21 | | - /// This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream` |
22 | | - /// that can be used to (asynchronously) fetch the results. |
23 | | - /// |
24 | | - /// At the moment, the stream never completes successfully with 0 items. Ie. the first call |
25 | | - /// to `resolve-next-address` never returns `ok(none)`. This may change in the future. |
26 | | - /// |
27 | | - /// # Typical errors |
28 | | - /// - `invalid-name`: `name` is a syntactically invalid domain name. |
29 | | - /// - `invalid-name`: `name` is an IP address. |
30 | | - /// - `address-family-not-supported`: The specified `address-family` is not supported. (EAI_FAMILY) |
31 | | - /// |
32 | | - /// # References: |
33 | | - /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html> |
34 | | - /// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html> |
35 | | - /// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo> |
36 | | - /// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3> |
37 | | - resolve-addresses: func(network: borrow<network>, name: string, address-family: option<ip-address-family>, include-unavailable: bool) -> result<resolve-address-stream, error-code>; |
| 7 | + /// Resolve an internet host name to a list of IP addresses. |
| 8 | + /// |
| 9 | + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. |
| 10 | + /// |
| 11 | + /// # Parameters |
| 12 | + /// - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted |
| 13 | + /// to ASCII using IDNA encoding. |
| 14 | + /// - `address-family`: If provided, limit the results to addresses of this specific address family. |
| 15 | + /// - `include-unavailable`: When set to true, this function will also return addresses of which the runtime |
| 16 | + /// thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on |
| 17 | + /// systems without an active IPv6 interface. Notes: |
| 18 | + /// - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address. |
| 19 | + /// - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged. |
| 20 | + /// |
| 21 | + /// This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream` |
| 22 | + /// that can be used to (asynchronously) fetch the results. |
| 23 | + /// |
| 24 | + /// At the moment, the stream never completes successfully with 0 items. Ie. the first call |
| 25 | + /// to `resolve-next-address` never returns `ok(none)`. This may change in the future. |
| 26 | + /// |
| 27 | + /// # Typical errors |
| 28 | + /// - `invalid-name`: `name` is a syntactically invalid domain name. |
| 29 | + /// - `invalid-name`: `name` is an IP address. |
| 30 | + /// - `address-family-not-supported`: The specified `address-family` is not supported. (EAI_FAMILY) |
| 31 | + /// |
| 32 | + /// # References: |
| 33 | + /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html> |
| 34 | + /// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html> |
| 35 | + /// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo> |
| 36 | + /// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3> |
| 37 | + resolve-addresses: func(network: borrow<network>, name: string, address-family: option<ip-address-family>, include-unavailable: bool) -> result<resolve-address-stream, error-code>; |
38 | 38 |
|
39 | | - resource resolve-address-stream { |
40 | | - /// Returns the next address from the resolver. |
41 | | - /// |
42 | | - /// This function should be called multiple times. On each call, it will |
43 | | - /// return the next address in connection order preference. If all |
44 | | - /// addresses have been exhausted, this function returns `none`. |
45 | | - /// |
46 | | - /// This function never returns IPv4-mapped IPv6 addresses. |
47 | | - /// |
48 | | - /// # Typical errors |
49 | | - /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) |
50 | | - /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) |
51 | | - /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) |
52 | | - /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) |
53 | | - resolve-next-address: func() -> result<option<ip-address>, error-code>; |
| 39 | + resource resolve-address-stream { |
| 40 | + /// Returns the next address from the resolver. |
| 41 | + /// |
| 42 | + /// This function should be called multiple times. On each call, it will |
| 43 | + /// return the next address in connection order preference. If all |
| 44 | + /// addresses have been exhausted, this function returns `none`. |
| 45 | + /// |
| 46 | + /// This function never returns IPv4-mapped IPv6 addresses. |
| 47 | + /// |
| 48 | + /// # Typical errors |
| 49 | + /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) |
| 50 | + /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) |
| 51 | + /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) |
| 52 | + /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) |
| 53 | + resolve-next-address: func() -> result<option<ip-address>, error-code>; |
54 | 54 |
|
55 | | - /// Create a `pollable` which will resolve once the stream is ready for I/O. |
56 | | - /// |
57 | | - /// Note: this function is here for WASI Preview2 only. |
58 | | - /// It's planned to be removed when `future` is natively supported in Preview3. |
59 | | - subscribe: func() -> pollable; |
60 | | - } |
| 55 | + /// Create a `pollable` which will resolve once the stream is ready for I/O. |
| 56 | + /// |
| 57 | + /// Note: this function is here for WASI Preview2 only. |
| 58 | + /// It's planned to be removed when `future` is natively supported in Preview3. |
| 59 | + subscribe: func() -> pollable; |
| 60 | + } |
61 | 61 | } |
0 commit comments