aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-10-19 22:00:37 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-10-19 22:00:37 +0900
commitcfdf9ea8c1246979f48174628872e79cfb1657a2 (patch)
treecfa4175161b687f5fe74bed37d0df0f3568cb717 /src/namestore
parent89fed7a08bc0dc499ecbdd90f519fc4de94c06e3 (diff)
downloadgnunet-cfdf9ea8c1246979f48174628872e79cfb1657a2.tar.gz
gnunet-cfdf9ea8c1246979f48174628872e79cfb1657a2.zip
-comments; gitignore
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/.gitignore1
-rw-r--r--src/namestore/gnunet-namestore-zonefile.c41
2 files changed, 40 insertions, 2 deletions
diff --git a/src/namestore/.gitignore b/src/namestore/.gitignore
index b26f32d1d..a1104c30b 100644
--- a/src/namestore/.gitignore
+++ b/src/namestore/.gitignore
@@ -1,6 +1,7 @@
1gnunet-service-namestore 1gnunet-service-namestore
2gnunet-namestore 2gnunet-namestore
3gnunet-namestore-dbtool 3gnunet-namestore-dbtool
4gnunet-namestore-zonefile
4gnunet-namestore-fcfsd 5gnunet-namestore-fcfsd
5test_namestore_api_lookup_nick.nc 6test_namestore_api_lookup_nick.nc
6test_namestore_api_lookup_private.nc 7test_namestore_api_lookup_private.nc
diff --git a/src/namestore/gnunet-namestore-zonefile.c b/src/namestore/gnunet-namestore-zonefile.c
index 645498257..a55e3a0aa 100644
--- a/src/namestore/gnunet-namestore-zonefile.c
+++ b/src/namestore/gnunet-namestore-zonefile.c
@@ -42,9 +42,22 @@ do_shutdown (void *cls)
42{ 42{
43 (void) cls; 43 (void) cls;
44} 44}
45
45/** 46/**
46 * Main function that will be run. 47 * Main function that will be run.
47 * 48 *
49 * TODO:
50 * - We need to actually create and store the records with in begin/commit
51 * - We need to get as argument for what zone to import
52 * - We must assume that names are not repeated later in the zonefile because
53 * our _store APIs are replacing. No sure if that is common in zonefiles.
54 * - We must only actually store a record set when the name to store changes or
55 * the end of the file is reached.
56 * that way we can group them and add (see above).
57 * - We currently do not allow multiline payloads which seem to be common
58 * - We currently do not sanitize payloads (e.g. `()')
59 * - We need to hope our string formats are compatible, but seems ok.
60 *
48 * @param cls closure 61 * @param cls closure
49 * @param args remaining command-line arguments 62 * @param args remaining command-line arguments
50 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 63 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
@@ -61,18 +74,23 @@ run (void *cls,
61 char *token; 74 char *token;
62 char origin[255]; 75 char origin[255];
63 char lastname[255]; 76 char lastname[255];
77 struct GNUNET_TIME_Relative ttl;
64 int origin_line = 0; 78 int origin_line = 0;
79 int ttl_line = 0;
80 uint32_t ttl_tmp;
65 81
66 /* use filename provided as 1st argument (stdin by default) */ 82 /* use filename provided as 1st argument (stdin by default) */
67 int i = 0; 83 int i = 0;
68 while (fgets (buf, 5000, stdin)) /* read each line of input */ 84 while (fgets (buf, 5000, stdin)) /* read each line of input */
69 { 85 {
86 i++;
70 origin_line = 0; 87 origin_line = 0;
88 ttl_line = 0;
71 /* Find space */ 89 /* Find space */
72 next = strchr (buf, ' '); 90 next = strchr (buf, ' ');
73 if (NULL == next) 91 if (NULL == next)
74 { 92 {
75 fprintf (stderr, "End?\n"); 93 fprintf (stderr, "Error at line %u: %s\n", i, buf);
76 break; 94 break;
77 } 95 }
78 next[0] = '\0'; 96 next[0] = '\0';
@@ -80,7 +98,9 @@ run (void *cls,
80 if (0 == (strcmp (buf, "$ORIGIN"))) 98 if (0 == (strcmp (buf, "$ORIGIN")))
81 origin_line = 1; 99 origin_line = 1;
82 else if (0 == (strcmp (buf, "$TTL"))) 100 else if (0 == (strcmp (buf, "$TTL")))
83 continue; // FIXME 101 {
102 ttl_line = 1;
103 }
84 else 104 else
85 { 105 {
86 if (0 == strlen (buf)) // Inherit name from before 106 if (0 == strlen (buf)) // Inherit name from before
@@ -118,6 +138,23 @@ run (void *cls,
118 next++; 138 next++;
119 token = next; 139 token = next;
120 140
141 if (ttl_line)
142 {
143 next = strchr (token, ';');
144 if (NULL != next)
145 next[0] = '\0';
146 next = strchr (token, ' ');
147 if (NULL != next)
148 next[0] = '\0';
149 if (1 != sscanf (token, "%u", &ttl_tmp))
150 {
151 fprintf (stderr, "Unable to parse TTL `%s'\n", token);
152 break;
153 }
154 printf ("TTL is: %u\n", ttl_tmp);
155 ttl.rel_value_us = ttl_tmp * 1000 * 1000;
156 continue;
157 }
121 if (origin_line) 158 if (origin_line)
122 { 159 {
123 next = strchr (token, ';'); 160 next = strchr (token, ';');