From a7bece2014ec043cfe58418dc13e982f79dcfcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 11 May 2015 16:35:24 +0200 Subject: proxy: introduce a proxy options struct It is currently unused; it will go into the remote's options. --- include/git2/proxy.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 include/git2/proxy.h (limited to 'include/git2/proxy.h') diff --git a/include/git2/proxy.h b/include/git2/proxy.h new file mode 100644 index 000000000..2a3ce8f3e --- /dev/null +++ b/include/git2/proxy.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_proxy_h__ +#define INCLUDE_git_proxy_h__ + +#include "common.h" +#include "transport.h" + +GIT_BEGIN_DECL + +/** + * The type of proxy to use. + */ +typedef enum { + /** + * Do not attempt to connect through a proxy + */ + GIT_PROXY_NONE, + /** + * Try to auto-detect the proxy from the git configuration. + */ + GIT_PROXY_AUTO, + /** + * Connect through a HTTP proxy + */ + GIT_PROXY_HTTP, + /** + * Connect through a SOCKS v4 proxy + */ + GIT_PROXY_SOCKS4, + /** + * Connect through a SOCKS v5 proxy + */ + GIT_PROXY_SOCKS5, +} git_proxy_t; + +/** + * Options for connecting through a proxy + * + * Note that not all types may be supported, depending on the platform + * and compilation options. + */ +typedef struct { + unsigned int version; + + /** + * The type of proxy to use, by URL, auto-detect. + */ + git_proxy_t type; + + /** + * The URL of the proxy. + */ + const char *url; + + /** + * This will be called if the remote host requires + * authentication in order to connect to it. + * + * Returning GIT_PASSTHROUGH will make libgit2 behave as + * though this field isn't set. + */ + git_cred_acquire_cb credentials; + + /** + * If cert verification fails, this will be called to let the + * user make the final decision of whether to allow the + * connection to proceed. Returns 1 to allow the connection, 0 + * to disallow it or a negative value to indicate an error. + */ + git_transport_certificate_check_cb certificate_check; +} git_proxy_options; + +#define GIT_PROXY_OPTIONS_VERSION 1 +#define GIT_PROXY_OPTIONS_INIT {GIT_PROXY_OPTIONS_VERSION} + +/** + * Initialize a proxy options structure + * + * @param opts the options struct to initialize + * @param version the version of the struct, use `GIT_PROXY_OPTIONS_VERSION` + */ +GIT_EXTERN(int) git_proxy_init_options(git_proxy_options *opts, unsigned int version); + +GIT_END_DECL + +#endif -- cgit v1.2.1 From 60d717c6f1238f810402956779dcebb10f0cf175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 2 Oct 2015 10:10:13 +0200 Subject: proxy: add a payload field for the proxy options I don't quite recall what we do in the other places where we use this, but we should pass this payload to the callbacks. --- include/git2/proxy.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/git2/proxy.h') diff --git a/include/git2/proxy.h b/include/git2/proxy.h index 2a3ce8f3e..b45b55b3b 100644 --- a/include/git2/proxy.h +++ b/include/git2/proxy.h @@ -73,6 +73,12 @@ typedef struct { * to disallow it or a negative value to indicate an error. */ git_transport_certificate_check_cb certificate_check; + + /** + * Payload to be provided to the credentials and certificate + * check callbacks. + */ + void *payload; } git_proxy_options; #define GIT_PROXY_OPTIONS_VERSION 1 -- cgit v1.2.1 From 0d72f67f28d52b3d7fb2760484fb51c014273bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 14 Mar 2016 17:36:04 +0100 Subject: proxy: don't specify the protocol in the type We leave this up to the scheme in the url field. The type should only tell us about whether we want a proxy and whether we want to auto-detect it. --- include/git2/proxy.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'include/git2/proxy.h') diff --git a/include/git2/proxy.h b/include/git2/proxy.h index b45b55b3b..dcd615633 100644 --- a/include/git2/proxy.h +++ b/include/git2/proxy.h @@ -18,6 +18,9 @@ GIT_BEGIN_DECL typedef enum { /** * Do not attempt to connect through a proxy + * + * If built against lbicurl, it itself may attempt to connect + * to a proxy if the environment variables specify it. */ GIT_PROXY_NONE, /** @@ -25,17 +28,9 @@ typedef enum { */ GIT_PROXY_AUTO, /** - * Connect through a HTTP proxy - */ - GIT_PROXY_HTTP, - /** - * Connect through a SOCKS v4 proxy - */ - GIT_PROXY_SOCKS4, - /** - * Connect through a SOCKS v5 proxy + * Connect via the URL given in the options */ - GIT_PROXY_SOCKS5, + GIT_PROXY_SPECIFIED, } git_proxy_t; /** -- cgit v1.2.1