Skip to content

Commit 7715008

Browse files
author
mannol
committed
Merged upstream
2 parents 5c0b6c8 + 7787454 commit 7715008

File tree

14 files changed

+61
-54
lines changed

14 files changed

+61
-54
lines changed

INSTALL.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ pkg install autoconf automake gcc-47
4545
On FreeBSD 10+:
4646

4747
```tcsh
48-
pkg install automake autoconf
48+
pkg install net-im/tox
4949
```
50+
Note, if you install from ports select NaCl for performance, and sodium if you want it to be portable.
5051

5152
You should get and install [libsodium](https://github.com/jedisct1/libsodium):
5253
```bash
5354
git clone git://github.com/jedisct1/libsodium.git
5455
cd libsodium
55-
git checkout tags/0.4.2
56+
git checkout tags/0.5.0
5657
./autogen.sh
5758
./configure && make check
58-
sudo checkinstall --install --pkgname libsodium --pkgversion 0.4.2 --nodoc
59+
sudo checkinstall --install --pkgname libsodium --pkgversion 0.5.0 --nodoc
5960
sudo ldconfig
6061
cd ..
6162
```
@@ -67,7 +68,7 @@ this will install the libs to /usr/local/lib and the headers to /usr/local/inclu
6768
```bash
6869
git clone git://github.com/jedisct1/libsodium.git
6970
cd libsodium
70-
git checkout tags/0.4.2
71+
git checkout tags/0.5.0
7172
./autogen.sh
7273
./configure
7374
make check
@@ -183,10 +184,10 @@ MinGW will install an "MinGW shell" (you should get a shortcut for it), make
183184
sure to perform all operations (i.e., generating/running configure script, compiling, etc.) from the MinGW shell.
184185

185186
First download the source tarball from https://download.libsodium.org/libsodium/releases/ and build it.
186-
Assuming that you got the libsodium-0.4.2.tar.gz release:
187+
Assuming that you got the libsodium-0.5.0.tar.gz release:
187188
```cmd
188-
tar -zxvf libsodium-0.4.2.tar.gz
189-
cd libsodium-0.4.2
189+
tar -zxvf libsodium-0.5.0.tar.gz
190+
cd libsodium-0.5.0
190191
./configure
191192
make
192193
make install

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
![Project Tox](https://raw.github.com/irungentoo/ProjectTox-Core/master/other/tox.png "Project Tox")
1+
![Project Tox](https://raw.github.com/irungentoo/toxcore/master/other/tox.png "Project Tox")
22
***
33

44
With the rise of governmental monitoring programs, Tox, a FOSS initiative, aims to be an easy to use, all-in-one communication platform that ensures their users full privacy and secure message delivery.<br /> <br />
55

6-
[**Website**](https://tox.im) **|** [**Wiki**](http://wiki.tox.im/) **|** [**Blog**](https://blog.libtoxcore.so/) **|** [**FAQ**](http://wiki.tox.im/FAQ) **|** [**Binaries**](http://download.tox.im/) **|** [**Clients**](http://wiki.tox.im/Client) **|** [**Compiling**](http://wiki.tox.im/Installing) **|** [**API**](http://api.libtoxcore.so/) **|** [**Qt-GUI**](https://github.com/nurupo/ProjectTox-Qt-GUI) **|** **IRC:** #tox@freenode
6+
[**Website**](https://tox.im) **|** [**Wiki**](https://wiki.tox.im/) **|** [**Blog**](https://blog.libtoxcore.so/) **|** [**FAQ**](http://wiki.tox.im/FAQ) **|** [**Binaries**](https://wiki.tox.im/Binaries) **|** [**Clients**](https://wiki.tox.im/Client) **|** [**Compiling**](https://wiki.tox.im/Installing) **|** [**API**](https://libtoxcore.so/) **|** **IRC:** #tox@freenode
77

88

99
## The Complex Stuff:
1010
### UDP vs. TCP
11-
Tox must use UDP simply because [hole punching](http://en.wikipedia.org/wiki/UDP_hole_punching) with TCP is not as reliable.
11+
Tox must use UDP simply because [hole punching](https://en.wikipedia.org/wiki/UDP_hole_punching) with TCP is not as reliable.
1212
However, Tox does use [TCP relays](https://github.com/irungentoo/ProjectTox-Core/blob/master/docs/TCP_Network.txt) as a fallback if it encounters a firewall that prevents UDP hole punching.
1313

1414
### Connecting & Communicating
15-
Every peer is represented as a [byte string][String] (the public key [Tox ID] of the peer). By using torrent-style DHT, peers can find the IP of other peers by using their Tox ID. Once the IP is obtained, peers can initiate a [secure](https://github.com/irungentoo/ProjectTox-Core/wiki/Crypto) connection with each other. Once the connection is made, peers can exchange messages, send files, start video chats, etc. using encrypted communications.
15+
Every peer is represented as a [byte string][String] (the public key [Tox ID] of the peer). By using torrent-style DHT, peers can find the IP of other peers by using their Tox ID. Once the IP is obtained, peers can initiate a [secure](https://github.com/irungentoo/toxcore/wiki/Crypto) connection with each other. Once the connection is made, peers can exchange messages, send files, start video chats, etc. using encrypted communications.
1616

1717

18-
**Current build status:** [![Build Status](https://travis-ci.org/irungentoo/ProjectTox-Core.png?branch=master)](https://travis-ci.org/irungentoo/ProjectTox-Core)
18+
**Current build status:** [![Build Status](https://travis-ci.org/irungentoo/toxcore.png?branch=master)](https://travis-ci.org/irungentoo/toxcore)
1919

2020

2121
## Q&A:
@@ -34,9 +34,9 @@ The goal of this project is to create a configuration-free P2P Skype replacement
3434
## Documentation:
3535

3636
- [Installation](/INSTALL.md)
37-
- [DHT Protocol](http://wiki.tox.im/index.php/DHT)<br />
38-
- [Lossless UDP Protocol](http://wiki.tox.im/index.php/Lossless_UDP)<br />
39-
- [Crypto](http://wiki.tox.im/index.php/Crypto)<br />
40-
- [Ideas](http://wiki.tox.im/index.php/Ideas)
37+
- [DHT Protocol](https://wiki.tox.im/index.php/DHT)<br />
38+
- [Lossless UDP Protocol](https://wiki.tox.im/index.php/Lossless_UDP)<br />
39+
- [Crypto](https://wiki.tox.im/index.php/Crypto)<br />
40+
- [Ideas](https://wiki.tox.im/index.php/Ideas)
4141

4242
[String]: https://en.wikipedia.org/wiki/String_(computer_science)

other/fun/sign.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ int load_file(char *filename, char **result)
3636

3737
if (size != fread(*result, sizeof(char), size, f)) {
3838
free(*result);
39+
fclose(f);
3940
return -2; // -2 means file reading fail
4041
}
4142

testing/nTox.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,11 @@ void line_eval(Tox *m, char *line)
531531
}
532532
}
533533
} else if (inpt_command == 't') {
534-
char msg[512];
535534
char *posi[1];
536535
int friendnum = strtoul(line + prompt_offset, posi, 0);
537536

538537
if (**posi != 0) {
538+
char msg[512];
539539
sprintf(msg, "[t] Sending file %s to friendnum %u filenumber is %i (-1 means failure)", *posi + 1, friendnum,
540540
add_filesender(m, friendnum, *posi + 1));
541541
new_lines(msg);
@@ -634,7 +634,7 @@ void line_eval(Tox *m, char *line)
634634
* otherwise turns spaces into newlines if possible */
635635
void wrap(char output[STRING_LENGTH_WRAPPED], char input[STRING_LENGTH], int line_width)
636636
{
637-
size_t i, k, m, len = strlen(input);
637+
size_t i, len = strlen(input);
638638

639639
if ((line_width < 4) || (len < (size_t)line_width)) {
640640
/* if line_width ridiculously tiny, it's not worth the effort */
@@ -652,8 +652,8 @@ void wrap(char output[STRING_LENGTH_WRAPPED], char input[STRING_LENGTH], int lin
652652

653653
for (i = line_width; i < len; i += line_width) {
654654
/* look backward for a space to expand/turn into a new line */
655-
k = i;
656-
m = i - line_width;
655+
size_t k = i;
656+
size_t m = i - line_width;
657657

658658
while (input[k] != ' ' && k > m) {
659659
k--;
@@ -837,7 +837,6 @@ void do_refresh()
837837
{
838838
int count = 0;
839839
char wrap_output[STRING_LENGTH_WRAPPED];
840-
int L;
841840
int i;
842841

843842
for (i = 0; i < HISTORY; i++) {
@@ -846,7 +845,7 @@ void do_refresh()
846845
else
847846
wrap(wrap_output, lines[i], x);
848847

849-
L = count_lines(wrap_output);
848+
int L = count_lines(wrap_output);
850849
count = count + L;
851850

852851
if (count < y) {
@@ -921,11 +920,10 @@ static char *data_file_name = NULL;
921920
static int load_data(Tox *m)
922921
{
923922
FILE *data_file = fopen(data_file_name, "r");
924-
size_t size = 0;
925923

926924
if (data_file) {
927925
fseek(data_file, 0, SEEK_END);
928-
size = ftell(data_file);
926+
size_t size = ftell(data_file);
929927
rewind(data_file);
930928

931929
uint8_t data[size];
@@ -1215,7 +1213,6 @@ int main(int argc, char *argv[])
12151213
exit(1);
12161214

12171215
int on = 0;
1218-
int c = 0;
12191216
char *filename = "data";
12201217
char idstring[200] = {0};
12211218
Tox *m;
@@ -1282,8 +1279,6 @@ int main(int argc, char *argv[])
12821279

12831280
time_t timestamp0 = time(NULL);
12841281

1285-
uint8_t pollok = 0;
1286-
12871282
while (1) {
12881283
if (on == 0) {
12891284
if (tox_isconnected(m)) {
@@ -1305,7 +1300,7 @@ int main(int argc, char *argv[])
13051300
tox_do(m);
13061301
do_refresh();
13071302

1308-
c = timeout_getch(m);
1303+
int c = timeout_getch(m);
13091304

13101305
if (c == ERR || c == 27)
13111306
continue;

toxav/codec.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,11 @@ void queue(JitterBuffer *q, RTPMessage *pk)
154154
q->queue[q->rear] = pk;
155155

156156
int a;
157-
int b;
158157
int j;
159158
a = q->rear;
160159

161160
for (j = 0; j < q->size - 1; ++j) {
162-
b = a - 1;
161+
int b = a - 1;
163162

164163
if (b < 0)
165164
b += q->capacity;
@@ -336,4 +335,4 @@ int energy_VAD(CodecState* cs, int16_t* PCM, uint16_t frame_size, float energy)
336335

337336
if ( cs->EVAD_tolerance_cr ) { cs->EVAD_tolerance_cr --; return 1; }
338337
return 0;
339-
}
338+
}

toxav/msi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,11 @@ MSIMessage *parse_message ( const uint8_t *data, uint16_t length )
431431
*/
432432
int stringify_message(MSIMessage *msg, char *dest)
433433
{
434+
// THIS CODE HAS NO EFFECT, AND THE ARGUMENTS ARE NOT MODIFIED
435+
#if 0
436+
434437
#define HDR_TO_STR(__dest, __hdr) if (__hdr.header_value) {\
435-
char nltstr[MSI_MAXMSG_SIZE]; memset(nltstr, '\0', MSI_MAXMSG_SIZE); int i = 0; \
438+
char nltstr[MSI_MAXMSG_SIZE]; memset(nltstr+__hdr.size, '\0', MSI_MAXMSG_SIZE-__hdr.size); int i = 0; \
436439
for ( ; i < __hdr.size; i ++) nltstr[i] = (char)__hdr.header_value[i]; \
437440
}
438441

@@ -452,6 +455,7 @@ int stringify_message(MSIMessage *msg, char *dest)
452455
// U8_TO_NLTCHAR(msg->version.header_value, msg->version.size, nltstr, MSI_MAXMSG_SIZE);
453456
// sprintf(dest, "Version: %s\n", nltstr);
454457
// }
458+
#endif
455459

456460
return 0;
457461
}

toxav/rtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ int rtp_release_session_recv ( RTPSession *session )
604604
void rtp_queue_adjust_limit(RTPSession *session, uint64_t limit)
605605
{
606606
pthread_mutex_lock(&session->mutex);
607-
607+
608608
RTPMessage *_tmp, * _it = session->oldest_msg;
609609

610610
for ( ; session->queue_size > limit; _it = _tmp ) {

toxav/toxav.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,20 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
475475
if (cii(call_index, av->msi_session)) return ErrorNoCall;
476476

477477
uint8_t packet [RTP_PAYLOAD_SIZE];
478-
int recved_size = 0;
479-
int rc;
480478
CallSpecific *call = &av->calls[call_index];
481479

480+
int recved_size = 0;
481+
482482
do {
483483
recved_size = toxav_recv_rtp_payload(av, call_index, TypeVideo, packet);
484484

485-
if (recved_size > 0 && ( rc = vpx_codec_decode(&call->cs->v_decoder, packet, recved_size, NULL, 0) ) != VPX_CODEC_OK) {
486-
LOGGER_ERROR("Error decoding video: %s\n", vpx_codec_err_to_string(rc));
487-
return ErrorInternal;
485+
if (recved_size > 0) {
486+
int rc = vpx_codec_decode(&call->cs->v_decoder, packet, recved_size, NULL, 0);
487+
488+
if (rc != VPX_CODEC_OK) {
489+
LOGGER_ERROR("Error decoding video: %s\n", vpx_codec_err_to_string(rc));
490+
return ErrorInternal;
491+
}
488492
}
489493

490494
} while (recved_size > 0);

toxcore/DHT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,11 +2221,11 @@ uint16_t random_nodes_path(DHT *dht, Node_format *nodes, uint16_t max_num)
22212221
return 0;
22222222

22232223
uint16_t count = 0;
2224-
Client_data *list = NULL;
22252224
uint16_t list_size = 0;
22262225
uint32_t i;
22272226

22282227
for (i = 0; i < max_num; ++i) {
2228+
Client_data *list = NULL;
22292229
uint16_t rand_num = rand() % (dht->num_friends);
22302230
list = dht->friends_list[rand_num].client_list;
22312231
list_size = MAX_FRIEND_CLIENTS;

toxcore/Messenger.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,11 @@ int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint3
581581
if (friend_not_valid(m, friendnumber))
582582
return -1;
583583

584-
memset(buf, 0, maxlen);
585-
memcpy(buf, m->friendlist[friendnumber].statusmessage, MIN(maxlen, m->friendlist[friendnumber].statusmessage_length));
586-
return MIN(maxlen, m->friendlist[friendnumber].statusmessage_length);
584+
int msglen = MIN(maxlen, m->friendlist[friendnumber].statusmessage_length);
585+
586+
memcpy(buf, m->friendlist[friendnumber].statusmessage, msglen);
587+
memset(buf + msglen, 0, maxlen - msglen);
588+
return msglen;
587589
}
588590

589591
/* return the size of friendnumber's user status.
@@ -596,9 +598,10 @@ int m_get_self_statusmessage_size(Messenger *m)
596598

597599
int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen)
598600
{
599-
memset(buf, 0, maxlen);
600-
memcpy(buf, m->statusmessage, MIN(maxlen, m->statusmessage_length));
601-
return MIN(maxlen, m->statusmessage_length);
601+
int msglen = MIN(maxlen, m->statusmessage_length);
602+
memcpy(buf, m->statusmessage, msglen);
603+
memset(buf + msglen, 0, maxlen - msglen);
604+
return msglen;
602605
}
603606

604607
uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber)
@@ -2693,7 +2696,6 @@ void messenger_save(Messenger *m, uint8_t *data)
26932696
memset(relays, 0, len);
26942697
copy_connected_tcp_relays(m->net_crypto, relays, NUM_SAVED_TCP_RELAYS);
26952698
memcpy(data, relays, len);
2696-
data += len;
26972699
}
26982700

26992701
static int messenger_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type)

toxcore/TCP_server.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ static sock_t new_listening_TCP_socket(int family, uint16_t port)
818818
return ~0;
819819
}
820820

821-
int ok = 1;
822821
#ifndef TCP_SERVER_USE_EPOLL
823-
ok = set_socket_nonblock(sock);
822+
int ok = set_socket_nonblock(sock);
823+
#else
824+
int ok = 1;
824825
#endif
825826

826827
if (ok && family == AF_INET6) {

toxcore/assoc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,15 @@ void do_Assoc(Assoc *assoc, DHT *dht)
886886
* send getnode() requests to both */
887887
uint8_t *target_id = NULL;
888888
Client_entry *heard = NULL, *seen = NULL;
889-
size_t i, k, m, bckt;
889+
size_t i, k, m;
890890

891891
for (i = 1; i < assoc->candidates_bucket_count; i++) {
892892
if (i % 2)
893893
k = - (i >> 1);
894894
else
895895
k = i >> 1;
896896

897-
bckt = (candidate + k) % assoc->candidates_bucket_count;
897+
size_t bckt = (candidate + k) % assoc->candidates_bucket_count;
898898

899899
for (m = 0; m < assoc->candidates_bucket_size; m++)
900900
if (assoc->candidates[bckt].list[m].hash) {

toxcore/network.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,10 @@ Networking_Core *new_networking(IP ip, uint16_t port)
596596
*/
597597
uint16_t port_to_try = port;
598598
*portptr = htons(port_to_try);
599-
int tries, res;
599+
int tries;
600600

601601
for (tries = TOX_PORTRANGE_FROM; tries <= TOX_PORTRANGE_TO; tries++) {
602-
res = bind(temp->sock, (struct sockaddr *)&addr, addrsize);
602+
int res = bind(temp->sock, (struct sockaddr *)&addr, addrsize);
603603

604604
if (!res) {
605605
temp->port = *portptr;

toxcore/onion_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
10011001
if (count < (uint32_t)rand() % MAX_ONION_CLIENTS) {
10021002
Node_format nodes_list[MAX_SENT_NODES];
10031003
uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->friends_list[friendnum].real_client_id, nodes_list,
1004-
rand() % 2 ? AF_INET : AF_INET6, 1, 0);
1004+
(rand() % 2) ? AF_INET : AF_INET6, 1, 0);
10051005

10061006
for (i = 0; i < num_nodes; ++i)
10071007
client_send_announce_request(onion_c, friendnum + 1, nodes_list[i].ip_port, nodes_list[i].client_id, 0, ~0);
@@ -1083,7 +1083,7 @@ static void do_announce(Onion_Client *onion_c)
10831083
if (count < (uint32_t)rand() % MAX_ONION_CLIENTS) {
10841084
Node_format nodes_list[MAX_SENT_NODES];
10851085
uint32_t num_nodes = get_close_nodes(onion_c->dht, onion_c->c->self_public_key, nodes_list,
1086-
rand() % 2 ? AF_INET : AF_INET6, 1, 0);
1086+
(rand() % 2) ? AF_INET : AF_INET6, 1, 0);
10871087

10881088
for (i = 0; i < num_nodes; ++i) {
10891089
client_send_announce_request(onion_c, 0, nodes_list[i].ip_port, nodes_list[i].client_id, 0, ~0);

0 commit comments

Comments
 (0)