mirror of
https://github.com/curl/curl.git
synced 2026-08-24 12:13:33 +03:00
lib: introduce Curl_peer
`struct Curl_peer` keeps information about a communication endpoint together. It will replace `conn->host` and `conn->conn_to_host` and proxyinfo host. It will also become part of `struct ssl_peer`. It has a reference counter, so an instance can be shared between connections and filters. Elminiates `conn->host` and `conn->connect_to_host`, used in the proxyinfo structures. Passed to DNS resolution and socks filters, etc. Pass peer to http proxy and socks tunnel filters. Use peer in dns filter and resolving. Make `Curl_peer` a member in the `struct ssl_peer`. Add `docs/internals/PEERS.md` for documentation. Closes #21472
This commit is contained in:
parent
9c9a4f3eab
commit
bc40e09f63
67 changed files with 1902 additions and 1295 deletions
108
lib/protocol.c
108
lib/protocol.c
|
|
@ -361,6 +361,51 @@ const struct Curl_scheme Curl_scheme_smtps = {
|
|||
PORT_SMTPS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_socks = {
|
||||
"socks", /* scheme */
|
||||
ZERO_NULL,
|
||||
CURLPROTO_SOCKS, /* protocol */
|
||||
CURLPROTO_SOCKS, /* family */
|
||||
PROTOPT_NO_TRANSFER, /* flags */
|
||||
PORT_SOCKS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_socks4 = {
|
||||
"socks4", /* scheme */
|
||||
ZERO_NULL,
|
||||
CURLPROTO_SOCKS, /* protocol */
|
||||
CURLPROTO_SOCKS, /* family */
|
||||
PROTOPT_NO_TRANSFER, /* flags */
|
||||
PORT_SOCKS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_socks4a = {
|
||||
"socks4a", /* scheme */
|
||||
ZERO_NULL,
|
||||
CURLPROTO_SOCKS, /* protocol */
|
||||
CURLPROTO_SOCKS, /* family */
|
||||
PROTOPT_NO_TRANSFER, /* flags */
|
||||
PORT_SOCKS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_socks5 = {
|
||||
"socks5", /* scheme */
|
||||
ZERO_NULL,
|
||||
CURLPROTO_SOCKS, /* protocol */
|
||||
CURLPROTO_SOCKS, /* family */
|
||||
PROTOPT_NO_TRANSFER, /* flags */
|
||||
PORT_SOCKS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_socks5h = {
|
||||
"socks5h", /* scheme */
|
||||
ZERO_NULL,
|
||||
CURLPROTO_SOCKS, /* protocol */
|
||||
CURLPROTO_SOCKS, /* family */
|
||||
PROTOPT_NO_TRANSFER, /* flags */
|
||||
PORT_SOCKS, /* defport */
|
||||
};
|
||||
|
||||
const struct Curl_scheme Curl_scheme_telnet = {
|
||||
"telnet", /* scheme */
|
||||
#ifdef CURL_DISABLE_TELNET
|
||||
|
|
@ -430,49 +475,54 @@ const struct Curl_scheme *Curl_getn_scheme(const char *scheme, size_t len)
|
|||
6. make sure this function uses the same hash function that worked for
|
||||
schemetable.c
|
||||
*/
|
||||
static const struct Curl_scheme * const all_schemes[47] = {
|
||||
&Curl_scheme_mqtt,
|
||||
&Curl_scheme_smtp,
|
||||
&Curl_scheme_tftp,
|
||||
&Curl_scheme_imap, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&Curl_scheme_ldaps,
|
||||
&Curl_scheme_dict, NULL,
|
||||
&Curl_scheme_file, NULL,
|
||||
&Curl_scheme_pop3s,
|
||||
&Curl_scheme_ftp,
|
||||
&Curl_scheme_scp,
|
||||
&Curl_scheme_mqtts,
|
||||
&Curl_scheme_imaps,
|
||||
&Curl_scheme_ldap,
|
||||
&Curl_scheme_http,
|
||||
&Curl_scheme_smb, NULL, NULL,
|
||||
&Curl_scheme_telnet,
|
||||
&Curl_scheme_https,
|
||||
&Curl_scheme_gopher,
|
||||
&Curl_scheme_rtsp, NULL, NULL,
|
||||
&Curl_scheme_wss, NULL,
|
||||
&Curl_scheme_gophers,
|
||||
static const struct Curl_scheme * const all_schemes[59] = { NULL,
|
||||
&Curl_scheme_pop3, NULL,
|
||||
&Curl_scheme_smtps,
|
||||
&Curl_scheme_pop3,
|
||||
&Curl_scheme_ws, NULL, NULL,
|
||||
&Curl_scheme_socks,
|
||||
&Curl_scheme_socks4,
|
||||
&Curl_scheme_socks5, NULL, NULL,
|
||||
&Curl_scheme_gophers,
|
||||
&Curl_scheme_ws,
|
||||
&Curl_scheme_sftp,
|
||||
&Curl_scheme_ftps, NULL,
|
||||
&Curl_scheme_smbs, NULL,
|
||||
&Curl_scheme_socks4a,
|
||||
&Curl_scheme_scp,
|
||||
&Curl_scheme_rtsp,
|
||||
&Curl_scheme_dict, NULL, NULL,
|
||||
&Curl_scheme_gopher, NULL, NULL, NULL,
|
||||
&Curl_scheme_wss, NULL,
|
||||
&Curl_scheme_smb, NULL,
|
||||
&Curl_scheme_ldap,
|
||||
&Curl_scheme_ldaps,
|
||||
&Curl_scheme_imap, NULL, NULL, NULL,
|
||||
&Curl_scheme_imaps,
|
||||
&Curl_scheme_https,
|
||||
&Curl_scheme_tftp,
|
||||
&Curl_scheme_telnet, NULL, NULL, NULL,
|
||||
&Curl_scheme_file,
|
||||
&Curl_scheme_smtp, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&Curl_scheme_ftp,
|
||||
&Curl_scheme_mqtt, NULL,
|
||||
&Curl_scheme_socks5h,
|
||||
&Curl_scheme_http,
|
||||
&Curl_scheme_pop3s, NULL,
|
||||
&Curl_scheme_mqtts, NULL,
|
||||
&Curl_scheme_smbs,
|
||||
&Curl_scheme_ftps,
|
||||
};
|
||||
|
||||
if(len && (len <= 7)) {
|
||||
const char *s = scheme;
|
||||
size_t l = len;
|
||||
const struct Curl_scheme *h;
|
||||
unsigned int c = 792;
|
||||
unsigned int c = 443;
|
||||
while(l) {
|
||||
c <<= 4;
|
||||
c <<= 5;
|
||||
c += (unsigned int)Curl_raw_tolower(*s);
|
||||
s++;
|
||||
l--;
|
||||
}
|
||||
|
||||
h = all_schemes[c % 47];
|
||||
h = all_schemes[c % 59];
|
||||
if(h && curl_strnequal(scheme, h->name, len) && !h->name[len])
|
||||
return h;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue