aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-rps.c')
-rw-r--r--src/rps/gnunet-rps.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index d82528182..f6bc94eca 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -41,9 +41,9 @@ static struct GNUNET_RPS_Handle *rps_handle;
41static struct GNUNET_RPS_Request_Handle *req_handle; 41static struct GNUNET_RPS_Request_Handle *req_handle;
42 42
43/** 43/**
44 * PeerID in string representation (Option --seed) 44 * PeerID (Option --seed)
45 */ 45 */
46static char *peer_id_str; 46static struct GNUNET_PeerIdentity peer_id;
47 47
48 48
49/** 49/**
@@ -103,11 +103,13 @@ run (void *cls,
103 const struct GNUNET_CONFIGURATION_Handle *cfg) 103 const struct GNUNET_CONFIGURATION_Handle *cfg)
104{ 104{
105 static uint64_t num_peers; 105 static uint64_t num_peers;
106 struct GNUNET_PeerIdentity peer_id; 106 struct GNUNET_PeerIdentity zero_pid;
107 107
108 rps_handle = GNUNET_RPS_connect (cfg); 108 rps_handle = GNUNET_RPS_connect (cfg);
109 109
110 if (NULL == peer_id_str) 110 if (0 == memcmp (&zero_pid,
111 &peer_id,
112 sizeof (peer_id)))
111 { /* Request n PeerIDs */ 113 { /* Request n PeerIDs */
112 /* If number was specified use it, else request single peer. */ 114 /* If number was specified use it, else request single peer. */
113 num_peers = (NULL == args[0]) ? 1 : atoi (args[0]); 115 num_peers = (NULL == args[0]) ? 1 : atoi (args[0]);
@@ -118,16 +120,6 @@ run (void *cls,
118 } 120 }
119 else 121 else
120 { /* Seed PeerID */ 122 { /* Seed PeerID */
121 if (GNUNET_OK !=
122 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id_str,
123 strlen (peer_id_str),
124 &peer_id.public_key))
125 {
126 FPRINTF (stderr,
127 _("Failed to parse peer identity `%s'\n"),
128 peer_id_str);
129 return;
130 }
131 GNUNET_RPS_seed_ids (rps_handle, 1, &peer_id); 123 GNUNET_RPS_seed_ids (rps_handle, 1, &peer_id);
132 FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (&peer_id)); 124 FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (&peer_id));
133 ret = 0; 125 ret = 0;
@@ -148,11 +140,11 @@ main (int argc, char *const *argv)
148 const char helpstr[] = 140 const char helpstr[] =
149 "Get random GNUnet peers. If none is specified a single is requested."; 141 "Get random GNUnet peers. If none is specified a single is requested.";
150 struct GNUNET_GETOPT_CommandLineOption options[] = { 142 struct GNUNET_GETOPT_CommandLineOption options[] = {
151 GNUNET_GETOPT_OPTION_STRING ('s', 143 GNUNET_GETOPT_OPTION_SET_BASE32_AUTO ('s',
152 "seed", 144 "seed",
153 "PEER_ID", 145 "PEER_ID",
154 gettext_noop ("Seed a PeerID"), 146 gettext_noop ("Seed a PeerID"),
155 &peer_id_str), 147 &peer_id),
156 GNUNET_GETOPT_OPTION_END 148 GNUNET_GETOPT_OPTION_END
157 }; 149 };
158 return (GNUNET_OK == 150 return (GNUNET_OK ==