{
PROP_0,
PROP_PROTOCOL,
+ PROP_DESTINATION_PROTOCOL,
PROP_DESTINATION_HOSTNAME,
PROP_DESTINATION_PORT,
PROP_USERNAME,
- PROP_PASSWORD
+ PROP_PASSWORD,
+ PROP_URI
};
struct _GProxyAddressPrivate
{
+ gchar *uri;
gchar *protocol;
gchar *username;
gchar *password;
+ gchar *dest_protocol;
gchar *dest_hostname;
guint16 dest_port;
};
{
GProxyAddress *proxy = G_PROXY_ADDRESS (object);
+ g_free (proxy->priv->uri);
g_free (proxy->priv->protocol);
g_free (proxy->priv->username);
g_free (proxy->priv->password);
g_free (proxy->priv->dest_hostname);
+ g_free (proxy->priv->dest_protocol);
G_OBJECT_CLASS (g_proxy_address_parent_class)->finalize (object);
}
static void
g_proxy_address_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GProxyAddress *proxy = G_PROXY_ADDRESS (object);
proxy->priv->protocol = g_value_dup_string (value);
break;
+ case PROP_DESTINATION_PROTOCOL:
+ g_free (proxy->priv->dest_protocol);
+ proxy->priv->dest_protocol = g_value_dup_string (value);
+ break;
+
case PROP_DESTINATION_HOSTNAME:
g_free (proxy->priv->dest_hostname);
proxy->priv->dest_hostname = g_value_dup_string (value);
proxy->priv->password = g_value_dup_string (value);
break;
+ case PROP_URI:
+ g_free (proxy->priv->uri);
+ proxy->priv->uri = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
g_value_set_string (value, proxy->priv->protocol);
break;
+ case PROP_DESTINATION_PROTOCOL:
+ g_value_set_string (value, proxy->priv->dest_protocol);
+ break;
+
case PROP_DESTINATION_HOSTNAME:
g_value_set_string (value, proxy->priv->dest_hostname);
break;
g_value_set_string (value, proxy->priv->password);
break;
+ case PROP_URI:
+ g_value_set_string (value, proxy->priv->uri);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ /**
+ * GProxyAddress:destination-protocol:
+ *
+ * The protocol being spoke to the destination host, or %NULL if
+ * the #GProxyAddress doesn't know.
+ *
+ * Since: 2.34
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_DESTINATION_PROTOCOL,
+ g_param_spec_string ("destination-protocol",
+ P_("Destionation Protocol"),
+ P_("The proxy destination protocol"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (gobject_class,
PROP_DESTINATION_HOSTNAME,
g_param_spec_string ("destination-hostname",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GProxyAddress:uri:
+ *
+ * The URI string that the proxy was constructed from (or %NULL
+ * if the creator didn't specify this).
+ *
+ * Since: 2.34
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_URI,
+ g_param_spec_string ("uri",
+ P_("URI"),
+ P_("The proxy's URI"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
}
static void
* Creates a new #GProxyAddress for @inetaddr with @protocol that should
* tunnel through @dest_hostname and @dest_port.
*
+ * (Note that this method doesn't set the #GProxyAddress:uri or
+ * #GProxyAddress:destination-protocol fields; use g_object_new()
+ * directly if you want to set those.)
+ *
* Returns: a new #GProxyAddress
*
* Since: 2.26
* g_proxy_address_get_protocol:
* @proxy: a #GProxyAddress
*
- * Gets @proxy's protocol.
+ * Gets @proxy's protocol. eg, "socks" or "http"
*
* Returns: the @proxy's protocol
*
}
/**
+ * g_proxy_address_get_destination_protocol:
+ * @proxy: a #GProxyAddress
+ *
+ * Gets the protocol that is being spoken to the destination
+ * server; eg, "http" or "ftp".
+ *
+ * Returns: the @proxy's destination protocol
+ *
+ * Since: 2.34
+ */
+const gchar *
+g_proxy_address_get_destination_protocol (GProxyAddress *proxy)
+{
+ return proxy->priv->dest_protocol;
+}
+
+/**
* g_proxy_address_get_destination_hostname:
* @proxy: a #GProxyAddress
*
- * Gets @proxy's destination hostname.
+ * Gets @proxy's destination hostname; that is, the name of the host
+ * that will be connected to via the proxy, not the name of the proxy
+ * itself.
*
* Returns: the @proxy's destination hostname
*
* g_proxy_address_get_destination_port:
* @proxy: a #GProxyAddress
*
- * Gets @proxy's destination port.
+ * Gets @proxy's destination port; that is, the port on the
+ * destination host that will be connected to via the proxy, not the
+ * port number of the proxy itself.
*
* Returns: the @proxy's destination port
*
{
return proxy->priv->password;
}
+
+
+/**
+ * g_proxy_address_get_uri:
+ * @proxy: a #GProxyAddress
+ *
+ * Gets the proxy URI that @proxy was constructed from.
+ *
+ * Returns: the @proxy's URI, or %NULL if unknown
+ *
+ * Since: 2.34
+ */
+const gchar *
+g_proxy_address_get_uri (GProxyAddress *proxy)
+{
+ return proxy->priv->uri;
+}
gchar **next_proxy;
GSocketAddressEnumerator *addr_enum;
GSocketAddress *proxy_address;
+ const gchar *proxy_uri;
gchar *proxy_type;
gchar *proxy_username;
gchar *proxy_password;
while (priv->addr_enum == NULL && *priv->next_proxy)
{
GSocketConnectable *connectable = NULL;
- const gchar *proxy_uri;
GProxy *proxy;
- proxy_uri = *priv->next_proxy++;
+ priv->proxy_uri = *priv->next_proxy++;
g_free (priv->proxy_type);
- priv->proxy_type = g_uri_parse_scheme (proxy_uri);
+ priv->proxy_type = g_uri_parse_scheme (priv->proxy_uri);
if (priv->proxy_type == NULL)
continue;
{
GError *error = NULL;
- connectable = g_network_address_parse_uri (proxy_uri, 0, &error);
+ connectable = g_network_address_parse_uri (priv->proxy_uri, 0, &error);
if (error)
{
g_warning ("Invalid proxy URI '%s': %s",
- proxy_uri, error->message);
+ priv->proxy_uri, error->message);
g_error_free (error);
}
- save_userinfo (priv, proxy_uri);
+ save_userinfo (priv, priv->proxy_uri);
}
if (connectable)
while (result == NULL && (*priv->next_proxy || priv->addr_enum))
{
gchar *dest_hostname;
+ gchar *dest_protocol;
GInetSocketAddress *inetsaddr;
GInetAddress *inetaddr;
guint16 port;
{
dest_hostname = g_strdup (priv->dest_hostname);
}
-
+ dest_protocol = g_uri_parse_scheme (priv->dest_uri);
g_return_val_if_fail (G_IS_INET_SOCKET_ADDRESS (priv->proxy_address),
NULL);
inetaddr = g_inet_socket_address_get_address (inetsaddr);
port = g_inet_socket_address_get_port (inetsaddr);
- result = g_proxy_address_new (inetaddr, port,
- priv->proxy_type,
- dest_hostname, priv->dest_port,
- priv->proxy_username,
- priv->proxy_password);
-
+ result = g_object_new (G_TYPE_PROXY_ADDRESS,
+ "address", inetaddr,
+ "port", port,
+ "protocol", priv->proxy_type,
+ "destination-protocol", dest_protocol,
+ "destination-hostname", dest_hostname,
+ "destination-port", priv->dest_port,
+ "username", priv->proxy_username,
+ "password", priv->proxy_password,
+ "uri", priv->proxy_uri,
+ NULL);
g_free (dest_hostname);
+ g_free (dest_protocol);
if (priv->supports_hostname || priv->next_dest_ip == NULL)
{
}
else
{
- gchar *dest_hostname;
+ gchar *dest_hostname, *dest_protocol;
GInetSocketAddress *inetsaddr;
GInetAddress *inetaddr;
guint16 port;
{
dest_hostname = g_strdup (priv->dest_hostname);
}
+ dest_protocol = g_uri_parse_scheme (priv->dest_uri);
g_return_if_fail (G_IS_INET_SOCKET_ADDRESS (priv->proxy_address));
inetaddr = g_inet_socket_address_get_address (inetsaddr);
port = g_inet_socket_address_get_port (inetsaddr);
- result = g_proxy_address_new (inetaddr, port,
- priv->proxy_type,
- dest_hostname, priv->dest_port,
- priv->proxy_username,
- priv->proxy_password);
-
+ result = g_object_new (G_TYPE_PROXY_ADDRESS,
+ "address", inetaddr,
+ "port", port,
+ "protocol", priv->proxy_type,
+ "destination-protocol", dest_protocol,
+ "destination-hostname", dest_hostname,
+ "destination-port", priv->dest_port,
+ "username", priv->proxy_username,
+ "password", priv->proxy_password,
+ "uri", priv->proxy_uri,
+ NULL);
g_free (dest_hostname);
+ g_free (dest_protocol);
if (priv->supports_hostname || priv->next_dest_ip == NULL)
{