mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
net_ip2host() and net_host2ip() now treat any IPv6 IPs as 0.0.0.0, if IPv6
support isn't enabled in irssi. Also DCC's human readable IP address is taken from DCC SEND request directly with IPv6. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2825 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
b95f6acc4f
commit
eddc3d90c6
@ -518,12 +518,16 @@ int net_ip2host(IPADDR *ip, char *host)
|
|||||||
#else
|
#else
|
||||||
unsigned long ip4;
|
unsigned long ip4;
|
||||||
|
|
||||||
|
if (ip->family != AF_INET) {
|
||||||
|
strcpy(host, "0.0.0.0");
|
||||||
|
} else {
|
||||||
ip4 = ntohl(ip->ip.s_addr);
|
ip4 = ntohl(ip->ip.s_addr);
|
||||||
g_snprintf(host, MAX_IP_LEN, "%lu.%lu.%lu.%lu",
|
g_snprintf(host, MAX_IP_LEN, "%lu.%lu.%lu.%lu",
|
||||||
(ip4 & 0xff000000UL) >> 24,
|
(ip4 & 0xff000000UL) >> 24,
|
||||||
(ip4 & 0x00ff0000) >> 16,
|
(ip4 & 0x00ff0000) >> 16,
|
||||||
(ip4 & 0x0000ff00) >> 8,
|
(ip4 & 0x0000ff00) >> 8,
|
||||||
(ip4 & 0x000000ff));
|
(ip4 & 0x000000ff));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -532,15 +536,16 @@ int net_host2ip(const char *host, IPADDR *ip)
|
|||||||
{
|
{
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (strchr(host, ':') != NULL) {
|
if (strchr(host, ':') != NULL) {
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
ip->family = AF_INET6;
|
ip->family = AF_INET6;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
if (inet_pton(AF_INET6, host, &ip->ip) == 0)
|
if (inet_pton(AF_INET6, host, &ip->ip) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
#else
|
||||||
|
ip->ip.s_addr = 0;
|
||||||
#endif
|
#endif
|
||||||
{
|
} else {
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
ip->family = AF_INET;
|
ip->family = AF_INET;
|
||||||
#ifdef HAVE_INET_ATON
|
#ifdef HAVE_INET_ATON
|
||||||
|
@ -315,6 +315,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
|
|||||||
{
|
{
|
||||||
GET_DCC_REC *dcc;
|
GET_DCC_REC *dcc;
|
||||||
IPADDR ip;
|
IPADDR ip;
|
||||||
|
const char *address;
|
||||||
char **params, *fname;
|
char **params, *fname;
|
||||||
int paramcount, fileparams;
|
int paramcount, fileparams;
|
||||||
int port, len, quoted = FALSE;
|
int port, len, quoted = FALSE;
|
||||||
@ -333,7 +334,8 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
|
|||||||
|
|
||||||
fileparams = get_file_params_count(params, paramcount);
|
fileparams = get_file_params_count(params, paramcount);
|
||||||
|
|
||||||
dcc_str2ip(params[fileparams], &ip);
|
address = params[fileparams];
|
||||||
|
dcc_str2ip(address, &ip);
|
||||||
port = atoi(params[fileparams+1]);
|
port = atoi(params[fileparams+1]);
|
||||||
size = atol(params[fileparams+2]);
|
size = atol(params[fileparams+2]);
|
||||||
|
|
||||||
@ -358,7 +360,13 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data,
|
|||||||
dcc = dcc_get_create(server, chat, nick, fname);
|
dcc = dcc_get_create(server, chat, nick, fname);
|
||||||
dcc->target = g_strdup(target);
|
dcc->target = g_strdup(target);
|
||||||
memcpy(&dcc->addr, &ip, sizeof(ip));
|
memcpy(&dcc->addr, &ip, sizeof(ip));
|
||||||
|
if (dcc->addr.family == AF_INET)
|
||||||
net_ip2host(&dcc->addr, dcc->addrstr);
|
net_ip2host(&dcc->addr, dcc->addrstr);
|
||||||
|
else {
|
||||||
|
/* with IPv6, show it to us as it was sent */
|
||||||
|
strncpy(dcc->addrstr, address, sizeof(dcc->addrstr)-1);
|
||||||
|
dcc->addrstr[sizeof(dcc->addrstr)-1] = '\0';
|
||||||
|
}
|
||||||
dcc->port = port;
|
dcc->port = port;
|
||||||
dcc->size = size;
|
dcc->size = size;
|
||||||
dcc->file_quoted = quoted;
|
dcc->file_quoted = quoted;
|
||||||
|
Loading…
Reference in New Issue
Block a user