diff options
author | irungentoo <irungentoo@gmail.com> | 2014-06-14 11:31:56 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-06-14 11:31:56 -0400 |
commit | d6a9ce3175bc80f1b04694b3c1415807a1fbab18 (patch) | |
tree | 2550e74e7872539aa0b9f4cd3443472018a493f5 /testing | |
parent | 9c11c15385ff44609ac8438378a5bcb05d47c572 (diff) |
Fixed some issues in toxdns and added a test.
Added request_id.
request_id must be obtained with tox_generate_dns3_string, stored,
then passed to tox_decrypt_dns3_TXT when we want to decrypt the
received response.
Diffstat (limited to 'testing')
-rw-r--r-- | testing/Makefile.inc | 21 | ||||
-rw-r--r-- | testing/dns3_test.c | 51 | ||||
-rw-r--r-- | testing/nToxAudio.h | 55 |
3 files changed, 71 insertions, 56 deletions
diff --git a/testing/Makefile.inc b/testing/Makefile.inc index 2142b4ca..d29c5d55 100644 --- a/testing/Makefile.inc +++ b/testing/Makefile.inc | |||
@@ -24,7 +24,8 @@ if BUILD_TESTING | |||
24 | 24 | ||
25 | noinst_PROGRAMS += DHT_test \ | 25 | noinst_PROGRAMS += DHT_test \ |
26 | Messenger_test \ | 26 | Messenger_test \ |
27 | crypto_speed_test | 27 | crypto_speed_test \ |
28 | dns3_test | ||
28 | 29 | ||
29 | DHT_test_SOURCES = ../testing/DHT_test.c | 30 | DHT_test_SOURCES = ../testing/DHT_test.c |
30 | 31 | ||
@@ -71,6 +72,24 @@ crypto_speed_test_LDADD = \ | |||
71 | $(NACL_LIBS) \ | 72 | $(NACL_LIBS) \ |
72 | $(WINSOCK2_LIBS) | 73 | $(WINSOCK2_LIBS) |
73 | 74 | ||
75 | |||
76 | dns3_test_SOURCES = \ | ||
77 | ../testing/dns3_test.c | ||
78 | |||
79 | dns3_test_CFLAGS = \ | ||
80 | $(LIBSODIUM_CFLAGS) \ | ||
81 | $(NACL_CFLAGS) | ||
82 | |||
83 | dns3_test_LDADD = \ | ||
84 | $(LIBSODIUM_LDFLAGS) \ | ||
85 | $(NACL_LDFLAGS) \ | ||
86 | libtoxdns.la \ | ||
87 | libtoxcore.la \ | ||
88 | $(LIBSODIUM_LIBS) \ | ||
89 | $(NACL_OBJECTS) \ | ||
90 | $(NACL_LIBS) \ | ||
91 | $(WINSOCK2_LIBS) | ||
92 | |||
74 | if !WIN32 | 93 | if !WIN32 |
75 | 94 | ||
76 | noinst_PROGRAMS += tox_sync | 95 | noinst_PROGRAMS += tox_sync |
diff --git a/testing/dns3_test.c b/testing/dns3_test.c new file mode 100644 index 00000000..69649f50 --- /dev/null +++ b/testing/dns3_test.c | |||
@@ -0,0 +1,51 @@ | |||
1 | |||
2 | |||
3 | #include "../toxdns/toxdns.h" | ||
4 | #include "../toxcore/tox.h" | ||
5 | #include "misc_tools.c" | ||
6 | |||
7 | |||
8 | int main(int argc, char *argv[]) | ||
9 | { | ||
10 | if (argc < 4) { | ||
11 | printf("Usage: %s domain domain_public_key queried_username\nEX: %s utox.org D3154F65D28A5B41A05D4AC7E4B39C6B1C233CC857FB365C56E8392737462A12 username\n", | ||
12 | argv[0], argv[0]); | ||
13 | exit(0); | ||
14 | } | ||
15 | |||
16 | uint8_t string[1024] = {0}; | ||
17 | void *d = tox_dns3_new(hex_string_to_bin(argv[2])); | ||
18 | unsigned int i; | ||
19 | uint32_t request_id; | ||
20 | /* | ||
21 | for (i = 0; i < 255; ++i) { | ||
22 | tox_generate_dns3_string(d, string, sizeof(string), &request_id, string, i); | ||
23 | printf("%s\n", string); | ||
24 | }*/ | ||
25 | int len = tox_generate_dns3_string(d, string + 1, sizeof(string) - 1, &request_id, (uint8_t *)argv[3], strlen(argv[3])); | ||
26 | |||
27 | if (len == -1) | ||
28 | return -1; | ||
29 | |||
30 | string[0] = '_'; | ||
31 | memcpy(string + len + 1, "._tox.", sizeof("._tox.")); | ||
32 | memcpy((char *)(string + len + 1 + sizeof("._tox.") - 1), argv[1], strlen(argv[1])); | ||
33 | printf("Do a DNS request and find the TXT record for:\n%s\nThen paste the contents of the data contained in the id field here:\n", | ||
34 | string); | ||
35 | |||
36 | scanf("%s", string); | ||
37 | uint8_t tox_id[TOX_FRIEND_ADDRESS_SIZE]; | ||
38 | |||
39 | if (tox_decrypt_dns3_TXT(d, tox_id, string, strlen((char *)string), request_id) != 0) | ||
40 | return -1; | ||
41 | |||
42 | printf("The Tox id for username %s is:\n", argv[3]); | ||
43 | |||
44 | //unsigned int i; | ||
45 | for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; ++i) { | ||
46 | printf("%02hhX", tox_id[i]); | ||
47 | } | ||
48 | |||
49 | printf("\n"); | ||
50 | return 0; | ||
51 | } | ||
diff --git a/testing/nToxAudio.h b/testing/nToxAudio.h deleted file mode 100644 index 19b31f8b..00000000 --- a/testing/nToxAudio.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /* nTox.h | ||
2 | * | ||
3 | *Textual frontend for Tox. | ||
4 | * | ||
5 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
6 | * | ||
7 | * This file is part of Tox. | ||
8 | * | ||
9 | * Tox is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation, either version 3 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * Tox is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef NTOX_H | ||
25 | #define NTOX_H | ||
26 | |||
27 | #include <stdio.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <string.h> | ||
30 | #include <ncurses.h> | ||
31 | #include <curses.h> | ||
32 | #include <ctype.h> | ||
33 | #include <sys/socket.h> | ||
34 | #include <netinet/in.h> | ||
35 | #include <arpa/inet.h> | ||
36 | #include <sys/types.h> | ||
37 | #include <netdb.h> | ||
38 | #include "../core/Messenger.h" | ||
39 | #include "../core/network.h" | ||
40 | |||
41 | #define STRING_LENGTH 256 | ||
42 | #define HISTORY 50 | ||
43 | #define PUB_KEY_BYTES 32 | ||
44 | |||
45 | void new_lines(char *line); | ||
46 | void line_eval(char *line); | ||
47 | void wrap(char output[STRING_LENGTH], char input[STRING_LENGTH], int line_width) ; | ||
48 | int count_lines(char *string) ; | ||
49 | char *appender(char *str, const char c); | ||
50 | void do_refresh(); | ||
51 | |||
52 | |||
53 | |||
54 | |||
55 | #endif | ||