mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Merge pull request #1135 from horgh/horgh/resolve-setting
Remove resolve_reverse_lookup setting
This commit is contained in:
commit
4c5f708b9b
@ -6,7 +6,7 @@
|
|||||||
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
|
||||||
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
|
||||||
|
|
||||||
#define IRSSI_ABI_VERSION 23
|
#define IRSSI_ABI_VERSION 24
|
||||||
|
|
||||||
#define DEFAULT_SERVER_ADD_PORT 6667
|
#define DEFAULT_SERVER_ADD_PORT 6667
|
||||||
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
|
|
||||||
/* nonblocking gethostbyname(), ip (IPADDR) + error (int, 0 = not error) is
|
/* nonblocking gethostbyname(), ip (IPADDR) + error (int, 0 = not error) is
|
||||||
written to pipe when found PID of the resolver child is returned */
|
written to pipe when found PID of the resolver child is returned */
|
||||||
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
|
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe, int reverse_lookup)
|
||||||
int reverse_lookup)
|
|
||||||
{
|
{
|
||||||
RESOLVED_IP_REC rec;
|
RESOLVED_IP_REC rec;
|
||||||
const char *errorstr;
|
const char *errorstr;
|
||||||
int pid;
|
int pid;
|
||||||
int len;
|
|
||||||
|
(void) reverse_lookup; /* Kept for API backward compatibility */
|
||||||
|
|
||||||
g_return_val_if_fail(addr != NULL, FALSE);
|
g_return_val_if_fail(addr != NULL, FALSE);
|
||||||
|
|
||||||
@ -57,13 +57,6 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
|
|||||||
rec.error = net_gethostbyname(addr, &rec.ip4, &rec.ip6);
|
rec.error = net_gethostbyname(addr, &rec.ip4, &rec.ip6);
|
||||||
if (rec.error == 0) {
|
if (rec.error == 0) {
|
||||||
errorstr = NULL;
|
errorstr = NULL;
|
||||||
if (reverse_lookup) {
|
|
||||||
/* reverse lookup the IP, ignore any error */
|
|
||||||
if (rec.ip4.family != 0)
|
|
||||||
net_gethostbyaddr(&rec.ip4, &rec.host4);
|
|
||||||
if (rec.ip6.family != 0)
|
|
||||||
net_gethostbyaddr(&rec.ip6, &rec.host6);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
errorstr = net_gethosterror(rec.error);
|
errorstr = net_gethosterror(rec.error);
|
||||||
rec.errlen = errorstr == NULL ? 0 : strlen(errorstr)+1;
|
rec.errlen = errorstr == NULL ? 0 : strlen(errorstr)+1;
|
||||||
@ -72,22 +65,6 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
|
|||||||
g_io_channel_write_block(pipe, &rec, sizeof(rec));
|
g_io_channel_write_block(pipe, &rec, sizeof(rec));
|
||||||
if (rec.errlen != 0)
|
if (rec.errlen != 0)
|
||||||
g_io_channel_write_block(pipe, (void *) errorstr, rec.errlen);
|
g_io_channel_write_block(pipe, (void *) errorstr, rec.errlen);
|
||||||
else {
|
|
||||||
if (rec.host4) {
|
|
||||||
len = strlen(rec.host4) + 1;
|
|
||||||
g_io_channel_write_block(pipe, (void *) &len,
|
|
||||||
sizeof(int));
|
|
||||||
g_io_channel_write_block(pipe, (void *) rec.host4,
|
|
||||||
len);
|
|
||||||
}
|
|
||||||
if (rec.host6) {
|
|
||||||
len = strlen(rec.host6) + 1;
|
|
||||||
g_io_channel_write_block(pipe, (void *) &len,
|
|
||||||
sizeof(int));
|
|
||||||
g_io_channel_write_block(pipe, (void *) rec.host6,
|
|
||||||
len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
_exit(99);
|
_exit(99);
|
||||||
@ -99,12 +76,8 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
|
|||||||
/* get the resolved IP address */
|
/* get the resolved IP address */
|
||||||
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
|
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
|
||||||
{
|
{
|
||||||
int len;
|
|
||||||
|
|
||||||
rec->error = -1;
|
rec->error = -1;
|
||||||
rec->errorstr = NULL;
|
rec->errorstr = NULL;
|
||||||
rec->host4 = NULL;
|
|
||||||
rec->host6 = NULL;
|
|
||||||
|
|
||||||
fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
|
fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
|
||||||
|
|
||||||
@ -120,17 +93,6 @@ int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
|
|||||||
reason, just ignore it. */
|
reason, just ignore it. */
|
||||||
rec->errorstr = g_malloc0(rec->errlen+1);
|
rec->errorstr = g_malloc0(rec->errlen+1);
|
||||||
g_io_channel_read_block(pipe, rec->errorstr, rec->errlen);
|
g_io_channel_read_block(pipe, rec->errorstr, rec->errlen);
|
||||||
} else {
|
|
||||||
if (rec->host4) {
|
|
||||||
g_io_channel_read_block(pipe, &len, sizeof(int));
|
|
||||||
rec->host4 = g_malloc0(len);
|
|
||||||
g_io_channel_read_block(pipe, rec->host4, len);
|
|
||||||
}
|
|
||||||
if (rec->host6) {
|
|
||||||
g_io_channel_read_block(pipe, &len, sizeof(int));
|
|
||||||
rec->host6 = g_malloc0(len);
|
|
||||||
g_io_channel_read_block(pipe, rec->host6, len);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -9,12 +9,10 @@ typedef struct {
|
|||||||
int errlen; /* error text length */
|
int errlen; /* error text length */
|
||||||
char *errorstr; /* error string - dynamically allocated, you'll
|
char *errorstr; /* error string - dynamically allocated, you'll
|
||||||
need to free() it yourself unless it's NULL */
|
need to free() it yourself unless it's NULL */
|
||||||
char *host4, *host6; /* dito */
|
|
||||||
} RESOLVED_IP_REC;
|
} RESOLVED_IP_REC;
|
||||||
|
|
||||||
/* nonblocking gethostbyname(), PID of the resolver child is returned. */
|
/* nonblocking gethostbyname(), PID of the resolver child is returned. */
|
||||||
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
|
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe, int reverse_lookup);
|
||||||
int reverse_lookup);
|
|
||||||
/* get the resolved IP address. returns -1 if some error occurred with read() */
|
/* get the resolved IP address. returns -1 if some error occurred with read() */
|
||||||
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec);
|
int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec);
|
||||||
|
|
||||||
|
@ -261,7 +261,6 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
RESOLVED_IP_REC iprec;
|
RESOLVED_IP_REC iprec;
|
||||||
IPADDR *ip;
|
IPADDR *ip;
|
||||||
const char *errormsg;
|
const char *errormsg;
|
||||||
char *servername = NULL;
|
|
||||||
|
|
||||||
g_source_remove(server->connect_tag);
|
g_source_remove(server->connect_tag);
|
||||||
server->connect_tag = -1;
|
server->connect_tag = -1;
|
||||||
@ -283,11 +282,9 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
} else if (server->connrec->family == AF_INET) {
|
} else if (server->connrec->family == AF_INET) {
|
||||||
/* force IPv4 connection */
|
/* force IPv4 connection */
|
||||||
ip = iprec.ip4.family == 0 ? NULL : &iprec.ip4;
|
ip = iprec.ip4.family == 0 ? NULL : &iprec.ip4;
|
||||||
servername = iprec.host4;
|
|
||||||
} else if (server->connrec->family == AF_INET6) {
|
} else if (server->connrec->family == AF_INET6) {
|
||||||
/* force IPv6 connection */
|
/* force IPv6 connection */
|
||||||
ip = iprec.ip6.family == 0 ? NULL : &iprec.ip6;
|
ip = iprec.ip6.family == 0 ? NULL : &iprec.ip6;
|
||||||
servername = iprec.host6;
|
|
||||||
} else {
|
} else {
|
||||||
/* pick the one that was found, or if both do it like
|
/* pick the one that was found, or if both do it like
|
||||||
/SET resolve_prefer_ipv6 says. */
|
/SET resolve_prefer_ipv6 says. */
|
||||||
@ -295,19 +292,13 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
(iprec.ip6.family != 0 &&
|
(iprec.ip6.family != 0 &&
|
||||||
settings_get_bool("resolve_prefer_ipv6"))) {
|
settings_get_bool("resolve_prefer_ipv6"))) {
|
||||||
ip = &iprec.ip6;
|
ip = &iprec.ip6;
|
||||||
servername = iprec.host6;
|
|
||||||
} else {
|
} else {
|
||||||
ip = &iprec.ip4;
|
ip = &iprec.ip4;
|
||||||
servername = iprec.host4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip != NULL) {
|
if (ip != NULL) {
|
||||||
/* host lookup ok */
|
/* host lookup ok */
|
||||||
if (servername) {
|
|
||||||
g_free(server->connrec->address);
|
|
||||||
server->connrec->address = g_strdup(servername);
|
|
||||||
}
|
|
||||||
server_real_connect(server, ip, NULL);
|
server_real_connect(server, ip, NULL);
|
||||||
errormsg = NULL;
|
errormsg = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -333,8 +324,6 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free(iprec.errorstr);
|
g_free(iprec.errorstr);
|
||||||
g_free(iprec.host4);
|
|
||||||
g_free(iprec.host6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
|
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
|
||||||
@ -418,8 +407,7 @@ int server_start_connect(SERVER_REC *server)
|
|||||||
server->connrec->proxy : server->connrec->address;
|
server->connrec->proxy : server->connrec->address;
|
||||||
server->connect_pid =
|
server->connect_pid =
|
||||||
net_gethostbyname_nonblock(connect_address,
|
net_gethostbyname_nonblock(connect_address,
|
||||||
server->connect_pipe[1],
|
server->connect_pipe[1], 0);
|
||||||
settings_get_bool("resolve_reverse_lookup"));
|
|
||||||
server->connect_tag =
|
server->connect_tag =
|
||||||
g_input_add(server->connect_pipe[0], G_INPUT_READ,
|
g_input_add(server->connect_pipe[0], G_INPUT_READ,
|
||||||
(GInputFunction)
|
(GInputFunction)
|
||||||
@ -739,7 +727,6 @@ static void sig_chat_protocol_deinit(CHAT_PROTOCOL_REC *proto)
|
|||||||
void servers_init(void)
|
void servers_init(void)
|
||||||
{
|
{
|
||||||
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
|
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
|
||||||
settings_add_bool("server", "resolve_reverse_lookup", FALSE);
|
|
||||||
lookup_servers = servers = NULL;
|
lookup_servers = servers = NULL;
|
||||||
|
|
||||||
signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
|
signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
|
||||||
|
@ -557,7 +557,8 @@ static int backwards_compatibility(const char *module, CONFIG_NODE *node,
|
|||||||
g_free(new_value);
|
g_free(new_value);
|
||||||
config_changed = TRUE;
|
config_changed = TRUE;
|
||||||
return new_key != NULL;
|
return new_key != NULL;
|
||||||
} else if (g_ascii_strcasecmp(node->key, "actlist_moves") == 0 &&
|
}
|
||||||
|
if (g_ascii_strcasecmp(node->key, "actlist_moves") == 0 &&
|
||||||
node->value != NULL && g_ascii_strcasecmp(node->value, "yes") == 0) {
|
node->value != NULL && g_ascii_strcasecmp(node->value, "yes") == 0) {
|
||||||
config_node_set_str(mainconfig, parent, "actlist_sort", "recent");
|
config_node_set_str(mainconfig, parent, "actlist_sort", "recent");
|
||||||
config_node_set_str(mainconfig, parent, node->key, NULL);
|
config_node_set_str(mainconfig, parent, node->key, NULL);
|
||||||
@ -565,6 +566,12 @@ static int backwards_compatibility(const char *module, CONFIG_NODE *node,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (g_strcmp0(module, "core") == 0 &&
|
||||||
|
g_strcmp0(node->key, "resolve_reverse_lookup") == 0) {
|
||||||
|
config_node_set_str(mainconfig, parent, node->key, NULL);
|
||||||
|
config_changed = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
return new_key != NULL;
|
return new_key != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user