mirror of
https://github.com/curl/curl.git
synced 2026-08-25 18:33:42 +03:00
socket: support binding to interface *AND* IP
Introduce new notation for CURLOPT_INTERFACE / --interface: ifhost!<interface>!<host> Binding to an interface doesn't set the address, and an interface can have multiple addresses. When binding to an address (without interface), the kernel is free to choose the route, and it can route through any device that can access the target address, not necessarily the one with the chosen address. Moreover, it is possible for different interfaces to have the same IP address, on which case we need to provide a way to be more specific. Factor out the parsing part of interface option, and add unit tests: 1663. Closes #13719
This commit is contained in:
parent
23fe1a52dc
commit
3060557af7
10 changed files with 322 additions and 79 deletions
|
|
@ -28,15 +28,16 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
|
|||
|
||||
Pass a char pointer as parameter. This sets the *interface* name to use as
|
||||
outgoing network interface. The name can be an interface name, an IP address,
|
||||
or a hostname.
|
||||
or a hostname. If you prefer one of these, you can use the following special
|
||||
prefixes:
|
||||
|
||||
If the parameter starts with "if!" then it is treated only as an interface
|
||||
name. If the parameter starts with "host!" it is treated as either an IP
|
||||
address or a hostname.
|
||||
* `if!<name>` - Interface name
|
||||
* `host!<name>` - IP address or hostname
|
||||
* `ifhost!<interface>!<host>` - Interface name and IP address or hostname
|
||||
|
||||
If "if!" is specified but the parameter does not match an existing interface,
|
||||
*CURLE_INTERFACE_FAILED* is returned from the libcurl function used to perform
|
||||
the transfer.
|
||||
If `if!` or `ifhost!` is specified but the parameter does not match an existing
|
||||
interface, *CURLE_INTERFACE_FAILED* is returned from the libcurl function used
|
||||
to perform the transfer.
|
||||
|
||||
libcurl does not support using network interface names for this option on
|
||||
Windows.
|
||||
|
|
@ -74,7 +75,9 @@ int main(void)
|
|||
|
||||
# AVAILABILITY
|
||||
|
||||
The "if!" and "host!" syntax was added in 7.24.0.
|
||||
The `if!` and `host!` syntax was added in 7.24.0.
|
||||
|
||||
The `ifhost!` syntax was added in 8.9.0.
|
||||
|
||||
# RETURN VALUE
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue