mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 02:33:12 +02:00
xfer: add support of IPv6 for DCC chat/file (patch #7992)
This commit is contained in:
committed by
Sebastien Helleu
parent
9040dfbf52
commit
144dc60d0a
@@ -36,6 +36,9 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
@@ -4402,8 +4405,11 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
|
||||
{
|
||||
struct t_infolist *infolist;
|
||||
struct t_irc_server *ptr_server;
|
||||
const char *plugin_name, *plugin_id, *type, *filename;
|
||||
int spaces_in_name;
|
||||
const char *plugin_name, *plugin_id, *type, *filename, *local_address;
|
||||
char converted_addr[NI_MAXHOST];
|
||||
struct addrinfo *ainfo;
|
||||
struct sockaddr_in *saddr;
|
||||
int spaces_in_name, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -4416,14 +4422,40 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
|
||||
{
|
||||
plugin_name = weechat_infolist_string (infolist, "plugin_name");
|
||||
plugin_id = weechat_infolist_string (infolist, "plugin_id");
|
||||
if (plugin_name && (strcmp (plugin_name, IRC_PLUGIN_NAME) == 0) && plugin_id)
|
||||
if (plugin_name && (strcmp (plugin_name, IRC_PLUGIN_NAME) == 0)
|
||||
&& plugin_id)
|
||||
{
|
||||
ptr_server = irc_server_search (plugin_id);
|
||||
if (ptr_server)
|
||||
{
|
||||
type = weechat_infolist_string (infolist, "type_string");
|
||||
if (type)
|
||||
converted_addr[0] = '\0';
|
||||
local_address = weechat_infolist_string (infolist,
|
||||
"local_address");
|
||||
if (local_address)
|
||||
{
|
||||
rc = getaddrinfo (local_address, NULL, NULL, &ainfo);
|
||||
if ((rc == 0) && ainfo && ainfo->ai_addr)
|
||||
{
|
||||
if (ainfo->ai_family == AF_INET)
|
||||
{
|
||||
/* transform dotted 4 IP address to ulong string */
|
||||
saddr = (struct sockaddr_in *)ainfo->ai_addr;
|
||||
snprintf (converted_addr, sizeof (converted_addr),
|
||||
"%lu",
|
||||
(unsigned long)ntohl (saddr->sin_addr.s_addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (converted_addr, sizeof (converted_addr),
|
||||
"%s", local_address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type = weechat_infolist_string (infolist, "type_string");
|
||||
if (type && converted_addr[0])
|
||||
{
|
||||
/* send DCC PRIVMSG */
|
||||
if (strcmp (type, "file_send") == 0)
|
||||
{
|
||||
filename = weechat_infolist_string (infolist, "filename");
|
||||
@@ -4436,7 +4468,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
|
||||
(spaces_in_name) ? "\"" : "",
|
||||
filename,
|
||||
(spaces_in_name) ? "\"" : "",
|
||||
weechat_infolist_string (infolist, "local_address"),
|
||||
converted_addr,
|
||||
weechat_infolist_integer (infolist, "port"),
|
||||
weechat_infolist_string (infolist, "size"));
|
||||
}
|
||||
@@ -4446,7 +4478,7 @@ irc_server_xfer_send_ready_cb (void *data, const char *signal,
|
||||
IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"PRIVMSG %s :\01DCC CHAT chat %s %d\01",
|
||||
weechat_infolist_string (infolist, "remote_nick"),
|
||||
weechat_infolist_string (infolist, "local_address"),
|
||||
converted_addr,
|
||||
weechat_infolist_integer (infolist, "port"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user