1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

/SET irssiproxy_bind specifies the IP where to listen in, patch by BC-bd

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2843 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-06-06 20:14:31 +00:00 committed by cras
parent 694251442c
commit 964ff29779
2 changed files with 21 additions and 3 deletions

View File

@ -538,15 +538,32 @@ static LISTEN_REC *find_listen(const char *ircnet, int port)
static void add_listen(const char *ircnet, int port) static void add_listen(const char *ircnet, int port)
{ {
LISTEN_REC *rec; LISTEN_REC *rec;
IPADDR ip4, ip6, *my_ip;
if (port <= 0 || *ircnet == '\0') return; if (port <= 0 || *ircnet == '\0')
return;
/* bind to specific host/ip? */
my_ip = NULL;
if (*settings_get_str("irssiproxy_bind") != '\0') {
if (net_gethostbyname(settings_get_str("irssiproxy_bind"),
&ip4, &ip6) != 0) {
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR,
"Proxy: can not resolve '%s' - aborting",
settings_get_str("irssiproxy_bind"));
return;
}
my_ip = ip6.family == 0 ? &ip4 : ip4.family == 0 ||
settings_get_bool("resolve_prefer_ipv6") ? &ip6 : &ip4;
}
rec = g_new0(LISTEN_REC, 1); rec = g_new0(LISTEN_REC, 1);
rec->ircnet = g_strdup(ircnet); rec->ircnet = g_strdup(ircnet);
rec->port = port; rec->port = port;
/* start listening */ rec->handle = net_listen(my_ip, &rec->port);
rec->handle = net_listen(NULL, &rec->port);
if (rec->handle == NULL) { if (rec->handle == NULL) {
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, printtext(NULL, NULL, MSGLEVEL_CLIENTERROR,
"Proxy: Listen in port %d failed: %s", "Proxy: Listen in port %d failed: %s",

View File

@ -27,6 +27,7 @@ void irc_proxy_init(void)
{ {
settings_add_str("irssiproxy", "irssiproxy_ports", ""); settings_add_str("irssiproxy", "irssiproxy_ports", "");
settings_add_str("irssiproxy", "irssiproxy_password", ""); settings_add_str("irssiproxy", "irssiproxy_password", "");
settings_add_str("irssiproxy", "irssiproxy_bind", "");
if (*settings_get_str("irssiproxy_password") == '\0') { if (*settings_get_str("irssiproxy_password") == '\0') {
/* no password - bad idea! */ /* no password - bad idea! */