mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
http: Add flag to force use of TOR (part 1)
* common/http.h (HTTP_FLAG_FORCE_TOR): New. * common/http.c (http_raw_connect, send_request): Detect flag and return an error for now. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
f986b23e13
commit
b4bc1c8b10
@ -747,6 +747,12 @@ http_raw_connect (http_t *r_hd, const char *server, unsigned short port,
|
|||||||
|
|
||||||
*r_hd = NULL;
|
*r_hd = NULL;
|
||||||
|
|
||||||
|
if ((flags & HTTP_FLAG_FORCE_TOR))
|
||||||
|
{
|
||||||
|
log_error ("TOR support is not yet available\n");
|
||||||
|
return gpg_err_make (default_errsource, GPG_ERR_NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the handle. */
|
/* Create the handle. */
|
||||||
hd = xtrycalloc (1, sizeof *hd);
|
hd = xtrycalloc (1, sizeof *hd);
|
||||||
if (!hd)
|
if (!hd)
|
||||||
@ -1452,6 +1458,12 @@ send_request (http_t hd, const char *httphost, const char *auth,
|
|||||||
}
|
}
|
||||||
#endif /*USE_TLS*/
|
#endif /*USE_TLS*/
|
||||||
|
|
||||||
|
if ((hd->flags & HTTP_FLAG_FORCE_TOR))
|
||||||
|
{
|
||||||
|
log_error ("TOR support is not yet available\n");
|
||||||
|
return gpg_err_make (default_errsource, GPG_ERR_NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
server = *hd->uri->host ? hd->uri->host : "localhost";
|
server = *hd->uri->host ? hd->uri->host : "localhost";
|
||||||
port = hd->uri->port ? hd->uri->port : 80;
|
port = hd->uri->port ? hd->uri->port : 80;
|
||||||
|
|
||||||
|
@ -78,8 +78,9 @@ enum
|
|||||||
{
|
{
|
||||||
HTTP_FLAG_TRY_PROXY = 1, /* Try to use a proxy. */
|
HTTP_FLAG_TRY_PROXY = 1, /* Try to use a proxy. */
|
||||||
HTTP_FLAG_SHUTDOWN = 2, /* Close sending end after the request. */
|
HTTP_FLAG_SHUTDOWN = 2, /* Close sending end after the request. */
|
||||||
|
HTTP_FLAG_FORCE_TOR = 4, /* Force a TOR connection. */
|
||||||
HTTP_FLAG_LOG_RESP = 8, /* Log the server respone. */
|
HTTP_FLAG_LOG_RESP = 8, /* Log the server respone. */
|
||||||
HTTP_FLAG_FORCE_TLS = 16, /* Force the use opf TLS. */
|
HTTP_FLAG_FORCE_TLS = 16, /* Force the use of TLS. */
|
||||||
HTTP_FLAG_IGNORE_CL = 32, /* Ignore content-length. */
|
HTTP_FLAG_IGNORE_CL = 32, /* Ignore content-length. */
|
||||||
HTTP_FLAG_IGNORE_IPv4 = 64, /* Do not use IPv4. */
|
HTTP_FLAG_IGNORE_IPv4 = 64, /* Do not use IPv4. */
|
||||||
HTTP_FLAG_IGNORE_IPv6 = 128 /* Do not use IPv6. */
|
HTTP_FLAG_IGNORE_IPv6 = 128 /* Do not use IPv6. */
|
||||||
|
@ -174,6 +174,7 @@ main (int argc, char **argv)
|
|||||||
" --cacert FNAME expect CA certificate in file FNAME\n"
|
" --cacert FNAME expect CA certificate in file FNAME\n"
|
||||||
" --no-verify do not verify the certificate\n"
|
" --no-verify do not verify the certificate\n"
|
||||||
" --force-tls use HTTP_FLAG_FORCE_TLS\n"
|
" --force-tls use HTTP_FLAG_FORCE_TLS\n"
|
||||||
|
" --force-tor use HTTP_FLAG_FORCE_TOR\n"
|
||||||
" --no-out do not print the content\n",
|
" --no-out do not print the content\n",
|
||||||
stdout);
|
stdout);
|
||||||
exit (0);
|
exit (0);
|
||||||
@ -217,6 +218,11 @@ main (int argc, char **argv)
|
|||||||
my_http_flags |= HTTP_FLAG_FORCE_TLS;
|
my_http_flags |= HTTP_FLAG_FORCE_TLS;
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp (*argv, "--force-tor"))
|
||||||
|
{
|
||||||
|
my_http_flags |= HTTP_FLAG_FORCE_TOR;
|
||||||
|
argc--; argv++;
|
||||||
|
}
|
||||||
else if (!strcmp (*argv, "--no-out"))
|
else if (!strcmp (*argv, "--no-out"))
|
||||||
{
|
{
|
||||||
no_out = 1;
|
no_out = 1;
|
||||||
@ -316,6 +322,8 @@ main (int argc, char **argv)
|
|||||||
printf ("TLS : %s\n",
|
printf ("TLS : %s\n",
|
||||||
uri->use_tls? "yes":
|
uri->use_tls? "yes":
|
||||||
(my_http_flags&HTTP_FLAG_FORCE_TLS)? "forced" : "no");
|
(my_http_flags&HTTP_FLAG_FORCE_TLS)? "forced" : "no");
|
||||||
|
printf ("Tor : %s\n",
|
||||||
|
(my_http_flags&HTTP_FLAG_FORCE_TOR)? "yes" : "no");
|
||||||
|
|
||||||
}
|
}
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user