mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-21 13:34:34 +03:00
core: Support a per-remote "proxy" configuration option
We don't want to have to force people to set it in the environment. https://bugzilla.gnome.org/show_bug.cgi?id=733734
This commit is contained in:
parent
43bba232a0
commit
b97a5f59df
@ -126,6 +126,12 @@ Boston, MA 02111-1307, USA.
|
||||
<literal>https</literal>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>proxy</varname></term>
|
||||
<listitem><para>A string value, if given should be a URL for a
|
||||
HTTP proxy to use for access to this repository.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>gpg-verify</varname></term>
|
||||
<listitem><para>A boolean value, defaults to true.
|
||||
|
@ -172,16 +172,7 @@ _ostree_fetcher_init (OstreeFetcher *self)
|
||||
http_proxy = g_getenv ("http_proxy");
|
||||
if (http_proxy)
|
||||
{
|
||||
SoupURI *proxy_uri = soup_uri_new (http_proxy);
|
||||
if (!proxy_uri)
|
||||
{
|
||||
g_warning ("Invalid proxy URI '%s'", http_proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set (self->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
|
||||
soup_uri_free (proxy_uri);
|
||||
}
|
||||
_ostree_fetcher_set_proxy (self, http_proxy);
|
||||
}
|
||||
|
||||
if (g_getenv ("OSTREE_DEBUG_HTTP"))
|
||||
@ -224,6 +215,22 @@ _ostree_fetcher_new (GFile *tmpdir,
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
_ostree_fetcher_set_proxy (OstreeFetcher *self,
|
||||
const char *http_proxy)
|
||||
{
|
||||
SoupURI *proxy_uri = soup_uri_new (http_proxy);
|
||||
if (!proxy_uri)
|
||||
{
|
||||
g_warning ("Invalid proxy URI '%s'", http_proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set (self->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
|
||||
soup_uri_free (proxy_uri);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_ostree_fetcher_set_client_cert (OstreeFetcher *fetcher,
|
||||
GTlsCertificate *cert)
|
||||
|
@ -54,6 +54,9 @@ GType _ostree_fetcher_get_type (void) G_GNUC_CONST;
|
||||
OstreeFetcher *_ostree_fetcher_new (GFile *tmpdir,
|
||||
OstreeFetcherConfigFlags flags);
|
||||
|
||||
void _ostree_fetcher_set_proxy (OstreeFetcher *fetcher,
|
||||
const char *proxy);
|
||||
|
||||
void _ostree_fetcher_set_client_cert (OstreeFetcher *fetcher,
|
||||
GTlsCertificate *cert);
|
||||
|
||||
|
@ -1151,6 +1151,17 @@ ostree_repo_pull (OstreeRepo *self,
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
gs_free char *http_proxy = NULL;
|
||||
|
||||
if (!ot_keyfile_get_value_with_default (config, remote_key, "proxy",
|
||||
NULL, &http_proxy, error))
|
||||
goto out;
|
||||
|
||||
if (http_proxy)
|
||||
_ostree_fetcher_set_proxy (pull_data->fetcher, http_proxy);
|
||||
}
|
||||
|
||||
if (!pull_data->base_uri)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
|
Loading…
Reference in New Issue
Block a user