1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="networking.html" title="Low-level network support">
9 <link rel="prev" href="GUnixCredentialsMessage.html" title="GUnixCredentialsMessage">
10 <link rel="next" href="GProxyAddress.html" title="GProxyAddress">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
17 <td><a accesskey="p" href="GUnixCredentialsMessage.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="networking.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GIO Reference Manual</th>
21 <td><a accesskey="n" href="GProxyAddress.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#GProxy.synopsis" class="shortcut">Top</a>
26 <a href="#GProxy.description" class="shortcut">Description</a>
28 <a href="#GProxy.object-hierarchy" class="shortcut">Object Hierarchy</a>
30 <a href="#GProxy.prerequisites" class="shortcut">Prerequisites</a>
33 <div class="refentry">
34 <a name="GProxy"></a><div class="titlepage"></div>
35 <div class="refnamediv"><table width="100%"><tr>
37 <h2><span class="refentrytitle"><a name="GProxy.top_of_page"></a>GProxy</span></h2>
38 <p>GProxy — Interface for proxy handling</p>
40 <td valign="top" align="right"></td>
42 <div class="refsynopsisdiv">
43 <a name="GProxy.synopsis"></a><h2>Synopsis</h2>
44 <pre class="synopsis"> <a class="link" href="GProxy.html#GProxy-struct" title="GProxy">GProxy</a>;
45 struct <a class="link" href="GProxy.html#GProxyInterface" title="struct GProxyInterface">GProxyInterface</a>;
46 #define <a class="link" href="GProxy.html#G-PROXY-EXTENSION-POINT-NAME:CAPS" title="G_PROXY_EXTENSION_POINT_NAME">G_PROXY_EXTENSION_POINT_NAME</a>
47 <a class="link" href="GIOStream.html" title="GIOStream"><span class="returnvalue">GIOStream</span></a> * <a class="link" href="GProxy.html#g-proxy-connect" title="g_proxy_connect ()">g_proxy_connect</a> (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
48 <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *connection</code></em>,
49 <em class="parameter"><code><a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a> *proxy_address</code></em>,
50 <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
51 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
52 <span class="returnvalue">void</span> <a class="link" href="GProxy.html#g-proxy-connect-async" title="g_proxy_connect_async ()">g_proxy_connect_async</a> (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
53 <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *connection</code></em>,
54 <em class="parameter"><code><a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a> *proxy_address</code></em>,
55 <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
56 <em class="parameter"><code><a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
57 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
58 <a class="link" href="GIOStream.html" title="GIOStream"><span class="returnvalue">GIOStream</span></a> * <a class="link" href="GProxy.html#g-proxy-connect-finish" title="g_proxy_connect_finish ()">g_proxy_connect_finish</a> (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
59 <em class="parameter"><code><a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *result</code></em>,
60 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
61 <a class="link" href="GProxy.html" title="GProxy"><span class="returnvalue">GProxy</span></a> * <a class="link" href="GProxy.html#g-proxy-get-default-for-protocol" title="g_proxy_get_default_for_protocol ()">g_proxy_get_default_for_protocol</a> (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *protocol</code></em>);
62 <a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GProxy.html#g-proxy-supports-hostname" title="g_proxy_supports_hostname ()">g_proxy_supports_hostname</a> (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>);
65 <div class="refsect1">
66 <a name="GProxy.object-hierarchy"></a><h2>Object Hierarchy</h2>
67 <pre class="synopsis">
72 <div class="refsect1">
73 <a name="GProxy.prerequisites"></a><h2>Prerequisites</h2>
76 <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>.</p>
78 <div class="refsect1">
79 <a name="GProxy.description"></a><h2>Description</h2>
81 A <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> handles connecting to a remote host via a given type of
82 proxy server. It is implemented by the 'gio-proxy' extension point.
83 The extensions are named after their proxy protocol name. As an
84 example, a SOCKS5 proxy implementation can be retrieved with the
85 name 'socks5' using the function
86 <a class="link" href="gio-Extension-Points.html#g-io-extension-point-get-extension-by-name" title="g_io_extension_point_get_extension_by_name ()"><code class="function">g_io_extension_point_get_extension_by_name()</code></a>.
89 <div class="refsect1">
90 <a name="GProxy.details"></a><h2>Details</h2>
91 <div class="refsect2">
92 <a name="GProxy-struct"></a><h3>GProxy</h3>
93 <pre class="programlisting">typedef struct _GProxy GProxy;</pre>
95 Interface that handles proxy connection and payload.
97 <p class="since">Since 2.26</p>
100 <div class="refsect2">
101 <a name="GProxyInterface"></a><h3>struct GProxyInterface</h3>
102 <pre class="programlisting">struct GProxyInterface {
103 GTypeInterface g_iface;
107 GIOStream * (* connect) (GProxy *proxy,
108 GIOStream *connection,
109 GProxyAddress *proxy_address,
110 GCancellable *cancellable,
113 void (* connect_async) (GProxy *proxy,
114 GIOStream *connection,
115 GProxyAddress *proxy_address,
116 GCancellable *cancellable,
117 GAsyncReadyCallback callback,
120 GIOStream * (* connect_finish) (GProxy *proxy,
121 GAsyncResult *result,
124 gboolean (* supports_hostname) (GProxy *proxy);
128 Provides an interface for handling proxy connection and payload.
130 <div class="variablelist"><table border="0">
131 <col align="left" valign="top">
134 <td><p><span class="term"><a href="./../gobject/gobject/gobject-Type-Information.html#GTypeInterface"><span class="type">GTypeInterface</span></a> <em class="structfield"><code><a name="GProxyInterface.g-iface"></a>g_iface</code></em>;</span></p></td>
135 <td>The parent interface.</td>
138 <td><p><span class="term"><em class="structfield"><code><a name="GProxyInterface.connect"></a>connect</code></em> ()</span></p></td>
139 <td>Connect to proxy server and wrap (if required) the <span class="type">connection</span>
140 to handle payload.</td>
143 <td><p><span class="term"><em class="structfield"><code><a name="GProxyInterface.connect-async"></a>connect_async</code></em> ()</span></p></td>
144 <td>Same as <code class="function">connect()</code> but asynchronous.</td>
147 <td><p><span class="term"><em class="structfield"><code><a name="GProxyInterface.connect-finish"></a>connect_finish</code></em> ()</span></p></td>
148 <td>Returns the result of <code class="function">connect_async()</code>
152 <td><p><span class="term"><em class="structfield"><code><a name="GProxyInterface.supports-hostname"></a>supports_hostname</code></em> ()</span></p></td>
153 <td>Returns whether the proxy supports hostname lookups.</td>
157 <p class="since">Since 2.26</p>
160 <div class="refsect2">
161 <a name="G-PROXY-EXTENSION-POINT-NAME:CAPS"></a><h3>G_PROXY_EXTENSION_POINT_NAME</h3>
162 <pre class="programlisting">#define G_PROXY_EXTENSION_POINT_NAME "gio-proxy"
165 Extension point for proxy functionality.
168 <p class="since">Since 2.26</p>
171 <div class="refsect2">
172 <a name="g-proxy-connect"></a><h3>g_proxy_connect ()</h3>
173 <pre class="programlisting"><a class="link" href="GIOStream.html" title="GIOStream"><span class="returnvalue">GIOStream</span></a> * g_proxy_connect (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
174 <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *connection</code></em>,
175 <em class="parameter"><code><a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a> *proxy_address</code></em>,
176 <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
177 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
179 Given <em class="parameter"><code>connection</code></em> to communicate with a proxy (eg, a
180 <a class="link" href="GSocketConnection.html" title="GSocketConnection"><span class="type">GSocketConnection</span></a> that is connected to the proxy server), this
181 does the necessary handshake to connect to <em class="parameter"><code>proxy_address</code></em>, and if
182 required, wraps the <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> to handle proxy payload.
184 <div class="variablelist"><table border="0">
185 <col align="left" valign="top">
188 <td><p><span class="term"><em class="parameter"><code>proxy</code></em> :</span></p></td>
189 <td>a <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a>
193 <td><p><span class="term"><em class="parameter"><code>connection</code></em> :</span></p></td>
194 <td>a <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a>
198 <td><p><span class="term"><em class="parameter"><code>proxy_address</code></em> :</span></p></td>
199 <td>a <a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a>
203 <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
204 <td>a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
208 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
209 <td>return <a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>
213 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
214 <td>a <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> that will replace <em class="parameter"><code>connection</code></em>. This might
215 be the same as <em class="parameter"><code>connection</code></em>, in which case a reference
216 will be added. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
221 <p class="since">Since 2.26</p>
224 <div class="refsect2">
225 <a name="g-proxy-connect-async"></a><h3>g_proxy_connect_async ()</h3>
226 <pre class="programlisting"><span class="returnvalue">void</span> g_proxy_connect_async (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
227 <em class="parameter"><code><a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a> *connection</code></em>,
228 <em class="parameter"><code><a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a> *proxy_address</code></em>,
229 <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
230 <em class="parameter"><code><a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
231 <em class="parameter"><code><a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
233 Asynchronous version of <a class="link" href="GProxy.html#g-proxy-connect" title="g_proxy_connect ()"><code class="function">g_proxy_connect()</code></a>.
235 <div class="variablelist"><table border="0">
236 <col align="left" valign="top">
239 <td><p><span class="term"><em class="parameter"><code>proxy</code></em> :</span></p></td>
240 <td>a <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a>
244 <td><p><span class="term"><em class="parameter"><code>connection</code></em> :</span></p></td>
245 <td>a <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a>
249 <td><p><span class="term"><em class="parameter"><code>proxy_address</code></em> :</span></p></td>
250 <td>a <a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a>
254 <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
255 <td>a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
259 <td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
260 <td>a <a class="link" href="GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a>. <span class="annotation">[<acronym title="The callback is valid until first called."><span class="acronym">scope async</span></acronym>]</span>
264 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
265 <td>callback data. <span class="annotation">[<acronym title="This parameter is a 'user_data', for callbacks; many bindings can pass NULL here."><span class="acronym">closure</span></acronym>]</span>
270 <p class="since">Since 2.26</p>
273 <div class="refsect2">
274 <a name="g-proxy-connect-finish"></a><h3>g_proxy_connect_finish ()</h3>
275 <pre class="programlisting"><a class="link" href="GIOStream.html" title="GIOStream"><span class="returnvalue">GIOStream</span></a> * g_proxy_connect_finish (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>,
276 <em class="parameter"><code><a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *result</code></em>,
277 <em class="parameter"><code><a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
279 See <a class="link" href="GProxy.html#g-proxy-connect" title="g_proxy_connect ()"><code class="function">g_proxy_connect()</code></a>.
281 <div class="variablelist"><table border="0">
282 <col align="left" valign="top">
285 <td><p><span class="term"><em class="parameter"><code>proxy</code></em> :</span></p></td>
286 <td>a <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a>
290 <td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
291 <td>a <a class="link" href="GAsyncResult.html" title="GAsyncResult"><span class="type">GAsyncResult</span></a>
295 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
296 <td>return <a href="./../glib/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a>
300 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
301 <td>a <a class="link" href="GIOStream.html" title="GIOStream"><span class="type">GIOStream</span></a>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
306 <p class="since">Since 2.26</p>
309 <div class="refsect2">
310 <a name="g-proxy-get-default-for-protocol"></a><h3>g_proxy_get_default_for_protocol ()</h3>
311 <pre class="programlisting"><a class="link" href="GProxy.html" title="GProxy"><span class="returnvalue">GProxy</span></a> * g_proxy_get_default_for_protocol (<em class="parameter"><code>const <a href="./../glib/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *protocol</code></em>);</pre>
313 Lookup "gio-proxy" extension point for a proxy implementation that supports
316 <div class="variablelist"><table border="0">
317 <col align="left" valign="top">
320 <td><p><span class="term"><em class="parameter"><code>protocol</code></em> :</span></p></td>
321 <td>the proxy protocol name (e.g. http, socks, etc)</td>
324 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
325 <td>return a <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> or NULL if protocol
326 is not supported. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
331 <p class="since">Since 2.26</p>
334 <div class="refsect2">
335 <a name="g-proxy-supports-hostname"></a><h3>g_proxy_supports_hostname ()</h3>
336 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_proxy_supports_hostname (<em class="parameter"><code><a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a> *proxy</code></em>);</pre>
338 Some proxy protocols expect to be passed a hostname, which they
339 will resolve to an IP address themselves. Others, like SOCKS4, do
340 not allow this. This function will return <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if <em class="parameter"><code>proxy</code></em> is
341 implementing such a protocol. When <a href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> is returned, the caller
342 should resolve the destination hostname first, and then pass a
343 <a class="link" href="GProxyAddress.html" title="GProxyAddress"><span class="type">GProxyAddress</span></a> containing the stringified IP address to
344 <a class="link" href="GProxy.html#g-proxy-connect" title="g_proxy_connect ()"><code class="function">g_proxy_connect()</code></a> or <a class="link" href="GProxy.html#g-proxy-connect-async" title="g_proxy_connect_async ()"><code class="function">g_proxy_connect_async()</code></a>.
346 <div class="variablelist"><table border="0">
347 <col align="left" valign="top">
350 <td><p><span class="term"><em class="parameter"><code>proxy</code></em> :</span></p></td>
351 <td>a <a class="link" href="GProxy.html" title="GProxy"><span class="type">GProxy</span></a>
355 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
357 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if hostname resolution is supported.</td>
361 <p class="since">Since 2.26</p>
367 Generated by GTK-Doc V1.18</div>