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