diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-03-20 13:53:23 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-04-04 17:58:11 +0200 |
commit | ac3aa3cc3a617bc54ed8beb2b5a30c0b95483525 (patch) | |
tree | 6e0444e568722f18501746665a07dfa3434c7ad6 /src/messenger/gnunet-service-messenger.c | |
parent | 2413977f917534aa24ef562a28da193a2cdaa343 (diff) | |
download | gnunet-ac3aa3cc3a617bc54ed8beb2b5a30c0b95483525.tar.gz gnunet-ac3aa3cc3a617bc54ed8beb2b5a30c0b95483525.zip |
-multiple fixes and correction regarding messenger service
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-added message states to tunnels
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-fixed requests for deleted messages returning previous ones
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-added automatic solving of member id collissions
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-added light timestamp verification
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-fixed decoding asserts and member session forwarding
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-added permission check for member sessions during local join
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/gnunet-service-messenger.c')
-rwxr-xr-x | src/messenger/gnunet-service-messenger.c | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index 76fb31d95..7edd76d32 100755 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -25,6 +25,8 @@ | |||
25 | 25 | ||
26 | #include "gnunet-service-messenger.h" | 26 | #include "gnunet-service-messenger.h" |
27 | 27 | ||
28 | #include "gnunet-service-messenger_handle.h" | ||
29 | #include "gnunet-service-messenger_message_kind.h" | ||
28 | #include "gnunet-service-messenger_service.h" | 30 | #include "gnunet-service-messenger_service.h" |
29 | #include "messenger_api_message.h" | 31 | #include "messenger_api_message.h" |
30 | 32 | ||
@@ -209,6 +211,9 @@ check_for_message: | |||
209 | 211 | ||
210 | struct GNUNET_MESSENGER_Message message; | 212 | struct GNUNET_MESSENGER_Message message; |
211 | 213 | ||
214 | if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN)) | ||
215 | return GNUNET_NO; | ||
216 | |||
212 | if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL)) | 217 | if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL)) |
213 | return GNUNET_NO; | 218 | return GNUNET_NO; |
214 | 219 | ||
@@ -266,6 +271,35 @@ end_handling: | |||
266 | } | 271 | } |
267 | 272 | ||
268 | static void | 273 | static void |
274 | callback_found_message (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, | ||
275 | const struct GNUNET_MESSENGER_Message *message, | ||
276 | const struct GNUNET_HashCode *hash) | ||
277 | { | ||
278 | struct GNUNET_MESSENGER_Client *msg_client = cls; | ||
279 | |||
280 | if (!message) | ||
281 | { | ||
282 | send_room_message(room, msg_client->handle, create_message_request(hash)); | ||
283 | return; | ||
284 | } | ||
285 | |||
286 | struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room); | ||
287 | |||
288 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message); | ||
289 | |||
290 | if (!member) | ||
291 | { | ||
292 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (hash)); | ||
293 | return; | ||
294 | } | ||
295 | |||
296 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash); | ||
297 | |||
298 | if (session) | ||
299 | notify_handle_message (msg_client->handle, get_room_key(room), session, message, hash); | ||
300 | } | ||
301 | |||
302 | static void | ||
269 | handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg) | 303 | handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg) |
270 | { | 304 | { |
271 | struct GNUNET_MESSENGER_Client *msg_client = cls; | 305 | struct GNUNET_MESSENGER_Client *msg_client = cls; |
@@ -280,26 +314,27 @@ handle_get_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg) | |||
280 | goto end_handling; | 314 | goto end_handling; |
281 | } | 315 | } |
282 | 316 | ||
283 | const struct GNUNET_MESSENGER_Message *message = get_room_message (room, msg_client->handle, &(msg->hash), | 317 | struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room); |
284 | GNUNET_YES); | ||
285 | |||
286 | if (!message) | ||
287 | goto end_handling; | ||
288 | |||
289 | struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room); | ||
290 | 318 | ||
291 | struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message); | 319 | struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, get_handle_member_id( |
320 | msg_client->handle, &(msg->key) | ||
321 | )); | ||
292 | 322 | ||
293 | if (!member) | 323 | if (!member) |
294 | { | 324 | { |
295 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (&(msg->hash))); | 325 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Member not valid to request a message!\n"); |
296 | goto end_handling; | 326 | goto end_handling; |
297 | } | 327 | } |
298 | 328 | ||
299 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, &(msg->hash)); | 329 | struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_handle_ego(msg_client->handle)->pub)); |
300 | 330 | ||
301 | if (session) | 331 | if (!session) |
302 | notify_handle_message (msg_client->handle, get_room_key(room), session, message, &(msg->hash)); | 332 | { |
333 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Session not valid to request a message!\n"); | ||
334 | goto end_handling; | ||
335 | } | ||
336 | |||
337 | request_room_message (room, &(msg->hash), session, callback_found_message, msg_client); | ||
303 | 338 | ||
304 | end_handling: | 339 | end_handling: |
305 | GNUNET_SERVICE_client_continue (msg_client->client); | 340 | GNUNET_SERVICE_client_continue (msg_client->client); |