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 //Declaration name in C language
42 enum
43 {
44 	GIT_PROXY_NONE = .git_proxy_t.GIT_PROXY_NONE,
45 	GIT_PROXY_AUTO = .git_proxy_t.GIT_PROXY_AUTO,
46 	GIT_PROXY_SPECIFIED = .git_proxy_t.GIT_PROXY_SPECIFIED,
47 }
48 
49 /**
50  * Options for connecting through a proxy
51  *
52  * Note that not all types may be supported, depending on the platform
53  * and compilation options.
54  */
55 struct git_proxy_options
56 {
57 	uint version_;
58 
59 	/**
60 	 * The type of proxy to use, by URL, auto-detect.
61 	 */
62 	.git_proxy_t type;
63 
64 	/**
65 	 * The URL of the proxy.
66 	 */
67 	const (char)* url;
68 
69 	/**
70 	 * This will be called if the remote host requires
71 	 * authentication in order to connect to it.
72 	 *
73 	 * Returning git_error_code.GIT_PASSTHROUGH will make libgit2 behave as
74 	 * though this field isn't set.
75 	 */
76 	libgit2_d.credential.git_credential_acquire_cb credentials;
77 
78 	/**
79 	 * If cert verification fails, this will be called to let the
80 	 * user make the final decision of whether to allow the
81 	 * connection to proceed. Returns 0 to allow the connection
82 	 * or a negative value to indicate an error.
83 	 */
84 	libgit2_d.cert.git_transport_certificate_check_cb certificate_check;
85 
86 	/**
87 	 * Payload to be provided to the credentials and certificate
88 	 * check callbacks.
89 	 */
90 	void* payload;
91 }
92 
93 enum GIT_PROXY_OPTIONS_VERSION = 1;
94 
95 pragma(inline, true)
96 pure nothrow @safe @nogc
97 .git_proxy_options GIT_PROXY_OPTIONS_INIT()
98 
99 	do
100 	{
101 		.git_proxy_options OUTPUT =
102 		{
103 			version_: .GIT_PROXY_OPTIONS_VERSION,
104 		};
105 
106 		return OUTPUT;
107 	}
108 
109 /**
110  * Initialize git_proxy_options structure
111  *
112  * Initializes a `git_proxy_options` with default values. Equivalent to
113  * creating an instance with `GIT_PROXY_OPTIONS_INIT`.
114  *
115  * Params:
116  *      opts = The `git_proxy_options` struct to initialize.
117  *      version = The struct version; pass `GIT_PROXY_OPTIONS_VERSION`.
118  *
119  * Returns: Zero on success; -1 on failure.
120  */
121 //GIT_EXTERN
122 int git_proxy_options_init(.git_proxy_options* opts, uint version_);