Connect to own TCP server if hosting one.

Removed useless code.
This commit is contained in:
irungentoo 2015-05-12 20:59:28 -04:00
parent 478552d338
commit 53c6b26a7e
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 14 additions and 25 deletions

View File

@ -2216,6 +2216,11 @@ void do_friends(Messenger *m)
m->friendlist[i].user_istyping_sent = 1;
}
if (m->friendlist[i].tcp_server_sent == 0) {
if (send_user_tcp_server(m, i))
m->friendlist[i].tcp_server_sent = 1;
}
check_friend_tcp_udp(m, i);
do_receipts(m, i);
do_reqchunk_filecb(m, i);
@ -2286,6 +2291,15 @@ void do_messenger(Messenger *m)
for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) {
add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].public_key);
}
if (m->tcp_server) {
/* Add self tcp server. */
IP_Port local_ip_port;
local_ip_port.port = m->options.tcp_server_port;
local_ip_port.ip.family = AF_INET;
local_ip_port.ip.ip4.uint32 = INADDR_LOOPBACK;
add_tcp_relay(m->net_crypto, local_ip_port, m->tcp_server->public_key);
}
}
unix_time_update();

View File

@ -239,31 +239,6 @@ void tox_get_savedata(const Tox *tox, uint8_t *data)
}
}
static int address_to_ip(Messenger *m, const char *address, IP_Port *ip_port, IP_Port *ip_port_v4)
{
if (!addr_parse_ip(address, &ip_port->ip)) {
if (m->options.udp_disabled) { /* Disable DNS when udp is disabled. */
return -1;
}
IP *ip_extra = NULL;
ip_init(&ip_port->ip, m->options.ipv6enabled);
if (m->options.ipv6enabled && ip_port_v4) {
/* setup for getting BOTH: an IPv6 AND an IPv4 address */
ip_port->ip.family = AF_UNSPEC;
ip_reset(&ip_port_v4->ip);
ip_extra = &ip_port_v4->ip;
}
if (!addr_resolve(address, &ip_port->ip, ip_extra)) {
return -1;
}
}
return 0;
}
bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error)
{
if (!address || !public_key) {