aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c49
-rwxr-xr-xsrc/peerinfo-tool/test_gnunet_peerinfo.py.in12
2 files changed, 9 insertions, 52 deletions
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index 88bca1e7d..28f2284ce 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -49,7 +49,6 @@ struct PrintContext
49 char **address_list; 49 char **address_list;
50 unsigned int num_addresses; 50 unsigned int num_addresses;
51 uint32_t off; 51 uint32_t off;
52 uint32_t trust;
53}; 52};
54 53
55 54
@@ -60,9 +59,8 @@ dump_pc (struct PrintContext *pc)
60 unsigned int i; 59 unsigned int i;
61 60
62 GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc); 61 GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc);
63 printf (_("Peer `%s' with trust %8u\n"), 62 printf (_("Peer `%s'\n"),
64 (const char *) &enc, 63 (const char *) &enc);
65 pc->trust);
66 for (i=0;i<pc->num_addresses;i++) 64 for (i=0;i<pc->num_addresses;i++)
67 { 65 {
68 printf ("\t%s\n", 66 printf ("\t%s\n",
@@ -156,13 +154,13 @@ print_address (void *cls,
156 154
157/** 155/**
158 * Print information about the peer. 156 * Print information about the peer.
159 * Currently prints the GNUNET_PeerIdentity, trust and the IP. 157 * Currently prints the GNUNET_PeerIdentity and the IP.
160 * Could of course do more (e.g. resolve via DNS). 158 * Could of course do more (e.g. resolve via DNS).
161 */ 159 */
162static void 160static void
163print_peer_info (void *cls, 161print_peer_info (void *cls,
164 const struct GNUNET_PeerIdentity *peer, 162 const struct GNUNET_PeerIdentity *peer,
165 const struct GNUNET_HELLO_Message *hello, uint32_t trust) 163 const struct GNUNET_HELLO_Message *hello)
166{ 164{
167 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 165 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
168 struct PrintContext *pc; 166 struct PrintContext *pc;
@@ -170,22 +168,8 @@ print_peer_info (void *cls,
170 if (peer == NULL) 168 if (peer == NULL)
171 { 169 {
172 GNUNET_PEERINFO_disconnect (peerinfo); 170 GNUNET_PEERINFO_disconnect (peerinfo);
173 switch (trust) 171 fprintf (stderr,
174 { 172 _("Error in communication with PEERINFO service\n"));
175 case 0:
176 break;
177 case 1:
178 fprintf (stderr,
179 _("Timeout trying to interact with PEERINFO service\n"));
180 break;
181 case 2:
182 fprintf (stderr,
183 _("Error in communication with PEERINFO service\n"));
184 break;
185 default:
186 GNUNET_break (0);
187 break;
188 }
189 return; 173 return;
190 } 174 }
191 if (be_quiet) 175 if (be_quiet)
@@ -196,7 +180,6 @@ print_peer_info (void *cls,
196 } 180 }
197 pc = GNUNET_malloc (sizeof (struct PrintContext)); 181 pc = GNUNET_malloc (sizeof (struct PrintContext));
198 pc->peer = *peer; 182 pc->peer = *peer;
199 pc->trust = trust;
200 GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_address, pc); 183 GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_address, pc);
201 if (0 == pc->off) 184 if (0 == pc->off)
202 { 185 {
@@ -228,27 +211,10 @@ run (void *cls,
228 struct GNUNET_PeerIdentity pid; 211 struct GNUNET_PeerIdentity pid;
229 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 212 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
230 char *fn; 213 char *fn;
231 int delta;
232 214
233 sched = s; 215 sched = s;
234 cfg = c; 216 cfg = c;
235 delta = 0; 217 if (args[0] != NULL)
236 if ( (args[0] != NULL) &&
237 (args[1] != NULL) &&
238 (1 == sscanf(args[0], "%d", &delta)) &&
239 (GNUNET_OK ==
240 GNUNET_CRYPTO_hash_from_string (args[1],
241 &pid.hashPubKey)) )
242 {
243 peerinfo = GNUNET_PEERINFO_connect (sched, cfg);
244 GNUNET_PEERINFO_iterate (peerinfo,
245 &pid,
246 delta,
247 GNUNET_TIME_UNIT_SECONDS,
248 &print_peer_info, NULL);
249 return;
250 }
251 else if (args[0] != NULL)
252 { 218 {
253 fprintf (stderr, 219 fprintf (stderr,
254 _("Invalid command line argument `%s'\n"), 220 _("Invalid command line argument `%s'\n"),
@@ -266,7 +232,6 @@ run (void *cls,
266 } 232 }
267 (void) GNUNET_PEERINFO_iterate (peerinfo, 233 (void) GNUNET_PEERINFO_iterate (peerinfo,
268 NULL, 234 NULL,
269 0,
270 GNUNET_TIME_relative_multiply 235 GNUNET_TIME_relative_multiply
271 (GNUNET_TIME_UNIT_SECONDS, 2), 236 (GNUNET_TIME_UNIT_SECONDS, 2),
272 &print_peer_info, NULL); 237 &print_peer_info, NULL);
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo.py.in b/src/peerinfo-tool/test_gnunet_peerinfo.py.in
index ba542f28a..01f76aa1e 100755
--- a/src/peerinfo-tool/test_gnunet_peerinfo.py.in
+++ b/src/peerinfo-tool/test_gnunet_peerinfo.py.in
@@ -46,12 +46,12 @@ try:
46 os.system ('gnunet-arm -q -i transport -c test_gnunet_peerinfo_data.conf') 46 os.system ('gnunet-arm -q -i transport -c test_gnunet_peerinfo_data.conf')
47 os.system ('sleep 1') 47 os.system ('sleep 1')
48 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf') 48 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf')
49 pinfo.expect (re.compile ("Peer `.*\' with trust *0\r")); 49 pinfo.expect (re.compile ("Peer `.*\'\r"));
50 pinfo.expect (re.compile (" *localhost:24357\r")); 50 pinfo.expect (re.compile (" *localhost:24357\r"));
51 pinfo.expect (pexpect.EOF); 51 pinfo.expect (pexpect.EOF);
52 52
53 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -n') 53 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -n')
54 pinfo.expect (re.compile ("Peer `.*\' with trust *0\r")); 54 pinfo.expect (re.compile ("Peer `.*\'\r"));
55 pinfo.expect (re.compile (" *127..*:24357\r")); 55 pinfo.expect (re.compile (" *127..*:24357\r"));
56 pinfo.expect (pexpect.EOF); 56 pinfo.expect (pexpect.EOF);
57 57
@@ -59,14 +59,6 @@ try:
59 pid = pinfo.read (-1) 59 pid = pinfo.read (-1)
60 pid = pid.strip () 60 pid = pid.strip ()
61 61
62 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf 4 ' + pid)
63 pinfo.expect (re.compile ("Peer `" + pid + "\' with trust *4\r"));
64 pinfo.expect (pexpect.EOF);
65
66 pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -- -4 ' + pid)
67 pinfo.expect (re.compile ("Peer `" + pid + "\' with trust *0\r"));
68 pinfo.expect (pexpect.EOF);
69
70finally: 62finally:
71 os.system ('gnunet-arm -c test_gnunet_peerinfo_data.conf -eq') 63 os.system ('gnunet-arm -c test_gnunet_peerinfo_data.conf -eq')
72 os.system ('rm -rf /tmp/gnunet-test-peerinfo/') 64 os.system ('rm -rf /tmp/gnunet-test-peerinfo/')