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.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index e5da16e9..19ab4cc3 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -104,15 +104,12 @@ int main(int argc, char *argv[])
104 exit(0); 104 exit(0);
105 } 105 }
106 initMessenger(); 106 initMessenger();
107 if(argc > 3) 107 if(argc > 3) {
108 {
109 IP_Port bootstrap_ip_port; 108 IP_Port bootstrap_ip_port;
110 bootstrap_ip_port.port = htons(atoi(argv[2])); 109 bootstrap_ip_port.port = htons(atoi(argv[2]));
111 bootstrap_ip_port.ip.i = inet_addr(argv[1]); 110 bootstrap_ip_port.ip.i = inet_addr(argv[1]);
112 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); 111 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
113 } 112 } else {
114 else
115 {
116 FILE *file = fopen(argv[1], "rb"); 113 FILE *file = fopen(argv[1], "rb");
117 if ( file==NULL ){return 1;} 114 if ( file==NULL ){return 1;}
118 int read; 115 int read;
@@ -127,8 +124,7 @@ int main(int argc, char *argv[])
127 124
128 printf("OUR ID: "); 125 printf("OUR ID: ");
129 uint32_t i; 126 uint32_t i;
130 for(i = 0; i < 32; i++) 127 for(i = 0; i < 32; i++) {
131 {
132 if(self_public_key[i] < 16) 128 if(self_public_key[i] < 16)
133 printf("0"); 129 printf("0");
134 printf("%hhX",self_public_key[i]); 130 printf("%hhX",self_public_key[i]);
@@ -138,16 +134,14 @@ int main(int argc, char *argv[])
138 134
139 char temp_id[128]; 135 char temp_id[128];
140 printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); 136 printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n");
141 if(scanf("%s", temp_id) != 1) 137 if(scanf("%s", temp_id) != 1) {
142 {
143 return 1; 138 return 1;
144 } 139 }
145 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); 140 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
146 141
147 perror("Initialization"); 142 perror("Initialization");
148 143
149 while(1) 144 while(1) {
150 {
151 uint8_t name[128]; 145 uint8_t name[128];
152 getname(num, name); 146 getname(num, name);
153 printf("%s\n", name); 147 printf("%s\n", name);
@@ -162,6 +156,5 @@ int main(int argc, char *argv[])
162 fwrite(buffer, 1, Messenger_size(), file); 156 fwrite(buffer, 1, Messenger_size(), file);
163 free(buffer); 157 free(buffer);
164 fclose(file); 158 fclose(file);
165 } 159 }
166
167} 160}