diff options
-rw-r--r-- | core/Lossless_UDP.c | 2 | ||||
-rw-r--r-- | testing/nTox.c | 35 |
2 files changed, 25 insertions, 12 deletions
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 0194375a..fd17c0c0 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -428,7 +428,7 @@ int handle_handshake(uint8_t * packet, uint32_t length, IP_Port source) | |||
428 | memcpy(&temp, packet + 5, 4); | 428 | memcpy(&temp, packet + 5, 4); |
429 | handshake_id2 = ntohl(temp); | 429 | handshake_id2 = ntohl(temp); |
430 | 430 | ||
431 | if (handshake_id2 == 0) { | 431 | if (handshake_id2 == 0 && is_connected(connection) < 3) { |
432 | send_handshake(source, handshake_id(source), handshake_id1); | 432 | send_handshake(source, handshake_id(source), handshake_id1); |
433 | return 0; | 433 | return 0; |
434 | } | 434 | } |
diff --git a/testing/nTox.c b/testing/nTox.c index 7ba31110..2acf7e94 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -38,6 +38,10 @@ char line[STRING_LENGTH]; | |||
38 | int x,y; | 38 | int x,y; |
39 | int nick_before; | 39 | int nick_before; |
40 | 40 | ||
41 | |||
42 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; | ||
43 | uint8_t num_requests; | ||
44 | |||
41 | void new_lines(char *line) | 45 | void new_lines(char *line) |
42 | { | 46 | { |
43 | int i; | 47 | int i; |
@@ -114,6 +118,17 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
114 | sprintf(numstring, "[i] changed status to %s", (char*)status); | 118 | sprintf(numstring, "[i] changed status to %s", (char*)status); |
115 | new_lines(numstring); | 119 | new_lines(numstring); |
116 | } | 120 | } |
121 | else if (line[1] == 'a') { | ||
122 | uint8_t numf = atoi(line + 3); | ||
123 | char numchar[100]; | ||
124 | sprintf(numchar, "[i] friend request %u accepted", numf); | ||
125 | new_lines(numchar); | ||
126 | int num = m_addfriend_norequest(pending_requests[numf]); | ||
127 | sprintf(numchar, "[i] added friendnumber %d", num); | ||
128 | new_lines(numchar); | ||
129 | do_refresh(); | ||
130 | |||
131 | } | ||
117 | else if (line[1] == 'q') { //exit | 132 | else if (line[1] == 'q') { //exit |
118 | endwin(); | 133 | endwin(); |
119 | exit(EXIT_SUCCESS); | 134 | exit(EXIT_SUCCESS); |
@@ -184,20 +199,18 @@ void do_refresh() | |||
184 | refresh(); | 199 | refresh(); |
185 | } | 200 | } |
186 | 201 | ||
202 | |||
203 | |||
187 | void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) | 204 | void print_request(uint8_t *public_key, uint8_t *data, uint16_t length) |
188 | { | 205 | { |
189 | new_lines("[i] received friend request"); | 206 | new_lines("[i] received friend request with message:"); |
207 | new_lines((char *)data); | ||
208 | char numchar[100]; | ||
209 | sprintf(numchar, "[i] To accept the request do: /a %u", num_requests); | ||
210 | new_lines(numchar); | ||
211 | memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE); | ||
212 | ++num_requests; | ||
190 | do_refresh(); | 213 | do_refresh(); |
191 | if (memcmp(data , "Install Gentoo", sizeof("Install Gentoo")) == 0) | ||
192 | //if the request contained the message of peace the person is obviously a friend so we add him. | ||
193 | { | ||
194 | new_lines("[i] friend request accepted"); | ||
195 | do_refresh(); | ||
196 | int num = m_addfriend_norequest(public_key); | ||
197 | char numchar[100]; | ||
198 | sprintf(numchar, "[i] added friendnumber %d", num); | ||
199 | new_lines(numchar); | ||
200 | } | ||
201 | } | 214 | } |
202 | 215 | ||
203 | void print_message(int friendnumber, uint8_t * string, uint16_t length) | 216 | void print_message(int friendnumber, uint8_t * string, uint16_t length) |