diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 10:31:29 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 23:09:28 +0000 |
commit | 8739f7fccb7cafc54ca0f5fa074c9a740f7048ba (patch) | |
tree | 88e9f53fa6e734cd8095487d1896c56f844c782c /toxcore/onion_client.c | |
parent | 64d0297acc7d6a1697683052e15cc76383312c38 (diff) |
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.
This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.
[1] struct/union/enum
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r-- | toxcore/onion_client.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index fa6c08c9..35e725b7 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -265,8 +265,8 @@ static uint16_t random_nodes_path_onion(const Onion_Client *onion_c, Node_format | |||
265 | 265 | ||
266 | unsigned int num_nodes = (onion_c->path_nodes_index < MAX_PATH_NODES) ? onion_c->path_nodes_index : MAX_PATH_NODES; | 266 | unsigned int num_nodes = (onion_c->path_nodes_index < MAX_PATH_NODES) ? onion_c->path_nodes_index : MAX_PATH_NODES; |
267 | 267 | ||
268 | //if (DHT_non_lan_connected(onion_c->dht)) { | 268 | //if (dht_non_lan_connected(onion_c->dht)) { |
269 | if (DHT_isconnected(onion_c->dht)) { | 269 | if (dht_isconnected(onion_c->dht)) { |
270 | if (num_nodes == 0) { | 270 | if (num_nodes == 0) { |
271 | return 0; | 271 | return 0; |
272 | } | 272 | } |
@@ -990,7 +990,7 @@ static int handle_dhtpk_announce(void *object, const uint8_t *source_pubkey, con | |||
990 | const Family family = nodes[i].ip_port.ip.family; | 990 | const Family family = nodes[i].ip_port.ip.family; |
991 | 991 | ||
992 | if (net_family_is_ipv4(family) || net_family_is_ipv6(family)) { | 992 | if (net_family_is_ipv4(family) || net_family_is_ipv6(family)) { |
993 | DHT_getnodes(onion_c->dht, &nodes[i].ip_port, nodes[i].public_key, onion_c->friends_list[friend_num].dht_public_key); | 993 | dht_getnodes(onion_c->dht, &nodes[i].ip_port, nodes[i].public_key, onion_c->friends_list[friend_num].dht_public_key); |
994 | } else if (net_family_is_tcp_ipv4(family) || net_family_is_tcp_ipv6(family)) { | 994 | } else if (net_family_is_tcp_ipv4(family) || net_family_is_tcp_ipv6(family)) { |
995 | if (onion_c->friends_list[friend_num].tcp_relay_node_callback) { | 995 | if (onion_c->friends_list[friend_num].tcp_relay_node_callback) { |
996 | void *obj = onion_c->friends_list[friend_num].tcp_relay_node_callback_object; | 996 | void *obj = onion_c->friends_list[friend_num].tcp_relay_node_callback_object; |
@@ -1326,8 +1326,13 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num) | |||
1326 | return -1; | 1326 | return -1; |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | //if (onion_c->friends_list[friend_num].know_dht_public_key) | 1329 | #if 0 |
1330 | // DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].dht_public_key, 0); | 1330 | |
1331 | if (onion_c->friends_list[friend_num].know_dht_public_key) { | ||
1332 | dht_delfriend(onion_c->dht, onion_c->friends_list[friend_num].dht_public_key, 0); | ||
1333 | } | ||
1334 | |||
1335 | #endif | ||
1331 | 1336 | ||
1332 | crypto_memzero(&onion_c->friends_list[friend_num], sizeof(Onion_Friend)); | 1337 | crypto_memzero(&onion_c->friends_list[friend_num], sizeof(Onion_Friend)); |
1333 | unsigned int i; | 1338 | unsigned int i; |
@@ -1456,7 +1461,7 @@ int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_p | |||
1456 | return -1; | 1461 | return -1; |
1457 | } | 1462 | } |
1458 | 1463 | ||
1459 | return DHT_getfriendip(onion_c->dht, dht_public_key, ip_port); | 1464 | return dht_getfriendip(onion_c->dht, dht_public_key, ip_port); |
1460 | } | 1465 | } |
1461 | 1466 | ||
1462 | 1467 | ||
@@ -1824,7 +1829,7 @@ void do_onion_client(Onion_Client *onion_c) | |||
1824 | } | 1829 | } |
1825 | } | 1830 | } |
1826 | 1831 | ||
1827 | bool UDP_connected = DHT_non_lan_connected(onion_c->dht); | 1832 | bool UDP_connected = dht_non_lan_connected(onion_c->dht); |
1828 | 1833 | ||
1829 | if (is_timeout(onion_c->first_run, ONION_CONNECTION_SECONDS * 2)) { | 1834 | if (is_timeout(onion_c->first_run, ONION_CONNECTION_SECONDS * 2)) { |
1830 | set_tcp_onion_status(nc_get_tcp_c(onion_c->c), !UDP_connected); | 1835 | set_tcp_onion_status(nc_get_tcp_c(onion_c->c), !UDP_connected); |