diff options
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index ee59e7432..207394dd9 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1371,12 +1371,12 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1371 | struct GNUNET_GNSRECORD_Data *rd; | 1371 | struct GNUNET_GNSRECORD_Data *rd; |
1372 | 1372 | ||
1373 | /* FIXME: We could easily support append and delete with this as well */ | 1373 | /* FIXME: We could easily support append and delete with this as well */ |
1374 | if (!add) | 1374 | if (! add) |
1375 | { | 1375 | { |
1376 | fprintf (stderr, _("Recordlines only work with option `%s'\n"), | 1376 | fprintf (stderr, _ ("Recordlines only work with option `%s'\n"), |
1377 | "-a"); | 1377 | "-a"); |
1378 | ret = 1; | 1378 | ret = 1; |
1379 | finish_command(); | 1379 | finish_command (); |
1380 | return; | 1380 | return; |
1381 | } | 1381 | } |
1382 | if (NULL == name) | 1382 | if (NULL == name) |
@@ -1741,10 +1741,47 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1741 | 1741 | ||
1742 | #define MAX_ARGS 20 | 1742 | #define MAX_ARGS 20 |
1743 | 1743 | ||
1744 | static int | ||
1745 | get_identity_for_string (const char *str, | ||
1746 | struct GNUNET_IDENTITY_PrivateKey *zk) | ||
1747 | { | ||
1748 | const struct GNUNET_IDENTITY_PrivateKey *privkey; | ||
1749 | struct GNUNET_IDENTITY_PublicKey pubkey; | ||
1750 | struct GNUNET_IDENTITY_PublicKey ego_pubkey; | ||
1751 | struct EgoEntry *ego_entry; | ||
1752 | |||
1753 | if (GNUNET_OK == GNUNET_IDENTITY_public_key_from_string (str, | ||
1754 | &pubkey)) | ||
1755 | { | ||
1756 | for (ego_entry = ego_head; | ||
1757 | NULL != ego_entry; ego_entry = ego_entry->next) | ||
1758 | { | ||
1759 | privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
1760 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey); | ||
1761 | if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey))) | ||
1762 | { | ||
1763 | *zk = *privkey; | ||
1764 | return GNUNET_OK; | ||
1765 | } | ||
1766 | } | ||
1767 | } | ||
1768 | else | ||
1769 | { | ||
1770 | for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
1771 | { | ||
1772 | /** FIXME: Check for zTLD? **/ | ||
1773 | if (0 != strcmp (str, ego_entry->identifier)) | ||
1774 | continue; | ||
1775 | *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
1776 | return GNUNET_OK; | ||
1777 | } | ||
1778 | } | ||
1779 | return GNUNET_NO; | ||
1780 | } | ||
1781 | |||
1744 | static void | 1782 | static void |
1745 | process_command_stdin () | 1783 | process_command_stdin () |
1746 | { | 1784 | { |
1747 | struct EgoEntry *ego_entry; | ||
1748 | char buf[MAX_LINE_LEN]; | 1785 | char buf[MAX_LINE_LEN]; |
1749 | static struct GNUNET_IDENTITY_PrivateKey next_zone_key; | 1786 | static struct GNUNET_IDENTITY_PrivateKey next_zone_key; |
1750 | static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; | 1787 | static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; |
@@ -1783,13 +1820,12 @@ process_command_stdin () | |||
1783 | ret = 1; | 1820 | ret = 1; |
1784 | return; | 1821 | return; |
1785 | } | 1822 | } |
1786 | for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | 1823 | if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key)) |
1787 | { | 1824 | { |
1788 | /** FIXME: Check for zTLD? **/ | 1825 | fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1); |
1789 | if (0 != strcmp (tmp + 1, ego_entry->identifier)) | 1826 | ret = 1; |
1790 | continue; | 1827 | GNUNET_SCHEDULER_shutdown (); |
1791 | next_zone_key = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 1828 | return; |
1792 | break; | ||
1793 | } | 1829 | } |
1794 | *tmp = '\0'; | 1830 | *tmp = '\0'; |
1795 | printf ("Switching to new name `%s' in zone `%s'\n", next_name, tmp + 1); | 1831 | printf ("Switching to new name `%s' in zone `%s'\n", next_name, tmp + 1); |