mirror of
https://github.com/irssi/irssi.git
synced 2026-08-24 11:02:21 +02:00
PROXY: implemented native proxy support
This patch creates a hook into the net_connect*() methods which call a method to connect to a proxy. Previous solution to send certain strings in the normal IRC dialog was some kind of hack as most proxies require some kind of negotation. E.g. HTTP proxies sent a 'HTTP/1.0 200 Connection established' HTTP header and clients have to wait for it. Else, sent bytes of the following IRC login will be dropped silently. With old method, it is also impossible to tunnel SSL IRC connections through the proxy as proxy speaks plain text or a special protocol while e.g. 'CONNECT ... HTTP/1.0' will be encrypted with key of IRC server. There are further enhancements possible: the whole net_connect stuff should be made asynchronously. Currently, only the hostname is resolved in the background (which makes little sense of local proxies usually).
This commit is contained in:
parent
3d6051a03e
commit
0236ee5eaa
12 changed files with 297 additions and 48 deletions
81
src/core/network-proxy.h
Normal file
81
src/core/network-proxy.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* --*- c -*--
|
||||
* Copyright (C) 2008 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 and/or 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef H_IRSSI_SRC_CORE_PROXY_H
|
||||
#define H_IRSSI_SRC_CORE_PROXY_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* helper structure for the send_string*() functions of the network_proxy
|
||||
* class */
|
||||
struct network_proxy_send_string_info
|
||||
{
|
||||
char const *host; /* hostname of the IRC server */
|
||||
uint16_t port; /* portnumber of the IRC server */
|
||||
|
||||
/* function which is used to send string; usually irc_send_cmd_now() */
|
||||
void (*func)(void *obj, char const *);
|
||||
|
||||
/* object for func */
|
||||
void *obj;
|
||||
};
|
||||
|
||||
struct network_proxy {
|
||||
/* destroys the network_proxy structure which must not be used anymore
|
||||
* after; this memberfunction is mandatory */
|
||||
void (*destroy)(struct network_proxy *);
|
||||
|
||||
/* connects through the proxy; this memberfunction is mandatory
|
||||
*
|
||||
* \arg hint_ip the asynchronously resolved ip of the proxy; when
|
||||
* NULL, method will resolve it itself
|
||||
* \arg address the hostname where proxy shall connect to
|
||||
* \arg port port address where proxy shall connect to
|
||||
*/
|
||||
GIOChannel * (*connect)(struct network_proxy const *, IPADDR const *hint_ip,
|
||||
char const *address, int port);
|
||||
|
||||
/* clones the given network_proxy object; this memberfunction is
|
||||
* mandatory */
|
||||
struct network_proxy * (*clone)(struct network_proxy const *);
|
||||
|
||||
|
||||
/* sends a string after connection has been established but before IRC
|
||||
* authentication begins; this memberfunction is optional
|
||||
*/
|
||||
void (*send_string)(struct network_proxy const *,
|
||||
struct network_proxy_send_string_info const *);
|
||||
|
||||
/* sends a string after connection IRC authentication suceeded; this
|
||||
* memberfunction is optional
|
||||
*/
|
||||
void (*send_string_after)(struct network_proxy const *,
|
||||
struct network_proxy_send_string_info const *);
|
||||
|
||||
|
||||
/* hostname of proxy host */
|
||||
char const *host;
|
||||
|
||||
/* portnumber of proxy */
|
||||
int port;
|
||||
};
|
||||
|
||||
/* factory method to create a proxy object based upon value of 'type' */
|
||||
struct network_proxy * network_proxy_create(char const *type);
|
||||
|
||||
|
||||
#endif /* H_IRSSI_SRC_CORE_PROXY_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue