summaryrefslogtreecommitdiff
path: root/testing/Messenger_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/Messenger_test.c')
-rw-r--r--testing/Messenger_test.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index 6b0e56fc..c049aa18 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -7,7 +7,7 @@
7 * If it recieves a message from a friend it replies back. 7 * If it recieves a message from a friend it replies back.
8 * 8 *
9 * 9 *
10 * This is how I compile it: gcc -O2 -Wall -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/DHT.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/* Messenger_test.c 10 * This is how I compile it: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../core/DHT.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/{cpucycles.o,libnacl.a,randombytes.o} Messenger_test.c
11 * 11 *
12 * 12 *
13 * Command line arguments are the ip and port of a node (for bootstrapping). 13 * Command line arguments are the ip and port of a node (for bootstrapping).
@@ -77,8 +77,8 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
77 77
78int main(int argc, char *argv[]) 78int main(int argc, char *argv[])
79{ 79{
80 if (argc < 3) { 80 if (argc < 4) {
81 printf("usage %s ip port (of the DHT bootstrap node)\n", argv[0]); 81 printf("usage %s ip port public_key (of the DHT bootstrap node)\n", argv[0]);
82 exit(0); 82 exit(0);
83 } 83 }
84 initMessenger(); 84 initMessenger();
@@ -96,14 +96,17 @@ int main(int argc, char *argv[])
96 96
97 char temp_id[128]; 97 char temp_id[128];
98 printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); 98 printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n");
99 scanf("%s", temp_id); 99 if(scanf("%s", temp_id) != 1)
100 {
101 return 1;
102 }
100 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); 103 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
101 104
102 perror("Initialization"); 105 perror("Initialization");
103 IP_Port bootstrap_ip_port; 106 IP_Port bootstrap_ip_port;
104 bootstrap_ip_port.port = htons(atoi(argv[2])); 107 bootstrap_ip_port.port = htons(atoi(argv[2]));
105 bootstrap_ip_port.ip.i = inet_addr(argv[1]); 108 bootstrap_ip_port.ip.i = inet_addr(argv[1]);
106 DHT_bootstrap(bootstrap_ip_port); 109 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
107 110
108 while(1) 111 while(1)
109 { 112 {