diff options
Diffstat (limited to 'src/cli/gns')
42 files changed, 3529 insertions, 0 deletions
diff --git a/src/cli/gns/.gitignore b/src/cli/gns/.gitignore new file mode 100644 index 000000000..23bd1d13b --- /dev/null +++ b/src/cli/gns/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | gnunet-gns | ||
2 | gnunet-gns-proxy-setup-ca | ||
diff --git a/src/cli/gns/Makefile.am b/src/cli/gns/Makefile.am new file mode 100644 index 000000000..ae167bca5 --- /dev/null +++ b/src/cli/gns/Makefile.am | |||
@@ -0,0 +1,108 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | pkgdata_DATA = \ | ||
5 | gnunet-gns-proxy-ca.template | ||
6 | |||
7 | if USE_COVERAGE | ||
8 | AM_CFLAGS = --coverage -O0 | ||
9 | endif | ||
10 | |||
11 | if HAVE_LIBIDN | ||
12 | LIBIDN= -lidn | ||
13 | else | ||
14 | LIBIDN= | ||
15 | endif | ||
16 | |||
17 | if HAVE_LIBIDN2 | ||
18 | LIBIDN2= -lidn2 | ||
19 | else | ||
20 | LIBIDN2= | ||
21 | endif | ||
22 | |||
23 | pkgcfgdir = $(pkgdatadir)/config.d/ | ||
24 | |||
25 | libexecdir= $(pkglibdir)/libexec/ | ||
26 | |||
27 | plugindir = $(libdir)/gnunet | ||
28 | |||
29 | bin_PROGRAMS = \ | ||
30 | gnunet-gns | ||
31 | |||
32 | bin_SCRIPTS = \ | ||
33 | gnunet-gns-proxy-setup-ca | ||
34 | |||
35 | gnunet-gns-proxy-setup-ca: gnunet-gns-proxy-setup-ca.in Makefile | ||
36 | $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/scripts/dosubst.awk < $(srcdir)/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca | ||
37 | @chmod +x gnunet-gns-proxy-setup-ca | ||
38 | |||
39 | test_gnunet_gns.sh: test_gnunet_gns.sh.in Makefile | ||
40 | $(AWK) -v bdir="$(bindir)" -v py="$(PYTHON)" -v awkay="$(AWK_BINARY)" -v pfx="$(prefix)" -v prl="$(PERL)" -v sysconfdirectory="$(sysconfdir)" -v pkgdatadirectory="$(pkgdatadir)" -f $(top_srcdir)/scripts/dosubst.awk < $(srcdir)/test_gnunet_gns.sh.in > test_gnunet_gns.sh | ||
41 | @chmod +x test_gnunet_gns.sh | ||
42 | |||
43 | CLEANFILES = test_gnunet_gns.sh | ||
44 | |||
45 | gnunet_gns_SOURCES = \ | ||
46 | gnunet-gns.c | ||
47 | gnunet_gns_LDADD = \ | ||
48 | $(top_builddir)/src/service/gns/libgnunetgns.la \ | ||
49 | $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \ | ||
50 | $(top_builddir)/src/service/identity/libgnunetidentity.la \ | ||
51 | $(top_builddir)/src/lib/util/libgnunetutil.la \ | ||
52 | $(LIBIDN) $(LIBIDN2) \ | ||
53 | $(GN_LIBINTL) | ||
54 | |||
55 | check_SCRIPTS = \ | ||
56 | test_gns_lookup.sh \ | ||
57 | test_gns_config_lookup.sh \ | ||
58 | test_gns_ipv6_lookup.sh\ | ||
59 | test_gns_txt_lookup.sh\ | ||
60 | test_gns_caa_lookup.sh\ | ||
61 | test_gns_mx_lookup.sh \ | ||
62 | test_gns_gns2dns_lookup.sh \ | ||
63 | test_gns_gns2dns_zkey_lookup.sh \ | ||
64 | test_gns_gns2dns_cname_lookup.sh \ | ||
65 | test_gns_dht_lookup.sh\ | ||
66 | test_gns_delegated_lookup.sh \ | ||
67 | test_gns_at_lookup.sh\ | ||
68 | test_gns_zkey_lookup.sh\ | ||
69 | test_gns_rel_expiration.sh\ | ||
70 | test_gns_soa_lookup.sh\ | ||
71 | test_gns_revocation.sh\ | ||
72 | test_gns_redirect_lookup.sh | ||
73 | |||
74 | EXTRA_DIST = \ | ||
75 | test_gns_defaults.conf \ | ||
76 | test_gns_lookup.conf \ | ||
77 | test_gns_simple_lookup.conf \ | ||
78 | openssl.cnf \ | ||
79 | gnunet-gns-proxy-setup-ca.in \ | ||
80 | zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey \ | ||
81 | zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \ | ||
82 | zonefiles/test_zonekey \ | ||
83 | test_gns_lookup.sh \ | ||
84 | test_gns_config_lookup.sh \ | ||
85 | test_gns_ipv6_lookup.sh\ | ||
86 | test_gns_txt_lookup.sh\ | ||
87 | test_gns_caa_lookup.sh\ | ||
88 | test_gns_mx_lookup.sh \ | ||
89 | test_gns_gns2dns_lookup.sh \ | ||
90 | test_gns_gns2dns_zkey_lookup.sh \ | ||
91 | test_gns_gns2dns_cname_lookup.sh \ | ||
92 | test_gns_dht_lookup.sh\ | ||
93 | test_gns_delegated_lookup.sh \ | ||
94 | test_gns_at_lookup.sh\ | ||
95 | test_gns_zkey_lookup.sh\ | ||
96 | test_gns_rel_expiration.sh\ | ||
97 | test_gns_soa_lookup.sh\ | ||
98 | test_gns_revocation.sh\ | ||
99 | test_gns_redirect_lookup.sh\ | ||
100 | $(pkgdata_DATA) \ | ||
101 | test_gnunet_gns.sh.in | ||
102 | |||
103 | if ENABLE_TEST_RUN | ||
104 | if HAVE_SQLITE | ||
105 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | ||
106 | TESTS = $(check_SCRIPTS) | ||
107 | endif | ||
108 | endif | ||
diff --git a/src/cli/gns/gnunet-gns-proxy-ca.template b/src/cli/gns/gnunet-gns-proxy-ca.template new file mode 100644 index 000000000..b1a0d16fd --- /dev/null +++ b/src/cli/gns/gnunet-gns-proxy-ca.template | |||
@@ -0,0 +1,303 @@ | |||
1 | # X.509 Certificate options | ||
2 | # | ||
3 | # DN options | ||
4 | |||
5 | # The organization of the subject. | ||
6 | organization = "GNU" | ||
7 | |||
8 | # The organizational unit of the subject. | ||
9 | unit = "GNUnet" | ||
10 | |||
11 | # The locality of the subject. | ||
12 | locality = World | ||
13 | |||
14 | # The state of the certificate owner. | ||
15 | # state = "Attiki" | ||
16 | |||
17 | # The country of the subject. Two letter code. | ||
18 | country = ZZ | ||
19 | |||
20 | # The common name of the certificate owner. | ||
21 | cn = "GNS Proxy CA" | ||
22 | |||
23 | # A user id of the certificate owner. | ||
24 | #uid = "clauper" | ||
25 | |||
26 | # Set domain components | ||
27 | #dc = "name" | ||
28 | #dc = "domain" | ||
29 | |||
30 | # If the supported DN OIDs are not adequate you can set | ||
31 | # any OID here. | ||
32 | # For example set the X.520 Title and the X.520 Pseudonym | ||
33 | # by using OID and string pairs. | ||
34 | #dn_oid = "2.5.4.12 Dr." | ||
35 | #dn_oid = "2.5.4.65 jackal" | ||
36 | |||
37 | # This is deprecated and should not be used in new | ||
38 | # certificates. | ||
39 | # pkcs9_email = "none@none.org" | ||
40 | |||
41 | # An alternative way to set the certificate's distinguished name directly | ||
42 | # is with the "dn" option. The attribute names allowed are: | ||
43 | # C (country), street, O (organization), OU (unit), title, CN (common name), | ||
44 | # L (locality), ST (state), placeOfBirth, gender, countryOfCitizenship, | ||
45 | # countryOfResidence, serialNumber, telephoneNumber, surName, initials, | ||
46 | # generationQualifier, givenName, pseudonym, dnQualifier, postalCode, name, | ||
47 | # businessCategory, DC, UID, jurisdictionOfIncorporationLocalityName, | ||
48 | # jurisdictionOfIncorporationStateOrProvinceName, | ||
49 | # jurisdictionOfIncorporationCountryName, XmppAddr, and numeric OIDs. | ||
50 | |||
51 | #dn = "cn = Nikos,st = New\, Something,C=GR,surName=Mavrogiannopoulos,2.5.4.9=Arkadias" | ||
52 | |||
53 | # The serial number of the certificate | ||
54 | # The value is in decimal (e.g. 1963) or hex (e.g. 0x07ab). | ||
55 | # Comment the field for a random serial number. | ||
56 | #serial = 007 | ||
57 | |||
58 | # In how many days, counting from today, this certificate will expire. | ||
59 | # Use -1 if there is no expiration date. | ||
60 | expiration_days = 3650 | ||
61 | |||
62 | # Alternatively you may set concrete dates and time. The GNU date string | ||
63 | # formats are accepted. See: | ||
64 | # https://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html | ||
65 | |||
66 | #activation_date = "2004-02-29 16:21:42" | ||
67 | #expiration_date = "2025-02-29 16:24:41" | ||
68 | |||
69 | # X.509 v3 extensions | ||
70 | |||
71 | # A dnsname in case of a WWW server. | ||
72 | #dns_name = "www.none.org" | ||
73 | #dns_name = "www.morethanone.org" | ||
74 | |||
75 | # An othername defined by an OID and a hex encoded string | ||
76 | #other_name = "1.3.6.1.5.2.2 302ca00d1b0b56414e5245494e2e4f5247a11b3019a006020400000002a10f300d1b047269636b1b0561646d696e" | ||
77 | #other_name_utf8 = "1.2.4.5.6 A UTF8 string" | ||
78 | #other_name_octet = "1.2.4.5.6 A string that will be encoded as ASN.1 octet string" | ||
79 | |||
80 | # Allows writing an XmppAddr Identifier | ||
81 | #xmpp_name = juliet@im.example.com | ||
82 | |||
83 | # Names used in PKINIT | ||
84 | #krb5_principal = user@REALM.COM | ||
85 | #krb5_principal = HTTP/user@REALM.COM | ||
86 | |||
87 | # A subject alternative name URI | ||
88 | #uri = "https://www.example.com" | ||
89 | |||
90 | # An IP address in case of a server. | ||
91 | #ip_address = "192.168.1.1" | ||
92 | |||
93 | # An email in case of a person | ||
94 | email = "bounce@gnunet.org" | ||
95 | |||
96 | # TLS feature (rfc7633) extension. That can is used to indicate mandatory TLS | ||
97 | # extension features to be provided by the server. In practice this is used | ||
98 | # to require the Status Request (extid: 5) extension from the server. That is, | ||
99 | # to require the server holding this certificate to provide a stapled OCSP response. | ||
100 | # You can have multiple lines for multiple TLS features. | ||
101 | |||
102 | # To ask for OCSP status request use: | ||
103 | #tls_feature = 5 | ||
104 | |||
105 | # Challenge password used in certificate requests | ||
106 | challenge_password = 123456 | ||
107 | |||
108 | # Password when encrypting a private key | ||
109 | #password = secret | ||
110 | |||
111 | # An URL that has CRLs (certificate revocation lists) | ||
112 | # available. Needed in CA certificates. | ||
113 | #crl_dist_points = "https://www.getcrl.crl/getcrl/" | ||
114 | |||
115 | # Whether this is a CA certificate or not | ||
116 | ca | ||
117 | |||
118 | # Subject Unique ID (in hex) | ||
119 | #subject_unique_id = 00153224 | ||
120 | |||
121 | # Issuer Unique ID (in hex) | ||
122 | #issuer_unique_id = 00153225 | ||
123 | |||
124 | #### Key usage | ||
125 | |||
126 | # The following key usage flags are used by CAs and end certificates | ||
127 | |||
128 | # Whether this certificate will be used to sign data (needed | ||
129 | # in TLS DHE ciphersuites). This is the digitalSignature flag | ||
130 | # in RFC5280 terminology. | ||
131 | signing_key | ||
132 | |||
133 | # Whether this certificate will be used to encrypt data (needed | ||
134 | # in TLS RSA ciphersuites). Note that it is preferred to use different | ||
135 | # keys for encryption and signing. This is the keyEncipherment flag | ||
136 | # in RFC5280 terminology. | ||
137 | encryption_key | ||
138 | |||
139 | # Whether this key will be used to sign other certificates. The | ||
140 | # keyCertSign flag in RFC5280 terminology. | ||
141 | cert_signing_key | ||
142 | |||
143 | # Whether this key will be used to sign CRLs. The | ||
144 | # cRLSign flag in RFC5280 terminology. | ||
145 | #crl_signing_key | ||
146 | |||
147 | # The keyAgreement flag of RFC5280. It's purpose is loosely | ||
148 | # defined. Not use it unless required by a protocol. | ||
149 | #key_agreement | ||
150 | |||
151 | # The dataEncipherment flag of RFC5280. It's purpose is loosely | ||
152 | # defined. Not use it unless required by a protocol. | ||
153 | #data_encipherment | ||
154 | |||
155 | # The nonRepudiation flag of RFC5280. It's purpose is loosely | ||
156 | # defined. Not use it unless required by a protocol. | ||
157 | #non_repudiation | ||
158 | |||
159 | #### Extended key usage (key purposes) | ||
160 | |||
161 | # The following extensions are used in an end certificate | ||
162 | # to clarify its purpose. Some CAs also use it to indicate | ||
163 | # the types of certificates they are purposed to sign. | ||
164 | |||
165 | |||
166 | # Whether this certificate will be used for a TLS client; | ||
167 | # this sets the id-kp-clientAuth (1.3.6.1.5.5.7.3.2) of | ||
168 | # extended key usage. | ||
169 | #tls_www_client | ||
170 | |||
171 | # Whether this certificate will be used for a TLS server; | ||
172 | # this sets the id-kp-serverAuth (1.3.6.1.5.5.7.3.1) of | ||
173 | # extended key usage. | ||
174 | tls_www_server | ||
175 | |||
176 | # Whether this key will be used to sign code. This sets the | ||
177 | # id-kp-codeSigning (1.3.6.1.5.5.7.3.3) of extended key usage | ||
178 | # extension. | ||
179 | #code_signing_key | ||
180 | |||
181 | # Whether this key will be used to sign OCSP data. This sets the | ||
182 | # id-kp-OCSPSigning (1.3.6.1.5.5.7.3.9) of extended key usage extension. | ||
183 | #ocsp_signing_key | ||
184 | |||
185 | # Whether this key will be used for time stamping. This sets the | ||
186 | # id-kp-timeStamping (1.3.6.1.5.5.7.3.8) of extended key usage extension. | ||
187 | #time_stamping_key | ||
188 | |||
189 | # Whether this key will be used for email protection. This sets the | ||
190 | # id-kp-emailProtection (1.3.6.1.5.5.7.3.4) of extended key usage extension. | ||
191 | #email_protection_key | ||
192 | |||
193 | # Whether this key will be used for IPsec IKE operations (1.3.6.1.5.5.7.3.17). | ||
194 | #ipsec_ike_key | ||
195 | |||
196 | ## adding custom key purpose OIDs | ||
197 | |||
198 | # for microsoft smart card logon | ||
199 | # key_purpose_oid = 1.3.6.1.4.1.311.20.2.2 | ||
200 | |||
201 | # for email protection | ||
202 | # key_purpose_oid = 1.3.6.1.5.5.7.3.4 | ||
203 | |||
204 | # for any purpose (must not be used in intermediate CA certificates) | ||
205 | # key_purpose_oid = 2.5.29.37.0 | ||
206 | |||
207 | ### end of key purpose OIDs | ||
208 | |||
209 | ### Adding arbitrary extensions | ||
210 | # This requires to provide the extension OIDs, as well as the extension data in | ||
211 | # hex format. The following two options are available since GnuTLS 3.5.3. | ||
212 | #add_extension = "1.2.3.4 0x0AAB01ACFE" | ||
213 | |||
214 | # As above but encode the data as an octet string | ||
215 | #add_extension = "1.2.3.4 octet_string(0x0AAB01ACFE)" | ||
216 | |||
217 | # For portability critical extensions shouldn't be set to certificates. | ||
218 | #add_critical_extension = "5.6.7.8 0x1AAB01ACFE" | ||
219 | |||
220 | # When generating a certificate from a certificate | ||
221 | # request, then honor the extensions stored in the request | ||
222 | # and store them in the real certificate. | ||
223 | #honor_crq_extensions | ||
224 | |||
225 | # Alternatively only specific extensions can be copied. | ||
226 | #honor_crq_ext = 2.5.29.17 | ||
227 | #honor_crq_ext = 2.5.29.15 | ||
228 | |||
229 | # Path length constraint. Sets the maximum number of | ||
230 | # certificates that can be used to certify this certificate. | ||
231 | # (i.e. the certificate chain length) | ||
232 | #path_len = -1 | ||
233 | #path_len = 2 | ||
234 | |||
235 | # OCSP URI | ||
236 | # ocsp_uri = https://my.ocsp.server/ocsp | ||
237 | |||
238 | # CA issuers URI | ||
239 | # ca_issuers_uri = https://my.ca.issuer | ||
240 | |||
241 | # Certificate policies | ||
242 | #policy1 = 1.3.6.1.4.1.5484.1.10.99.1.0 | ||
243 | #policy1_txt = "This is a long policy to summarize" | ||
244 | #policy1_url = https://www.example.com/a-policy-to-read | ||
245 | |||
246 | #policy2 = 1.3.6.1.4.1.5484.1.10.99.1.1 | ||
247 | #policy2_txt = "This is a short policy" | ||
248 | #policy2_url = https://www.example.com/another-policy-to-read | ||
249 | |||
250 | # The number of additional certificates that may appear in a | ||
251 | # path before the anyPolicy is no longer acceptable. | ||
252 | #inhibit_anypolicy_skip_certs 1 | ||
253 | |||
254 | # Name constraints | ||
255 | |||
256 | # DNS | ||
257 | #nc_permit_dns = example.com | ||
258 | #nc_exclude_dns = test.example.com | ||
259 | |||
260 | |||
261 | #nc_permit_email = "nmav@ex.net" | ||
262 | |||
263 | # Exclude subdomains of example.com | ||
264 | #nc_exclude_email = .example.com | ||
265 | |||
266 | # Exclude all e-mail addresses of example.com | ||
267 | #nc_exclude_email = example.com | ||
268 | |||
269 | # IP | ||
270 | #nc_permit_ip = 192.168.0.0/16 | ||
271 | #nc_exclude_ip = 192.168.5.0/24 | ||
272 | #nc_permit_ip = fc0a:eef2:e7e7:a56e::/64 | ||
273 | |||
274 | |||
275 | # Options for proxy certificates | ||
276 | #proxy_policy_language = 1.3.6.1.5.5.7.21.1 | ||
277 | |||
278 | |||
279 | # Options for generating a CRL | ||
280 | |||
281 | # The number of days the next CRL update will be due. | ||
282 | # next CRL update will be in 43 days | ||
283 | #crl_next_update = 43 | ||
284 | |||
285 | # this is the 5th CRL by this CA | ||
286 | # The value is in decimal (e.g. 1963) or hex (e.g. 0x07ab). | ||
287 | # Comment the field for a time-based number. | ||
288 | # Time-based CRL numbers generated in GnuTLS 3.6.3 and later | ||
289 | # are significantly larger than those generated in previous | ||
290 | # versions. Since CRL numbers need to be monotonic, you need | ||
291 | # to specify the CRL number here manually if you intend to | ||
292 | # downgrade to an earlier version than 3.6.3 after publishing | ||
293 | # the CRL as it is not possible to specify CRL numbers greater | ||
294 | # than 2**63-2 using hex notation in those versions. | ||
295 | #crl_number = 5 | ||
296 | |||
297 | # Specify the update dates more precisely. | ||
298 | #crl_this_update_date = "2004-02-29 16:21:42" | ||
299 | #crl_next_update_date = "2025-02-29 16:24:41" | ||
300 | |||
301 | # The date that the certificates will be made seen as | ||
302 | # being revoked. | ||
303 | #crl_revocation_date = "2025-02-29 16:24:41" | ||
diff --git a/src/cli/gns/gnunet-gns-proxy-setup-ca.in b/src/cli/gns/gnunet-gns-proxy-setup-ca.in new file mode 100644 index 000000000..b3ebfd11d --- /dev/null +++ b/src/cli/gns/gnunet-gns-proxy-setup-ca.in | |||
@@ -0,0 +1,339 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # This shell script will generate an X509 certificate for | ||
4 | # your gnunet-gns-proxy and install it (for both GNUnet | ||
5 | # and your browser). | ||
6 | # | ||
7 | # TODO: Implement support for more browsers | ||
8 | # TODO: Debug and switch to the new version | ||
9 | # TODO - The only remaining task is fixing the getopts | ||
10 | # TODO: Error checks | ||
11 | # | ||
12 | # The current version partially reuses and recycles | ||
13 | # code from build.sh by NetBSD (although not entirely | ||
14 | # used because it needs debugging): | ||
15 | # | ||
16 | # Copyright (c) 2001-2011 The NetBSD Foundation, Inc. | ||
17 | # All rights reserved. | ||
18 | # | ||
19 | # This code is derived from software contributed to | ||
20 | # The NetBSD Foundation by Todd Vierling and Luke Mewburn. | ||
21 | # | ||
22 | # Redistribution and use in source and binary forms, with or | ||
23 | # without modification, are permitted provided that the following | ||
24 | # conditions are met: | ||
25 | # 1. Redistributions of source code must retain the above | ||
26 | # copyright notice, this list of conditions and the following | ||
27 | # disclaimer. | ||
28 | # 2. Redistributions in binary form must reproduce the above | ||
29 | # copyright notice, this list of conditions and the following | ||
30 | # disclaimer in the documentation and/or other materials | ||
31 | # provided with the distribution. | ||
32 | # | ||
33 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND | ||
34 | # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
35 | # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
36 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
37 | # DISCLAIMED. | ||
38 | # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR | ||
39 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
40 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
41 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
42 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
43 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
44 | # LIABILITY, OR TORT | ||
45 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
46 | # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
47 | # OF SUCH DAMAGE. | ||
48 | |||
49 | dir=$(dirname "$0") | ||
50 | |||
51 | progname=${0##*/} | ||
52 | |||
53 | existence() { | ||
54 | command -v "$1" >/dev/null 2>&1 | ||
55 | } | ||
56 | |||
57 | statusmsg() | ||
58 | { | ||
59 | ${runcmd} echo "${tab}$@" | tee -a "${results}" | ||
60 | } | ||
61 | |||
62 | infomsg() | ||
63 | { | ||
64 | if [ x$verbosity = x1 ]; then | ||
65 | statusmsg "INFO:${tab}$@" | ||
66 | fi | ||
67 | } | ||
68 | |||
69 | warningmsg() | ||
70 | { | ||
71 | statusmsg "WARNING:${tab}$@" | ||
72 | } | ||
73 | |||
74 | errormsg() | ||
75 | { | ||
76 | statusmsg "ERROR:${tab}$@" | ||
77 | } | ||
78 | |||
79 | linemsg() | ||
80 | { | ||
81 | statusmsg "=========================================" | ||
82 | } | ||
83 | |||
84 | |||
85 | print_version() | ||
86 | { | ||
87 | GNUNET_ARM_VERSION=`gnunet-arm -v | awk '{print $2 " " $3}'` | ||
88 | echo ${progname} $GNUNET_ARM_VERSION | ||
89 | } | ||
90 | |||
91 | # Whitespace normalization without depending on shell features: | ||
92 | tab=' ' | ||
93 | tab2=' ' | ||
94 | nl=' | ||
95 | ' | ||
96 | |||
97 | setdefaults() | ||
98 | { | ||
99 | verbosity=0 | ||
100 | resfile= | ||
101 | results=/dev/null | ||
102 | tmpdir=${TMPDIR:-/tmp} | ||
103 | runcmd= | ||
104 | } | ||
105 | |||
106 | usage() | ||
107 | { | ||
108 | if [ -n "$*" ]; then | ||
109 | echo "${nl}${progname}: $*" | ||
110 | fi | ||
111 | cat <<_usage_ | ||
112 | |||
113 | Usage: ${progname} [-hvVto] [-c FILE] | ||
114 | |||
115 | Options: | ||
116 | ${tab}-c FILE Use the configuration file FILE. | ||
117 | ${tab}-h${tab2}${tab2}Print this help message. | ||
118 | ${tab}-o${tab2}${tab2}Display summary of statusmessages | ||
119 | ${tab}-t${tab2}${tab2}Short developer test on binaries | ||
120 | ${tab}-v${tab2}${tab2}Print the version and exit. | ||
121 | ${tab}-V${tab2}${tab2}be verbose | ||
122 | |||
123 | _usage_ | ||
124 | exit 1 | ||
125 | } | ||
126 | |||
127 | |||
128 | generate_ca() | ||
129 | { | ||
130 | echo "" | ||
131 | infomsg "Generating CA" | ||
132 | TMPDIR=${TMPDIR:-/tmp} | ||
133 | if test -e "$TMPDIR"; then | ||
134 | GNSCERT=`mktemp -t cert.pem.XXXXXXXX` || exit 1 | ||
135 | GNSCAKY=`mktemp -t caky.pem.XXXXXXXX` || exit 1 | ||
136 | GNSCANO=`mktemp -t cano.pem.XXXXXXXX` || exit 1 | ||
137 | else | ||
138 | # This warning is mostly pointless. | ||
139 | warningmsg "You need to export the TMPDIR variable" | ||
140 | fi | ||
141 | |||
142 | # # ------------- gnutls | ||
143 | # | ||
144 | # if ! which certutil > /dev/null | ||
145 | # then | ||
146 | # warningmsg "The 'certutil' command was not found." | ||
147 | # warningmsg "Not importing into browsers." | ||
148 | # warningmsg "For 'certutil' install nss." | ||
149 | # else | ||
150 | # # Generate CA key | ||
151 | # # pkcs#8 password-protects key | ||
152 | # certtool --pkcs8 --generate-privkey --sec-param high --outfile ca-key.pem | ||
153 | # # self-sign the CA to create public certificate | ||
154 | # certtool --generate-self-signed --load-privkey ca-key.pem --template ca.cfg --outfile ca.pem | ||
155 | |||
156 | # ------------- openssl | ||
157 | |||
158 | GNUTLS_CA_TEMPLATE=@PKGDATADIRECTORY@/gnunet-gns-proxy-ca.template | ||
159 | OPENSSLCFG=@PKGDATADIRECTORY@/openssl.cnf | ||
160 | CERTTOOL="" | ||
161 | OPENSSL=0 | ||
162 | if test -x $(existence gnunet-certtool) | ||
163 | # if test -z "`gnutls-certtool --version`" > /dev/null | ||
164 | then | ||
165 | # We only support gnutls certtool for now. Treat the grep | ||
166 | # for "gnutls" in the output with extra care, it only matches | ||
167 | # the email address! It is probably safer to run strings(1) | ||
168 | # over certtool for a string matching "gnutls" | ||
169 | if test -z "`certtool --version | grep gnutls`" > /dev/null | ||
170 | then | ||
171 | warningmsg "'gnutls-certtool' or 'certtool' command not found. Trying openssl." | ||
172 | # if test -z "`openssl version`" > /dev/null | ||
173 | if test -x $(existence openssl) | ||
174 | then | ||
175 | OPENSSL=1 | ||
176 | else | ||
177 | warningmsg "Install either gnutls certtool or openssl for certificate generation!" | ||
178 | statusmsg "Cleaning up." | ||
179 | rm -f $GNSCAKY $GNSCERT | ||
180 | exit 1 | ||
181 | fi | ||
182 | fi | ||
183 | CERTTOOL="certtool" | ||
184 | else | ||
185 | CERTTOOL="gnutls-certtool" | ||
186 | fi | ||
187 | if test -n "${GNUNET_CONFIG_FILE}"; then | ||
188 | GNUNET_CONFIG="-c ${GNUNET_CONFIG_FILE}" | ||
189 | else | ||
190 | GNUNET_CONFIG="" | ||
191 | fi | ||
192 | GNS_CA_CERT_PEM=`gnunet-config ${GNUNET_CONFIG} -s gns-proxy -o PROXY_CACERT -f ${options}` | ||
193 | mkdir -p `dirname $GNS_CA_CERT_PEM` | ||
194 | |||
195 | if test 1 -eq $OPENSSL | ||
196 | then | ||
197 | if test 1 -eq $verbosity; then | ||
198 | openssl req -config $OPENSSLCFG -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System" | ||
199 | else | ||
200 | openssl req -config $OPENSSLCFG -new -x509 -days 3650 -extensions v3_ca -keyout $GNSCAKY -out $GNSCERT -subj "/C=ZZ/L=World/O=GNU/OU=GNUnet/CN=GNS Proxy CA/emailAddress=bounce@gnunet.org" -passout pass:"GNU Name System" >/dev/null 2>&1 | ||
201 | fi | ||
202 | infomsg "Removing passphrase from key" | ||
203 | if test 1 -eq $verbosity; then | ||
204 | openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO | ||
205 | else | ||
206 | openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO >/dev/null 2>&1 | ||
207 | fi | ||
208 | cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM | ||
209 | else | ||
210 | if test 1 -eq $verbosity; then | ||
211 | $CERTTOOL --generate-privkey --outfile $GNSCAKY | ||
212 | $CERTTOOL --template $GNUTLS_CA_TEMPLATE --generate-self-signed --load-privkey $GNSCAKY --outfile $GNSCERT | ||
213 | else | ||
214 | $CERTTOOL --generate-privkey --outfile $GNSCAKY >/dev/null 2>&1 | ||
215 | $CERTTOOL --template $GNUTLS_CA_TEMPLATE --generate-self-signed --load-privkey $GNSCAKY --outfile $GNSCERT >/dev/null 2>&1 | ||
216 | fi | ||
217 | infomsg "Making private key available to gnunet-gns-proxy" | ||
218 | cat $GNSCERT $GNSCAKY > $GNS_CA_CERT_PEM | ||
219 | fi | ||
220 | } | ||
221 | |||
222 | importbrowsers() | ||
223 | { | ||
224 | # if test -z "`command -v certutil`" > /dev/null 2>&1 | ||
225 | if test -x $(existence gnutls-certutil) || test -x $(existence certutil) | ||
226 | then | ||
227 | statusmsg "Importing CA into browsers" | ||
228 | # TODO: Error handling? | ||
229 | for f in ~/.mozilla/firefox/*.*/ | ||
230 | do | ||
231 | if [ -d $f ]; then | ||
232 | infomsg "Importing CA into Firefox at $f" | ||
233 | # delete old certificate (if any) | ||
234 | certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null | ||
235 | # add new certificate | ||
236 | certutil -A -n "GNS Proxy CA" -t CT,, -d "$f" < $GNSCERT | ||
237 | fi | ||
238 | done | ||
239 | for f in ~/.mozilla/icecat/*.*/ | ||
240 | do | ||
241 | if [ -d $f ]; then | ||
242 | infomsg "Importing CA into Icecat at $f" | ||
243 | # delete old certificate (if any) | ||
244 | certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null | ||
245 | # add new certificate | ||
246 | certutil -A -n "GNS Proxy CA" -t CT,, -d "$f" < $GNSCERT | ||
247 | fi | ||
248 | done | ||
249 | # TODO: Error handling? | ||
250 | if [ -d ~/.pki/nssdb/ ]; then | ||
251 | statusmsg "Importing CA into Chrome at ~/.pki/nssdb/" | ||
252 | # delete old certificate (if any) | ||
253 | certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null | ||
254 | # add new certificate | ||
255 | certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb/ < $GNSCERT | ||
256 | fi | ||
257 | else | ||
258 | warningmsg "The 'certutil' command was not found." | ||
259 | warningmsg "Not importing into browsers." | ||
260 | warningmsg "For 'certutil' install nss." | ||
261 | fi | ||
262 | } | ||
263 | |||
264 | clean_up() | ||
265 | { | ||
266 | infomsg "Cleaning up." | ||
267 | rm -f $GNSCAKY $GNSCANO $GNSCERT | ||
268 | if test -e $SETUP_TMPDIR | ||
269 | then | ||
270 | rm -rf $SETUP_TMPDIR | ||
271 | fi | ||
272 | |||
273 | linemsg | ||
274 | statusmsg "You can now start gnunet-gns-proxy." | ||
275 | statusmsg "Afterwards, configure your browser " | ||
276 | statusmsg "to use a SOCKS proxy on port 7777. " | ||
277 | linemsg | ||
278 | } | ||
279 | |||
280 | main() | ||
281 | { | ||
282 | setdefaults | ||
283 | while getopts "vhVtoc:" opt; do | ||
284 | case $opt in | ||
285 | v) | ||
286 | print_version | ||
287 | exit 0 | ||
288 | ;; | ||
289 | h) | ||
290 | usage | ||
291 | ;; | ||
292 | V) | ||
293 | verbosity=1 | ||
294 | ;; | ||
295 | c) | ||
296 | options="$options -c $OPTARG" | ||
297 | infomsg "Using configuration file $OPTARG" | ||
298 | GNUNET_CONFIG_FILE=${OPTARG} | ||
299 | ;; | ||
300 | t) | ||
301 | verbosity=1 | ||
302 | infomsg "Running short developer test" | ||
303 | if test -x $(existence openssl); then | ||
304 | openssl version | ||
305 | fi | ||
306 | if test -x $(existence certtool); then | ||
307 | certtool --version | ||
308 | fi | ||
309 | if test -x $(existence gnutls-certtool); then | ||
310 | gnutls-certtool --version | ||
311 | fi | ||
312 | exit 0 | ||
313 | ;; | ||
314 | o) | ||
315 | resfile=$(mktemp -t ${progname}.results) | ||
316 | results="${resfile}" | ||
317 | ;; | ||
318 | \?) | ||
319 | echo "Invalid option: -$OPTARG" >&2 | ||
320 | usage | ||
321 | ;; | ||
322 | :) | ||
323 | echo "Option -$OPTARG requires an argument." >&2 | ||
324 | usage | ||
325 | ;; | ||
326 | esac | ||
327 | done | ||
328 | generate_ca | ||
329 | importbrowsers | ||
330 | if [ -s "${results}" ]; then | ||
331 | echo "===> Summary of results:" | ||
332 | sed -e 's/^===>//;s/^/ /' "${results}" | ||
333 | echo "===> ." | ||
334 | infomsg "Please remove ${results} manually." | ||
335 | fi | ||
336 | clean_up | ||
337 | } | ||
338 | |||
339 | main "$@" | ||
diff --git a/src/cli/gns/gnunet-gns.c b/src/cli/gns/gnunet-gns.c new file mode 100644 index 000000000..724fbce24 --- /dev/null +++ b/src/cli/gns/gnunet-gns.c | |||
@@ -0,0 +1,411 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012-2013, 2017-2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file gnunet-gns.c | ||
22 | * @brief command line tool to access distributed GNS | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #if HAVE_LIBIDN2 | ||
27 | #if HAVE_IDN2_H | ||
28 | #include <idn2.h> | ||
29 | #elif HAVE_IDN2_IDN2_H | ||
30 | #include <idn2/idn2.h> | ||
31 | #endif | ||
32 | #elif HAVE_LIBIDN | ||
33 | #if HAVE_IDNA_H | ||
34 | #include <idna.h> | ||
35 | #elif HAVE_IDN_IDNA_H | ||
36 | #include <idn/idna.h> | ||
37 | #endif | ||
38 | #endif | ||
39 | #include <gnunet_util_lib.h> | ||
40 | #include <gnunet_gnsrecord_lib.h> | ||
41 | #include <gnunet_namestore_service.h> | ||
42 | #include <gnunet_gns_service.h> | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Configuration we are using. | ||
47 | */ | ||
48 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
49 | |||
50 | /** | ||
51 | * Handle to GNS service. | ||
52 | */ | ||
53 | static struct GNUNET_GNS_Handle *gns; | ||
54 | |||
55 | /** | ||
56 | * GNS name to lookup. (-u option) | ||
57 | */ | ||
58 | static char *lookup_name; | ||
59 | |||
60 | /** | ||
61 | * DNS IDNA name to lookup. (set if -d option is set) | ||
62 | */ | ||
63 | char *idna_name; | ||
64 | |||
65 | /** | ||
66 | * DNS compatibility (name is given as DNS name, possible IDNA). | ||
67 | */ | ||
68 | static int dns_compat; | ||
69 | |||
70 | /** | ||
71 | * record type to look up (-t option) | ||
72 | */ | ||
73 | static char *lookup_type; | ||
74 | |||
75 | /** | ||
76 | * raw output | ||
77 | */ | ||
78 | static int raw; | ||
79 | |||
80 | /** | ||
81 | * Desired record type. | ||
82 | */ | ||
83 | static uint32_t rtype; | ||
84 | |||
85 | /** | ||
86 | * Timeout for lookup | ||
87 | */ | ||
88 | static struct GNUNET_TIME_Relative timeout; | ||
89 | |||
90 | /** | ||
91 | * Timeout task | ||
92 | */ | ||
93 | static struct GNUNET_SCHEDULER_Task *to_task; | ||
94 | |||
95 | /** | ||
96 | * Handle to lookup request | ||
97 | */ | ||
98 | static struct GNUNET_GNS_LookupWithTldRequest *lr; | ||
99 | |||
100 | /** | ||
101 | * Global return value. | ||
102 | * 0 on success (default), | ||
103 | * 1 on internal failures | ||
104 | * 2 on launch failure, | ||
105 | * 4 if the name is not a GNS-supported TLD, | ||
106 | */ | ||
107 | static int global_ret; | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Task run on shutdown. Cleans up everything. | ||
112 | * | ||
113 | * @param cls unused | ||
114 | */ | ||
115 | static void | ||
116 | do_shutdown (void *cls) | ||
117 | { | ||
118 | (void) cls; | ||
119 | if (NULL != to_task) | ||
120 | { | ||
121 | GNUNET_SCHEDULER_cancel (to_task); | ||
122 | to_task = NULL; | ||
123 | } | ||
124 | if (NULL != lr) | ||
125 | { | ||
126 | GNUNET_GNS_lookup_with_tld_cancel (lr); | ||
127 | lr = NULL; | ||
128 | } | ||
129 | if (NULL != gns) | ||
130 | { | ||
131 | GNUNET_GNS_disconnect (gns); | ||
132 | gns = NULL; | ||
133 | } | ||
134 | if (NULL != idna_name) | ||
135 | { | ||
136 | GNUNET_free (idna_name); | ||
137 | idna_name = NULL; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Task to run on timeout | ||
144 | * | ||
145 | * @param cls unused | ||
146 | */ | ||
147 | static void | ||
148 | do_timeout (void*cls) | ||
149 | { | ||
150 | to_task = NULL; | ||
151 | global_ret = 3; // Timeout | ||
152 | GNUNET_SCHEDULER_shutdown (); | ||
153 | } | ||
154 | |||
155 | |||
156 | /** | ||
157 | * Function called with the result of a GNS lookup. | ||
158 | * | ||
159 | * @param cls the 'const char *' name that was resolved | ||
160 | * @param was_gns #GNUNET_NO if TLD did not indicate use of GNS | ||
161 | * @param rd_count number of records returned | ||
162 | * @param rd array of @a rd_count records with the results | ||
163 | */ | ||
164 | static void | ||
165 | process_lookup_result (void *cls, | ||
166 | int was_gns, | ||
167 | uint32_t rd_count, | ||
168 | const struct GNUNET_GNSRECORD_Data *rd) | ||
169 | { | ||
170 | struct GNUNET_TIME_Relative block_exp; | ||
171 | const char *typename; | ||
172 | char *string_val; | ||
173 | |||
174 | lr = NULL; | ||
175 | if (GNUNET_NO == was_gns) | ||
176 | { | ||
177 | global_ret = 4; /* not for GNS */ | ||
178 | GNUNET_SCHEDULER_shutdown (); | ||
179 | return; | ||
180 | } | ||
181 | block_exp = GNUNET_TIME_absolute_get_remaining ( | ||
182 | GNUNET_GNSRECORD_record_get_expiration_time ( | ||
183 | rd_count, | ||
184 | rd, | ||
185 | GNUNET_TIME_UNIT_ZERO_ABS)); | ||
186 | if (! raw) | ||
187 | { | ||
188 | printf ("<<< %u record(s) found:\n\n", rd_count); | ||
189 | } | ||
190 | for (uint32_t i = 0; i < rd_count; i++) | ||
191 | { | ||
192 | typename = GNUNET_GNSRECORD_number_to_typename (rd[i]. | ||
193 | record_type); | ||
194 | string_val = GNUNET_GNSRECORD_value_to_string (rd[i].record_type | ||
195 | , | ||
196 | rd[i].data, | ||
197 | rd[i].data_size); | ||
198 | if (NULL == string_val) | ||
199 | { | ||
200 | fprintf (stderr, | ||
201 | "Record %u of type %d malformed, skipping\n", | ||
202 | (unsigned int) i, | ||
203 | (int) rd[i].record_type); | ||
204 | continue; | ||
205 | } | ||
206 | if (raw) | ||
207 | printf ("%s\n", string_val); | ||
208 | else | ||
209 | printf ("%s: `%s' %s\n", | ||
210 | typename, | ||
211 | string_val, | ||
212 | (0 != (rd[i].flags | ||
213 | & | ||
214 | GNUNET_GNSRECORD_RF_SUPPLEMENTAL) | ||
215 | ) ? | ||
216 | "(supplemental)" : ""); | ||
217 | GNUNET_free (string_val); | ||
218 | } | ||
219 | if (! raw) | ||
220 | { | ||
221 | if (0 != rd_count) | ||
222 | printf ("\nRecord set expires in %s.\n", | ||
223 | GNUNET_STRINGS_relative_time_to_string ( | ||
224 | block_exp, GNUNET_YES)); | ||
225 | } | ||
226 | GNUNET_SCHEDULER_shutdown (); | ||
227 | } | ||
228 | |||
229 | |||
230 | /** | ||
231 | * Main function that will be run. | ||
232 | * | ||
233 | * @param cls closure | ||
234 | * @param args remaining command-line arguments | ||
235 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
236 | * @param c configuration | ||
237 | */ | ||
238 | static void | ||
239 | run (void *cls, | ||
240 | char *const *args, | ||
241 | const char *cfgfile, | ||
242 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
243 | { | ||
244 | const char *effective_lookup_type; | ||
245 | (void) cls; | ||
246 | (void) args; | ||
247 | (void) cfgfile; | ||
248 | |||
249 | cfg = c; | ||
250 | to_task = NULL; | ||
251 | { | ||
252 | char *colon; | ||
253 | |||
254 | if (NULL != (colon = strchr (lookup_name, ':'))) | ||
255 | *colon = '\0'; | ||
256 | } | ||
257 | |||
258 | /** | ||
259 | * If DNS compatibility is requested, we first verify that the | ||
260 | * lookup_name is in a DNS format. If yes, we convert it to UTF-8. | ||
261 | */ | ||
262 | if (GNUNET_YES == dns_compat) | ||
263 | { | ||
264 | Idna_rc rc; | ||
265 | |||
266 | if (GNUNET_OK != GNUNET_DNSPARSER_check_name (lookup_name)) | ||
267 | { | ||
268 | fprintf (stderr, | ||
269 | _ ("`%s' is not a valid DNS domain name\n"), | ||
270 | lookup_name); | ||
271 | global_ret = 3; | ||
272 | return; | ||
273 | } | ||
274 | if (IDNA_SUCCESS != | ||
275 | (rc = idna_to_unicode_8z8z (lookup_name, &idna_name, | ||
276 | IDNA_ALLOW_UNASSIGNED))) | ||
277 | { | ||
278 | fprintf (stderr, | ||
279 | _ ( | ||
280 | "Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"), | ||
281 | lookup_name, | ||
282 | idna_strerror (rc)); | ||
283 | global_ret = 4; | ||
284 | return; | ||
285 | } | ||
286 | lookup_name = idna_name; | ||
287 | } | ||
288 | |||
289 | if (GNUNET_YES != | ||
290 | GNUNET_CLIENT_test (cfg, | ||
291 | "arm")) | ||
292 | { | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
294 | _ ( | ||
295 | "Cannot resolve using GNS: GNUnet peer not running\n")); | ||
296 | global_ret = 5; | ||
297 | return; | ||
298 | } | ||
299 | to_task = GNUNET_SCHEDULER_add_delayed (timeout, | ||
300 | &do_timeout, | ||
301 | NULL); | ||
302 | gns = GNUNET_GNS_connect (cfg); | ||
303 | if (NULL == gns) | ||
304 | { | ||
305 | fprintf (stderr, | ||
306 | _ ("Failed to connect to GNS\n")); | ||
307 | global_ret = 2; | ||
308 | return; | ||
309 | } | ||
310 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
311 | NULL); | ||
312 | if (NULL != lookup_type) | ||
313 | { | ||
314 | effective_lookup_type = lookup_type; | ||
315 | rtype = GNUNET_GNSRECORD_typename_to_number (lookup_type); | ||
316 | } | ||
317 | else | ||
318 | { | ||
319 | effective_lookup_type = "A"; | ||
320 | rtype = GNUNET_DNSPARSER_TYPE_A; | ||
321 | } | ||
322 | if (UINT32_MAX == rtype) | ||
323 | { | ||
324 | fprintf (stderr, | ||
325 | _ ("Invalid typename specified, assuming `ANY'\n")); | ||
326 | rtype = GNUNET_GNSRECORD_TYPE_ANY; | ||
327 | } | ||
328 | if (! raw) | ||
329 | { | ||
330 | printf (">>> Looking for `%s' records under `%s'\n", | ||
331 | effective_lookup_type, lookup_name); | ||
332 | } | ||
333 | lr = GNUNET_GNS_lookup_with_tld (gns, | ||
334 | lookup_name, | ||
335 | rtype, | ||
336 | GNUNET_GNS_LO_DEFAULT, | ||
337 | &process_lookup_result, | ||
338 | lookup_name); | ||
339 | if (NULL == lr) | ||
340 | { | ||
341 | global_ret = 2; | ||
342 | GNUNET_SCHEDULER_shutdown (); | ||
343 | return; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | |||
348 | /** | ||
349 | * The main function for gnunet-gns. | ||
350 | * | ||
351 | * @param argc number of arguments from the command line | ||
352 | * @param argv command line arguments | ||
353 | * @return 0 ok, 1 on error | ||
354 | */ | ||
355 | int | ||
356 | main (int argc, char *const *argv) | ||
357 | { | ||
358 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; | ||
359 | struct GNUNET_GETOPT_CommandLineOption options[] = | ||
360 | { GNUNET_GETOPT_option_mandatory ( | ||
361 | GNUNET_GETOPT_option_string ('u', | ||
362 | "lookup", | ||
363 | "NAME", | ||
364 | gettext_noop ( | ||
365 | "Lookup a record for the given name"), | ||
366 | &lookup_name)), | ||
367 | GNUNET_GETOPT_option_string ('t', | ||
368 | "type", | ||
369 | "TYPE", | ||
370 | gettext_noop ( | ||
371 | "Specify the type of the record to lookup"), | ||
372 | &lookup_type), | ||
373 | GNUNET_GETOPT_option_relative_time ('T', | ||
374 | "timeout", | ||
375 | "TIMEOUT", | ||
376 | gettext_noop ( | ||
377 | "Specify a timeout for the lookup"), | ||
378 | &timeout), | ||
379 | GNUNET_GETOPT_option_flag ('r', | ||
380 | "raw", | ||
381 | gettext_noop ("No unneeded output"), | ||
382 | &raw), | ||
383 | GNUNET_GETOPT_option_flag ('d', | ||
384 | "dns", | ||
385 | gettext_noop ( | ||
386 | "DNS Compatibility: Name is passed in IDNA instead of UTF-8"), | ||
387 | &dns_compat), | ||
388 | GNUNET_GETOPT_OPTION_END }; | ||
389 | int ret; | ||
390 | |||
391 | if (GNUNET_OK != | ||
392 | GNUNET_STRINGS_get_utf8_args (argc, argv, | ||
393 | &argc, &argv)) | ||
394 | return 2; | ||
395 | |||
396 | GNUNET_log_setup ("gnunet-gns", "WARNING", NULL); | ||
397 | ret = GNUNET_PROGRAM_run (argc, | ||
398 | argv, | ||
399 | "gnunet-gns", | ||
400 | _ ("GNUnet GNS resolver tool"), | ||
401 | options, | ||
402 | &run, | ||
403 | NULL); | ||
404 | GNUNET_free_nz ((void *) argv); | ||
405 | if (GNUNET_OK != ret) | ||
406 | return 1; | ||
407 | return global_ret; | ||
408 | } | ||
409 | |||
410 | |||
411 | /* end of gnunet-gns.c */ | ||
diff --git a/src/cli/gns/meson.build b/src/cli/gns/meson.build new file mode 100644 index 000000000..bb6bfc477 --- /dev/null +++ b/src/cli/gns/meson.build | |||
@@ -0,0 +1,69 @@ | |||
1 | configure_file(input : 'gnunet-gns-proxy-setup-ca.in', | ||
2 | output : 'gnunet-gns-proxy-setup-ca', | ||
3 | configuration : cdata, | ||
4 | install: true, | ||
5 | install_mode: 'rwxr-xr-x', | ||
6 | install_dir: get_option('bindir')) | ||
7 | |||
8 | install_data('gnunet-gns-proxy-ca.template', | ||
9 | install_dir: get_option('datadir')/'gnunet') | ||
10 | install_data('openssl.cnf', | ||
11 | install_dir: get_option('datadir')/'gnunet') | ||
12 | |||
13 | executable ('gnunet-gns', | ||
14 | 'gnunet-gns.c', | ||
15 | dependencies: [libgnunetgns_dep, | ||
16 | libgnunetgnsrecord_dep, | ||
17 | idn_dep, | ||
18 | libgnunetutil_dep], | ||
19 | include_directories: [incdir, configuration_inc], | ||
20 | install: true, | ||
21 | install_dir: get_option('bindir')) | ||
22 | |||
23 | testgns = [ | ||
24 | 'test_dns2gns', | ||
25 | 'test_gns_at_lookup', | ||
26 | 'test_gns_caa_lookup', | ||
27 | 'test_gns_config_lookup', | ||
28 | 'test_gns_delegated_lookup', | ||
29 | 'test_gns_dht_lookup', | ||
30 | 'test_gns_gns2dns_cname_lookup', | ||
31 | 'test_gns_gns2dns_lookup', | ||
32 | 'test_gns_gns2dns_zkey_lookup', | ||
33 | 'test_gns_ipv6_lookup', | ||
34 | 'test_gns_lookup', | ||
35 | 'test_gns_mx_lookup', | ||
36 | 'test_gns_quickupdate', | ||
37 | 'test_gns_redirect_lookup', | ||
38 | 'test_gns_rel_expiration', | ||
39 | 'test_gns_revocation', | ||
40 | 'test_gns_soa_lookup', | ||
41 | 'test_gns_txt_lookup', | ||
42 | 'test_gns_zkey_lookup', | ||
43 | 'test_gns_sbox_simple', | ||
44 | 'test_gns_sbox', | ||
45 | 'test_gns_box_sbox', | ||
46 | ] | ||
47 | |||
48 | testconfigs = [ | ||
49 | 'test_dns2gns.conf', | ||
50 | 'test_gns_defaults.conf', | ||
51 | 'test_gns_lookup.conf', | ||
52 | 'test_gns_lookup_peer1.conf', | ||
53 | 'test_gns_lookup_peer2.conf', | ||
54 | 'test_gns_simple_lookup.conf' | ||
55 | ] | ||
56 | |||
57 | foreach f : testconfigs | ||
58 | configure_file(input: f, output: f, copy: true) | ||
59 | endforeach | ||
60 | |||
61 | foreach t : testgns | ||
62 | |||
63 | test_filename = t + '.sh' | ||
64 | test_file = configure_file(input : test_filename, | ||
65 | output : test_filename, | ||
66 | copy: true) | ||
67 | |||
68 | test(t, test_file, suite: 'gns', workdir: meson.current_build_dir(), is_parallel: false) | ||
69 | endforeach | ||
diff --git a/src/cli/gns/openssl.cnf b/src/cli/gns/openssl.cnf new file mode 100644 index 000000000..5dce35388 --- /dev/null +++ b/src/cli/gns/openssl.cnf | |||
@@ -0,0 +1,244 @@ | |||
1 | # | ||
2 | # OpenSSL example configuration file. | ||
3 | # This is mostly being used for generation of certificate requests. | ||
4 | # | ||
5 | |||
6 | # This definition stops the following lines choking if HOME isn't | ||
7 | # defined. | ||
8 | HOME = . | ||
9 | #RANDFILE = $ENV::HOME/.rnd | ||
10 | |||
11 | # Extra OBJECT IDENTIFIER info: | ||
12 | #oid_file = $ENV::HOME/.oid | ||
13 | oid_section = new_oids | ||
14 | |||
15 | # To use this configuration file with the "-extfile" option of the | ||
16 | # "openssl x509" utility, name here the section containing the | ||
17 | # X.509v3 extensions to use: | ||
18 | # extensions = | ||
19 | # (Alternatively, use a configuration file that has only | ||
20 | # X.509v3 extensions in its main [= default] section.) | ||
21 | |||
22 | [ new_oids ] | ||
23 | |||
24 | # We can add new OIDs in here for use by 'ca' and 'req'. | ||
25 | # Add a simple OID like this: | ||
26 | # testoid1=1.2.3.4 | ||
27 | # Or use config file substitution like this: | ||
28 | # testoid2=${testoid1}.5.6 | ||
29 | |||
30 | #################################################################### | ||
31 | [ ca ] | ||
32 | default_ca = CA_default # The default ca section | ||
33 | |||
34 | #################################################################### | ||
35 | [ CA_default ] | ||
36 | |||
37 | dir = ./demoCA # Where everything is kept | ||
38 | certs = $dir/certs # Where the issued certs are kept | ||
39 | crl_dir = $dir/crl # Where the issued crl are kept | ||
40 | database = $dir/index.txt # database index file. | ||
41 | new_certs_dir = $dir/newcerts # default place for new certs. | ||
42 | |||
43 | certificate = $dir/cacert.pem # The CA certificate | ||
44 | serial = $dir/serial # The current serial number | ||
45 | crl = $dir/crl.pem # The current CRL | ||
46 | private_key = $dir/private/cakey.pem# The private key | ||
47 | RANDFILE = $dir/private/.rand # private random number file | ||
48 | |||
49 | x509_extensions = usr_cert # The extensions to add to the cert | ||
50 | |||
51 | # Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs | ||
52 | # so this is commented out by default to leave a V1 CRL. | ||
53 | # crl_extensions = crl_ext | ||
54 | |||
55 | default_days = 365 # how long to certify for | ||
56 | default_crl_days= 30 # how long before next CRL | ||
57 | default_md = md5 # which md to use. | ||
58 | preserve = no # keep passed DN ordering | ||
59 | |||
60 | # A few difference way of specifying how similar the request should look | ||
61 | # For type CA, the listed attributes must be the same, and the optional | ||
62 | # and supplied fields are just that :-) | ||
63 | policy = policy_match | ||
64 | |||
65 | # For the CA policy | ||
66 | [ policy_match ] | ||
67 | countryName = match | ||
68 | stateOrProvinceName = match | ||
69 | organizationName = match | ||
70 | organizationalUnitName = optional | ||
71 | commonName = supplied | ||
72 | emailAddress = optional | ||
73 | |||
74 | # For the 'anything' policy | ||
75 | # At this point in time, you must list all acceptable 'object' | ||
76 | # types. | ||
77 | [ policy_anything ] | ||
78 | countryName = optional | ||
79 | stateOrProvinceName = optional | ||
80 | localityName = optional | ||
81 | organizationName = optional | ||
82 | organizationalUnitName = optional | ||
83 | commonName = supplied | ||
84 | emailAddress = optional | ||
85 | |||
86 | #################################################################### | ||
87 | [ req ] | ||
88 | default_bits = 1024 | ||
89 | default_keyfile = privkey.pem | ||
90 | distinguished_name = req_distinguished_name | ||
91 | attributes = req_attributes | ||
92 | x509_extensions = v3_ca # The extensions to add to the self signed cert | ||
93 | |||
94 | # Passwords for private keys if not present they will be prompted for | ||
95 | # input_password = secret | ||
96 | # output_password = secret | ||
97 | |||
98 | # This sets a mask for permitted string types. There are several options. | ||
99 | # default: PrintableString, T61String, BMPString. | ||
100 | # pkix : PrintableString, BMPString. | ||
101 | # utf8only: only UTF8Strings. | ||
102 | # nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). | ||
103 | # MASK:XXXX a literal mask value. | ||
104 | # WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings | ||
105 | # so use this option with caution! | ||
106 | string_mask = nombstr | ||
107 | |||
108 | # req_extensions = v3_req # The extensions to add to a certificate request | ||
109 | |||
110 | [ req_distinguished_name ] | ||
111 | countryName = Country Name (2 letter code) | ||
112 | countryName_default = AU | ||
113 | countryName_min = 2 | ||
114 | countryName_max = 2 | ||
115 | |||
116 | stateOrProvinceName = State or Province Name (full name) | ||
117 | stateOrProvinceName_default = Some-State | ||
118 | |||
119 | localityName = Locality Name (eg, city) | ||
120 | |||
121 | 0.organizationName = Organization Name (eg, company) | ||
122 | 0.organizationName_default = Internet Widgits Pty Ltd | ||
123 | |||
124 | # we can do this but it is not needed normally :-) | ||
125 | #1.organizationName = Second Organization Name (eg, company) | ||
126 | #1.organizationName_default = World Wide Web Pty Ltd | ||
127 | |||
128 | organizationalUnitName = Organizational Unit Name (eg, section) | ||
129 | #organizationalUnitName_default = | ||
130 | |||
131 | commonName = Common Name (eg, YOUR name) | ||
132 | commonName_max = 64 | ||
133 | |||
134 | emailAddress = Email Address | ||
135 | emailAddress_max = 40 | ||
136 | |||
137 | # SET-ex3 = SET extension number 3 | ||
138 | |||
139 | [ req_attributes ] | ||
140 | challengePassword = A challenge password | ||
141 | challengePassword_min = 4 | ||
142 | challengePassword_max = 20 | ||
143 | |||
144 | unstructuredName = An optional company name | ||
145 | |||
146 | [ usr_cert ] | ||
147 | |||
148 | # These extensions are added when 'ca' signs a request. | ||
149 | |||
150 | # This goes against PKIX guidelines but some CAs do it and some software | ||
151 | # requires this to avoid interpreting an end user certificate as a CA. | ||
152 | |||
153 | basicConstraints=CA:FALSE | ||
154 | |||
155 | # Here are some examples of the usage of nsCertType. If it is omitted | ||
156 | # the certificate can be used for anything *except* object signing. | ||
157 | |||
158 | # This is OK for an SSL server. | ||
159 | # nsCertType = server | ||
160 | |||
161 | # For an object signing certificate this would be used. | ||
162 | # nsCertType = objsign | ||
163 | |||
164 | # For normal client use this is typical | ||
165 | # nsCertType = client, email | ||
166 | |||
167 | # and for everything including object signing: | ||
168 | # nsCertType = client, email, objsign | ||
169 | |||
170 | # This is typical in keyUsage for a client certificate. | ||
171 | # keyUsage = nonRepudiation, digitalSignature, keyEncipherment | ||
172 | |||
173 | # This will be displayed in Netscape's comment listbox. | ||
174 | nsComment = "OpenSSL Generated Certificate" | ||
175 | |||
176 | # PKIX recommendations harmless if included in all certificates. | ||
177 | subjectKeyIdentifier=hash | ||
178 | authorityKeyIdentifier=keyid,issuer:always | ||
179 | |||
180 | # This stuff is for subjectAltName and issuerAltname. | ||
181 | # Import the email address. | ||
182 | # subjectAltName=email:copy | ||
183 | |||
184 | # Copy subject details | ||
185 | # issuerAltName=issuer:copy | ||
186 | |||
187 | #nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem | ||
188 | #nsBaseUrl | ||
189 | #nsRevocationUrl | ||
190 | #nsRenewalUrl | ||
191 | #nsCaPolicyUrl | ||
192 | #nsSslServerName | ||
193 | |||
194 | [ v3_req ] | ||
195 | |||
196 | # Extensions to add to a certificate request | ||
197 | |||
198 | basicConstraints = CA:FALSE | ||
199 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment | ||
200 | |||
201 | [ v3_ca ] | ||
202 | |||
203 | |||
204 | # Extensions for a typical CA | ||
205 | |||
206 | |||
207 | # PKIX recommendation. | ||
208 | |||
209 | subjectKeyIdentifier=hash | ||
210 | |||
211 | authorityKeyIdentifier=keyid:always,issuer:always | ||
212 | |||
213 | # This is what PKIX recommends but some broken software chokes on critical | ||
214 | # extensions. | ||
215 | #basicConstraints = critical,CA:true | ||
216 | # So we do this instead. | ||
217 | basicConstraints = CA:true | ||
218 | |||
219 | # Key usage: this is typical for a CA certificate. However since it will | ||
220 | # prevent it being used as an test self-signed certificate it is best | ||
221 | # left out by default. | ||
222 | # keyUsage = cRLSign, keyCertSign | ||
223 | |||
224 | # Some might want this also | ||
225 | # nsCertType = sslCA, emailCA | ||
226 | |||
227 | # Include email address in subject alt name: another PKIX recommendation | ||
228 | # subjectAltName=email:copy | ||
229 | # Copy issuer details | ||
230 | # issuerAltName=issuer:copy | ||
231 | |||
232 | # DER hex encoding of an extension: beware experts only! | ||
233 | # obj=DER:02:03 | ||
234 | # Where 'obj' is a standard or added object | ||
235 | # You can even override a supported extension: | ||
236 | # basicConstraints= critical, DER:30:03:01:01:FF | ||
237 | |||
238 | [ crl_ext ] | ||
239 | |||
240 | # CRL extensions. | ||
241 | # Only issuerAltName and authorityKeyIdentifier make any sense in a CRL. | ||
242 | |||
243 | # issuerAltName=issuer:copy | ||
244 | authorityKeyIdentifier=keyid:always,issuer:always | ||
diff --git a/src/cli/gns/test_dns2gns.conf b/src/cli/gns/test_dns2gns.conf new file mode 100644 index 000000000..2f6bdc797 --- /dev/null +++ b/src/cli/gns/test_dns2gns.conf | |||
@@ -0,0 +1,69 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | ||
2 | |||
3 | [namecache] | ||
4 | DISABLE = YES | ||
5 | |||
6 | [PATHS] | ||
7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ | ||
8 | |||
9 | [dht] | ||
10 | START_ON_DEMAND = YES | ||
11 | IMMEDIATE_START = YES | ||
12 | |||
13 | [gns] | ||
14 | # PREFIX = valgrind --leak-check=full --track-origins=yes | ||
15 | START_ON_DEMAND = YES | ||
16 | AUTO_IMPORT_PKEY = YES | ||
17 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
18 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
19 | RECORD_PUT_INTERVAL = 1 h | ||
20 | ZONE_PUBLISH_TIME_WINDOW = 1 h | ||
21 | .gnunet.org = | ||
22 | |||
23 | [namestore] | ||
24 | IMMEDIATE_START = YES | ||
25 | #PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/ns_log | ||
26 | |||
27 | [revocation] | ||
28 | WORKBITS = 1 | ||
29 | |||
30 | [dhtcache] | ||
31 | QUOTA = 1 MB | ||
32 | DATABASE = heap | ||
33 | |||
34 | [topology] | ||
35 | TARGET-CONNECTION-COUNT = 16 | ||
36 | AUTOCONNECT = YES | ||
37 | FRIENDS-ONLY = NO | ||
38 | MINIMUM-FRIENDS = 0 | ||
39 | |||
40 | [ats] | ||
41 | WAN_QUOTA_IN = 1 GB | ||
42 | WAN_QUOTA_OUT = 1 GB | ||
43 | |||
44 | [transport] | ||
45 | plugins = tcp | ||
46 | NEIGHBOUR_LIMIT = 50 | ||
47 | PORT = 2091 | ||
48 | |||
49 | [transport-tcp] | ||
50 | TIMEOUT = 300 s | ||
51 | |||
52 | [nat] | ||
53 | DISABLEV6 = YES | ||
54 | BINDTO = 127.0.0.1 | ||
55 | ENABLE_UPNP = NO | ||
56 | BEHIND_NAT = NO | ||
57 | ALLOW_NAT = NO | ||
58 | INTERNAL_ADDRESS = 127.0.0.1 | ||
59 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
60 | |||
61 | [dns2gns] | ||
62 | BINARY = gnunet-dns2gns | ||
63 | START_ON_DEMAND = YES | ||
64 | IMMEDIATE_START = YES | ||
65 | RUN_PER_USER = YES | ||
66 | BIND_TO = 127.0.0.1 | ||
67 | BIND_TO6 = ::1 | ||
68 | PORT = 12000 | ||
69 | OPTIONS = -d 1.1.1.1 | ||
diff --git a/src/cli/gns/test_dns2gns.sh b/src/cli/gns/test_dns2gns.sh new file mode 100755 index 000000000..a6024ca3c --- /dev/null +++ b/src/cli/gns/test_dns2gns.sh | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_dns2gns.conf" INT | ||
4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
5 | |||
6 | LOCATION=$(which gnunet-config) | ||
7 | if [ -z $LOCATION ] | ||
8 | then | ||
9 | LOCATION="gnunet-config" | ||
10 | fi | ||
11 | $LOCATION --version 1> /dev/null | ||
12 | if test $? != 0 | ||
13 | then | ||
14 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
15 | exit 77 | ||
16 | fi | ||
17 | |||
18 | rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME` | ||
19 | MY_EGO="localego" | ||
20 | TEST_IP="127.0.0.1" | ||
21 | TEST_IPV6="dead::beef" | ||
22 | LABEL="fnord" | ||
23 | TEST_DOMAIN="taler.net" | ||
24 | |||
25 | gnunet-arm -s -c test_dns2gns.conf | ||
26 | PKEY=`gnunet-identity -V -C $MY_EGO -c test_dns2gns.conf` | ||
27 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_dns2gns.conf | ||
28 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_dns2gns.conf | ||
29 | |||
30 | # FIXME resolution works but always returns all available records | ||
31 | # also, the records seem to be returned twice if using GNS | ||
32 | |||
33 | if nslookup -port=12000 $LABEL.$PKEY localhost && nslookup -port=12000 $LABEL.$MY_EGO localhost; then | ||
34 | echo "PASS: GNS records can be resolved using dns2gns bridge" | ||
35 | else | ||
36 | echo "FAIL: GNS records can't be resolved using dns2gns bridge" | ||
37 | gnunet-arm -e -c test_dns2gns.conf | ||
38 | rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME` | ||
39 | exit 1 | ||
40 | fi | ||
41 | |||
42 | if nslookup -port=12000 $TEST_DOMAIN localhost; then | ||
43 | echo "PASS: DNS records can be resolved using dns2gns bridge" | ||
44 | else | ||
45 | echo "FAIL: DNS records can't be resolved using dns2gns bridge" | ||
46 | gnunet-arm -e -c test_dns2gns.conf | ||
47 | rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME` | ||
48 | exit 1 | ||
49 | fi | ||
50 | gnunet-arm -e -c test_dns2gns.conf | ||
51 | |||
52 | rm -rf `gnunet-config -c test_dns2gns.conf -f -s paths -o GNUNET_TEST_HOME` | ||
diff --git a/src/cli/gns/test_gns_at_lookup.sh b/src/cli/gns/test_gns_at_lookup.sh new file mode 100755 index 000000000..6a2c958de --- /dev/null +++ b/src/cli/gns/test_gns_at_lookup.sh | |||
@@ -0,0 +1,41 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
19 | |||
20 | TEST_IP="127.0.0.1" | ||
21 | MY_EGO="myego" | ||
22 | gnunet-arm -s -c test_gns_lookup.conf | ||
23 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | ||
24 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | ||
25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
26 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
27 | gnunet-namestore -p -z delegatedego -a -n '@' -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
28 | sleep 0.5 | ||
29 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
30 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
31 | gnunet-namestore -z delegatedego -d -n '@' -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
32 | gnunet-arm -e -c test_gns_lookup.conf | ||
33 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
34 | |||
35 | if [ "$RES_IP" = "$TEST_IP" ] | ||
36 | then | ||
37 | exit 0 | ||
38 | else | ||
39 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
40 | exit 1 | ||
41 | fi | ||
diff --git a/src/cli/gns/test_gns_box_sbox.sh b/src/cli/gns/test_gns_box_sbox.sh new file mode 100755 index 000000000..d7e95912e --- /dev/null +++ b/src/cli/gns/test_gns_box_sbox.sh | |||
@@ -0,0 +1,59 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | TEST_B="TXT_record_in_BOX" | ||
20 | TEST_S="TXT_record_in_SBOX" | ||
21 | TEST_A="10.1.11.10" | ||
22 | MY_EGO="myego" | ||
23 | LABEL="testsbox" | ||
24 | SERVICE="443" | ||
25 | SERVICE_TEXT="_443" | ||
26 | PROTOCOL="6" | ||
27 | PROTOCOL_TEXT="_tcp" | ||
28 | gnunet-arm -s -c test_gns_lookup.conf | ||
29 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
30 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$SERVICE_TEXT.$PROTOCOL_TEXT 16 $TEST_S" -e never -c test_gns_lookup.conf | ||
31 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "$PROTOCOL $SERVICE 16 $TEST_B" -e never -c test_gns_lookup.conf | ||
32 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$SERVICE_TEXT.$PROTOCOL_TEXT 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
33 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "$PROTOCOL $SERVICE 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
34 | sleep 0.5 | ||
35 | RES_B_S=`$DO_TIMEOUT gnunet-gns --raw -u $SERVICE_TEXT.$PROTOCOL_TEXT.$LABEL.$MY_EGO -t TXT -c test_gns_lookup.conf` | ||
36 | RES_A=`$DO_TIMEOUT gnunet-gns --raw -u $SERVICE_TEXT.$PROTOCOL_TEXT.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
37 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$SERVICE_TEXT.$PROTOCOL_TEXT 16 $TEST_S" -e never -c test_gns_lookup.conf | ||
38 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t BOX -V "$PROTOCOL $SERVICE 16 $TEST_B" -e never -c test_gns_lookup.conf | ||
39 | gnunet-namestore -p -z $MY_EGO -d -n $LABEL -t SBOX -V "$SERVICE_TEXT.$PROTOCOL_TEXT 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
40 | gnunet-namestore -p -z $MY_EGO -d -n $LABEL -t BOX -V "$PROTOCOL $SERVICE 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
41 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
42 | gnunet-arm -e -c test_gns_lookup.conf | ||
43 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
44 | |||
45 | { read RES_A1; read RES_A2; read RES_B; read RES_S;} <<< "${RES_B_S}" | ||
46 | if [ "$RES_B" = "$RES_S" ] | ||
47 | then | ||
48 | echo "Failed to resolve to diffrent TXT records, got '$RES_B' and '$RES_S'." | ||
49 | exit 1 | ||
50 | fi | ||
51 | |||
52 | { read RES_S_A; read RES_B_A;} <<< "${RES_A}" | ||
53 | if [ "$RES_S_A" = "$TEST_A" ] && [ "$RES_B_A" = "$TEST_A" ] | ||
54 | then | ||
55 | exit 0 | ||
56 | else | ||
57 | echo "Failed to resolve to proper A '$TEST_A', got '$RES_S_A' and '$RES_S_B'." | ||
58 | exit 1 | ||
59 | fi | ||
diff --git a/src/cli/gns/test_gns_caa_lookup.sh b/src/cli/gns/test_gns_caa_lookup.sh new file mode 100755 index 000000000..fb488f47b --- /dev/null +++ b/src/cli/gns/test_gns_caa_lookup.sh | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | TEST_CAA="0 issue ca.example.net; policy=ev" | ||
20 | MY_EGO="myego" | ||
21 | LABEL="testcaa" | ||
22 | gnunet-arm -s -c test_gns_lookup.conf | ||
23 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
24 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t CAA -V "$TEST_CAA" -e never -c test_gns_lookup.conf | ||
25 | sleep 0.5 | ||
26 | RES_CAA=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t CAA -c test_gns_lookup.conf` | ||
27 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t CAA -V "$TEST_CAA" -e never -c test_gns_lookup.conf | ||
28 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
29 | gnunet-arm -e -c test_gns_lookup.conf | ||
30 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
31 | |||
32 | if [ "$RES_CAA" = "$TEST_CAA" ] | ||
33 | then | ||
34 | exit 0 | ||
35 | else | ||
36 | echo "Failed to resolve to proper CAA, got '$RES_CAA'." | ||
37 | exit 1 | ||
38 | fi | ||
diff --git a/src/cli/gns/test_gns_config_lookup.sh b/src/cli/gns/test_gns_config_lookup.sh new file mode 100755 index 000000000..bda08f87b --- /dev/null +++ b/src/cli/gns/test_gns_config_lookup.sh | |||
@@ -0,0 +1,44 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | MY_EGO="myego" | ||
17 | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
19 | CFG=`mktemp --tmpdir=$PWD` | ||
20 | cp test_gns_lookup.conf $CFG || exit 77 | ||
21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
22 | TEST_IP="dead::beef" | ||
23 | gnunet-arm -s -c $CFG || exit 77 | ||
24 | gnunet-identity -C $MY_EGO -c $CFG | ||
25 | EPUB=`gnunet-identity -d -c $CFG | grep $MY_EGO | awk '{print $3}'` | ||
26 | gnunet-arm -e -c $CFG | ||
27 | gnunet-config -c $CFG -s "gns" -o ".google.com" -V $EPUB | ||
28 | gnunet-arm -s -c $CFG | ||
29 | sleep 1 | ||
30 | gnunet-namestore -p -z $MY_EGO -a -n www -t AAAA -V $TEST_IP -e never -c $CFG | ||
31 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.google.com -t AAAA -c $CFG` | ||
32 | gnunet-namestore -z $MY_EGO -d -n www -t AAAA -V $TEST_IP -e never -c $CFG | ||
33 | gnunet-identity -D $MY_EGO -c $CFG | ||
34 | gnunet-arm -e -c $CFG | ||
35 | rm -rf `gnunet-config -c $CFG -f -s paths -o GNUNET_TEST_HOME` | ||
36 | rm $CFG | ||
37 | |||
38 | if [ "$RES_IP" = "$TEST_IP" ] | ||
39 | then | ||
40 | exit 0 | ||
41 | else | ||
42 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
43 | exit 1 | ||
44 | fi | ||
diff --git a/src/cli/gns/test_gns_defaults.conf b/src/cli/gns/test_gns_defaults.conf new file mode 100644 index 000000000..80a2f3c44 --- /dev/null +++ b/src/cli/gns/test_gns_defaults.conf | |||
@@ -0,0 +1,34 @@ | |||
1 | [PATHS] | ||
2 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-testing/ | ||
3 | |||
4 | [namestore-sqlite] | ||
5 | FILENAME = $GNUNET_TEST_HOME/namestore/sqlite_test.db | ||
6 | |||
7 | [namecache-sqlite] | ||
8 | FILENAME=$GNUNET_TEST_HOME/namecache/namecache.db | ||
9 | |||
10 | [identity] | ||
11 | # Directory where we store information about our egos | ||
12 | EGODIR = $GNUNET_TEST_HOME/identity/egos/ | ||
13 | |||
14 | [dhtcache] | ||
15 | DATABASE = heap | ||
16 | |||
17 | [transport] | ||
18 | PLUGINS = tcp | ||
19 | |||
20 | [transport-tcp] | ||
21 | BINDTO = 127.0.0.1 | ||
22 | |||
23 | |||
24 | [fs] | ||
25 | IMMEDIATE_START = NO | ||
26 | START_ON_DEMAND = NO | ||
27 | |||
28 | [rps] | ||
29 | IMMEDIATE_START = NO | ||
30 | START_ON_DEMAND = NO | ||
31 | |||
32 | [topology] | ||
33 | IMMEDIATE_START = NO | ||
34 | START_ON_DEMAND = NO | ||
diff --git a/src/cli/gns/test_gns_delegated_lookup.sh b/src/cli/gns/test_gns_delegated_lookup.sh new file mode 100755 index 000000000..5105abdb5 --- /dev/null +++ b/src/cli/gns/test_gns_delegated_lookup.sh | |||
@@ -0,0 +1,45 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
5 | |||
6 | LOCATION=$(which gnunet-config) | ||
7 | if [ -z $LOCATION ] | ||
8 | then | ||
9 | LOCATION="gnunet-config" | ||
10 | fi | ||
11 | $LOCATION --version 1> /dev/null | ||
12 | if test $? != 0 | ||
13 | then | ||
14 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
15 | exit 77 | ||
16 | fi | ||
17 | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
19 | MY_EGO="myego" | ||
20 | OTHER_EGO="delegatedego" | ||
21 | FINAL_LABEL="www" | ||
22 | DELEGATION_LABEL="b" | ||
23 | |||
24 | TEST_IP="127.0.0.1" | ||
25 | gnunet-arm -s -c test_gns_lookup.conf | ||
26 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | ||
27 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | ||
28 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
29 | gnunet-namestore -p -z $MY_EGO -a -n $DELEGATION_LABEL -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
30 | gnunet-namestore -p -z $OTHER_EGO -a -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
31 | sleep 0.5 | ||
32 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $FINAL_LABEL.$DELEGATION_LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
33 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
34 | gnunet-namestore -z $OTHER_EGO -d -n $FINAL_LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
35 | gnunet-arm -e -c test_gns_lookup.conf | ||
36 | |||
37 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
38 | |||
39 | if [ "$RES_IP" = "$TEST_IP" ] | ||
40 | then | ||
41 | exit 0 | ||
42 | else | ||
43 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
44 | exit 1 | ||
45 | fi | ||
diff --git a/src/cli/gns/test_gns_dht_lookup.sh b/src/cli/gns/test_gns_dht_lookup.sh new file mode 100755 index 000000000..da87d8477 --- /dev/null +++ b/src/cli/gns/test_gns_dht_lookup.sh | |||
@@ -0,0 +1,63 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
5 | |||
6 | LOCATION=$(which gnunet-config) | ||
7 | if [ -z $LOCATION ] | ||
8 | then | ||
9 | LOCATION="gnunet-config" | ||
10 | fi | ||
11 | $LOCATION --version 1> /dev/null | ||
12 | if test $? != 0 | ||
13 | then | ||
14 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
15 | exit 77 | ||
16 | fi | ||
17 | |||
18 | TEST_IP="127.0.0.1" | ||
19 | MY_EGO="myego" | ||
20 | OTHER_EGO="delegatedego" | ||
21 | |||
22 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
23 | gnunet-arm -s -c test_gns_lookup.conf | ||
24 | gnunet-arm -i zonemaster -c test_gns_lookup.conf | ||
25 | gnunet-arm -i datastore -c test_gns_lookup.conf | ||
26 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | ||
27 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | ||
28 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
29 | echo "MYEGO: $MY_EGO OTHER_EGO: $DELEGATED_PKEY" | ||
30 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
31 | #This works | ||
32 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
33 | #This doesn't | ||
34 | gnunet-namestore -p -z $OTHER_EGO -a -n www2 -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | ||
35 | sleep 6 | ||
36 | #gnunet-namestore -p -z $OTHER_EGO -d -n www2 -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | ||
37 | #gnunet-namestore -p -z $OTHER_EGO -a -n www2 -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | ||
38 | gnunet-arm -k zonemaster -c test_gns_lookup.conf | ||
39 | gnunet-arm -i zonemaster -c test_gns_lookup.conf | ||
40 | #gnunet-arm -r -c test_gns_lookup.conf | ||
41 | #gnunet-arm -i zonemaster | ||
42 | #gnunet-arm -i gns -c test_gns_lookup.conf | ||
43 | #gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf | ||
44 | #gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
45 | #gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
46 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
47 | RES_IP_REL=`$DO_TIMEOUT gnunet-gns --raw -u www2.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
48 | #gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
49 | gnunet-arm -e -c test_gns_lookup.conf | ||
50 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
51 | |||
52 | if [ "$RES_IP_REL" != "$TEST_IP" ] | ||
53 | then | ||
54 | echo "Failed to resolve to proper IP, got $RES_IP_REL. (relative expiration)" | ||
55 | #exit 1 | ||
56 | fi | ||
57 | if [ "$RES_IP" = "$TEST_IP" ] | ||
58 | then | ||
59 | exit 0 | ||
60 | else | ||
61 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
62 | exit 1 | ||
63 | fi | ||
diff --git a/src/cli/gns/test_gns_gns2dns_cname_lookup.sh b/src/cli/gns/test_gns_gns2dns_cname_lookup.sh new file mode 100755 index 000000000..c33c9d132 --- /dev/null +++ b/src/cli/gns/test_gns_gns2dns_cname_lookup.sh | |||
@@ -0,0 +1,98 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | # IP address of 'www.gnunet.org' | ||
19 | TEST_IP="147.87.255.218" | ||
20 | # IP address of 'gnunet.org' | ||
21 | TEST_IPALT="131.159.74.67" | ||
22 | # IPv6 address of 'gnunet.org' | ||
23 | TEST_IP6="2a07:6b47:100:464::9357:ffdb" | ||
24 | |||
25 | # main label used during resolution | ||
26 | TEST_RECORD_NAME="homepage" | ||
27 | |||
28 | XNS=ns.joker.com | ||
29 | |||
30 | if ! nslookup gnunet.org a.$XNS > /dev/null 2>&1 | ||
31 | then | ||
32 | echo "Cannot reach DNS, skipping test" | ||
33 | exit 77 | ||
34 | fi | ||
35 | |||
36 | # helper record for pointing to the DNS resolver | ||
37 | TEST_RESOLVER_LABEL="resolver" | ||
38 | # GNS2DNS record value: delegate to DNS domain 'gnunet.org' | ||
39 | # using the TEST_RESOLVER_LABEL DNS server for resolution | ||
40 | TEST_RECORD_GNS2DNS1="gnunet.org@a.$XNS" | ||
41 | TEST_RECORD_GNS2DNS2="gnunet.org@b.$XNS" | ||
42 | TEST_RECORD_GNS2DNS3="gnunet.org@c.$XNS" | ||
43 | |||
44 | MY_EGO="myego" | ||
45 | # various names we will use for resolution | ||
46 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | ||
47 | |||
48 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
49 | |||
50 | gnunet-arm -s -c test_gns_lookup.conf | ||
51 | OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf www.gnunet.org` | ||
52 | echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
53 | echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
54 | |||
55 | |||
56 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
57 | |||
58 | # set IP address for DNS resolver for resolving in gnunet.org domain | ||
59 | # map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS | ||
60 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf | ||
61 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf | ||
62 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf | ||
63 | |||
64 | gnunet-namestore -z $MY_EGO -D -c test_gns_lookup.conf | ||
65 | |||
66 | sleep 0.5 | ||
67 | |||
68 | # lookup 'www.gnunet.org', IPv4 | ||
69 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf` | ||
70 | # lookup 'www.gnunet.org', IPv6 | ||
71 | RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf` | ||
72 | |||
73 | # clean up | ||
74 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS1 -e never -c test_gns_lookup.conf | ||
75 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS2 -e never -c test_gns_lookup.conf | ||
76 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS3 -e never -c test_gns_lookup.conf | ||
77 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
78 | gnunet-arm -e -c test_gns_lookup.conf | ||
79 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
80 | |||
81 | ret=0 | ||
82 | if echo "$RES_IP" | grep "$TEST_IP" > /dev/null | ||
83 | then | ||
84 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | ||
85 | else | ||
86 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP." | ||
87 | ret=1 | ||
88 | fi | ||
89 | |||
90 | if echo "$RES_IP6" | grep "$TEST_IP6" > /dev/null | ||
91 | then | ||
92 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | ||
93 | else | ||
94 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6." | ||
95 | ret=1 | ||
96 | fi | ||
97 | |||
98 | exit $ret | ||
diff --git a/src/cli/gns/test_gns_gns2dns_lookup.sh b/src/cli/gns/test_gns_gns2dns_lookup.sh new file mode 100755 index 000000000..43a4756d3 --- /dev/null +++ b/src/cli/gns/test_gns_gns2dns_lookup.sh | |||
@@ -0,0 +1,117 @@ | |||
1 | #!/bin/sh | ||
2 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
17 | # IP address of 'docs.gnunet.org' | ||
18 | TEST_IP_ALT2="147.87.255.218" | ||
19 | # IP address of 'www.gnunet.org' | ||
20 | TEST_IP="147.87.255.218" | ||
21 | # IPv6 address of 'gnunet.org' | ||
22 | TEST_IP6="2a07:6b47:100:464::9357:ffdb" | ||
23 | # permissive DNS resolver we will use for the test | ||
24 | TEST_IP_GNS2DNS="8.8.8.8" | ||
25 | |||
26 | # main label used during resolution | ||
27 | TEST_RECORD_NAME="homepage" | ||
28 | |||
29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS > /dev/null 2>&1 | ||
30 | then | ||
31 | echo "Cannot reach DNS, skipping test" | ||
32 | exit 77 | ||
33 | fi | ||
34 | |||
35 | # helper record for pointing to the DNS resolver | ||
36 | TEST_RESOLVER_LABEL="resolver" | ||
37 | # GNS2DNS record value: delegate to DNS domain 'gnunet.org' | ||
38 | # using the TEST_RESOLVER_LABEL DNS server for resolution | ||
39 | TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.+" | ||
40 | |||
41 | MY_EGO="myego" | ||
42 | # various names we will use for resolution | ||
43 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | ||
44 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" | ||
45 | TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO" | ||
46 | |||
47 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
48 | |||
49 | |||
50 | gnunet-arm -s -c test_gns_lookup.conf | ||
51 | |||
52 | OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf www.gnunet.org` | ||
53 | echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
54 | echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
55 | |||
56 | |||
57 | |||
58 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
59 | |||
60 | # set IP address for DNS resolver for resolving in gnunet.org domain | ||
61 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | ||
62 | # map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS | ||
63 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | ||
64 | |||
65 | sleep 1 | ||
66 | |||
67 | gnunet-gns -u $TEST_RECORD_NAME.$MY_EGO -t GNS2DNS -c test_gns_lookup.conf | ||
68 | |||
69 | # lookup 'www.gnunet.org', IPv4 | ||
70 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf` | ||
71 | # lookup 'www.gnunet.org', IPv6 | ||
72 | RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf | head -n1` | ||
73 | # lookup 'gnunet.org', IPv4 | ||
74 | RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf` | ||
75 | # lookup 'docs.gnunet.org', IPv4 | ||
76 | RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf` | ||
77 | |||
78 | # clean up | ||
79 | gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | ||
80 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | ||
81 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
82 | gnunet-arm -e -c test_gns_lookup.conf | ||
83 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
84 | |||
85 | ret=0 | ||
86 | if echo "$RES_IP" | grep "$TEST_IP" > /dev/null | ||
87 | then | ||
88 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | ||
89 | else | ||
90 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP." | ||
91 | ret=1 | ||
92 | fi | ||
93 | |||
94 | if [ "${RES_IP6%?}" = "${TEST_IP6%?}" ] | ||
95 | then | ||
96 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | ||
97 | else | ||
98 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6." | ||
99 | ret=1 | ||
100 | fi | ||
101 | |||
102 | if echo "$RES_IP_ALT" | grep "$TEST_IP" > /dev/null | ||
103 | then | ||
104 | echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT." | ||
105 | else | ||
106 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT, got $RES_IP_ALT, wanted $TEST_IP." | ||
107 | ret=1 | ||
108 | fi | ||
109 | |||
110 | if echo "$RES_IP_ALT2" | grep "$TEST_IP_ALT2" > /dev/null | ||
111 | then | ||
112 | echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2." | ||
113 | else | ||
114 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT2, got $RES_IP_ALT2, wanted $TEST_IP_ALT2." | ||
115 | ret=1 | ||
116 | fi | ||
117 | exit $ret | ||
diff --git a/src/cli/gns/test_gns_gns2dns_zkey_lookup.sh b/src/cli/gns/test_gns_gns2dns_zkey_lookup.sh new file mode 100755 index 000000000..03549314e --- /dev/null +++ b/src/cli/gns/test_gns_gns2dns_zkey_lookup.sh | |||
@@ -0,0 +1,116 @@ | |||
1 | #!/bin/sh | ||
2 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
17 | # IP address of 'docs.gnunet.org' | ||
18 | TEST_IP_ALT2="147.87.255.218" | ||
19 | # IP address of 'www.gnunet.org' | ||
20 | TEST_IP="147.87.255.218" | ||
21 | # IPv6 address of 'gnunet.org' | ||
22 | TEST_IP6="2a07:6b47:100:464::9357:ffdb" | ||
23 | # permissive DNS resolver we will use for the test | ||
24 | TEST_IP_GNS2DNS="8.8.8.8" | ||
25 | |||
26 | # main label used during resolution | ||
27 | TEST_RECORD_NAME="homepage" | ||
28 | |||
29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS > /dev/null 2>&1 | ||
30 | then | ||
31 | echo "Cannot reach DNS, skipping test" | ||
32 | exit 77 | ||
33 | fi | ||
34 | |||
35 | # helper record for pointing to the DNS resolver | ||
36 | TEST_RESOLVER_LABEL="resolver" | ||
37 | |||
38 | MY_EGO="myego" | ||
39 | # various names we will use for resolution | ||
40 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | ||
41 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" | ||
42 | TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO" | ||
43 | |||
44 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
45 | |||
46 | |||
47 | gnunet-arm -s -c test_gns_lookup.conf | ||
48 | |||
49 | OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf www.gnunet.org` | ||
50 | echo $OUT | grep $TEST_IP - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv4 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
51 | echo $OUT | grep $TEST_IP6 - > /dev/null || { gnunet-arm -e -c test_gns_lookup.conf ; echo "IPv6 for gnunet.org not found ($OUT), skipping test"; exit 77; } | ||
52 | |||
53 | |||
54 | |||
55 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
56 | MY_EGO_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep ${MY_EGO} | awk '{print $3}') | ||
57 | # GNS2DNS record value: delegate to DNS domain 'gnunet.org' | ||
58 | # using the TEST_RESOLVER_LABEL DNS server for resolution | ||
59 | TEST_RECORD_GNS2DNS="gnunet.org@${TEST_RESOLVER_LABEL}.${MY_EGO_PKEY}" | ||
60 | |||
61 | # set IP address for DNS resolver for resolving in gnunet.org domain | ||
62 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | ||
63 | # map '$TEST_RECORD_NAME.$MY_EGO' to 'gnunet.org' in DNS | ||
64 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | ||
65 | |||
66 | sleep 1 | ||
67 | |||
68 | # lookup 'www.gnunet.org', IPv4 | ||
69 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t A -c test_gns_lookup.conf` | ||
70 | # lookup 'www.gnunet.org', IPv6 | ||
71 | RES_IP6=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t AAAA -c test_gns_lookup.conf | head -n1` | ||
72 | # lookup 'gnunet.org', IPv4 | ||
73 | RES_IP_ALT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT -t A -c test_gns_lookup.conf` | ||
74 | # lookup 'docs.gnunet.org', IPv4 | ||
75 | RES_IP_ALT2=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ALT2 -t A -c test_gns_lookup.conf` | ||
76 | |||
77 | # clean up | ||
78 | gnunet-namestore -z $MY_EGO -d -n $TEST_RESOLVER_LABEL -t A -V $TEST_IP_GNS2DNS -e never -c test_gns_lookup.conf | ||
79 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V $TEST_RECORD_GNS2DNS -e never -c test_gns_lookup.conf | ||
80 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
81 | gnunet-arm -e -c test_gns_lookup.conf | ||
82 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
83 | |||
84 | ret=0 | ||
85 | if echo "$RES_IP" | grep "$TEST_IP" > /dev/null | ||
86 | then | ||
87 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | ||
88 | else | ||
89 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP, wanted $TEST_IP." | ||
90 | ret=1 | ||
91 | fi | ||
92 | |||
93 | if [ "${RES_IP6%?}" = "${TEST_IP6%?}" ] | ||
94 | then | ||
95 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | ||
96 | else | ||
97 | echo "Failed to resolve to proper IP for $TEST_DOMAIN, got $RES_IP6, wanted $TEST_IP6." | ||
98 | ret=1 | ||
99 | fi | ||
100 | |||
101 | if echo "$RES_IP_ALT" | grep "$TEST_IP" > /dev/null | ||
102 | then | ||
103 | echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT." | ||
104 | else | ||
105 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT, got $RES_IP_ALT, wanted $TEST_IP." | ||
106 | ret=1 | ||
107 | fi | ||
108 | |||
109 | if echo "$RES_IP_ALT2" | grep "$TEST_IP_ALT2" > /dev/null | ||
110 | then | ||
111 | echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2." | ||
112 | else | ||
113 | echo "Failed to resolve to proper IP for $TEST_DOMAIN_ALT2, got $RES_IP_ALT2, wanted $TEST_IP_ALT2." | ||
114 | ret=1 | ||
115 | fi | ||
116 | exit $ret | ||
diff --git a/src/cli/gns/test_gns_ipv6_lookup.sh b/src/cli/gns/test_gns_ipv6_lookup.sh new file mode 100755 index 000000000..31e662f68 --- /dev/null +++ b/src/cli/gns/test_gns_ipv6_lookup.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | MY_EGO="myego" | ||
17 | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
19 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
20 | TEST_IP="dead::beef" | ||
21 | gnunet-arm -s -c test_gns_lookup.conf | ||
22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
23 | gnunet-namestore -p -z $MY_EGO -a -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf | ||
24 | sleep 0.5 | ||
25 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t AAAA -c test_gns_lookup.conf` | ||
26 | gnunet-namestore -z $MY_EGO -d -n www -t AAAA -V $TEST_IP -e never -c test_gns_lookup.conf | ||
27 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
28 | gnunet-arm -e -c test_gns_lookup.conf | ||
29 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
30 | |||
31 | if [ "$RES_IP" = "$TEST_IP" ] | ||
32 | then | ||
33 | exit 0 | ||
34 | else | ||
35 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
36 | exit 1 | ||
37 | fi | ||
diff --git a/src/cli/gns/test_gns_lightest.sh b/src/cli/gns/test_gns_lightest.sh new file mode 100755 index 000000000..2d2203e66 --- /dev/null +++ b/src/cli/gns/test_gns_lightest.sh | |||
@@ -0,0 +1,141 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | START_EGO="startego" | ||
20 | MY_EGO="test-lightest" | ||
21 | LABEL="test-scheme" | ||
22 | PTR_LABEL="test-ptr" | ||
23 | TEST_URI="10 1 \"https://ec.europa.eu/tools/lotl/eu-lotl.xml\"" | ||
24 | TEST_SMIMEA="3 0 1 f7e8e4e554fb7c7a8f6f360e0ca2f59d466c8f9539a25963f5ed37e905f0c797" | ||
25 | SCHEME="_scheme" | ||
26 | TRUST="_trust" | ||
27 | TRANSLATION="_translation" | ||
28 | TEST_PTR="$SCHEME.$TRUST.$LABEL.$MY_EGO.$START_EGO" | ||
29 | TEST_PTR2="$TRANSLATION.$TRUST.$LABEL.$MY_EGO.$START_EGO" | ||
30 | gnunet-arm -s -c test_gns_lookup.conf | ||
31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
32 | gnunet-identity -C $START_EGO -c test_gns_lookup.conf | ||
33 | PKEY=`gnunet-identity -d -e $MY_EGO -q -c test_gns_lookup.conf` | ||
34 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "49152 49152 12 $TEST_PTR" -e never -c test_gns_lookup.conf | ||
35 | gnunet-namestore -p -z $MY_EGO -a -n $PTR_LABEL -t BOX -V "49152 49153 12 $TEST_PTR2" -e never -c test_gns_lookup.conf | ||
36 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
37 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
38 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49153 256 $TEST_URI" -e never -c test_gns_lookup.conf | ||
39 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49153 53 $TEST_SMIMEA" -e never -c test_gns_lookup.conf | ||
40 | gnunet-namestore -p -z $START_EGO -a -n $MY_EGO -t PKEY -V "$PKEY" -e never -c test_gns_lookup.conf | ||
41 | sleep 0.5 | ||
42 | PTR_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $SCHEME.$TRUST.$PTR_LABEL.$MY_EGO.$START_EGO -t PTR -c test_gns_lookup.conf` | ||
43 | PTR_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $TRANSLATION.$TRUST.$PTR_LABEL.$MY_EGO.$START_EGO -t PTR -c test_gns_lookup.conf` | ||
44 | |||
45 | SUCCESS=0 | ||
46 | if [ "$PTR_SCHEME" != "$TEST_PTR" ] | ||
47 | then | ||
48 | echo "Failed to resolve to proper PTR, got '$PTR_SCHEME'." | ||
49 | SUCCESS=1 | ||
50 | else | ||
51 | echo "Resolved to proper PTR, got '$PTR_SCHEME'." | ||
52 | fi | ||
53 | |||
54 | if [ "$PTR_TRANSLATION" != "$TEST_PTR2" ] | ||
55 | then | ||
56 | echo "Failed to resolve to proper PTR, got '$PTR_TRANSLATION'." | ||
57 | SUCCESS=1 | ||
58 | else | ||
59 | echo "Resolved to proper PTR, got '$PTR_TRANSLATION'." | ||
60 | fi | ||
61 | |||
62 | if [ "$SUCCESS" = "1" ] | ||
63 | then | ||
64 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
65 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
66 | gnunet-arm -e -c test_gns_lookup.conf | ||
67 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
68 | exit 1 | ||
69 | fi | ||
70 | |||
71 | |||
72 | RES_URI_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t URI -c test_gns_lookup.conf` | ||
73 | RES_SMIMEA_SCHEME=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_SCHEME -t SMIMEA -c test_gns_lookup.conf` | ||
74 | |||
75 | RES_URI_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRANSLATION -t URI -c test_gns_lookup.conf` | ||
76 | RES_SMIMEA_TRANSLATION=`$DO_TIMEOUT gnunet-gns --raw -u $PTR_TRANSLATION -t SMIMEA -c test_gns_lookup.conf` | ||
77 | |||
78 | |||
79 | if [ "$RES_URI_SCHEME" != "$TEST_URI" ] | ||
80 | then | ||
81 | echo "Failed to resolve to proper URI, got '$RES_URI_SCHEME'." | ||
82 | SUCCESS=1 | ||
83 | else | ||
84 | echo "Resolved to proper URI, got '$RES_URI_SCHEME'." | ||
85 | fi | ||
86 | |||
87 | if [ "$RES_SMIMEA_SCHEME" != "$TEST_SMIMEA" ] | ||
88 | then | ||
89 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
90 | SUCCESS=1 | ||
91 | else | ||
92 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_SCHEME'." | ||
93 | fi | ||
94 | |||
95 | if [ "$RES_URI_TRANSLATION" != "$TEST_URI" ] | ||
96 | then | ||
97 | echo "Failed to resolve to proper URI, got '$RES_URI_TRANSLATION'." | ||
98 | SUCCESS=1 | ||
99 | else | ||
100 | echo "Resolved to proper URI, got '$RES_URI_TRANSLATION'." | ||
101 | fi | ||
102 | |||
103 | if [ "$RES_SMIMEA_TRANSLATION" != "$TEST_SMIMEA" ] | ||
104 | then | ||
105 | echo "Failed to resolve to proper SMIMEA, got '$RES_SMIMEA_TRANSLATION'." | ||
106 | SUCCESS=1 | ||
107 | else | ||
108 | echo "Resolved to proper SMIMEA, got '$RES_SMIMEA_TRANSLATION'." | ||
109 | fi | ||
110 | |||
111 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 10 1 \"thisisnotavaliduri\"" -e never -c test_gns_lookup.conf | ||
112 | status=$? | ||
113 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t BOX -V "49152 49152 256 10 1 mailto:thisrecordismalformed@test.com" -e never -c test_gns_lookup.conf | ||
114 | status2=$? | ||
115 | |||
116 | if [ "$status" = "0" ] | ||
117 | then | ||
118 | echo "Failed to detect malformed URI." | ||
119 | SUCCESS=1 | ||
120 | else | ||
121 | echo "Detected malformed URI." | ||
122 | fi | ||
123 | |||
124 | if [ "$status2" = "0" ] | ||
125 | then | ||
126 | echo "Failed to detect malformed URI Record Presentation." | ||
127 | SUCCESS=1 | ||
128 | else | ||
129 | echo "Detected malformed URI Presentation." | ||
130 | fi | ||
131 | |||
132 | |||
133 | |||
134 | gnunet-namestore -z $MY_EGO -X -c test_gns_lookup.conf | ||
135 | gnunet-namestore -z $START_EGO -X -c test_gns_lookup.conf | ||
136 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
137 | gnunet-identity -D $START_EGO -c test_gns_lookup.conf | ||
138 | gnunet-arm -e -c test_gns_lookup.conf | ||
139 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
140 | |||
141 | exit $SUCCESS \ No newline at end of file | ||
diff --git a/src/cli/gns/test_gns_lookup.conf b/src/cli/gns/test_gns_lookup.conf new file mode 100644 index 000000000..46e89a64d --- /dev/null +++ b/src/cli/gns/test_gns_lookup.conf | |||
@@ -0,0 +1,65 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | ||
2 | |||
3 | [namecache] | ||
4 | DISABLE = NO | ||
5 | |||
6 | [PATHS] | ||
7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ | ||
8 | |||
9 | [dht] | ||
10 | START_ON_DEMAND = YES | ||
11 | |||
12 | [gns] | ||
13 | # PREFIX = valgrind --leak-check=full --track-origins=yes | ||
14 | START_ON_DEMAND = YES | ||
15 | AUTO_IMPORT_PKEY = YES | ||
16 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
17 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
18 | RECORD_PUT_INTERVAL = 1 h | ||
19 | ZONE_PUBLISH_TIME_WINDOW = 1 h | ||
20 | DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
21 | |||
22 | [namestore] | ||
23 | #PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/ns_log | ||
24 | |||
25 | [zonemaster] | ||
26 | IMMEDIATE_START = YES | ||
27 | START_ON_DEMAND = YES | ||
28 | |||
29 | [rest] | ||
30 | BASIC_AUTH_ENABLED=NO | ||
31 | |||
32 | [revocation] | ||
33 | WORKBITS = 2 | ||
34 | EPOCH_DURATION = 365 d | ||
35 | |||
36 | [dhtcache] | ||
37 | QUOTA = 1 MB | ||
38 | DATABASE = heap | ||
39 | |||
40 | [topology] | ||
41 | TARGET-CONNECTION-COUNT = 16 | ||
42 | AUTOCONNECT = YES | ||
43 | FRIENDS-ONLY = NO | ||
44 | MINIMUM-FRIENDS = 0 | ||
45 | |||
46 | [ats] | ||
47 | WAN_QUOTA_IN = 1 GB | ||
48 | WAN_QUOTA_OUT = 1 GB | ||
49 | |||
50 | [transport] | ||
51 | plugins = tcp | ||
52 | NEIGHBOUR_LIMIT = 50 | ||
53 | PORT = 2091 | ||
54 | |||
55 | [transport-tcp] | ||
56 | TIMEOUT = 300 s | ||
57 | |||
58 | [nat] | ||
59 | DISABLEV6 = YES | ||
60 | BINDTO = 127.0.0.1 | ||
61 | ENABLE_UPNP = NO | ||
62 | BEHIND_NAT = NO | ||
63 | ALLOW_NAT = NO | ||
64 | INTERNAL_ADDRESS = 127.0.0.1 | ||
65 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
diff --git a/src/cli/gns/test_gns_lookup.sh b/src/cli/gns/test_gns_lookup.sh new file mode 100755 index 000000000..92dfae28b --- /dev/null +++ b/src/cli/gns/test_gns_lookup.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | TEST_IP="127.0.0.1" | ||
20 | MY_EGO="myego" | ||
21 | LABEL="www" | ||
22 | gnunet-arm -s -c test_gns_lookup.conf | ||
23 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
24 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
25 | sleep 0.5 | ||
26 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
27 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
28 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
29 | gnunet-arm -e -c test_gns_lookup.conf | ||
30 | |||
31 | if [ "$RES_IP" = "$TEST_IP" ] | ||
32 | then | ||
33 | exit 0 | ||
34 | else | ||
35 | echo "FAIL: Failed to resolve to proper IP, got $RES_IP." | ||
36 | exit 1 | ||
37 | fi | ||
diff --git a/src/cli/gns/test_gns_lookup_peer1.conf b/src/cli/gns/test_gns_lookup_peer1.conf new file mode 100644 index 000000000..69e2f0973 --- /dev/null +++ b/src/cli/gns/test_gns_lookup_peer1.conf | |||
@@ -0,0 +1,75 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | ||
2 | |||
3 | [namecache] | ||
4 | DISABLE = YES | ||
5 | |||
6 | [PATHS] | ||
7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-1/ | ||
8 | GNUNET_RUNTIME_DIR = $GNUNET_TMP/test-gnunet-gns-peer-1-system-runtime/ | ||
9 | GNUNET_USER_RUNTIME_DIR = $GNUNET_TMP/test-gnunet-gns-peer-1-user-runtime/ | ||
10 | |||
11 | [dht] | ||
12 | START_ON_DEMAND = YES | ||
13 | IMMEDIATE_START = YES | ||
14 | |||
15 | [gns] | ||
16 | # PREFIX = valgrind --leak-check=full --track-origins=yes | ||
17 | START_ON_DEMAND = YES | ||
18 | AUTO_IMPORT_PKEY = YES | ||
19 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
20 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
21 | RECORD_PUT_INTERVAL = 1 h | ||
22 | ZONE_PUBLISH_TIME_WINDOW = 1 h | ||
23 | DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
24 | |||
25 | [namestore] | ||
26 | IMMEDIATE_START = YES | ||
27 | #PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/ns_log | ||
28 | |||
29 | [revocation] | ||
30 | WORKBITS = 1 | ||
31 | |||
32 | [dhtcache] | ||
33 | QUOTA = 1 MB | ||
34 | DATABASE = heap | ||
35 | |||
36 | [topology] | ||
37 | TARGET-CONNECTION-COUNT = 16 | ||
38 | AUTOCONNECT = YES | ||
39 | FRIENDS-ONLY = NO | ||
40 | MINIMUM-FRIENDS = 0 | ||
41 | |||
42 | [ats] | ||
43 | WAN_QUOTA_IN = 1 GB | ||
44 | WAN_QUOTA_OUT = 1 GB | ||
45 | |||
46 | [transport] | ||
47 | plugins = unix | ||
48 | NEIGHBOUR_LIMIT = 50 | ||
49 | PORT = 2091 | ||
50 | |||
51 | [transport-unix] | ||
52 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-transport-plugin-unix1.sock | ||
53 | |||
54 | [hostlist] | ||
55 | SERVERS = http://localhost:9999/ | ||
56 | OPTIONS = -b | ||
57 | IMMEDIATE_START = YES | ||
58 | |||
59 | [nat] | ||
60 | DISABLEV6 = YES | ||
61 | BINDTO = 127.0.0.1 | ||
62 | ENABLE_UPNP = NO | ||
63 | BEHIND_NAT = NO | ||
64 | ALLOW_NAT = NO | ||
65 | INTERNAL_ADDRESS = 127.0.0.1 | ||
66 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
67 | |||
68 | [dns2gns] | ||
69 | BINARY = gnunet-dns2gns | ||
70 | START_ON_DEMAND = YES | ||
71 | IMMEDIATE_START = YES | ||
72 | RUN_PER_USER = YES | ||
73 | BIND_TO = 127.0.0.1 | ||
74 | BIND_TO6 = ::1 | ||
75 | OPTIONS = -d 1.1.1.1 -p 12000 | ||
diff --git a/src/cli/gns/test_gns_lookup_peer2.conf b/src/cli/gns/test_gns_lookup_peer2.conf new file mode 100644 index 000000000..3de81d7f3 --- /dev/null +++ b/src/cli/gns/test_gns_lookup_peer2.conf | |||
@@ -0,0 +1,72 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | ||
2 | |||
3 | [namecache] | ||
4 | DISABLE = YES | ||
5 | |||
6 | [PATHS] | ||
7 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-gns-peer-2/ | ||
8 | GNUNET_RUNTIME_DIR = $GNUNET_TMP/test-gnunet-gns-peer-2-runtime/ | ||
9 | GNUNET_USER_RUNTIME_DIR = $GNUNET_TMP/test-gnunet-gns-peer-2-user-runtime/ | ||
10 | |||
11 | [dht] | ||
12 | START_ON_DEMAND = YES | ||
13 | IMMEDIATE_START = YES | ||
14 | |||
15 | [identity] | ||
16 | START_ON_DEMAND = YES | ||
17 | IMMEDIATE_START = YES | ||
18 | |||
19 | [gns] | ||
20 | # PREFIX = valgrind --leak-check=full --track-origins=yes | ||
21 | IMMEDIATE_START = YES | ||
22 | START_ON_DEMAND = YES | ||
23 | AUTO_IMPORT_PKEY = YES | ||
24 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
25 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
26 | RECORD_PUT_INTERVAL = 1 h | ||
27 | ZONE_PUBLISH_TIME_WINDOW = 1 h | ||
28 | DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
29 | |||
30 | [namestore] | ||
31 | IMMEDIATE_START = YES | ||
32 | #PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/ns_log | ||
33 | |||
34 | [revocation] | ||
35 | WORKBITS = 1 | ||
36 | |||
37 | [dhtcache] | ||
38 | QUOTA = 1 MB | ||
39 | DATABASE = heap | ||
40 | |||
41 | [topology] | ||
42 | TARGET-CONNECTION-COUNT = 16 | ||
43 | AUTOCONNECT = YES | ||
44 | FRIENDS-ONLY = NO | ||
45 | MINIMUM-FRIENDS = 0 | ||
46 | |||
47 | [hostlist] | ||
48 | SERVERS = | ||
49 | HTTPPORT = 9999 | ||
50 | OPTIONS = -p | ||
51 | IMMEDIATE_START = YES | ||
52 | |||
53 | |||
54 | [ats] | ||
55 | WAN_QUOTA_IN = 1 GB | ||
56 | WAN_QUOTA_OUT = 1 GB | ||
57 | |||
58 | [transport] | ||
59 | plugins = unix | ||
60 | NEIGHBOUR_LIMIT = 50 | ||
61 | |||
62 | [transport-unix] | ||
63 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-transport-plugin-unix2.sock | ||
64 | |||
65 | [nat] | ||
66 | DISABLEV6 = YES | ||
67 | BINDTO = 127.0.0.1 | ||
68 | ENABLE_UPNP = NO | ||
69 | BEHIND_NAT = NO | ||
70 | ALLOW_NAT = NO | ||
71 | INTERNAL_ADDRESS = 127.0.0.1 | ||
72 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
diff --git a/src/cli/gns/test_gns_multiple_record_lookup.sh b/src/cli/gns/test_gns_multiple_record_lookup.sh new file mode 100755 index 000000000..52a487329 --- /dev/null +++ b/src/cli/gns/test_gns_multiple_record_lookup.sh | |||
@@ -0,0 +1,95 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup_peer1.conf" INT | ||
4 | trap "gnunet-arm -e -c test_gns_lookup_peer2.conf" INT | ||
5 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
6 | |||
7 | unset XDG_DATA_HOME | ||
8 | unset XDG_CONFIG_HOME | ||
9 | unset XDG_CACHE_HOME | ||
10 | |||
11 | LOCATION=$(which gnunet-config) | ||
12 | if [ -z $LOCATION ] | ||
13 | then | ||
14 | LOCATION="gnunet-config" | ||
15 | fi | ||
16 | $LOCATION --version 1> /dev/null | ||
17 | if test $? != 0 | ||
18 | then | ||
19 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
20 | exit 77 | ||
21 | fi | ||
22 | |||
23 | rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` | ||
24 | rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` | ||
25 | OTHER_EGO="remoteego" | ||
26 | |||
27 | TEST_IP="127.0.0.1" | ||
28 | TEST_IPV6="dead::beef" | ||
29 | LABEL="fnord" | ||
30 | |||
31 | gnunet-arm -s -c test_gns_lookup_peer2.conf | ||
32 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup_peer2.conf | ||
33 | PKEY=`$DO_TIMEOUT gnunet-identity -d -c test_gns_lookup_peer2.conf | grep $OTHER_EGO | awk '{print $3}'` | ||
34 | |||
35 | # Note: if zonemaster is kept running, it MAY publish the "A" record in the | ||
36 | # DHT immediately and then _LATER_ also the "AAAA" record. But as then there | ||
37 | # will be TWO valid blocks in the DHT (one with only A and one with A and | ||
38 | # AAAA), the subsequent GET for both may fail and only return the result with | ||
39 | # just the "A" record). | ||
40 | # If we _waited_ until the original block with just "A" expired, everything | ||
41 | # would be fine, but we don't want to do that for the test, so we | ||
42 | # simply pause publishing to the DHT until all records are defined. | ||
43 | # In the future, it would be good to have an enhanced gnunet-namestore command | ||
44 | # that would read a series of changes to be made to a record set from | ||
45 | # stdin and do them _all_ *atomically*. Then we would not need to do this. | ||
46 | |||
47 | gnunet-arm -c test_gns_lookup_peer2.conf -k zonemaster | ||
48 | |||
49 | gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t A -V $TEST_IP -e 3600s -c test_gns_lookup_peer2.conf | ||
50 | gnunet-namestore -p -z $OTHER_EGO -a -n $LABEL -t AAAA -V $TEST_IPV6 -e 3600s -c test_gns_lookup_peer2.conf | ||
51 | gnunet-namestore -D -z $OTHER_EGO -n $LABEL -c test_gns_lookup_peer2.conf | ||
52 | |||
53 | gnunet-arm -c test_gns_lookup_peer2.conf -i zonemaster | ||
54 | |||
55 | gnunet-arm -s -c test_gns_lookup_peer1.conf | ||
56 | |||
57 | |||
58 | RESP=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t ANY -c test_gns_lookup_peer1.conf` | ||
59 | RESP1=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t A -c test_gns_lookup_peer1.conf` | ||
60 | RESP2=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$PKEY -t AAAA -c test_gns_lookup_peer1.conf` | ||
61 | |||
62 | echo "$LABEL.$PKEY" | ||
63 | echo $RESP $RESP1 $RESP2 | ||
64 | |||
65 | gnunet-arm -e -c test_gns_lookup_peer1.conf | ||
66 | gnunet-arm -e -c test_gns_lookup_peer2.conf | ||
67 | |||
68 | gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME | ||
69 | |||
70 | rm -rf `gnunet-config -c test_gns_lookup_peer1.conf -f -s paths -o GNUNET_TEST_HOME` | ||
71 | rm -rf `gnunet-config -c test_gns_lookup_peer2.conf -f -s paths -o GNUNET_TEST_HOME` | ||
72 | |||
73 | RESPONSES=($(echo $RESP | tr "\n" " " )) | ||
74 | |||
75 | if [ "$RESP1" == "$TEST_IP" ] | ||
76 | then | ||
77 | echo "PASS: A record resolution from DHT via separate peer" | ||
78 | else | ||
79 | echo "FAIL: A record resolution from DHT via separate peer, got $RESP1, expected $TEST_IP" | ||
80 | exit 1 | ||
81 | fi | ||
82 | if [ "$RESP2" == "$TEST_IPV6" ] | ||
83 | then | ||
84 | echo "PASS: AAAA record resolution from DHT via separate peer" | ||
85 | else | ||
86 | echo "FAIL: AAAA record resolution from DHT via separate peer, got $RESP2, expected $TEST_IPV6" | ||
87 | exit 1 | ||
88 | fi | ||
89 | if [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IPV6 $TEST_IP" ]] || [[ "${RESPONSES[0]} ${RESPONSES[1]}" == "$TEST_IP $TEST_IPV6" ]] | ||
90 | then | ||
91 | echo "PASS: ANY record resolution from DHT via separate peer" | ||
92 | else | ||
93 | echo "FAIL: ANY record resolution from DHT via separate peer, got $RESP, expected $TEST_IPV6 $TEST_IP or $TEST_IP $TEST_IPV6" | ||
94 | exit 1 | ||
95 | fi | ||
diff --git a/src/cli/gns/test_gns_mx_lookup.sh b/src/cli/gns/test_gns_mx_lookup.sh new file mode 100755 index 000000000..6f2b8192d --- /dev/null +++ b/src/cli/gns/test_gns_mx_lookup.sh | |||
@@ -0,0 +1,44 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
19 | |||
20 | MY_EGO="myego" | ||
21 | TEST_MX="5 mail.+" | ||
22 | gnunet-arm -s -c test_gns_lookup.conf | ||
23 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
24 | PKEY=`gnunet-identity -d | grep "$MY_EGO - " | awk '{print $3'}` | ||
25 | WANT_MX="5 mail.$PKEY" | ||
26 | gnunet-namestore -p -z $MY_EGO -a -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf | ||
27 | sleep 0.5 | ||
28 | RES_MX=`$DO_TIMEOUT gnunet-gns --raw -u www.$MY_EGO -t MX -c test_gns_lookup.conf` | ||
29 | gnunet-namestore -z $MY_EGO -d -n www -t MX -V "$TEST_MX" -e never -c test_gns_lookup.conf | ||
30 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
31 | gnunet-arm -e -c test_gns_lookup.conf | ||
32 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
33 | |||
34 | # make cmp case-insensitive by converting to lower case first | ||
35 | RES_MX=`echo $RES_MX | tr [A-Z] [a-z]` | ||
36 | WANT_MX=`echo $WANT_MX | tr [A-Z] [a-z]` | ||
37 | |||
38 | if [ "$RES_MX" = "$WANT_MX" ] | ||
39 | then | ||
40 | exit 0 | ||
41 | else | ||
42 | echo "FAIL: did not get proper IP, got $RES_MX, expected $WANT_MX." | ||
43 | exit 1 | ||
44 | fi | ||
diff --git a/src/cli/gns/test_gns_quickupdate.sh b/src/cli/gns/test_gns_quickupdate.sh new file mode 100755 index 000000000..eac69103d --- /dev/null +++ b/src/cli/gns/test_gns_quickupdate.sh | |||
@@ -0,0 +1,65 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | MY_EGO="myego" | ||
18 | OTHER_EGO="delegatedego" | ||
19 | |||
20 | |||
21 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
22 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
23 | TEST_IP="127.0.0.1" | ||
24 | gnunet-arm -s -c test_gns_lookup.conf | ||
25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
26 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | ||
27 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | ||
28 | gnunet-arm -i gns -c test_gns_lookup.conf | ||
29 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
30 | # Give GNS/namestore time to fully start and finish initial iteration | ||
31 | sleep 2 | ||
32 | # Performing namestore update | ||
33 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
34 | # Give GNS chance to observe store event via monitor | ||
35 | sleep 1 | ||
36 | gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
37 | # give GNS chance to process monitor event | ||
38 | sleep 1 | ||
39 | # stop everything and restart to check that DHT PUT did happen | ||
40 | gnunet-arm -k gns -c test_gns_lookup.conf | ||
41 | gnunet-arm -k namestore -c test_gns_lookup.conf | ||
42 | gnunet-arm -k namecache -c test_gns_lookup.conf | ||
43 | gnunet-arm -k zonemaster -c test_gns_lookup.conf | ||
44 | # Purge nameacache, as we might otherwise fetch from there | ||
45 | # FIXME: testcase started failing after the line below was fixed by adding '-f', | ||
46 | # might have never worked (!) | ||
47 | rm -r `gnunet-config -f -c test_gns_lookup.conf -s namecache-sqlite -o FILENAME` | ||
48 | gnunet-arm -i namestore -c test_gns_lookup.conf | ||
49 | gnunet-arm -i namecache -c test_gns_lookup.conf | ||
50 | gnunet-arm -i zonemaster -c test_gns_lookup.conf | ||
51 | gnunet-arm -i gns -c test_gns_lookup.conf | ||
52 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
53 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
54 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
55 | gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf | ||
56 | gnunet-arm -e -c test_gns_lookup.conf | ||
57 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
58 | |||
59 | if [ "$RES_IP" = "$TEST_IP" ] | ||
60 | then | ||
61 | exit 0 | ||
62 | else | ||
63 | echo "Failed to properly resolve IP, expected $TEST_IP, got $RES_IP." | ||
64 | exit 1 | ||
65 | fi | ||
diff --git a/src/cli/gns/test_gns_redirect_lookup.sh b/src/cli/gns/test_gns_redirect_lookup.sh new file mode 100755 index 000000000..90729713d --- /dev/null +++ b/src/cli/gns/test_gns_redirect_lookup.sh | |||
@@ -0,0 +1,100 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | # permissive DNS resolver we will use for the test | ||
18 | DNS_RESOLVER="8.8.8.8" | ||
19 | if ! nslookup gnunet.org $DNS_RESOLVER > /dev/null 2>&1 | ||
20 | then | ||
21 | echo "Cannot reach DNS, skipping test" | ||
22 | exit 77 | ||
23 | fi | ||
24 | |||
25 | |||
26 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
27 | |||
28 | TEST_IP_PLUS="127.0.0.1" | ||
29 | TEST_IP_DNS="147.87.255.218" | ||
30 | TEST_RECORD_REDIRECT_SERVER="server" | ||
31 | TEST_RECORD_REDIRECT_PLUS="server.+" | ||
32 | TEST_RECORD_REDIRECT_DNS="gnunet.org" | ||
33 | TEST_RECORD_NAME_SERVER="server" | ||
34 | TEST_RECORD_NAME_PLUS="www" | ||
35 | TEST_RECORD_NAME_ZKEY="www2" | ||
36 | TEST_RECORD_NAME_DNS="www3" | ||
37 | MY_EGO="myego" | ||
38 | TEST_DOMAIN_PLUS="www.$MY_EGO" | ||
39 | TEST_DOMAIN_ZKEY="www2.$MY_EGO" | ||
40 | TEST_DOMAIN_DNS="www3.$MY_EGO" | ||
41 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" | ||
42 | |||
43 | gnunet-arm -s -c test_gns_lookup.conf | ||
44 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
45 | MY_EGO_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep ${MY_EGO} | awk '{print $3}') | ||
46 | TEST_RECORD_REDIRECT_ZKEY="server.${MY_EGO_PKEY}" | ||
47 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_DNS -t REDIRECT -V $TEST_RECORD_REDIRECT_DNS -e never -c test_gns_lookup.conf | ||
48 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_PLUS -t REDIRECT -V $TEST_RECORD_REDIRECT_PLUS -e never -c test_gns_lookup.conf | ||
49 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME_ZKEY -t REDIRECT -V $TEST_RECORD_REDIRECT_ZKEY -e never -c test_gns_lookup.conf | ||
50 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_REDIRECT_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf | ||
51 | sleep 1 | ||
52 | RES_REDIRECT=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t A -c test_gns_lookup.conf` | ||
53 | RES_REDIRECT_RAW=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_PLUS -t REDIRECT -c test_gns_lookup.conf` | ||
54 | RES_REDIRECT_ZKEY=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_ZKEY -t A -c test_gns_lookup.conf` | ||
55 | RES_REDIRECT_DNS=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN_DNS -t A -c test_gns_lookup.conf | grep $TEST_IP_DNS` | ||
56 | |||
57 | TESTEGOZONE=`gnunet-identity -c test_gns_lookup.conf -d | awk '{print $3}'` | ||
58 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_DNS -t REDIRECT -V $TEST_RECORD_REDIRECT_DNS -e never -c test_gns_lookup.conf | ||
59 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_PLUS -t REDIRECT -V $TEST_RECORD_REDIRECT_PLUS -e never -c test_gns_lookup.conf | ||
60 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_NAME_ZKEY -t REDIRECT -V $TEST_RECORD_REDIRECT_ZKEY -e never -c test_gns_lookup.conf | ||
61 | gnunet-namestore -p -z $MY_EGO -d -n $TEST_RECORD_REDIRECT_SERVER -t A -V $TEST_IP_PLUS -e never -c test_gns_lookup.conf | ||
62 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
63 | gnunet-arm -e -c test_gns_lookup.conf | ||
64 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
65 | |||
66 | # make cmp case-insensitive by converting to lower case first | ||
67 | RES_REDIRECT_RAW=`echo $RES_REDIRECT_RAW | tr [A-Z] [a-z]` | ||
68 | TESTEGOZONE=`echo $TESTEGOZONE | tr [A-Z] [a-z]` | ||
69 | if [ "$RES_REDIRECT_RAW" = "server.$TESTEGOZONE" ] | ||
70 | then | ||
71 | echo "PASS: REDIRECT resolution from GNS" | ||
72 | else | ||
73 | echo "FAIL: REDIRECT resolution from GNS, got $RES_REDIRECT_RAW, expected server.$TESTEGOZONE." | ||
74 | exit 1 | ||
75 | fi | ||
76 | |||
77 | if [ "$RES_REDIRECT" = "$TEST_IP_PLUS" ] | ||
78 | then | ||
79 | echo "PASS: IP resolution from GNS (.+)" | ||
80 | else | ||
81 | echo "FAIL: IP resolution from GNS (.+), got $RES_REDIRECT, expected $TEST_IP_PLUS." | ||
82 | exit 1 | ||
83 | fi | ||
84 | |||
85 | if [ "$RES_REDIRECT_ZKEY" = "$TEST_IP_PLUS" ] | ||
86 | then | ||
87 | echo "PASS: IP resolution from GNS (.zkey)" | ||
88 | else | ||
89 | echo "FAIL: IP resolution from GNS (.zkey), got $RES_REDIRECT, expected $TEST_IP_PLUS." | ||
90 | exit 1 | ||
91 | fi | ||
92 | |||
93 | if echo "$RES_REDIRECT_DNS" | grep "$TEST_IP_DNS" > /dev/null | ||
94 | then | ||
95 | echo "PASS: IP resolution from DNS" | ||
96 | exit 0 | ||
97 | else | ||
98 | echo "FAIL: IP resolution from DNS, got $RES_REDIRECT_DNS, expected $TEST_IP_DNS." | ||
99 | exit 1 | ||
100 | fi | ||
diff --git a/src/cli/gns/test_gns_rel_expiration.sh b/src/cli/gns/test_gns_rel_expiration.sh new file mode 100755 index 000000000..a240cfd0f --- /dev/null +++ b/src/cli/gns/test_gns_rel_expiration.sh | |||
@@ -0,0 +1,64 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | |||
11 | if [ -z $(which timeout) ] | ||
12 | then | ||
13 | echo "timeout utility not found which is required for test." | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | $LOCATION --version 1> /dev/null | ||
18 | if test $? != 0 | ||
19 | then | ||
20 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
21 | exit 77 | ||
22 | fi | ||
23 | |||
24 | MY_EGO="myego" | ||
25 | OTHER_EGO="delegatedego" | ||
26 | |||
27 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
28 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
29 | TEST_IP="127.0.0.1" | ||
30 | gnunet-arm -s -c test_gns_lookup.conf | ||
31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
32 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | ||
33 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | ||
34 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
35 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | ||
36 | gnunet-arm -i gns -c test_gns_lookup.conf | ||
37 | sleep 0.5 | ||
38 | # confirm that lookup currently works | ||
39 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
40 | # remove entry | ||
41 | gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e '5 s' -c test_gns_lookup.conf | ||
42 | # wait for old entry with 5s 'expiration' to definitively expire | ||
43 | sleep 6 | ||
44 | # try again, should no longer work | ||
45 | RES_IP_EXP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
46 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
47 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
48 | gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf | ||
49 | gnunet-arm -e -c test_gns_lookup.conf | ||
50 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
51 | |||
52 | if [ "$RES_IP_EXP" = "$TEST_IP" ] | ||
53 | then | ||
54 | echo "Failed to properly expire IP, got $RES_IP_EXP." | ||
55 | exit 1 | ||
56 | fi | ||
57 | |||
58 | if [ "$RES_IP" = "$TEST_IP" ] | ||
59 | then | ||
60 | exit 0 | ||
61 | else | ||
62 | echo "Failed to properly resolve IP, got $RES_IP." | ||
63 | exit 1 | ||
64 | fi | ||
diff --git a/src/cli/gns/test_gns_revocation.sh b/src/cli/gns/test_gns_revocation.sh new file mode 100755 index 000000000..2253adcb4 --- /dev/null +++ b/src/cli/gns/test_gns_revocation.sh | |||
@@ -0,0 +1,50 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
5 | |||
6 | LOCATION=$(which gnunet-config) | ||
7 | if [ -z $LOCATION ] | ||
8 | then | ||
9 | LOCATION="gnunet-config" | ||
10 | fi | ||
11 | $LOCATION --version 1> /dev/null | ||
12 | if test $? != 0 | ||
13 | then | ||
14 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
15 | exit 77 | ||
16 | fi | ||
17 | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
19 | MY_EGO="myego" | ||
20 | OTHER_EGO="delegatedego" | ||
21 | TEST_IP="127.0.0.1" | ||
22 | |||
23 | gnunet-arm -s -c test_gns_lookup.conf | ||
24 | gnunet-identity -C $OTHER_EGO -c test_gns_lookup.conf | ||
25 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep $OTHER_EGO | awk '{print $3}') | ||
26 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
27 | gnunet-namestore -p -z $MY_EGO -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
28 | gnunet-namestore -p -z $OTHER_EGO -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
29 | sleep 1 | ||
30 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
31 | gnunet-revocation -R $OTHER_EGO -p -c test_gns_lookup.conf | ||
32 | RES_IP_REV=`$DO_TIMEOUT gnunet-gns --raw -u www.b.$MY_EGO -t A -c test_gns_lookup.conf` | ||
33 | gnunet-namestore -z $MY_EGO -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
34 | gnunet-namestore -z $OTHER_EGO -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
35 | gnunet-arm -e -c test_gns_lookup.conf | ||
36 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
37 | |||
38 | if [ "$RES_IP" != "$TEST_IP" ] | ||
39 | then | ||
40 | echo "Failed to resolve to proper IP, got $RES_IP." | ||
41 | exit 1 | ||
42 | fi | ||
43 | |||
44 | if [ "x$RES_IP_REV" = "x" ] | ||
45 | then | ||
46 | exit 0 | ||
47 | else | ||
48 | echo "Failed to revoke zone, got $RES_IP_REV." | ||
49 | exit 1 | ||
50 | fi | ||
diff --git a/src/cli/gns/test_gns_sbox.sh b/src/cli/gns/test_gns_sbox.sh new file mode 100755 index 000000000..6918bf130 --- /dev/null +++ b/src/cli/gns/test_gns_sbox.sh | |||
@@ -0,0 +1,121 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 7" | ||
19 | TEST_A="139.134.54.9" | ||
20 | MY_EGO="myego" | ||
21 | LABEL="testsbox" | ||
22 | PREFIX1="_name" | ||
23 | PREFIX2="__" | ||
24 | PREFIX3="_a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_" | ||
25 | PREFIX4="abcdefghijklmnopqrstuvwxyz.abcdefghijklmnopqrstuvwxyz._abc" | ||
26 | PREFIX5="abc.abc._abc.abc" | ||
27 | PREFIX6="abc.abc._abc.abc._abc" | ||
28 | PREFIX7="abc.abc._abc.abc._abc.abc" | ||
29 | PREFIX8="_at" | ||
30 | gnunet-arm -s -c test_gns_lookup.conf | ||
31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
32 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX1 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
33 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX2 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
34 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX3 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
35 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX4 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
36 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX5 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
37 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX6 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
38 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t SBOX -V "$PREFIX7 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
39 | gnunet-namestore -p -z $MY_EGO -a -n '@' -t SBOX -V "$PREFIX8 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
40 | sleep 0.5 | ||
41 | RES_A1=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX1.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
42 | RES_A2=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX2.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
43 | RES_A3=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX3.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
44 | RES_A4=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX4.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
45 | RES_A5=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX5.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
46 | RES_A6=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX6.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
47 | RES_A7=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX7.$LABEL.$MY_EGO -t A -c test_gns_lookup.conf` | ||
48 | RES_A8=`$DO_TIMEOUT gnunet-gns --raw -u $PREFIX8.$MY_EGO -t A -c test_gns_lookup.conf` | ||
49 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$PREFIX1 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
50 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$PREFIX2 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
51 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$PREFIX3 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
52 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$PREFIX4 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
53 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t SBOX -V "$PREFIX6 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
54 | gnunet-namestore -z $MY_EGO -d -n '@' -t SBOX -V "$PREFIX8 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
55 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
56 | gnunet-arm -e -c test_gns_lookup.conf | ||
57 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
58 | |||
59 | if [ "$RES_A1" = "$TEST_A" ] | ||
60 | then | ||
61 | exit 0 | ||
62 | else | ||
63 | echo "Failed to resolve to proper A, got '$RES_A1'." | ||
64 | exit 1 | ||
65 | fi | ||
66 | |||
67 | if [ "$RES_A2" = "$TEST_A" ] | ||
68 | then | ||
69 | exit 0 | ||
70 | else | ||
71 | echo "Failed to resolve to proper A, got '$RES_A2'." | ||
72 | exit 1 | ||
73 | fi | ||
74 | |||
75 | if [ "$RES_A3" = "$TEST_A" ] | ||
76 | then | ||
77 | exit 0 | ||
78 | else | ||
79 | echo "Failed to resolve to proper A, got '$RES_A3'." | ||
80 | exit 1 | ||
81 | fi | ||
82 | |||
83 | if [ "$RES_A4" = "$TEST_A" ] | ||
84 | then | ||
85 | exit 0 | ||
86 | else | ||
87 | echo "Failed to resolve to proper A, got '$RES_A4'." | ||
88 | exit 1 | ||
89 | fi | ||
90 | |||
91 | if [ "$RES_A5" = "$TEST_A" ] | ||
92 | then | ||
93 | echo "Should have failed to resolve to proper A, got '$RES_A5' anyway." | ||
94 | exit 1 | ||
95 | else | ||
96 | exit 0 | ||
97 | fi | ||
98 | |||
99 | if [ "$RES_A6" = "$TEST_A" ] | ||
100 | then | ||
101 | exit 0 | ||
102 | else | ||
103 | echo "Failed to resolve to proper A, got '$RES_A6'." | ||
104 | exit 1 | ||
105 | fi | ||
106 | |||
107 | if [ "$RES_A7" = "$TEST_A" ] | ||
108 | then | ||
109 | echo "Should have failed to resolve to proper A, got '$RES_A7' anyway." | ||
110 | exit 1 | ||
111 | else | ||
112 | exit 0 | ||
113 | fi | ||
114 | |||
115 | if [ "$RES_A8" = "$TEST_A" ] | ||
116 | then | ||
117 | exit 0 | ||
118 | else | ||
119 | echo "Failed to resolve to proper A, got '$RES_A8'." | ||
120 | exit 1 | ||
121 | fi | ||
diff --git a/src/cli/gns/test_gns_sbox_simple.sh b/src/cli/gns/test_gns_sbox_simple.sh new file mode 100755 index 000000000..f0d31e471 --- /dev/null +++ b/src/cli/gns/test_gns_sbox_simple.sh | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | TEST_A="139.134.54.9" | ||
20 | MY_EGO="myego" | ||
21 | HASH="c93f1e400f26708f98cb19d936620da35eec8f72e57f9eec01c1afd6" | ||
22 | PROTOCOL_TEXT="_smimecert" | ||
23 | gnunet-arm -s -c test_gns_lookup.conf | ||
24 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
25 | gnunet-namestore -p -z $MY_EGO -a -n '@' -t SBOX -V "$HASH.$PROTOCOL_TEXT 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
26 | sleep 0.5 | ||
27 | RES_A=`$DO_TIMEOUT gnunet-gns --raw -u $HASH.$PROTOCOL_TEXT.$MY_EGO -t A -c test_gns_lookup.conf` | ||
28 | gnunet-namestore -z $MY_EGO -d -n '@' -t SBOX -V "$HASH.$PROTOCOL_TEXT 1 $TEST_A" -e never -c test_gns_lookup.conf | ||
29 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
30 | gnunet-arm -e -c test_gns_lookup.conf | ||
31 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
32 | |||
33 | if [ "$RES_A" = "$TEST_A" ] | ||
34 | then | ||
35 | exit 0 | ||
36 | else | ||
37 | echo "Failed to resolve to proper A, got '$RES_A'." | ||
38 | exit 1 | ||
39 | fi | ||
diff --git a/src/cli/gns/test_gns_simple_lookup.conf b/src/cli/gns/test_gns_simple_lookup.conf new file mode 100644 index 000000000..374731377 --- /dev/null +++ b/src/cli/gns/test_gns_simple_lookup.conf | |||
@@ -0,0 +1,97 @@ | |||
1 | @INLINE@ test_gns_defaults.conf | ||
2 | [fs] | ||
3 | START_ON_DEMAND = NO | ||
4 | |||
5 | [resolver] | ||
6 | START_ON_DEMAND = YES | ||
7 | HOSTNAME = localhost | ||
8 | |||
9 | [dht] | ||
10 | START_ON_DEMAND = YES | ||
11 | ACCEPT_FROM6 = ::1; | ||
12 | ACCEPT_FROM = 127.0.0.1; | ||
13 | HOSTNAME = localhost | ||
14 | PORT = 12100 | ||
15 | BINARY = gnunet-service-dht | ||
16 | |||
17 | [dhtcache] | ||
18 | QUOTA = 1 MB | ||
19 | DATABASE = heap | ||
20 | |||
21 | [transport] | ||
22 | PLUGINS = tcp | ||
23 | ACCEPT_FROM6 = ::1; | ||
24 | ACCEPT_FROM = 127.0.0.1; | ||
25 | NEIGHBOUR_LIMIT = 50 | ||
26 | PORT = 12365 | ||
27 | |||
28 | [ats] | ||
29 | WAN_QUOTA_IN = 1 GB | ||
30 | WAN_QUOTA_OUT = 1 GB | ||
31 | |||
32 | [core] | ||
33 | PORT = 12092 | ||
34 | |||
35 | [arm] | ||
36 | PORT = 12366 | ||
37 | |||
38 | [transport-tcp] | ||
39 | TIMEOUT = 300 s | ||
40 | PORT = 12368 | ||
41 | BINDTO = 127.0.0.1 | ||
42 | |||
43 | [PATHS] | ||
44 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunetd-gns-peer-1/ | ||
45 | |||
46 | |||
47 | [nat] | ||
48 | DISABLEV6 = YES | ||
49 | ENABLE_UPNP = NO | ||
50 | BEHIND_NAT = NO | ||
51 | ALLOW_NAT = NO | ||
52 | INTERNAL_ADDRESS = 127.0.0.1 | ||
53 | EXTERNAL_ADDRESS = 127.0.0.1 | ||
54 | USE_LOCALADDR = NO | ||
55 | |||
56 | [dns] | ||
57 | START_ON_DEMAND = YES | ||
58 | DNS_EXIT = 8.8.8.8 | ||
59 | |||
60 | [gns] | ||
61 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
62 | START_ON_DEMAND = YES | ||
63 | BINARY = gnunet-service-gns | ||
64 | ZONEKEY = zonefiles/test_zonekey | ||
65 | PRIVATE_ZONE = private | ||
66 | PRIVATE_ZONEKEY = zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey | ||
67 | SHORTEN_ZONE = short | ||
68 | SHORTEN_ZONEKEY = zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey | ||
69 | #ZONEKEY = $GNUNET_TEST_HOME/gns/zonekey.zkey | ||
70 | HIJACK_DNS = NO | ||
71 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-gns.sock | ||
72 | AUTO_IMPORT_PKEY = YES | ||
73 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
74 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
75 | RECORD_PUT_INTERVAL = 1 h | ||
76 | |||
77 | [nse] | ||
78 | START_ON_DEMAND = NO | ||
79 | |||
80 | [statistics] | ||
81 | START_ON_DEMAND = NO | ||
82 | |||
83 | [namestore] | ||
84 | PORT = 22371 | ||
85 | START_ON_DEMAND = YES | ||
86 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-namestore-default.sock | ||
87 | UNIX_MATCH_UID = YES | ||
88 | UNIX_MATCH_GID = YES | ||
89 | HOSTNAME = localhost | ||
90 | BINARY = gnunet-service-namestore | ||
91 | ACCEPT_FROM = 127.0.0.1; | ||
92 | ACCEPT_FROM6 = ::1; | ||
93 | DATABASE = sqlite | ||
94 | ZONEFILE_DIRECTORY = $GNUNET_TEST_HOME | ||
95 | |||
96 | [namestore-sqlite] | ||
97 | FILENAME = $GNUNET_TEST_HOME/sqlite-default.db | ||
diff --git a/src/cli/gns/test_gns_soa_lookup.sh b/src/cli/gns/test_gns_soa_lookup.sh new file mode 100755 index 000000000..a697782bb --- /dev/null +++ b/src/cli/gns/test_gns_soa_lookup.sh | |||
@@ -0,0 +1,51 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
18 | |||
19 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
20 | MY_EGO="myego" | ||
21 | TEST_DOMAIN="homepage.$MY_EGO" | ||
22 | # some public DNS resolver we can use | ||
23 | #TEST_IP_GNS2DNS="184.172.157.218" # This one seems currently down. | ||
24 | TEST_IP_GNS2DNS="8.8.8.8" | ||
25 | TEST_RECORD_NAME="homepage" | ||
26 | TEST_RECORD_GNS2DNS="gnunet.org" | ||
27 | |||
28 | if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS > /dev/null 2>&1 | ||
29 | then | ||
30 | echo "Cannot reach DNS, skipping test" | ||
31 | exit 77 | ||
32 | fi | ||
33 | |||
34 | gnunet-arm -s -c test_gns_lookup.conf | ||
35 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
36 | gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf | ||
37 | sleep 0.5 | ||
38 | RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` | ||
39 | gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf > /dev/null 2>&1 | ||
40 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
41 | gnunet-arm -e -c test_gns_lookup.conf | ||
42 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
43 | |||
44 | if [ "x$RES_SOA" != "x" ] | ||
45 | then | ||
46 | echo "PASS: Resolved SOA for $TEST_DOMAIN to $RES_SOA." | ||
47 | exit 0 | ||
48 | else | ||
49 | echo "Failed to resolve to proper SOA for $TEST_DOMAIN, got no result." | ||
50 | exit 1 | ||
51 | fi | ||
diff --git a/src/cli/gns/test_gns_txt_lookup.sh b/src/cli/gns/test_gns_txt_lookup.sh new file mode 100755 index 000000000..4e36e8ad8 --- /dev/null +++ b/src/cli/gns/test_gns_txt_lookup.sh | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | |||
5 | LOCATION=$(which gnunet-config) | ||
6 | if [ -z $LOCATION ] | ||
7 | then | ||
8 | LOCATION="gnunet-config" | ||
9 | fi | ||
10 | $LOCATION --version 1> /dev/null | ||
11 | if test $? != 0 | ||
12 | then | ||
13 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
14 | exit 77 | ||
15 | fi | ||
16 | |||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" | ||
19 | TEST_TXT="GNS powered txt record data" | ||
20 | MY_EGO="myego" | ||
21 | LABEL="testtxt" | ||
22 | gnunet-arm -s -c test_gns_lookup.conf | ||
23 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | ||
24 | gnunet-namestore -p -z $MY_EGO -a -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf | ||
25 | sleep 0.5 | ||
26 | RES_TXT=`$DO_TIMEOUT gnunet-gns --raw -u $LABEL.$MY_EGO -t TXT -c test_gns_lookup.conf` | ||
27 | gnunet-namestore -z $MY_EGO -d -n $LABEL -t TXT -V "$TEST_TXT" -e never -c test_gns_lookup.conf | ||
28 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | ||
29 | gnunet-arm -e -c test_gns_lookup.conf | ||
30 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
31 | |||
32 | if [ "$RES_TXT" = "$TEST_TXT" ] | ||
33 | then | ||
34 | exit 0 | ||
35 | else | ||
36 | echo "Failed to resolve to proper TXT, got '$RES_TXT'." | ||
37 | exit 1 | ||
38 | fi | ||
diff --git a/src/cli/gns/test_gns_zkey_lookup.sh b/src/cli/gns/test_gns_zkey_lookup.sh new file mode 100755 index 000000000..3d4aefc7c --- /dev/null +++ b/src/cli/gns/test_gns_zkey_lookup.sh | |||
@@ -0,0 +1,39 @@ | |||
1 | #!/bin/sh | ||
2 | # This file is in the public domain. | ||
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" INT | ||
4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" | ||
5 | |||
6 | LOCATION=$(which gnunet-config) | ||
7 | if [ -z $LOCATION ] | ||
8 | then | ||
9 | LOCATION="gnunet-config" | ||
10 | fi | ||
11 | $LOCATION --version 1> /dev/null | ||
12 | if test $? != 0 | ||
13 | then | ||
14 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
15 | exit 77 | ||
16 | fi | ||
17 | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
19 | |||
20 | TEST_IP="127.0.0.1" | ||
21 | gnunet-arm -s -c test_gns_lookup.conf | ||
22 | gnunet-identity -C delegatedego -c test_gns_lookup.conf | ||
23 | DELEGATED_PKEY=$(gnunet-identity -d -c test_gns_lookup.conf | grep delegatedego | awk '{print $3}') | ||
24 | gnunet-identity -C testego -c test_gns_lookup.conf | ||
25 | gnunet-namestore -p -z testego -a -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
26 | gnunet-namestore -p -z delegatedego -a -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
27 | RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.${DELEGATED_PKEY} -t A -c test_gns_lookup.conf` | ||
28 | gnunet-namestore -z testego -d -n b -t PKEY -V $DELEGATED_PKEY -e never -c test_gns_lookup.conf | ||
29 | gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gns_lookup.conf | ||
30 | gnunet-arm -e -c test_gns_lookup.conf | ||
31 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | ||
32 | |||
33 | if [ "$RES_IP" = "$TEST_IP" ] | ||
34 | then | ||
35 | exit 0 | ||
36 | else | ||
37 | echo "Failed to resolve to proper IP, got $RES_IP, wanted $TEST_IP." | ||
38 | exit 1 | ||
39 | fi | ||
diff --git a/src/cli/gns/test_gnunet_gns.sh.in b/src/cli/gns/test_gnunet_gns.sh.in new file mode 100755 index 000000000..d0c07b4e4 --- /dev/null +++ b/src/cli/gns/test_gnunet_gns.sh.in | |||
@@ -0,0 +1,47 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | # test -z being correct was a false assumption here. | ||
4 | # I have no executable 'fooble', but this will | ||
5 | # return 1: | ||
6 | # if test -z "`which fooble`"; then echo 1; fi | ||
7 | # The command builtin might not work with busybox's ash | ||
8 | # but this works for now. | ||
9 | dir=$(dirname "$0") | ||
10 | |||
11 | existence() { | ||
12 | command -v "$1" >/dev/null 2>&1 | ||
13 | } | ||
14 | |||
15 | LOCATION=`existence gnunet-config` | ||
16 | if test -z $LOCATION; then | ||
17 | LOCATION="gnunet-config" | ||
18 | fi | ||
19 | $LOCATION --version | ||
20 | if test $? != 0 | ||
21 | then | ||
22 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
23 | exit 77 | ||
24 | fi | ||
25 | |||
26 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | ||
27 | ME=`whoami` | ||
28 | if [ "$ME" != "root" ] | ||
29 | then | ||
30 | echo "This test only works if run as root. Skipping." | ||
31 | exit 77 | ||
32 | fi | ||
33 | export PATH=".:$PATH" | ||
34 | gnunet-service-gns -c gns.conf & | ||
35 | sleep 1 | ||
36 | LO=`nslookup alice.gnu | grep Address | tail -n1` | ||
37 | if [ "$LO" != "Address: 1.2.3.4" ] | ||
38 | then | ||
39 | echo "Fail: $LO" | ||
40 | fi | ||
41 | LO=`nslookup www.bob.gnu | grep Address | tail -n1` | ||
42 | if [ "$LO" != "Address: 4.5.6.7" ] | ||
43 | then | ||
44 | echo "Fail: $LO" | ||
45 | fi | ||
46 | # XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now. | ||
47 | kill `jobs -p` | ||
diff --git a/src/cli/gns/zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey b/src/cli/gns/zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey new file mode 100644 index 000000000..895946037 --- /dev/null +++ b/src/cli/gns/zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0.zkey | |||
Binary files differ | |||
diff --git a/src/cli/gns/zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey b/src/cli/gns/zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey new file mode 100644 index 000000000..3ef49f0ac --- /dev/null +++ b/src/cli/gns/zonefiles/J7POEUT41A8PBFS7KVVDRF88GBOU4HK8PSU5QKVLVE3R9T91E99G.zkey | |||
Binary files differ | |||
diff --git a/src/cli/gns/zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey b/src/cli/gns/zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey new file mode 100644 index 000000000..89e0b3a0a --- /dev/null +++ b/src/cli/gns/zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey | |||
Binary files differ | |||
diff --git a/src/cli/gns/zonefiles/test_zonekey b/src/cli/gns/zonefiles/test_zonekey new file mode 100644 index 000000000..870c56315 --- /dev/null +++ b/src/cli/gns/zonefiles/test_zonekey | |||
Binary files differ | |||