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 module libgit2_d.proxy;
8 
9 
10 private static import libgit2_d.cert;
11 private static import libgit2_d.credential;
12 
13 extern (C):
14 nothrow @nogc:
15 public:
16 
17 /**
18  * The type of proxy to use.
19  */
20 enum git_proxy_t
21 {
22 	/**
23 	 * Do not attempt to connect through a proxy
24 	 *
25 	 * If built against libcurl, it itself may attempt to connect
26 	 * to a proxy if the environment variables specify it.
27 	 */
28 	GIT_PROXY_NONE,
29 
30 	/**
31 	 * Try to auto-detect the proxy from the git configuration.
32 	 */
33 	GIT_PROXY_AUTO,
34 
35 	/**
36 	 * Connect via the URL given in the options
37 	 */
38 	GIT_PROXY_SPECIFIED,
39 }
40 
41 /**
42  * Options for connecting through a proxy
43  *
44  * Note that not all types may be supported, depending on the platform
45  * and compilation options.
46  */
47 struct git_proxy_options
48 {
49 	uint version_;
50 
51 	/**
52 	 * The type of proxy to use, by URL, auto-detect.
53 	 */
54 	.git_proxy_t type;
55 
56 	/**
57 	 * The URL of the proxy.
58 	 */
59 	const (char)* url;
60 
61 	/**
62 	 * This will be called if the remote host requires
63 	 * authentication in order to connect to it.
64 	 *
65 	 * Returning git_error_code.GIT_PASSTHROUGH will make libgit2 behave as
66 	 * though this field isn't set.
67 	 */
68 	libgit2_d.credential.git_credential_acquire_cb credentials;
69 
70 	/**
71 	 * If cert verification fails, this will be called to let the
72 	 * user make the final decision of whether to allow the
73 	 * connection to proceed. Returns 0 to allow the connection
74 	 * or a negative value to indicate an error.
75 	 */
76 	libgit2_d.cert.git_transport_certificate_check_cb certificate_check;
77 
78 	/**
79 	 * Payload to be provided to the credentials and certificate
80 	 * check callbacks.
81 	 */
82 	void* payload;
83 }
84 
85 enum GIT_PROXY_OPTIONS_VERSION = 1;
86 
87 pragma(inline, true)
88 pure nothrow @safe @nogc
89 .git_proxy_options GIT_PROXY_OPTIONS_INIT()
90 
91 	do
92 	{
93 		.git_proxy_options OUTPUT =
94 		{
95 			version_: .GIT_PROXY_OPTIONS_VERSION,
96 		};
97 
98 		return OUTPUT;
99 	}
100 
101 /**
102  * Initialize git_proxy_options structure
103  *
104  * Initializes a `git_proxy_options` with default values. Equivalent to
105  * creating an instance with `GIT_PROXY_OPTIONS_INIT`.
106  *
107  * Params:
108  *      opts = The `git_proxy_options` struct to initialize.
109  *      version = The struct version; pass `GIT_PROXY_OPTIONS_VERSION`.
110  *
111  * Returns: Zero on success; -1 on failure.
112  */
113 //GIT_EXTERN
114 int git_proxy_options_init(.git_proxy_options* opts, uint version_);