mirror of
https://github.com/curl/curl.git
synced 2026-07-24 20:07:16 +03:00
Alexey Pesternikov introduced CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_OPENSOCKETDATA to set a callback that allows an application to replace the socket() call used by libcurl. It basically allows the app to change address, protocol or whatever of the socket. (I also did some whitespace indent/cleanups in lib/url.c which kind of hides some of these changes, sorry for mixing those in.)
This commit is contained in:
parent
ce81cd21d3
commit
ce1cfcb7a6
6 changed files with 140 additions and 67 deletions
|
|
@ -246,6 +246,19 @@ typedef int (*curl_sockopt_callback)(void *clientp,
|
|||
curl_socket_t curlfd,
|
||||
curlsocktype purpose);
|
||||
|
||||
struct Curl_sockaddr {
|
||||
int family;
|
||||
int socktype;
|
||||
int protocol;
|
||||
socklen_t addrlen;
|
||||
struct sockaddr addr;
|
||||
};
|
||||
|
||||
typedef curl_socket_t
|
||||
(*curl_opensocket_callback)(void* clentp,
|
||||
curlsocktype purpose,
|
||||
struct Curl_sockaddr* address);
|
||||
|
||||
#ifndef CURL_NO_OLDIES
|
||||
/* not used since 7.10.8, will be removed in a future release */
|
||||
typedef int (*curl_passwd_callback)(void *clientp,
|
||||
|
|
@ -1135,6 +1148,13 @@ typedef enum {
|
|||
/* used by scp/sftp to verify the host's public key */
|
||||
CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162),
|
||||
|
||||
/* Callback function for opening socket (instead of socket(2)). Optionally,
|
||||
callback is able change the address or refuse to connect returning
|
||||
CURL_SOCKET_BAD. The callback should have type
|
||||
curl_opensocket_callback */
|
||||
CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),
|
||||
CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),
|
||||
|
||||
CURLOPT_LASTENTRY /* the last unused */
|
||||
} CURLoption;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue