aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api_cmd_connecting_peers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api_cmd_connecting_peers.c')
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 34b3d5925..09ca9e54c 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -42,6 +42,15 @@
42 */ 42 */
43struct ConnectPeersState 43struct ConnectPeersState
44{ 44{
45 // Label of the cmd which started the test system.
46 const char *create_label;
47
48 /**
49 * Number globally identifying the node.
50 *
51 */
52 uint32_t num;
53
45 /** 54 /**
46 * Label of the cmd to start a peer. 55 * Label of the cmd to start a peer.
47 * 56 *
@@ -66,6 +75,13 @@ connect_peers_run (void *cls,
66 struct GNUNET_TESTING_Interpreter *is) 75 struct GNUNET_TESTING_Interpreter *is)
67{ 76{
68 struct ConnectPeersState *cps = cls; 77 struct ConnectPeersState *cps = cls;
78 const struct GNUNET_TESTING_Command *system_cmd;
79 struct GNUNET_TESTING_System *tl_system;
80 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct
81 GNUNET_CRYPTO_EddsaPrivateKey);
82 struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct
83 GNUNET_CRYPTO_EddsaPublicKey);
84 ;
69 const struct GNUNET_TESTING_Command *peer1_cmd; 85 const struct GNUNET_TESTING_Command *peer1_cmd;
70 // const struct GNUNET_TESTING_Command *peer2_cmd; 86 // const struct GNUNET_TESTING_Command *peer2_cmd;
71 struct GNUNET_TRANSPORT_ApplicationHandle *ah; 87 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
@@ -77,6 +93,8 @@ connect_peers_run (void *cls,
77 enum GNUNET_NetworkType nt = 0; 93 enum GNUNET_NetworkType nt = 0;
78 char *peer_id; 94 char *peer_id;
79 struct GNUNET_PeerIdentity *id; 95 struct GNUNET_PeerIdentity *id;
96 struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity);
97 uint32_t num;
80 98
81 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); 99 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
82 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, 100 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -88,9 +106,22 @@ connect_peers_run (void *cls,
88 GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, 106 GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
89 &id); 107 &id);
90 108
91 if (strstr (hello, "60002") != NULL) 109 system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label);
110 GNUNET_TESTING_get_trait_test_system (system_cmd,
111 &tl_system);
112
113 if (2 == cps->num)
114 num = 1;
115 else
116 num = 2;
117
118
119
120
121 // if (strstr (hello, "60002") != NULL)
122 if (2 == num)
92 { 123 {
93 addr = "tcp-192.168.15.2:60003"; 124 addr = "tcp-192.168.15.2:60002";
94 peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; 125 peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
95 } 126 }
96 else 127 else
@@ -99,10 +130,25 @@ connect_peers_run (void *cls,
99 peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; 130 peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
100 } 131 }
101 132
133 priv_key = GNUNET_TESTING_hostkey_get (tl_system,
134 num,
135 other);
136
137 GNUNET_CRYPTO_eddsa_key_get_public (priv_key,
138 pub_key);
139
102 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, 140 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
103 strlen (peer_id), 141 strlen (peer_id),
104 &peer->public_key); 142 &peer->public_key);
105 143
144 peer->public_key = *pub_key;
145
146 LOG (GNUNET_ERROR_TYPE_ERROR,
147 "\nnum: %u\n peer_id: %s\n pub_key %s\n",
148 num,
149 peer_id,
150 GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key));
151
106 cps->id = peer; 152 cps->id = peer;
107 153
108 // 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. 154 // 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.
@@ -210,12 +256,16 @@ connect_peers_cleanup (void *cls,
210 */ 256 */
211struct GNUNET_TESTING_Command 257struct GNUNET_TESTING_Command
212GNUNET_TRANSPORT_cmd_connect_peers (const char *label, 258GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
213 const char *start_peer_label) 259 const char *start_peer_label,
260 const char *create_label,
261 uint32_t num)
214{ 262{
215 struct ConnectPeersState *cps; 263 struct ConnectPeersState *cps;
216 264
217 cps = GNUNET_new (struct ConnectPeersState); 265 cps = GNUNET_new (struct ConnectPeersState);
218 cps->start_peer_label = start_peer_label; 266 cps->start_peer_label = start_peer_label;
267 cps->num = num;
268 cps->create_label = create_label;
219 269
220 270
221 struct GNUNET_TESTING_Command cmd = { 271 struct GNUNET_TESTING_Command cmd = {