diff options
author | t3sserakt <t3ss@posteo.de> | 2021-07-30 14:47:59 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-07-30 14:47:59 +0200 |
commit | 4748af6e8e04347ceaeec09ccdfc04d740fa65f0 (patch) | |
tree | 1d0feeab3254c58b175e1376f72e7e2b92ec222d /src/transport/transport_api_cmd_connecting_peers.c | |
parent | 1a542d67de29d6ed40706ca70988f79bfd00fb38 (diff) | |
download | gnunet-4748af6e8e04347ceaeec09ccdfc04d740fa65f0.tar.gz gnunet-4748af6e8e04347ceaeec09ccdfc04d740fa65f0.zip |
- there are two helper running, but only one is doing the work of both. Therefore connecting peers does not work atm.
Diffstat (limited to 'src/transport/transport_api_cmd_connecting_peers.c')
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index d9253b6d4..f4b2e935f 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_transport_application_service.h" | 29 | #include "gnunet_transport_application_service.h" |
30 | #include "gnunet_hello_lib.h" | 30 | #include "gnunet_hello_lib.h" |
31 | #include "gnunet_transport_service.h" | 31 | #include "gnunet_transport_service.h" |
32 | #include "transport-testing-cmds.h" | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * Generic logging shortcut | 35 | * Generic logging shortcut |
@@ -40,6 +41,8 @@ struct ConnectPeersState | |||
40 | const char *peer1_label; | 41 | const char *peer1_label; |
41 | 42 | ||
42 | const char *peer2_label; | 43 | const char *peer2_label; |
44 | |||
45 | struct GNUNET_PeerIdentity *id; | ||
43 | }; | 46 | }; |
44 | 47 | ||
45 | 48 | ||
@@ -52,12 +55,13 @@ connect_peers_run (void *cls, | |||
52 | const struct GNUNET_TESTING_Command *peer1_cmd; | 55 | const struct GNUNET_TESTING_Command *peer1_cmd; |
53 | const struct GNUNET_TESTING_Command *peer2_cmd; | 56 | const struct GNUNET_TESTING_Command *peer2_cmd; |
54 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | 57 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
55 | struct GNUNET_PeerIdentity *id; | 58 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); |
56 | char *addr; | 59 | char *addr; |
57 | struct GNUNET_TIME_Absolute t; | 60 | struct GNUNET_TIME_Absolute t; |
58 | char *hello; | 61 | char *hello; |
59 | size_t *hello_size; | 62 | size_t *hello_size; |
60 | enum GNUNET_NetworkType nt = 0; | 63 | enum GNUNET_NetworkType nt = 0; |
64 | char *peer_id; | ||
61 | 65 | ||
62 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); | 66 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); |
63 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | 67 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, |
@@ -70,6 +74,31 @@ connect_peers_run (void *cls, | |||
70 | "hello: %s\n", | 74 | "hello: %s\n", |
71 | hello); | 75 | hello); |
72 | 76 | ||
77 | /*GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | ||
78 | &id); | ||
79 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
80 | "pid %s\n", | ||
81 | GNUNET_i2s_full(id));*/ | ||
82 | |||
83 | if(strstr(hello, "60002") != NULL) | ||
84 | { | ||
85 | addr = "tcp-192.168.15.2:60003"; | ||
86 | peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | addr = "tcp-192.168.15.1:60002"; | ||
91 | peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; | ||
92 | } | ||
93 | |||
94 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
95 | "get pub key\n"); | ||
96 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | ||
97 | strlen (peer_id), | ||
98 | &peer->public_key); | ||
99 | |||
100 | cps->id = peer; | ||
101 | |||
73 | // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. | 102 | // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. |
74 | // --------------------------------------------- | 103 | // --------------------------------------------- |
75 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | 104 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); |
@@ -84,14 +113,16 @@ connect_peers_run (void *cls, | |||
84 | *hello_size, | 113 | *hello_size, |
85 | id, | 114 | id, |
86 | &nt, | 115 | &nt, |
87 | &t); | 116 | &t);*/ |
88 | 117 | ||
89 | //---------------------------------------------- | 118 | //---------------------------------------------- |
90 | 119 | ||
120 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
121 | "application validate\n"); | ||
91 | GNUNET_TRANSPORT_application_validate (ah, | 122 | GNUNET_TRANSPORT_application_validate (ah, |
92 | id, | 123 | peer, |
93 | nt, | 124 | nt, |
94 | addr);*/ | 125 | addr); |
95 | } | 126 | } |
96 | 127 | ||
97 | 128 | ||
@@ -100,34 +131,38 @@ connect_peers_finish (void *cls, | |||
100 | GNUNET_SCHEDULER_TaskCallback cont, | 131 | GNUNET_SCHEDULER_TaskCallback cont, |
101 | void *cont_cls) | 132 | void *cont_cls) |
102 | { | 133 | { |
103 | /*struct ConnectPeersState *cps = cls; | 134 | struct ConnectPeersState *cps = cls; |
104 | const struct GNUNET_TESTING_Command *peer1_cmd; | 135 | const struct GNUNET_TESTING_Command *peer1_cmd; |
105 | const struct GNUNET_TESTING_Command *peer2_cmd; | 136 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
106 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; | ||
107 | unsigned int ret; | 137 | unsigned int ret; |
108 | struct GNUNET_PeerIdentity *id; | 138 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); |
139 | struct GNUNET_HashCode hc; | ||
140 | int node_number; | ||
109 | 141 | ||
110 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); | 142 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); |
111 | GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | 143 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, |
112 | &id); | ||
113 | |||
114 | peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | ||
115 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer2_cmd, | ||
116 | &connected_peers_map); | 144 | &connected_peers_map); |
117 | 145 | ||
118 | ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map, | 146 | node_number = 1; |
119 | id); | 147 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); |
148 | |||
149 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | ||
150 | memcpy (key, | ||
151 | &hc, | ||
152 | sizeof (*key)); | ||
153 | ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map, | ||
154 | key); | ||
120 | 155 | ||
121 | if (GNUNET_YES == ret) | 156 | if (GNUNET_YES == ret) |
122 | { | 157 | { |
123 | cont (cont_cls); | 158 | cont (cont_cls); |
124 | } | ||
125 | |||
126 | return ret;*/ | ||
127 | cont (cont_cls); | ||
128 | LOG (GNUNET_ERROR_TYPE_ERROR, | 159 | LOG (GNUNET_ERROR_TYPE_ERROR, |
129 | "connect peer finish\n"); | 160 | "connect peer finish\n"); |
130 | return GNUNET_OK; | 161 | } |
162 | |||
163 | return ret; | ||
164 | /*cont (cont_cls); | ||
165 | return GNUNET_OK;*/ | ||
131 | } | 166 | } |
132 | 167 | ||
133 | 168 | ||