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_tunnel.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_tunnel.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_tunnel.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c index f7e8713c6..80d8dfa5e 100644 --- a/src/messenger/gnunet-service-messenger_tunnel.c +++ b/src/messenger/gnunet-service-messenger_tunnel.c | |||
@@ -27,6 +27,9 @@ | |||
27 | 27 | ||
28 | #include "gnunet-service-messenger_handle.h" | 28 | #include "gnunet-service-messenger_handle.h" |
29 | #include "gnunet-service-messenger_message_recv.h" | 29 | #include "gnunet-service-messenger_message_recv.h" |
30 | #include "gnunet-service-messenger_message_store.h" | ||
31 | #include "gnunet-service-messenger_operation_store.h" | ||
32 | #include "gnunet-service-messenger_operation.h" | ||
30 | #include "messenger_api_util.h" | 33 | #include "messenger_api_util.h" |
31 | 34 | ||
32 | struct GNUNET_MESSENGER_SrvTunnel* | 35 | struct GNUNET_MESSENGER_SrvTunnel* |
@@ -44,7 +47,8 @@ create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerId | |||
44 | tunnel->messenger_version = 0; | 47 | tunnel->messenger_version = 0; |
45 | 48 | ||
46 | tunnel->peer_message = NULL; | 49 | tunnel->peer_message = NULL; |
47 | tunnel->last_message = NULL; | 50 | |
51 | init_message_state(&(tunnel->state)); | ||
48 | 52 | ||
49 | return tunnel; | 53 | return tunnel; |
50 | } | 54 | } |
@@ -62,8 +66,7 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel) | |||
62 | if (tunnel->peer_message) | 66 | if (tunnel->peer_message) |
63 | GNUNET_free(tunnel->peer_message); | 67 | GNUNET_free(tunnel->peer_message); |
64 | 68 | ||
65 | if (tunnel->last_message) | 69 | clear_message_state(&(tunnel->state)); |
66 | GNUNET_free(tunnel->last_message); | ||
67 | 70 | ||
68 | GNUNET_free(tunnel); | 71 | GNUNET_free(tunnel); |
69 | } | 72 | } |
@@ -143,10 +146,18 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUN | |||
143 | static void | 146 | static void |
144 | update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash) | 147 | update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash) |
145 | { | 148 | { |
146 | if (!tunnel->last_message) | 149 | struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(tunnel->room); |
147 | tunnel->last_message = GNUNET_new(struct GNUNET_HashCode); | 150 | |
151 | const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)? | ||
152 | GNUNET_YES : GNUNET_NO | ||
153 | ); | ||
154 | |||
155 | struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(tunnel->room); | ||
156 | |||
157 | const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash); | ||
148 | 158 | ||
149 | GNUNET_memcpy(tunnel->last_message, hash, sizeof(*hash)); | 159 | if (message) |
160 | update_message_state(&(tunnel->state), requested, message, hash); | ||
150 | } | 161 | } |
151 | 162 | ||
152 | void | 163 | void |
@@ -171,7 +182,9 @@ handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header) | |||
171 | if (!tunnel) | 182 | if (!tunnel) |
172 | return; | 183 | return; |
173 | 184 | ||
174 | const int new_message = update_room_message (tunnel->room, copy_message (&message), &hash); | 185 | const int new_message = update_room_message ( |
186 | tunnel->room, copy_message (&message), &hash | ||
187 | ); | ||
175 | 188 | ||
176 | if (GNUNET_YES != new_message) | 189 | if (GNUNET_YES != new_message) |
177 | goto receive_done; | 190 | goto receive_done; |
@@ -313,9 +326,6 @@ void | |||
313 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, | 326 | forward_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, |
314 | const struct GNUNET_HashCode *hash) | 327 | const struct GNUNET_HashCode *hash) |
315 | { | 328 | { |
316 | if (!message) | ||
317 | return; | ||
318 | |||
319 | GNUNET_assert((tunnel) && (message) && (hash)); | 329 | GNUNET_assert((tunnel) && (message) && (hash)); |
320 | 330 | ||
321 | struct GNUNET_MESSENGER_Message *copy = copy_message(message); | 331 | struct GNUNET_MESSENGER_Message *copy = copy_message(message); |