summaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-05-09 11:07:47 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-05-09 11:07:47 +0000
commit6143cf95a47f8ec7de7898a416557f5034c36b27 (patch)
tree1f2ff800e197a13b59c17037173241e3e641411b /src/gns/gnunet-gns.c
parent695901a05a1ffc75be39e367fafa66fb7be1c7a3 (diff)
downloadgnunet-6143cf95a47f8ec7de7898a416557f5034c36b27.tar.gz
gnunet-6143cf95a47f8ec7de7898a416557f5034c36b27.zip
-per user lookups done
Diffstat (limited to 'src/gns/gnunet-gns.c')
-rw-r--r--src/gns/gnunet-gns.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index c17f15be3..7695f4213 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -60,7 +60,7 @@ static char *auth_name;
60/** 60/**
61 * raw output 61 * raw output
62 */ 62 */
63static int raw; 63static int raw = 0;
64 64
65static enum GNUNET_GNS_RecordType rtype; 65static enum GNUNET_GNS_RecordType rtype;
66 66
@@ -142,6 +142,41 @@ static void
142run (void *cls, char *const *args, const char *cfgfile, 142run (void *cls, char *const *args, const char *cfgfile,
143 const struct GNUNET_CONFIGURATION_Handle *cfg) 143 const struct GNUNET_CONFIGURATION_Handle *cfg)
144{ 144{
145 char* keyfile;
146 struct GNUNET_CRYPTO_RsaPrivateKey *key = NULL;
147 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
148 struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
149 struct GNUNET_CRYPTO_ShortHashCode user_zone;
150 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
151
152 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
153 "ZONEKEY", &keyfile))
154 {
155 if (!raw)
156 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
157 "No private key for root zone found, using default!\n");
158 zone = NULL;
159 }
160 else
161 {
162 if (GNUNET_YES == GNUNET_DISK_file_test (keyfile))
163 {
164 key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
165 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
166 GNUNET_CRYPTO_short_hash(&pkey,
167 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
168 &user_zone);
169 GNUNET_free(keyfile);
170 zone = &user_zone;
171 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
172 printf("asdsad\n");
173 if (!raw)
174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
175 "Using zone: %s!\n", &zonename);
176 GNUNET_CRYPTO_rsa_key_free(key);
177 }
178 }
179
145 gns = GNUNET_GNS_connect (cfg); 180 gns = GNUNET_GNS_connect (cfg);
146 if (lookup_type != NULL) 181 if (lookup_type != NULL)
147 rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type); 182 rtype = GNUNET_NAMESTORE_typename_to_number(lookup_type);
@@ -158,7 +193,7 @@ run (void *cls, char *const *args, const char *cfgfile,
158 if (shorten_name != NULL) 193 if (shorten_name != NULL)
159 { 194 {
160 /** shorten name */ 195 /** shorten name */
161 GNUNET_GNS_shorten(gns, shorten_name, &process_shorten_result, 196 GNUNET_GNS_shorten_zone (gns, shorten_name, zone, &process_shorten_result,
162 shorten_name); 197 shorten_name);
163 } 198 }
164 199
@@ -166,7 +201,7 @@ run (void *cls, char *const *args, const char *cfgfile,
166 { 201 {
167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
168 "Lookup\n"); 203 "Lookup\n");
169 GNUNET_GNS_lookup(gns, lookup_name, rtype, 204 GNUNET_GNS_lookup_zone (gns, lookup_name, zone, rtype,
170 &process_lookup_result, lookup_name); 205 &process_lookup_result, lookup_name);
171 } 206 }
172 207