This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* get current peername then sort namelist */ | |
uint8_t peername[TOX_MAX_NAME_LENGTH]; | |
if (change != TOX_CHAT_CHANGE_PEER_DEL) { | |
uint16_t n_len = groupchats[groupnum].peer_name_lengths[peernum]; | |
memcpy(peername, &groupchats[groupnum].peer_names[peernum*TOX_MAX_NAME_LENGTH], sizeof(peername)); | |
peername[n_len] = '\0'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Max size of a packet payload */ | |
#define FUZZ_PACKET_LEN_RANGE 512 | |
/* Sends packet of size length to peernumber for every relevant group message type */ | |
static void fuzz_send_group_packet(GC_Chat *chat, uint32_t peernumber, const uint8_t *packet, size_t length) | |
{ | |
size_t i; | |
/* All lossy packet types */ | |
for (i = GP_PING; i <= GP_TCP_RELAYS; ++i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void utox_group_peer_join_cb(Tox *tox, uint32_t groupnumber, uint32_t peer_id, void *UNUSED(user_data)) { | |
debug("newGC:\tpeer join group %u, peer %u\n", groupnumber, peer_id); | |
/* Get and store name for this group, used by other functions */ | |
uint32_t name_length = tox_group_peer_get_name_size(tox, groupnumber, peer_id, NULL); | |
uint8_t *name = malloc(name_length + 1); | |
TOX_ERR_GROUP_PEER_QUERY err = 0; | |
tox_group_peer_get_name(tox, groupnumber, peer_id, name, &err); | |
if (err) { | |
debug("newGC:\tError getting peer %u name!\n", peer_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#0 0x00007ff53fdda39b in recursive_DHT_bucket_get_nodes (bucket=0x16f57c0, nodes=0x0, number=number@entry=8, | |
public_key=public_key@entry=0x7ffd247512f0 "", friend_ok=friend_ok@entry=true, ret_ips=ret_ips@entry=true) | |
at ../toxcore/DHT.c:772 | |
i = 7 | |
counter = 0 | |
#1 0x00007ff53fdda480 in recursive_DHT_bucket_get_nodes (bucket=bucket@entry=0x1a144d0, nodes=0x0, | |
number=number@entry=8, public_key=public_key@entry=0x7ffd247512f0 "", friend_ok=friend_ok@entry=true, | |
ret_ips=ret_ips@entry=true) at ../toxcore/DHT.c:746 | |
ret = <optimized out> | |
#2 0x00007ff53fdda5c4 in dealloc_buckets (bucket=0x1a144d0) at ../toxcore/DHT.c:816 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
key = 'kw6PZq3Zd;ekR[_1' | |
ret = '' | |
for i, ch in enumerate(key): | |
ecx = i + 1 | |
edx = 0x66666667 | |
eax = ecx | |
eax = edx * eax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a string representation of a key into a byte array. The supplied | |
* string must contain 64 hex-characters. | |
* | |
* Returns a byte array of length 32 on success. | |
* Returns None on failure. | |
*/ | |
pub fn key_string_to_bytes(s: &str) -> Option<[u8; 32]> { | |
if s.len() < 64 { | |
return None; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let port = match get_available_port(DEAFULT_PORT_FROM, DEFAULT_PORT_TO) { | |
Some(port) => port, | |
None => panic!("failed to find available port"), | |
}; | |
let sockaddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port); | |
let new_sock = match UdpSocket::bind(&sockaddr) { | |
Ok(sock) => sock, | |
Err(e) => panic!("failed to bind socket to port {}; err={:?}", port, e), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basic rust callback function */ | |
pub fn func(data: &[u8], src_addr: &SocketAddr, obj: &Rc<RefCell<Any>>) { | |
let mut temp = obj.borrow_mut(); | |
let mut dht = match temp.downcast_mut::<DHT>() { | |
Some(dht) => dht, | |
None => return, | |
}; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Peer A receives Peer B's announcement from DHT: | |
A -> B send handshake request GH_REQUEST & HS_INVITE_REQUEST | |
B -> A send handshake response GH_RESPONSE & HS_INVITE_REQUEST | |
A -> B send invite request GP_INVITE_REQUEST | |
B -> A send invite response GP_INVITE_RESPONSE | |
A -> B send sync request GP_SYNC_REQUEST | |
B -> A send sync response GP_SYNC_RESPONSE | |
B -> A send all other peer announcements [goto: 2] | |
A -> Connection State = CS_CONNECTED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from sys import argv | |
""" | |
Converts a string representation of a sorted array of integers `s` into a bitfield. | |
e.g. indicesToBin("1 2 4 9 10 13 15 17 18 20 21 25 26 28 29 33 34 36 37 38 39") | |
-> "01101000011001010110110001101100011011110" |
OlderNewer