mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Base of hardening stuff.
This commit is contained in:
parent
bb0ec76de3
commit
a6edd9dad6
|
@ -1552,6 +1552,16 @@ static void do_NAT(DHT *dht)
|
|||
/*----------------------------------------------------------------------------------*/
|
||||
/*-----------------------END OF NAT PUNCHING FUNCTIONS------------------------------*/
|
||||
|
||||
|
||||
/* Handle a received ping request for. */
|
||||
static int handle_hardening(void *object, IP_Port source, uint8_t *source_pubkey, uint8_t *packet, uint32_t length)
|
||||
{
|
||||
DHT *dht = object;
|
||||
return 0;/* success*/
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
|
||||
DHT *new_DHT(Net_Crypto *c)
|
||||
{
|
||||
if (c == NULL)
|
||||
|
@ -1575,6 +1585,8 @@ DHT *new_DHT(Net_Crypto *c)
|
|||
networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_IPV6, &handle_sendnodes_ipv6, dht);
|
||||
init_cryptopackets(dht);
|
||||
cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, dht);
|
||||
cryptopacket_registerhandler(c, CRYPTO_PACKET_HARDENING, &handle_hardening, dht);
|
||||
|
||||
new_symmetric_key(dht->secret_symmetric_key);
|
||||
return dht;
|
||||
}
|
||||
|
|
|
@ -35,11 +35,6 @@
|
|||
/* A list of the clients mathematically closest to ours. */
|
||||
#define LCLIENT_LIST 32
|
||||
|
||||
/* The list of ip ports along with the ping_id of what we sent them and a timestamp. */
|
||||
#define LPING_ARRAY 256 // NOTE: Deprecated (doesn't do anything).
|
||||
|
||||
#define LSEND_NODES_ARRAY LPING_ARRAY/2
|
||||
|
||||
/* Maximum newly announced nodes to ping per TIME_TOPING seconds. */
|
||||
#define MAX_TOPING 16
|
||||
|
||||
|
@ -76,6 +71,21 @@ typedef struct {
|
|||
uint64_t NATping_timestamp;
|
||||
} NAT;
|
||||
|
||||
typedef struct {
|
||||
/* Node routes request correctly (true (1) or false/didn't check (0)) */
|
||||
uint8_t routes_requests_ok;
|
||||
/* Time which we last checked this.*/
|
||||
uint64_t routes_requests_timestamp;
|
||||
/* Node sends correct send_node (true (1) or false/didn't check (0)) */
|
||||
uint8_t send_nodes_ok;
|
||||
/* Time which we last checked this.*/
|
||||
uint64_t send_nodes_timestamp;
|
||||
/* Node can be used to test other nodes (true (1) or false/didn't check (0)) */
|
||||
uint8_t testing_requests;
|
||||
/* Time which we last checked this.*/
|
||||
uint64_t testing_timestamp;
|
||||
} Hardening;
|
||||
|
||||
typedef struct {
|
||||
uint8_t client_id[CLIENT_ID_SIZE];
|
||||
Client_data_old client_list[MAX_FRIEND_CLIENTS];
|
||||
|
@ -83,6 +93,7 @@ typedef struct {
|
|||
/* Time at which the last get_nodes request was sent. */
|
||||
uint64_t lastgetnode;
|
||||
|
||||
Hardening hardening;
|
||||
/* Symetric NAT hole punching stuff. */
|
||||
NAT nat;
|
||||
} DHT_Friend_old; /* required to load old state files */
|
||||
|
@ -94,6 +105,7 @@ typedef struct {
|
|||
/* Time at which the last get_nodes request was sent. */
|
||||
uint64_t lastgetnode;
|
||||
|
||||
Hardening hardening;
|
||||
/* Symetric NAT hole punching stuff. */
|
||||
NAT nat;
|
||||
} DHT_Friend;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Lossless_UDP.h"
|
||||
|
||||
#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */
|
||||
#define CRYPTO_PACKET_HARDENING 48 /* Hardening crypto packet ID. */
|
||||
#define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */
|
||||
#define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user