summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/proxy.h92
-rw-r--r--include/git2/remote.h19
-rw-r--r--include/git2/sys/remote.h16
-rw-r--r--include/git2/sys/stream.h3
-rw-r--r--include/git2/sys/transport.h4
5 files changed, 129 insertions, 5 deletions
diff --git a/include/git2/proxy.h b/include/git2/proxy.h
new file mode 100644
index 000000000..dcd615633
--- /dev/null
+++ b/include/git2/proxy.h
@@ -0,0 +1,92 @@
+/*
+ * 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
+ *
+ * If built against lbicurl, it itself may attempt to connect
+ * to a proxy if the environment variables specify it.
+ */
+ GIT_PROXY_NONE,
+ /**
+ * Try to auto-detect the proxy from the git configuration.
+ */
+ GIT_PROXY_AUTO,
+ /**
+ * Connect via the URL given in the options
+ */
+ GIT_PROXY_SPECIFIED,
+} 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;
+
+ /**
+ * Payload to be provided to the credentials and certificate
+ * check callbacks.
+ */
+ void *payload;
+} 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
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 4f345d30c..c459f42cc 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -15,6 +15,7 @@
#include "strarray.h"
#include "transport.h"
#include "pack.h"
+#include "proxy.h"
/**
* @file git2/remote.h
@@ -241,10 +242,11 @@ GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote,
* @param direction GIT_DIRECTION_FETCH if you want to fetch or
* GIT_DIRECTION_PUSH if you want to push
* @param callbacks the callbacks to use for this connection
+ * @param proxy_opts proxy settings
* @param custom_headers extra HTTP headers to use in this connection
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers);
+GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy_opts, const git_strarray *custom_headers);
/**
* Get the remote repository's reference advertisement list
@@ -549,13 +551,19 @@ typedef struct {
git_remote_autotag_option_t download_tags;
/**
+ * Proxy options to use, by default no proxy is used.
+ */
+ git_proxy_options proxy_opts;
+
+ /**
* Extra headers for this fetch operation
*/
git_strarray custom_headers;
} git_fetch_options;
#define GIT_FETCH_OPTIONS_VERSION 1
-#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1 }
+#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
/**
* Initializes a `git_fetch_options` with default values. Equivalent to
@@ -593,13 +601,18 @@ typedef struct {
git_remote_callbacks callbacks;
/**
+ * Proxy options to use, by default no proxy is used.
+ */
+ git_proxy_options proxy_opts;
+
+ /**
* Extra headers for this push operation
*/
git_strarray custom_headers;
} git_push_options;
#define GIT_PUSH_OPTIONS_VERSION 1
-#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT }
+#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
/**
* Initializes a `git_push_options` with default values. Equivalent to
diff --git a/include/git2/sys/remote.h b/include/git2/sys/remote.h
new file mode 100644
index 000000000..3037b411c
--- /dev/null
+++ b/include/git2/sys/remote.h
@@ -0,0 +1,16 @@
+/*
+ * 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_sys_git_transport_h
+#define INCLUDE_sys_git_transport_h
+
+#include "git2/net.h"
+#include "git2/types.h"
+
+GIT_BEGIN_DECL
+
+GIT_END_DECL
diff --git a/include/git2/sys/stream.h b/include/git2/sys/stream.h
index 2b4ff7fd8..eeeb68dae 100644
--- a/include/git2/sys/stream.h
+++ b/include/git2/sys/stream.h
@@ -9,6 +9,7 @@
#include "git2/common.h"
#include "git2/types.h"
+#include "git2/proxy.h"
GIT_BEGIN_DECL
@@ -32,7 +33,7 @@ typedef struct git_stream {
int proxy_support;
int (*connect)(struct git_stream *);
int (*certificate)(git_cert **, struct git_stream *);
- int (*set_proxy)(struct git_stream *, const char *proxy_url);
+ int (*set_proxy)(struct git_stream *, const git_proxy_options *proxy_opts);
ssize_t (*read)(struct git_stream *, void *, size_t);
ssize_t (*write)(struct git_stream *, const char *, size_t, int);
int (*close)(struct git_stream *);
diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h
index ce0234a18..60e38b21a 100644
--- a/include/git2/sys/transport.h
+++ b/include/git2/sys/transport.h
@@ -11,6 +11,7 @@
#include "git2/net.h"
#include "git2/types.h"
#include "git2/strarray.h"
+#include "git2/proxy.h"
/**
* @file git2/sys/transport.h
@@ -53,6 +54,7 @@ struct git_transport {
const char *url,
git_cred_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
+ const git_proxy_options *proxy_opts,
int direction,
int flags);
@@ -65,7 +67,7 @@ struct git_transport {
git_transport *transport);
/* Executes the push whose context is in the git_push object. */
- int (*push)(git_transport *transport, git_push *push, const git_remote_callbacks *callbacks);
+ int(*push)(git_transport *transport, git_push *push, const git_remote_callbacks *callbacks);
/* This function may be called after a successful call to connect(), when
* the direction is FETCH. The function performs a negotiation to calculate