]> git.proxmox.com Git - libgit2.git/blame - include/git2/proxy.h
New upstream version 1.1.0+dfsg.1
[libgit2.git] / include / git2 / proxy.h
CommitLineData
a7bece20
CMN
1/*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7#ifndef INCLUDE_git_proxy_h__
8#define INCLUDE_git_proxy_h__
9
10#include "common.h"
22a2d3d5
UG
11
12#include "cert.h"
13#include "credential.h"
a7bece20
CMN
14
15GIT_BEGIN_DECL
16
17/**
18 * The type of proxy to use.
19 */
20typedef enum {
21 /**
22 * Do not attempt to connect through a proxy
0d72f67f 23 *
6502398f 24 * If built against libcurl, it itself may attempt to connect
0d72f67f 25 * to a proxy if the environment variables specify it.
a7bece20
CMN
26 */
27 GIT_PROXY_NONE,
28 /**
29 * Try to auto-detect the proxy from the git configuration.
30 */
31 GIT_PROXY_AUTO,
32 /**
0d72f67f 33 * Connect via the URL given in the options
a7bece20 34 */
0d72f67f 35 GIT_PROXY_SPECIFIED,
a7bece20
CMN
36} git_proxy_t;
37
38/**
39 * Options for connecting through a proxy
40 *
41 * Note that not all types may be supported, depending on the platform
42 * and compilation options.
43 */
44typedef struct {
45 unsigned int version;
46
47 /**
48 * The type of proxy to use, by URL, auto-detect.
49 */
50 git_proxy_t type;
51
52 /**
53 * The URL of the proxy.
54 */
55 const char *url;
56
57 /**
58 * This will be called if the remote host requires
59 * authentication in order to connect to it.
60 *
61 * Returning GIT_PASSTHROUGH will make libgit2 behave as
62 * though this field isn't set.
63 */
22a2d3d5 64 git_credential_acquire_cb credentials;
a7bece20
CMN
65
66 /**
67 * If cert verification fails, this will be called to let the
68 * user make the final decision of whether to allow the
ac3d33df
JK
69 * connection to proceed. Returns 0 to allow the connection
70 * or a negative value to indicate an error.
a7bece20 71 */
22a2d3d5 72 git_transport_certificate_check_cb certificate_check;
60d717c6
CMN
73
74 /**
75 * Payload to be provided to the credentials and certificate
76 * check callbacks.
77 */
78 void *payload;
a7bece20
CMN
79} git_proxy_options;
80
81#define GIT_PROXY_OPTIONS_VERSION 1
82#define GIT_PROXY_OPTIONS_INIT {GIT_PROXY_OPTIONS_VERSION}
83
84/**
ac3d33df 85 * Initialize git_proxy_options structure
a7bece20 86 *
ac3d33df
JK
87 * Initializes a `git_proxy_options` with default values. Equivalent to
88 * creating an instance with `GIT_PROXY_OPTIONS_INIT`.
89 *
90 * @param opts The `git_proxy_options` struct to initialize.
91 * @param version The struct version; pass `GIT_PROXY_OPTIONS_VERSION`.
92 * @return Zero on success; -1 on failure.
a7bece20 93 */
22a2d3d5 94GIT_EXTERN(int) git_proxy_options_init(git_proxy_options *opts, unsigned int version);
a7bece20
CMN
95
96GIT_END_DECL
97
98#endif