File LICENSE.md changed (mode: 100644) (index 2061be2..a748cbe) |
... |
... |
it more useful to permit linking proprietary applications with the library. If |
654 |
654 |
this is what you want to do, use the GNU Lesser General Public License instead |
this is what you want to do, use the GNU Lesser General Public License instead |
655 |
655 |
of this License. But first, please read |
of this License. But first, please read |
656 |
656 |
<<http://www.gnu.org/philosophy/why-not-lgpl.html>>. |
<<http://www.gnu.org/philosophy/why-not-lgpl.html>>. |
|
657 |
|
|
|
658 |
|
This software uses cJson by DaveGamble. |
|
659 |
|
|
|
660 |
|
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors |
|
661 |
|
|
|
662 |
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
663 |
|
of this software and associated documentation files (the "Software"), to deal |
|
664 |
|
in the Software without restriction, including without limitation the rights |
|
665 |
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
666 |
|
copies of the Software, and to permit persons to whom the Software is |
|
667 |
|
furnished to do so, subject to the following conditions: |
|
668 |
|
|
|
669 |
|
The above copyright notice and this permission notice shall be included in |
|
670 |
|
all copies or substantial portions of the Software. |
|
671 |
|
|
|
672 |
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
673 |
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
674 |
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
675 |
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
676 |
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
677 |
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
678 |
|
THE SOFTWARE. |
File main.c changed (mode: 100644) (index 48e7875..e0d9066) |
... |
... |
void help() |
1254 |
1254 |
fprintf(stderr, " -F <path> - create a PID file named <path>\n"); |
fprintf(stderr, " -F <path> - create a PID file named <path>\n"); |
1255 |
1255 |
fprintf(stderr, " -U <username|userid> - drop privileges to <username> before forking. Use\n"); |
fprintf(stderr, " -U <username|userid> - drop privileges to <username> before forking. Use\n"); |
1256 |
1256 |
fprintf(stderr, " numeric <userid> in static builds.\n"); |
fprintf(stderr, " numeric <userid> in static builds.\n"); |
|
1257 |
|
fprintf(stderr, " -b <path> - bootstrap from Tox nodes in a JSON file like nodes.tox.chat/json\n"); |
1257 |
1258 |
fprintf(stderr, " -h - this help message\n"); |
fprintf(stderr, " -h - this help message\n"); |
1258 |
1259 |
} |
} |
1259 |
1260 |
|
|
File tox_bootstrap_json.c changed (mode: 100644) (index 0eecb00..61e9f69) |
6 |
6 |
|
|
7 |
7 |
#include "cJSON.h" |
#include "cJSON.h" |
8 |
8 |
#include "log.h" |
#include "log.h" |
|
9 |
|
#include "util.h" |
9 |
10 |
|
|
10 |
|
/* From https://github.com/TokTok/c-toxcore/blob/master/other/fun/cracker.c */ |
|
11 |
|
static size_t hex_string_to_bin(const char *hex_string, size_t hex_len, uint8_t *bytes) |
|
|
11 |
|
void do_bootstrap_file(Tox *tox, const char *json_file) |
12 |
12 |
{ |
{ |
13 |
|
size_t i; |
|
14 |
|
const char *pos = hex_string; |
|
15 |
|
// make even |
|
16 |
|
for (i = 0; i < hex_len / 2; ++i, pos += 2) { |
|
17 |
|
uint8_t val; |
|
18 |
|
if (sscanf(pos, "%02hhx", &val) != 1) { |
|
19 |
|
return 0; |
|
20 |
|
} |
|
21 |
|
bytes[i] = val; |
|
22 |
|
} |
|
23 |
|
if (i * 2 < hex_len) { |
|
24 |
|
uint8_t val; |
|
25 |
|
if (sscanf(pos, "%hhx", &val) != 1) { |
|
26 |
|
return 0; |
|
27 |
|
} |
|
28 |
|
bytes[i] = (uint8_t)(val << 4); |
|
29 |
|
++i; |
|
30 |
|
} |
|
31 |
|
return i; |
|
32 |
|
} |
|
33 |
|
|
|
34 |
|
/* Very stupid test to filter out hostnames */ |
|
35 |
|
static bool isValidIPv4(const char *ip_address) |
|
36 |
|
{ |
|
37 |
|
unsigned int a,b,c,d; |
|
38 |
|
return sscanf(ip_address,"%u.%u.%u.%u", &a, &b, &c, &d) == 4; |
|
39 |
|
} |
|
40 |
|
|
|
41 |
|
void do_bootstrap_file(Tox *tox, const char * json_file) |
|
42 |
|
{ |
|
43 |
|
char * buffer = NULL; |
|
|
13 |
|
char *buffer = NULL; |
44 |
14 |
long length; |
long length; |
45 |
15 |
|
|
46 |
16 |
const cJSON *node = NULL; |
const cJSON *node = NULL; |
|
... |
... |
void do_bootstrap_file(Tox *tox, const char * json_file) |
49 |
19 |
const cJSON *tcp_port = NULL; |
const cJSON *tcp_port = NULL; |
50 |
20 |
unsigned char key_bin[TOX_PUBLIC_KEY_SIZE]; |
unsigned char key_bin[TOX_PUBLIC_KEY_SIZE]; |
51 |
21 |
|
|
52 |
|
FILE * f = fopen (json_file, "rb"); |
|
|
22 |
|
FILE * f = fopen(json_file, "rb"); |
53 |
23 |
|
|
54 |
24 |
if (f) { |
if (f) { |
55 |
25 |
fseek (f, 0, SEEK_END); |
fseek (f, 0, SEEK_END); |
File util.c changed (mode: 100644) (index 3e6a99c..5299415) |
... |
... |
const char *readable_connection_status(TOX_CONNECTION status) |
202 |
202 |
return "Unknown connection status"; |
return "Unknown connection status"; |
203 |
203 |
} |
} |
204 |
204 |
} |
} |
|
205 |
|
|
|
206 |
|
/* From https://github.com/TokTok/c-toxcore/blob/master/other/fun/cracker.c */ |
|
207 |
|
size_t hex_string_to_bin(const char *hex_string, size_t hex_len, uint8_t *bytes) |
|
208 |
|
{ |
|
209 |
|
size_t i; |
|
210 |
|
const char *pos = hex_string; |
|
211 |
|
// make even |
|
212 |
|
for (i = 0; i < hex_len / 2; ++i, pos += 2) { |
|
213 |
|
uint8_t val; |
|
214 |
|
if (sscanf(pos, "%02hhx", &val) != 1) { |
|
215 |
|
return 0; |
|
216 |
|
} |
|
217 |
|
bytes[i] = val; |
|
218 |
|
} |
|
219 |
|
if (i * 2 < hex_len) { |
|
220 |
|
uint8_t val; |
|
221 |
|
if (sscanf(pos, "%hhx", &val) != 1) { |
|
222 |
|
return 0; |
|
223 |
|
} |
|
224 |
|
bytes[i] = (uint8_t)(val << 4); |
|
225 |
|
++i; |
|
226 |
|
} |
|
227 |
|
return i; |
|
228 |
|
} |
|
229 |
|
|
|
230 |
|
/* Very stupid test to filter out hostnames */ |
|
231 |
|
bool isValidIPv4(const char *ip_address) |
|
232 |
|
{ |
|
233 |
|
unsigned int a,b,c,d; |
|
234 |
|
return sscanf(ip_address,"%u.%u.%u.%u", &a, &b, &c, &d) == 4; |
|
235 |
|
} |
File util.h changed (mode: 100644) (index 7dced6b..1d3b339) |
... |
... |
void* file_raw(char *path, uint32_t *size); |
15 |
15 |
const char *readable_connection_status(TOX_CONNECTION status); |
const char *readable_connection_status(TOX_CONNECTION status); |
16 |
16 |
int parse_local_port_forward(char *string, int *local_port, char **hostname, int *remote_port); |
int parse_local_port_forward(char *string, int *local_port, char **hostname, int *remote_port); |
17 |
17 |
int parse_pipe_port_forward(char *string, char **hostname, int *remote_port); |
int parse_pipe_port_forward(char *string, char **hostname, int *remote_port); |
|
18 |
|
size_t hex_string_to_bin(const char *hex_string, size_t hex_len, uint8_t *bytes); |
|
19 |
|
bool isValidIPv4(const char *ip_address); |
18 |
20 |
|
|
19 |
21 |
#endif |
#endif |