summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-07-25 07:55:55 -0400
committerColin Walters <walters@verbum.org>2014-07-28 13:49:38 -0400
commitb97a5f59df26267b893a05b3cecbe04fe6e8db7e (patch)
treee9d038e5945383862103f0c3e927354124db41c1
parent43bba232a0af7b7dfef1eb2c6c6637dcba41e1d3 (diff)
downloadostree-b97a5f59df26267b893a05b3cecbe04fe6e8db7e.tar.gz
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
-rw-r--r--doc/ostree.repo-config.xml6
-rw-r--r--src/libostree/ostree-fetcher.c27
-rw-r--r--src/libostree/ostree-fetcher.h3
-rw-r--r--src/libostree/ostree-repo-pull.c11
4 files changed, 37 insertions, 10 deletions
diff --git a/doc/ostree.repo-config.xml b/doc/ostree.repo-config.xml
index bbacdd08..26fef077 100644
--- a/doc/ostree.repo-config.xml
+++ b/doc/ostree.repo-config.xml
@@ -127,6 +127,12 @@ Boston, MA 02111-1307, USA.
</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.
Controls whether or not OSTree will require commits to be
diff --git a/src/libostree/ostree-fetcher.c b/src/libostree/ostree-fetcher.c
index 0ea4d29d..298ba63f 100644
--- a/src/libostree/ostree-fetcher.c
+++ b/src/libostree/ostree-fetcher.c
@@ -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"))
@@ -225,6 +216,22 @@ _ostree_fetcher_new (GFile *tmpdir,
}
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)
{
diff --git a/src/libostree/ostree-fetcher.h b/src/libostree/ostree-fetcher.h
index 850d3178..0ab1def4 100644
--- a/src/libostree/ostree-fetcher.h
+++ b/src/libostree/ostree-fetcher.h
@@ -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);
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 51eb4d0c..76798d6e 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -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,