mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Prevent connection ips from switching on LAN.
This commit is contained in:
parent
f0f68efee8
commit
ab42c91a49
|
@ -28,6 +28,13 @@
|
||||||
#include "LAN_discovery.h"
|
#include "LAN_discovery.h"
|
||||||
#include "util.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
|
#define MAX_INTERFACES 16
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,6 @@
|
||||||
|
|
||||||
#include "DHT.h"
|
#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. */
|
/* Interval in seconds between LAN discovery packet sending. */
|
||||||
#define LAN_DISCOVERY_INTERVAL 10
|
#define LAN_DISCOVERY_INTERVAL 10
|
||||||
|
|
||||||
|
|
|
@ -1700,6 +1700,11 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!ipport_equal(&ip_port, &conn->ip_port)) {
|
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)) {
|
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);
|
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);
|
||||||
conn->ip_port = ip_port;
|
conn->ip_port = ip_port;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define NET_CRYPTO_H
|
#define NET_CRYPTO_H
|
||||||
|
|
||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
|
#include "LAN_discovery.h"
|
||||||
#include "TCP_client.h"
|
#include "TCP_client.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user