pidgin/pidgin

Remove SOCKS5 proxy code.

2020-11-17, Elliott Sales de Andrade
ea68b8867179
Parents 42456b38da44
Children 22d3e966281b
Remove SOCKS5 proxy code.

It's all embedded in the relevant prpls now.

Reviewed at https://reviews.imfreedom.org/r/226/
--- a/ChangeLog.API Mon Nov 16 19:40:20 2020 -0600
+++ b/ChangeLog.API Tue Nov 17 21:57:13 2020 -0600
@@ -445,6 +445,7 @@
* PurplePluginProtocolInfo
* pidgin_protocol_option_menu_new
* purple_proxy_connect_socks5
+ * purple_proxy_connect_socks5_account
* purple_quotedp_decode. See the GMime library if needed.
* purple_restore_default_signal_handlers
* purple_request_certificate
--- a/libpurple/proxy.c Mon Nov 16 19:40:20 2020 -0600
+++ b/libpurple/proxy.c Tue Nov 17 21:57:13 2020 -0600
@@ -822,201 +822,6 @@
return connect_data;
}
-static void
-socks5_proxy_connect_cb(GObject *source, GAsyncResult *res, gpointer user_data)
-{
- PurpleProxyConnectData *connect_data = user_data;
- GIOStream *stream;
- GError *error = NULL;
- GSocket *socket;
-
- stream = g_proxy_connect_finish(G_PROXY(source), res, &error);
-
- if (stream == NULL) {
- /* Ignore cancelled error as that signifies connect_data has
- * been freed
- */
- if (!g_error_matches(error, G_IO_ERROR,
- G_IO_ERROR_CANCELLED)) {
- purple_debug_error("proxy", "Unable to connect to "
- "destination host: %s\n",
- error->message);
- purple_proxy_connect_data_disconnect(connect_data,
- "Unable to connect to destination "
- "host.\n");
- }
-
- g_clear_error(&error);
- return;
- }
-
- if (!G_IS_SOCKET_CONNECTION(stream)) {
- purple_debug_error("proxy",
- "GProxy didn't return a GSocketConnection.\n");
- purple_proxy_connect_data_disconnect(connect_data,
- "GProxy didn't return a GSocketConnection.\n");
- g_object_unref(stream);
- return;
- }
-
- socket = g_socket_connection_get_socket(G_SOCKET_CONNECTION(stream));
-
- /* Duplicate the file descriptor, and then free the connection.
- * libpurple's proxy code doesn't keep an object around for the
- * lifetime of the connection. Therefore, in order to not leak
- * memory, the GSocketConnection (aka GIOStream here) must be
- * freed here. In order to avoid the double close/free of the
- * file descriptor, the file descriptor is duplicated.
- */
- connect_data->fd = duplicate_fd(g_socket_get_fd(socket));
- g_object_unref(stream);
-
- purple_proxy_connect_data_connected(connect_data);
-}
-
-/* This is called when we connect to the SOCKS5 proxy server (through any
- * relevant account proxy)
- */
-static void
-socks5_connect_to_host_cb(GObject *source, GAsyncResult *res,
- gpointer user_data)
-{
- PurpleProxyConnectData *connect_data = user_data;
- GSocketConnection *conn;
- GError *error = NULL;
- GProxy *proxy;
- PurpleProxyInfo *info;
- GSocketAddress *addr;
- GInetSocketAddress *inet_addr;
- GSocketAddress *proxy_addr;
-
- conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
- res, &error);
- if (conn == NULL) {
- /* Ignore cancelled error as that signifies connect_data has
- * been freed
- */
- if (!g_error_matches(error, G_IO_ERROR,
- G_IO_ERROR_CANCELLED)) {
- purple_debug_error("proxy", "Unable to connect to "
- "SOCKS5 host: %s\n", error->message);
- purple_proxy_connect_data_disconnect(connect_data,
- "Unable to connect to SOCKS5 host.\n");
- }
-
- g_clear_error(&error);
- return;
- }
-
- proxy = g_proxy_get_default_for_protocol("socks5");
- if (proxy == NULL) {
- purple_debug_error("proxy", "SOCKS5 proxy backend missing.\n");
- purple_proxy_connect_data_disconnect(connect_data,
- "SOCKS5 proxy backend missing.\n");
- g_object_unref(conn);
- return;
- }
-
- info = connect_data->gpi;
-
- addr = g_socket_connection_get_remote_address(conn, &error);
- if (addr == NULL) {
- purple_debug_error("proxy", "Unable to retrieve SOCKS5 host "
- "address from connection: %s\n",
- error->message);
- purple_proxy_connect_data_disconnect(connect_data,
- "Unable to retrieve SOCKS5 host address from "
- "connection");
- g_object_unref(conn);
- g_object_unref(proxy);
- g_clear_error(&error);
- return;
- }
-
- inet_addr = G_INET_SOCKET_ADDRESS(addr);
-
- proxy_addr = g_proxy_address_new(
- g_inet_socket_address_get_address(inet_addr),
- g_inet_socket_address_get_port(inet_addr),
- "socks5", connect_data->host, connect_data->port,
- purple_proxy_info_get_username(info),
- purple_proxy_info_get_password(info));
- g_object_unref(inet_addr);
-
- purple_debug_info("proxy", "Initiating SOCKS5 negotiation.\n");
-
- purple_debug_info("proxy",
- "Connecting to %s:%d via %s:%d using SOCKS5\n",
- connect_data->host, connect_data->port,
- purple_proxy_info_get_host(connect_data->gpi),
- purple_proxy_info_get_port(connect_data->gpi));
-
- g_proxy_connect_async(proxy, G_IO_STREAM(conn),
- G_PROXY_ADDRESS(proxy_addr),
- connect_data->cancellable,
- socks5_proxy_connect_cb, connect_data);
- g_object_unref(proxy_addr);
- g_object_unref(conn);
- g_object_unref(proxy);
-}
-
-/*
- * Combine some of this code with purple_proxy_connect()
- */
-PurpleProxyConnectData *
-purple_proxy_connect_socks5_account(void *handle, PurpleAccount *account,
- PurpleProxyInfo *gpi,
- const char *host, int port,
- PurpleProxyConnectFunction connect_cb,
- gpointer data)
-{
- PurpleProxyConnectData *connect_data;
- GSocketClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail(host != NULL, NULL);
- g_return_val_if_fail(port >= 0, NULL);
- g_return_val_if_fail(connect_cb != NULL, NULL);
-
- client = purple_gio_socket_client_new(account, &error);
-
- if (client == NULL) {
- /* Assume it's a proxy error */
- purple_notify_error(NULL, NULL, _("Invalid proxy settings"),
- error->message,
- purple_request_cpar_from_account(account));
- g_clear_error(&error);
- return NULL;
- }
-
- connect_data = g_new0(PurpleProxyConnectData, 1);
- connect_data->fd = -1;
- connect_data->handle = handle;
- connect_data->connect_cb = connect_cb;
- connect_data->data = data;
- connect_data->host = g_strdup(host);
- connect_data->port = port;
- connect_data->gpi = gpi;
- connect_data->cancellable = g_cancellable_new();
-
- purple_debug_info("proxy",
- "Connecting to %s:%d via %s:%d using SOCKS5\n",
- connect_data->host, connect_data->port,
- purple_proxy_info_get_host(connect_data->gpi),
- purple_proxy_info_get_port(connect_data->gpi));
-
- g_socket_client_connect_to_host_async(client,
- purple_proxy_info_get_host(connect_data->gpi),
- purple_proxy_info_get_port(connect_data->gpi),
- connect_data->cancellable, socks5_connect_to_host_cb,
- connect_data);
- g_object_unref(client);
-
- handles = g_slist_prepend(handles, connect_data);
-
- return connect_data;
-}
-
void
purple_proxy_connect_cancel(PurpleProxyConnectData *connect_data)
{
--- a/libpurple/proxy.h Mon Nov 16 19:40:20 2020 -0600
+++ b/libpurple/proxy.h Tue Nov 17 21:57:13 2020 -0600
@@ -288,37 +288,6 @@
PurpleProxyConnectFunction connect_cb, gpointer data);
/**
- * purple_proxy_connect_socks5_account: (skip)
- * @handle: A handle that should be associated with this
- * connection attempt. The handle can be used
- * to cancel the connection attempt using the
- * purple_proxy_connect_cancel_with_handle()
- * function.
- * @account: The account making the connection.
- * @gpi: The PurpleProxyInfo specifying the proxy settings
- * @host: The destination host.
- * @port: The destination port.
- * @connect_cb: (scope call): The function to call when the connection is
- * established. If the connection failed then
- * fd will be -1 and error message will be set
- * to something descriptive (hopefully).
- * @data: User-defined data.
- *
- * Makes a connection through a SOCKS5 proxy.
- *
- * Note that if the account that is making the connection uses a proxy, this
- * connection to a SOCKS5 proxy will be made through the account proxy.
- *
- * Returns: NULL if there was an error, or a reference to an
- * opaque data structure that can be used to cancel
- * the pending connection, if needed.
- */
-PurpleProxyConnectData *purple_proxy_connect_socks5_account(void *handle,
- PurpleAccount *account, PurpleProxyInfo *gpi,
- const char *host, int port,
- PurpleProxyConnectFunction connect_cb, gpointer data);
-
-/**
* purple_proxy_connect_cancel: (skip)
* @connect_data: The #PurpleProxyConnectData to cancel.
*