GSimpleProxyResolver

GSimpleProxyResolver — Simple proxy resolver implementation

Synopsis

#include <gio/gio.h>

struct              GSimpleProxyResolver;
GProxyResolver *    g_simple_proxy_resolver_new         (const gchar *default_proxy,
                                                         gchar **ignore_hosts);
void                g_simple_proxy_resolver_set_default_proxy
                                                        (GSimpleProxyResolver *resolver,
                                                         const gchar *default_proxy);
void                g_simple_proxy_resolver_set_ignore_hosts
                                                        (GSimpleProxyResolver *resolver,
                                                         gchar **ignore_hosts);
void                g_simple_proxy_resolver_set_uri_proxy
                                                        (GSimpleProxyResolver *resolver,
                                                         const gchar *uri_scheme,
                                                         const gchar *proxy);

Object Hierarchy

  GObject
   +----GSimpleProxyResolver

Implemented Interfaces

GSimpleProxyResolver implements GProxyResolver.

Properties

  "default-proxy"            gchar*                : Read / Write
  "ignore-hosts"             GStrv                 : Read / Write

Description

GSimpleProxyResolver is a simple GProxyResolver implementation that handles a single default proxy, multiple URI-scheme-specific proxies, and a list of hosts that proxies should not be used for.

GSimpleProxyResolver is never the default proxy resolver, but it can be used as the base class for another proxy resolver implementation, or it can be created and used manually, such as with g_socket_client_set_proxy_resolver().

Details

struct GSimpleProxyResolver

struct GSimpleProxyResolver;

A GProxyResolver implementation for using a fixed set of proxies.


g_simple_proxy_resolver_new ()

GProxyResolver *    g_simple_proxy_resolver_new         (const gchar *default_proxy,
                                                         gchar **ignore_hosts);

Creates a new GSimpleProxyResolver. See "default-proxy" and "ignore-hosts" for more details on how the arguments are interpreted.

default_proxy :

the default proxy to use, eg "socks://192.168.1.1". [allow-none]

ignore_hosts :

an optional list of hosts/IP addresses to not use a proxy for. [allow-none]

Returns :

a new GSimpleProxyResolver

Since 2.36


g_simple_proxy_resolver_set_default_proxy ()

void                g_simple_proxy_resolver_set_default_proxy
                                                        (GSimpleProxyResolver *resolver,
                                                         const gchar *default_proxy);

Sets the default proxy on resolver, to be used for any URIs that don't match "ignore-hosts" or a proxy set via g_simple_proxy_resolver_set_uri_proxy().

If default_proxy starts with "socks://", GSimpleProxyResolver will treat it as referring to all three of the socks5, socks4a, and socks4 proxy types.

resolver :

a GSimpleProxyResolver

default_proxy :

the default proxy to use

Since 2.36


g_simple_proxy_resolver_set_ignore_hosts ()

void                g_simple_proxy_resolver_set_ignore_hosts
                                                        (GSimpleProxyResolver *resolver,
                                                         gchar **ignore_hosts);

g_simple_proxy_resolver_set_uri_proxy ()

void                g_simple_proxy_resolver_set_uri_proxy
                                                        (GSimpleProxyResolver *resolver,
                                                         const gchar *uri_scheme,
                                                         const gchar *proxy);

Adds a URI-scheme-specific proxy to resolver; URIs whose scheme matches uri_scheme (and which don't match "ignore-hosts") will be proxied via proxy.

As with "default-proxy", if proxy starts with "socks://", GSimpleProxyResolver will treat it as referring to all three of the socks5, socks4a, and socks4 proxy types.

resolver :

a GSimpleProxyResolver

uri_scheme :

the URI scheme to add a proxy for

proxy :

the proxy to use for uri_scheme

Since 2.36

Property Details

The "default-proxy" property

  "default-proxy"            gchar*                : Read / Write

The default proxy URI that will be used for any URI that doesn't match "ignore-hosts", and doesn't match any of the schemes set with g_simple_proxy_resolver_set_uri_proxy().

Note that as a special case, if this URI starts with "socks://", GSimpleProxyResolver will treat it as referring to all three of the socks5, socks4a, and socks4 proxy types.

Default value: NULL


The "ignore-hosts" property

  "ignore-hosts"             GStrv                 : Read / Write

A list of hostnames and IP addresses that the resolver should allow direct connections to.

Entries can be in one of 4 formats:

  • A hostname, such as "example.com", ".example.com", or "*.example.com", any of which match "example.com" or any subdomain of it.
  • An IPv4 or IPv6 address, such as "192.168.1.1", which matches only that address.
  • A hostname or IP address followed by a port, such as "example.com:80", which matches whatever the hostname or IP address would match, but only for URLs with the (explicitly) indicated port. In the case of an IPv6 address, the address part must appear in brackets: "[::1]:443"
  • An IP address range, given by a base address and prefix length, such as "fe80::/10", which matches any address in that range.

Note that when dealing with Unicode hostnames, the matching is done against the ASCII form of the name.

Also note that hostname exclusions apply only to connections made to hosts identified by name, and IP address exclusions apply only to connections made to hosts identified by address. That is, if example.com has an address of 192.168.1.1, and the :ignore-hosts list contains only "192.168.1.1", then a connection to "example.com" (eg, via a GNetworkAddress) will use the proxy, and a connection to "192.168.1.1" (eg, via a GInetSocketAddress) will not.

These rules match the "ignore-hosts"/"noproxy" rules most commonly used by other applications.

See Also

g_socket_client_set_proxy_resolver()