Send groupchat ips like DHT ones.

This commit is contained in:
irungentoo 2013-12-08 18:23:30 -05:00
parent a4968bdbc5
commit 48c50b5cef
3 changed files with 11 additions and 2 deletions

View File

@ -848,15 +848,18 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
return sendpacket(dht->c->lossless_udp->net, ip_port, data, 1 + CLIENT_ID_SIZE + crypto_box_NONCEBYTES + len);
}
static void to_net_family(IP *ip)
void to_net_family(IP *ip)
{
ip->padding[0] = 0;
ip->padding[1] = 0;
ip->padding[2] = 0;
if (ip->family == AF_INET)
ip->family = TOX_AF_INET;
else if (ip->family == AF_INET6)
ip->family = TOX_AF_INET6;
}
static void to_host_family(IP *ip)
void to_host_family(IP *ip)
{
if (ip->family == TOX_AF_INET)
ip->family = AF_INET;

View File

@ -53,6 +53,10 @@
#define TOX_AF_INET 2
#define TOX_AF_INET6 10
/* Functions to transfer ips safely across wire. */
void to_net_family(IP *ip);
void to_host_family(IP *ip);
typedef struct {
IP_Port ip_port;
uint64_t timestamp;

View File

@ -354,6 +354,7 @@ static int send_sendnodes(Group_Chat *chat, IP_Port ip_port, int peernum, uint64
if (!is_timeout(chat->close[i].last_recv, BAD_GROUPNODE_TIMEOUT)) {
id_copy(contents.nodes[j].client_id, chat->close[i].client_id);
contents.nodes[j].ip_port = chat->close[i].ip_port;
to_net_family(&contents.nodes[j].ip_port.ip);
++j;
}
}
@ -417,6 +418,7 @@ static int handle_sendnodes(Group_Chat *chat, IP_Port source, int peernum, uint8
if (peern == -1)
continue;
to_host_family(&contents.nodes[i].ip_port.ip);
send_getnodes(chat, contents.nodes[i].ip_port, peern);
if (chat->assoc) {