Prevent connection ips from switching on LAN.

This commit is contained in:
irungentoo 2014-11-11 08:03:11 -05:00
parent f0f68efee8
commit ab42c91a49
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
4 changed files with 13 additions and 7 deletions

View File

@ -28,6 +28,13 @@
#include "LAN_discovery.h"
#include "util.h"
/* Used for get_broadcast(). */
#ifdef __linux
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <linux/netdevice.h>
#endif
#define MAX_INTERFACES 16

View File

@ -28,13 +28,6 @@
#include "DHT.h"
/* Used for get_broadcast(). */
#ifdef __linux
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <linux/netdevice.h>
#endif
/* Interval in seconds between LAN discovery packet sending. */
#define LAN_DISCOVERY_INTERVAL 10

View File

@ -1700,6 +1700,11 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port)
return -1;
if (!ipport_equal(&ip_port, &conn->ip_port)) {
if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_time) > current_time_monotonic()) {
if (LAN_ip(ip_port.ip) == 0 && LAN_ip(conn->ip_port.ip) == 0 && conn->ip_port.port == ip_port.port)
return -1;
}
if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) {
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
conn->ip_port = ip_port;

View File

@ -25,6 +25,7 @@
#define NET_CRYPTO_H
#include "DHT.h"
#include "LAN_discovery.h"
#include "TCP_client.h"
#include <pthread.h>