summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.h
blob: a5f72e82b36ee40c9d564158d5854a00740233a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* onion_client.h -- Implementation of the client part of docs/Prevent_Tracking.txt
*                   (The part that uses the onion stuff to connect to the friend)
*
*  Copyright (C) 2013 Tox project All Rights Reserved.
*
*  This file is part of Tox.
*
*  Tox is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  Tox is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with Tox.  If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef ONION_CLIENT_H
#define ONION_CLIENT_H

#include "onion_announce.h"

#define MAX_ONION_CLIENTS 8

typedef struct {
    uint8_t     client_id[CLIENT_ID_SIZE];
    IP_Port     ip_port;
    uint8_t     ping_id[ONION_PING_ID_SIZE];
    uint64_t    timestamp;
} Onion_Node;

typedef struct {
    Onion_Node clients_list[MAX_ONION_CLIENTS];
} Onion_Friend;

typedef struct {
    DHT     *dht;
    Networking_Core *net;
    Onion_Friend    *friends_list;
    uint16_t       num_friends;

    Onion_Node clients_announce_list[MAX_ONION_CLIENTS];

    uint8_t secret_symmetric_key[crypto_secretbox_KEYBYTES];
} Onion_Client;

int onion_addfriend(Onion_Client *onion_c, uint8_t *client_id);

int onion_delfriend(Onion_Client *onion_c, uint8_t *client_id);

int onion_getfriendip(Onion_Client *onion_c, uint8_t *client_id, IP_Port *ip_port);


void do_onion_client(Onion_Client *onion_c);

Onion_Client *new_onion_client(DHT *dht);

void kill_onion_client(Onion_Client *onion_c);

#endif