diff options
Diffstat (limited to 'src/gns')
26 files changed, 1011 insertions, 149 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 434d50f34..6ebbbcaff 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am | |||
@@ -89,9 +89,16 @@ bin_PROGRAMS += gnunet-bcd | |||
89 | endif | 89 | endif |
90 | endif | 90 | endif |
91 | 91 | ||
92 | if HAVE_MHD | ||
93 | if HAVE_JSON | ||
94 | REST_PLUGIN = libgnunet_plugin_rest_gns.la | ||
95 | endif | ||
96 | endif | ||
97 | |||
92 | plugin_LTLIBRARIES = \ | 98 | plugin_LTLIBRARIES = \ |
93 | libgnunet_plugin_block_gns.la \ | 99 | libgnunet_plugin_block_gns.la \ |
94 | libgnunet_plugin_gnsrecord_gns.la | 100 | libgnunet_plugin_gnsrecord_gns.la \ |
101 | $(REST_PLUGIN) | ||
95 | 102 | ||
96 | 103 | ||
97 | bin_SCRIPTS = \ | 104 | bin_SCRIPTS = \ |
@@ -104,6 +111,21 @@ gnunet-gns-proxy-setup-ca: gnunet-gns-proxy-setup-ca.in Makefile | |||
104 | $(do_subst) < $(srcdir)/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca | 111 | $(do_subst) < $(srcdir)/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca |
105 | chmod +x gnunet-gns-proxy-setup-ca | 112 | chmod +x gnunet-gns-proxy-setup-ca |
106 | 113 | ||
114 | |||
115 | libgnunet_plugin_rest_gns_la_SOURCES = \ | ||
116 | plugin_rest_gns.c | ||
117 | libgnunet_plugin_rest_gns_la_LIBADD = \ | ||
118 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
119 | libgnunetgns.la \ | ||
120 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
121 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
122 | $(top_builddir)/src/json/libgnunetjson.la \ | ||
123 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | ||
124 | $(LTLIBINTL) -ljansson -lmicrohttpd | ||
125 | libgnunet_plugin_rest_gns_la_LDFLAGS = \ | ||
126 | $(GN_PLUGIN_LDFLAGS) | ||
127 | |||
128 | |||
107 | libgnunet_plugin_gnsrecord_gns_la_SOURCES = \ | 129 | libgnunet_plugin_gnsrecord_gns_la_SOURCES = \ |
108 | plugin_gnsrecord_gns.c | 130 | plugin_gnsrecord_gns.c |
109 | libgnunet_plugin_gnsrecord_gns_la_LIBADD = \ | 131 | libgnunet_plugin_gnsrecord_gns_la_LIBADD = \ |
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 2e6a02b07..3252e4888 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in | |||
@@ -32,6 +32,8 @@ INTERCEPT_DNS = NO | |||
32 | BINARY = gnunet-gns-proxy | 32 | BINARY = gnunet-gns-proxy |
33 | START_ON_DEMAND = NO | 33 | START_ON_DEMAND = NO |
34 | RUN_PER_USER = YES | 34 | RUN_PER_USER = YES |
35 | BIND_TO=127.0.0.1 | ||
36 | BIND_TO6=::1 | ||
35 | 37 | ||
36 | # Where is the certificate for the GNS proxy stored? | 38 | # Where is the certificate for the GNS proxy stored? |
37 | PROXY_CACERT = $GNUNET_DATA_HOME/gns/gns_ca_cert.pem | 39 | PROXY_CACERT = $GNUNET_DATA_HOME/gns/gns_ca_cert.pem |
@@ -42,6 +44,8 @@ PROXY_UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-gns-proxy.sock | |||
42 | BINARY = gnunet-dns2gns | 44 | BINARY = gnunet-dns2gns |
43 | START_ON_DEMAND = NO | 45 | START_ON_DEMAND = NO |
44 | RUN_PER_USER = YES | 46 | RUN_PER_USER = YES |
47 | BIND_TO=127.0.0.1 | ||
48 | BIND_TO6=::1 | ||
45 | 49 | ||
46 | # -d: DNS resolver to use, -s: suffix to use, -f: fcfs suffix to use | 50 | # -d: DNS resolver to use, -s: suffix to use, -f: fcfs suffix to use |
47 | OPTIONS = -d 8.8.8.8 | 51 | OPTIONS = -d 8.8.8.8 |
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 68d090579..d2eabf02c 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -92,6 +92,17 @@ struct Request | |||
92 | uint16_t original_request_id; | 92 | uint16_t original_request_id; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | /** | ||
96 | * The address to bind to | ||
97 | */ | ||
98 | static in_addr_t address; | ||
99 | |||
100 | /** | ||
101 | * The IPv6 address to bind to | ||
102 | */ | ||
103 | static struct in6_addr address6; | ||
104 | |||
105 | |||
95 | 106 | ||
96 | /** | 107 | /** |
97 | * Handle to GNS resolver. | 108 | * Handle to GNS resolver. |
@@ -578,6 +589,7 @@ run (void *cls, | |||
578 | const char *cfgfile, | 589 | const char *cfgfile, |
579 | const struct GNUNET_CONFIGURATION_Handle *c) | 590 | const struct GNUNET_CONFIGURATION_Handle *c) |
580 | { | 591 | { |
592 | char *addr_str; | ||
581 | (void) cls; | 593 | (void) cls; |
582 | (void) args; | 594 | (void) args; |
583 | (void) cfgfile; | 595 | (void) cfgfile; |
@@ -602,6 +614,52 @@ run (void *cls, | |||
602 | gns = NULL; | 614 | gns = NULL; |
603 | return; | 615 | return; |
604 | } | 616 | } |
617 | |||
618 | /* Get address to bind to */ | ||
619 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dns2gns", | ||
620 | "BIND_TO", | ||
621 | &addr_str)) | ||
622 | { | ||
623 | //No address specified | ||
624 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
625 | "Don't know what to bind to...\n"); | ||
626 | GNUNET_free (addr_str); | ||
627 | GNUNET_SCHEDULER_shutdown (); | ||
628 | return; | ||
629 | } | ||
630 | if (1 != inet_pton (AF_INET, addr_str, &address)) | ||
631 | { | ||
632 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
633 | "Unable to parse address %s\n", | ||
634 | addr_str); | ||
635 | GNUNET_free (addr_str); | ||
636 | GNUNET_SCHEDULER_shutdown (); | ||
637 | return; | ||
638 | } | ||
639 | GNUNET_free (addr_str); | ||
640 | /* Get address to bind to */ | ||
641 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dns2gns", | ||
642 | "BIND_TO6", | ||
643 | &addr_str)) | ||
644 | { | ||
645 | //No address specified | ||
646 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
647 | "Don't know what to bind6 to...\n"); | ||
648 | GNUNET_free (addr_str); | ||
649 | GNUNET_SCHEDULER_shutdown (); | ||
650 | return; | ||
651 | } | ||
652 | if (1 != inet_pton (AF_INET6, addr_str, &address6)) | ||
653 | { | ||
654 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
655 | "Unable to parse IPv6 address %s\n", | ||
656 | addr_str); | ||
657 | GNUNET_free (addr_str); | ||
658 | GNUNET_SCHEDULER_shutdown (); | ||
659 | return; | ||
660 | } | ||
661 | GNUNET_free (addr_str); | ||
662 | |||
605 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, | 663 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, |
606 | SOCK_DGRAM, | 664 | SOCK_DGRAM, |
607 | IPPROTO_UDP); | 665 | IPPROTO_UDP); |
@@ -611,6 +669,7 @@ run (void *cls, | |||
611 | 669 | ||
612 | memset (&v4, 0, sizeof (v4)); | 670 | memset (&v4, 0, sizeof (v4)); |
613 | v4.sin_family = AF_INET; | 671 | v4.sin_family = AF_INET; |
672 | v4.sin_addr.s_addr = address; | ||
614 | #if HAVE_SOCKADDR_IN_SIN_LEN | 673 | #if HAVE_SOCKADDR_IN_SIN_LEN |
615 | v4.sin_len = sizeof (v4); | 674 | v4.sin_len = sizeof (v4); |
616 | #endif | 675 | #endif |
@@ -634,6 +693,7 @@ run (void *cls, | |||
634 | 693 | ||
635 | memset (&v6, 0, sizeof (v6)); | 694 | memset (&v6, 0, sizeof (v6)); |
636 | v6.sin6_family = AF_INET6; | 695 | v6.sin6_family = AF_INET6; |
696 | v6.sin6_addr = address6; | ||
637 | #if HAVE_SOCKADDR_IN_SIN_LEN | 697 | #if HAVE_SOCKADDR_IN_SIN_LEN |
638 | v6.sin6_len = sizeof (v6); | 698 | v6.sin6_len = sizeof (v6); |
639 | #endif | 699 | #endif |
diff --git a/src/gns/gnunet-gns-proxy-setup-ca.in b/src/gns/gnunet-gns-proxy-setup-ca.in index 0a6fab18a..184da4853 100644 --- a/src/gns/gnunet-gns-proxy-setup-ca.in +++ b/src/gns/gnunet-gns-proxy-setup-ca.in | |||
@@ -1,78 +1,252 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # This shell script will generate an X509 certificate for your gnunet-gns-proxy | ||
3 | # and install it (for both GNUnet and your browser). | ||
4 | # | 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. | ||
5 | 32 | ||
6 | OPENSSLCFG=@pkgdatadir@/openssl.cnf | 33 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND |
7 | if ! which openssl > /dev/null | 34 | # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
8 | then | 35 | # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
9 | echo "'openssl' command not found. Please install it." | 36 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
10 | exit 1 | 37 | # DISCLAIMED. |
11 | fi | 38 | # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR |
12 | 39 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
13 | echo "Generating CA" | 40 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
14 | options='' | 41 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
15 | while getopts "c:" opt; do | 42 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
16 | case $opt in | 43 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
17 | c) | 44 | # LIABILITY, OR TORT |
18 | options="$options -c $OPTARG" | 45 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
19 | ;; | 46 | # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
20 | \?) | 47 | # OF SUCH DAMAGE. |
21 | echo "Invalid option: -$OPTARG" >&2 | 48 | |
22 | exit 1 | 49 | progname=${0##*/} |
23 | ;; | 50 | |
24 | :) | 51 | setdefaults() |
25 | echo "Option -$OPTARG requires an argument." >&2 | 52 | { |
26 | exit 1 | 53 | verbosity=0 |
27 | ;; | 54 | runcmd= |
28 | esac | 55 | } |
29 | done | 56 | |
30 | 57 | statusmsg() | |
31 | GNSCERT=`mktemp /tmp/gnscertXXXXXX.pem` | 58 | { |
32 | GNSCAKY=`mktemp /tmp/gnscakeyXXXXXX.pem` | 59 | ${runcmd} echo " $@" |
33 | GNSCANO=`mktemp /tmp/gnscakeynoencXXXXXX.pem` | 60 | } |
34 | GNS_CA_CERT_PEM=`gnunet-config -s gns-proxy -o PROXY_CACERT -f $options` | 61 | |
35 | mkdir -p `dirname $GNS_CA_CERT_PEM` | 62 | infomsg() |
36 | 63 | { | |
37 | 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" | 64 | if [ $verbosity = 1 ]; then |
38 | 65 | statusmsg "INFO: $@" | |
39 | echo "Removing passphrase from key" | ||
40 | openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO | ||
41 | |||
42 | echo "Making private key available to gnunet-gns-proxy" | ||
43 | cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM | ||
44 | |||
45 | if ! which certutil > /dev/null | ||
46 | then | ||
47 | echo "The 'certutil' command was not found. Not importing into browsers." | ||
48 | echo "For 'certutil' install nss." | ||
49 | else | ||
50 | echo "Importing CA into browsers" | ||
51 | for f in ~/.mozilla/firefox/*.*/ | ||
52 | do | ||
53 | if [ -d $f ]; then | ||
54 | echo "Importing CA info Firefox at $f" | ||
55 | # delete old certificate (if any) | ||
56 | certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null | ||
57 | # add new certificate | ||
58 | certutil -A -n "GNS Proxy CA" -t CT,, -d "$f" < $GNSCERT | ||
59 | fi | 66 | fi |
60 | done | 67 | } |
61 | 68 | ||
62 | if [ -d ~/.pki/nssdb/ ]; then | 69 | warningmsg() |
63 | echo "Importing CA into Chrome at ~/.pki/nssdb/" | 70 | { |
64 | # delete old certificate (if any) | 71 | statusmsg "WARNING: $@" |
65 | certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null | 72 | } |
66 | # add new certificate | 73 | |
67 | certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb/ < $GNSCERT | 74 | errormsg() |
68 | fi | 75 | { |
69 | fi | 76 | statusmsg "ERROR: $@" |
70 | 77 | } | |
71 | echo "Cleaning up." | 78 | |
72 | rm -f $GNSCAKY $GNSCANO $GNSCERT | 79 | linemsg() |
73 | 80 | { | |
74 | echo "===================================" | 81 | statusmsg "=========================================" |
75 | echo "You can now start gnunet-gns-proxy." | 82 | } |
76 | echo "Afterwards, configure your browser " | 83 | |
77 | echo " to use a SOCKS proxy on port 7777." | 84 | |
78 | echo "===================================" | 85 | usage() |
86 | { | ||
87 | if [ -n "$*" ]; then | ||
88 | echo "" | ||
89 | echo "${progname}: $*" | ||
90 | fi | ||
91 | cat <<_usage_ | ||
92 | |||
93 | Usage: ${progname} [-hv] [-c FILE] [...] | ||
94 | |||
95 | Options: | ||
96 | -c FILE Use the configuration file FILE. | ||
97 | -h Print this help message. | ||
98 | -v Print the version and exit. | ||
99 | -V be verbose | ||
100 | |||
101 | _usage_ | ||
102 | exit 1 | ||
103 | } | ||
104 | |||
105 | |||
106 | generate_ca() | ||
107 | { | ||
108 | echo "" | ||
109 | infomsg "Generating CA" | ||
110 | TMPDIR=${TMPDIR:-/tmp} | ||
111 | if [ -e "$TMPDIR" ]; then | ||
112 | GNSCERT=`mktemp -t certXXXXXXXX.pem` || exit 1 | ||
113 | GNSCAKY=`mktemp -t cakyXXXXXXXX.pem` || exit 1 | ||
114 | GNSCANO=`mktemp -t canoXXXXXXXX.pem` || exit 1 | ||
115 | else | ||
116 | # This warning is mostly pointless. | ||
117 | warning "You need to export the TMPDIR variable" | ||
118 | fi | ||
119 | |||
120 | # # ------------- gnutls | ||
121 | # | ||
122 | # if ! which certutil > /dev/null | ||
123 | # then | ||
124 | # warningmsg "The 'certutil' command was not found." | ||
125 | # warningmsg "Not importing into browsers." | ||
126 | # warningmsg "For 'certutil' install nss." | ||
127 | # else | ||
128 | # # Generate CA key | ||
129 | # # pkcs#8 password-protects key | ||
130 | # certtool --pkcs8 --generate-privkey --sec-param high --outfile ca-key.pem | ||
131 | # # self-sign the CA to create public certificate | ||
132 | # certtool --generate-self-signed --load-privkey ca-key.pem --template ca.cfg --outfile ca.pem | ||
133 | |||
134 | # ------------- openssl | ||
135 | |||
136 | OPENSSLCFG=@pkgdatadir@/openssl.cnf | ||
137 | if test -z "`openssl version`" > /dev/null | ||
138 | then | ||
139 | warningmsg "'openssl' command not found. Please install it." | ||
140 | infomsg "Cleaning up." | ||
141 | rm -f $GNSCAKY $GNSCANO $GNSCERT | ||
142 | exit 1 | ||
143 | fi | ||
144 | if [ -n "${GNUNET_CONFIG_FILE}" ]; then | ||
145 | GNUNET_CONFIG="-c ${GNUNET_CONFIG_FILE}" | ||
146 | else | ||
147 | GNUNET_CONFIG="" | ||
148 | fi | ||
149 | GNS_CA_CERT_PEM=`gnunet-config ${GNUNET_CONFIG} -s gns-proxy -o PROXY_CACERT -f ${options}` | ||
150 | mkdir -p `dirname $GNS_CA_CERT_PEM` | ||
151 | |||
152 | 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" | ||
153 | |||
154 | infomsg "Removing passphrase from key" | ||
155 | openssl rsa -passin pass:"GNU Name System" -in $GNSCAKY -out $GNSCANO | ||
156 | |||
157 | infomsg "Making private key available to gnunet-gns-proxy" | ||
158 | cat $GNSCERT $GNSCANO > $GNS_CA_CERT_PEM | ||
159 | } | ||
160 | |||
161 | importbrowsers() | ||
162 | { | ||
163 | # Don't check with -H, -H defies any method to not | ||
164 | # print the output on screen! Let's hope that every | ||
165 | # certutil gets build with some kind of build flags | ||
166 | # which end up being printed here: | ||
167 | if test -z "`certutil --build-flags`" > /dev/null 2>&1 | ||
168 | then | ||
169 | warningmsg "The 'certutil' command was not found." | ||
170 | warningmsg "Not importing into browsers." | ||
171 | warningmsg "For 'certutil' install nss." | ||
172 | else | ||
173 | infomsg "Importing CA into browsers" | ||
174 | # TODO: Error handling? | ||
175 | for f in ~/.mozilla/firefox/*.*/ | ||
176 | do | ||
177 | if [ -d $f ]; then | ||
178 | infomsg "Importing CA into Firefox at $f" | ||
179 | # delete old certificate (if any) | ||
180 | certutil -D -n "GNS Proxy CA" -d "$f" >/dev/null 2>/dev/null | ||
181 | # add new certificate | ||
182 | certutil -A -n "GNS Proxy CA" -t CT,, -d "$f" < $GNSCERT | ||
183 | fi | ||
184 | done | ||
185 | # TODO: Error handling? | ||
186 | if [ -d ~/.pki/nssdb/ ]; then | ||
187 | infomsg "Importing CA into Chrome at ~/.pki/nssdb/" | ||
188 | # delete old certificate (if any) | ||
189 | certutil -D -n "GNS Proxy CA" -d ~/.pki/nssdb/ >/dev/null 2>/dev/null | ||
190 | # add new certificate | ||
191 | certutil -A -n "GNS Proxy CA" -t CT,, -d ~/.pki/nssdb/ < $GNSCERT | ||
192 | fi | ||
193 | fi | ||
194 | } | ||
195 | |||
196 | print_version() | ||
197 | { | ||
198 | GNUNET_ARM_VERSION=`gnunet-arm -v` | ||
199 | echo $GNUNET_ARM_VERSION | ||
200 | } | ||
201 | |||
202 | clean_up() | ||
203 | { | ||
204 | infomsg "Cleaning up." | ||
205 | rm -f $GNSCAKY $GNSCANO $GNSCERT | ||
206 | if [ -e $SETUP_TMPDIR ]; then | ||
207 | rm -rf $SETUP_TMPDIR | ||
208 | fi | ||
209 | |||
210 | linemsg | ||
211 | statusmsg "You can now start gnunet-gns-proxy." | ||
212 | statusmsg "Afterwards, configure your browser " | ||
213 | statusmsg "to use a SOCKS proxy on port 7777. " | ||
214 | linemsg | ||
215 | } | ||
216 | |||
217 | main() | ||
218 | { | ||
219 | while getopts "vhVc:" opt; do | ||
220 | case $opt in | ||
221 | v) | ||
222 | print_version | ||
223 | exit 0 | ||
224 | ;; | ||
225 | h) | ||
226 | usage | ||
227 | ;; | ||
228 | V) | ||
229 | verbosity=1 | ||
230 | ;; | ||
231 | c) | ||
232 | options="$options -c $OPTARG" | ||
233 | infomsg "Using configuration file $OPTARG" | ||
234 | GNUNET_CONFIG_FILE=${OPTARG} | ||
235 | ;; | ||
236 | \?) | ||
237 | echo "Invalid option: -$OPTARG" >&2 | ||
238 | usage | ||
239 | ;; | ||
240 | :) | ||
241 | echo "Option -$OPTARG requires an argument." >&2 | ||
242 | usage | ||
243 | ;; | ||
244 | esac | ||
245 | done | ||
246 | setdefaults | ||
247 | generate_ca | ||
248 | importbrowsers | ||
249 | clean_up | ||
250 | } | ||
251 | |||
252 | main "$@" | ||
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 65a7b6018..bae222499 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -661,6 +661,15 @@ struct Socks5Request | |||
661 | 661 | ||
662 | /* *********************** Globals **************************** */ | 662 | /* *********************** Globals **************************** */ |
663 | 663 | ||
664 | /** | ||
665 | * The address to bind to | ||
666 | */ | ||
667 | static in_addr_t address; | ||
668 | |||
669 | /** | ||
670 | * The IPv6 address to bind to | ||
671 | */ | ||
672 | static struct in6_addr address6; | ||
664 | 673 | ||
665 | /** | 674 | /** |
666 | * The port the proxy is running on (default 7777) | 675 | * The port the proxy is running on (default 7777) |
@@ -2182,7 +2191,7 @@ create_response (void *cls, | |||
2182 | } | 2191 | } |
2183 | MHD_get_connection_values (con, | 2192 | MHD_get_connection_values (con, |
2184 | MHD_HEADER_KIND, | 2193 | MHD_HEADER_KIND, |
2185 | &con_val_iter, | 2194 | (MHD_KeyValueIterator) &con_val_iter, |
2186 | s5r); | 2195 | s5r); |
2187 | curl_easy_setopt (s5r->curl, | 2196 | curl_easy_setopt (s5r->curl, |
2188 | CURLOPT_HTTPHEADER, | 2197 | CURLOPT_HTTPHEADER, |
@@ -3516,6 +3525,7 @@ bind_v4 () | |||
3516 | memset (&sa4, 0, sizeof (sa4)); | 3525 | memset (&sa4, 0, sizeof (sa4)); |
3517 | sa4.sin_family = AF_INET; | 3526 | sa4.sin_family = AF_INET; |
3518 | sa4.sin_port = htons (port); | 3527 | sa4.sin_port = htons (port); |
3528 | sa4.sin_addr.s_addr = address; | ||
3519 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3529 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3520 | sa4.sin_len = sizeof (sa4); | 3530 | sa4.sin_len = sizeof (sa4); |
3521 | #endif | 3531 | #endif |
@@ -3553,6 +3563,7 @@ bind_v6 () | |||
3553 | memset (&sa6, 0, sizeof (sa6)); | 3563 | memset (&sa6, 0, sizeof (sa6)); |
3554 | sa6.sin6_family = AF_INET6; | 3564 | sa6.sin6_family = AF_INET6; |
3555 | sa6.sin6_port = htons (port); | 3565 | sa6.sin6_port = htons (port); |
3566 | sa6.sin6_addr = address6; | ||
3556 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3567 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3557 | sa6.sin6_len = sizeof (sa6); | 3568 | sa6.sin6_len = sizeof (sa6); |
3558 | #endif | 3569 | #endif |
@@ -3591,10 +3602,56 @@ run (void *cls, | |||
3591 | { | 3602 | { |
3592 | char* cafile_cfg = NULL; | 3603 | char* cafile_cfg = NULL; |
3593 | char* cafile; | 3604 | char* cafile; |
3605 | char* addr_str; | ||
3594 | struct MhdHttpList *hd; | 3606 | struct MhdHttpList *hd; |
3595 | 3607 | ||
3596 | cfg = c; | 3608 | cfg = c; |
3597 | 3609 | ||
3610 | /* Get address to bind to */ | ||
3611 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "gns-proxy", | ||
3612 | "BIND_TO", | ||
3613 | &addr_str)) | ||
3614 | { | ||
3615 | //No address specified | ||
3616 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3617 | "Don't know what to bind to...\n"); | ||
3618 | GNUNET_free (addr_str); | ||
3619 | GNUNET_SCHEDULER_shutdown (); | ||
3620 | return; | ||
3621 | } | ||
3622 | if (1 != inet_pton (AF_INET, addr_str, &address)) | ||
3623 | { | ||
3624 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3625 | "Unable to parse address %s\n", | ||
3626 | addr_str); | ||
3627 | GNUNET_free (addr_str); | ||
3628 | GNUNET_SCHEDULER_shutdown (); | ||
3629 | return; | ||
3630 | } | ||
3631 | GNUNET_free (addr_str); | ||
3632 | /* Get address to bind to */ | ||
3633 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "gns-proxy", | ||
3634 | "BIND_TO6", | ||
3635 | &addr_str)) | ||
3636 | { | ||
3637 | //No address specified | ||
3638 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3639 | "Don't know what to bind6 to...\n"); | ||
3640 | GNUNET_free (addr_str); | ||
3641 | GNUNET_SCHEDULER_shutdown (); | ||
3642 | return; | ||
3643 | } | ||
3644 | if (1 != inet_pton (AF_INET6, addr_str, &address6)) | ||
3645 | { | ||
3646 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
3647 | "Unable to parse IPv6 address %s\n", | ||
3648 | addr_str); | ||
3649 | GNUNET_free (addr_str); | ||
3650 | GNUNET_SCHEDULER_shutdown (); | ||
3651 | return; | ||
3652 | } | ||
3653 | GNUNET_free (addr_str); | ||
3654 | |||
3598 | if (NULL == (curl_multi = curl_multi_init ())) | 3655 | if (NULL == (curl_multi = curl_multi_init ())) |
3599 | { | 3656 | { |
3600 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c new file mode 100644 index 000000000..e41df4085 --- /dev/null +++ b/src/gns/plugin_rest_gns.c | |||
@@ -0,0 +1,478 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012-2015 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 | * @author Philippe Buschmann | ||
22 | * @file gns/plugin_rest_gns.c | ||
23 | * @brief GNUnet Gns REST plugin | ||
24 | */ | ||
25 | |||
26 | #include "platform.h" | ||
27 | #include "gnunet_rest_plugin.h" | ||
28 | #include "gnunet_rest_lib.h" | ||
29 | #include "gnunet_json_lib.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | ||
31 | #include "gnunet_gns_service.h" | ||
32 | #include "microhttpd.h" | ||
33 | #include <jansson.h> | ||
34 | |||
35 | /** | ||
36 | * Rest API GNS Namespace | ||
37 | */ | ||
38 | #define GNUNET_REST_API_NS_GNS "/gns" | ||
39 | |||
40 | /** | ||
41 | * Rest API GNS Parameter record_type | ||
42 | */ | ||
43 | #define GNUNET_REST_GNS_PARAM_RECORD_TYPE "record_type" | ||
44 | |||
45 | /** | ||
46 | * Rest API GNS ERROR Unknown Error | ||
47 | */ | ||
48 | #define GNUNET_REST_GNS_ERROR_UNKNOWN "Unknown Error" | ||
49 | |||
50 | /** | ||
51 | * Rest API GNS ERROR Record not found | ||
52 | */ | ||
53 | #define GNUNET_REST_GNS_NOT_FOUND "Record not found" | ||
54 | |||
55 | /** | ||
56 | * The configuration handle | ||
57 | */ | ||
58 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
59 | |||
60 | /** | ||
61 | * HTTP methods allows for this plugin | ||
62 | */ | ||
63 | static char* allow_methods; | ||
64 | |||
65 | /** | ||
66 | * @brief struct returned by the initialization function of the plugin | ||
67 | */ | ||
68 | struct Plugin | ||
69 | { | ||
70 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
71 | }; | ||
72 | |||
73 | /** | ||
74 | * The request handle | ||
75 | */ | ||
76 | struct RequestHandle | ||
77 | { | ||
78 | |||
79 | /** | ||
80 | * Connection to GNS | ||
81 | */ | ||
82 | struct GNUNET_GNS_Handle *gns; | ||
83 | |||
84 | /** | ||
85 | * Active GNS lookup | ||
86 | */ | ||
87 | struct GNUNET_GNS_LookupWithTldRequest *gns_lookup; | ||
88 | |||
89 | /** | ||
90 | * Name to look up | ||
91 | */ | ||
92 | char *name; | ||
93 | |||
94 | /** | ||
95 | * Record type to look up | ||
96 | */ | ||
97 | int record_type; | ||
98 | |||
99 | /** | ||
100 | * Rest connection | ||
101 | */ | ||
102 | struct GNUNET_REST_RequestHandle *rest_handle; | ||
103 | |||
104 | /** | ||
105 | * Desired timeout for the lookup (default is no timeout). | ||
106 | */ | ||
107 | struct GNUNET_TIME_Relative timeout; | ||
108 | |||
109 | /** | ||
110 | * ID of a task associated with the resolution process. | ||
111 | */ | ||
112 | struct GNUNET_SCHEDULER_Task *timeout_task; | ||
113 | |||
114 | /** | ||
115 | * The plugin result processor | ||
116 | */ | ||
117 | GNUNET_REST_ResultProcessor proc; | ||
118 | |||
119 | /** | ||
120 | * The closure of the result processor | ||
121 | */ | ||
122 | void *proc_cls; | ||
123 | |||
124 | /** | ||
125 | * The url | ||
126 | */ | ||
127 | char *url; | ||
128 | |||
129 | /** | ||
130 | * Error response message | ||
131 | */ | ||
132 | char *emsg; | ||
133 | |||
134 | /** | ||
135 | * Response code | ||
136 | */ | ||
137 | int response_code; | ||
138 | |||
139 | }; | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Cleanup lookup handle | ||
144 | * @param handle Handle to clean up | ||
145 | */ | ||
146 | static void | ||
147 | cleanup_handle (void *cls) | ||
148 | { | ||
149 | struct RequestHandle *handle = cls; | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
151 | "Cleaning up\n"); | ||
152 | |||
153 | if (NULL != handle->gns_lookup) | ||
154 | { | ||
155 | GNUNET_GNS_lookup_with_tld_cancel (handle->gns_lookup); | ||
156 | handle->gns_lookup = NULL; | ||
157 | } | ||
158 | if (NULL != handle->gns) | ||
159 | { | ||
160 | GNUNET_GNS_disconnect (handle->gns); | ||
161 | handle->gns = NULL; | ||
162 | } | ||
163 | |||
164 | if (NULL != handle->timeout_task) | ||
165 | { | ||
166 | GNUNET_SCHEDULER_cancel (handle->timeout_task); | ||
167 | handle->timeout_task = NULL; | ||
168 | } | ||
169 | if (NULL != handle->url) | ||
170 | GNUNET_free (handle->url); | ||
171 | if (NULL != handle->name) | ||
172 | GNUNET_free (handle->name); | ||
173 | if (NULL != handle->emsg) | ||
174 | GNUNET_free (handle->emsg); | ||
175 | |||
176 | GNUNET_free (handle); | ||
177 | } | ||
178 | |||
179 | |||
180 | /** | ||
181 | * Task run on errors. Reports an error and cleans up everything. | ||
182 | * | ||
183 | * @param cls the `struct RequestHandle` | ||
184 | */ | ||
185 | static void | ||
186 | do_error (void *cls) | ||
187 | { | ||
188 | struct RequestHandle *handle = cls; | ||
189 | struct MHD_Response *resp; | ||
190 | json_t *json_error = json_object(); | ||
191 | char *response; | ||
192 | |||
193 | if (NULL == handle->emsg) | ||
194 | handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_ERROR_UNKNOWN); | ||
195 | |||
196 | json_object_set_new(json_error,"error", json_string(handle->emsg)); | ||
197 | |||
198 | if (0 == handle->response_code) | ||
199 | handle->response_code = MHD_HTTP_OK; | ||
200 | response = json_dumps (json_error, 0); | ||
201 | resp = GNUNET_REST_create_response (response); | ||
202 | handle->proc (handle->proc_cls, resp, handle->response_code); | ||
203 | json_decref(json_error); | ||
204 | GNUNET_free(response); | ||
205 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | ||
206 | } | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Iterator called on obtained result for a GNS lookup. | ||
211 | * | ||
212 | * @param cls closure with the object | ||
213 | * @param was_gns #GNUNET_NO if name was not a GNS name | ||
214 | * @param rd_count number of records in @a rd | ||
215 | * @param rd the records in reply | ||
216 | */ | ||
217 | static void | ||
218 | handle_gns_response (void *cls, | ||
219 | int was_gns, | ||
220 | uint32_t rd_count, | ||
221 | const struct GNUNET_GNSRECORD_Data *rd) | ||
222 | { | ||
223 | struct RequestHandle *handle = cls; | ||
224 | struct MHD_Response *resp; | ||
225 | json_t *result_array; | ||
226 | json_t *record_obj; | ||
227 | char *result; | ||
228 | |||
229 | handle->gns_lookup = NULL; | ||
230 | |||
231 | if (GNUNET_NO == was_gns) | ||
232 | { | ||
233 | handle->response_code = MHD_HTTP_NOT_FOUND; | ||
234 | handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND); | ||
235 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
236 | return; | ||
237 | } | ||
238 | |||
239 | result_array = json_array(); | ||
240 | for (uint32_t i=0;i<rd_count;i++) | ||
241 | { | ||
242 | if ((rd[i].record_type != handle->record_type) && | ||
243 | (GNUNET_GNSRECORD_TYPE_ANY != handle->record_type) ) | ||
244 | { | ||
245 | continue; | ||
246 | } | ||
247 | |||
248 | record_obj = GNUNET_JSON_from_gns_record(NULL,&rd[i]); | ||
249 | json_array_append (result_array, record_obj); | ||
250 | json_decref (record_obj); | ||
251 | } | ||
252 | |||
253 | result = json_dumps(result_array, 0); | ||
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); | ||
255 | resp = GNUNET_REST_create_response (result); | ||
256 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | ||
257 | GNUNET_free (result); | ||
258 | json_decref (result_array); | ||
259 | GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); | ||
260 | } | ||
261 | |||
262 | |||
263 | /** | ||
264 | * Handle gns GET request | ||
265 | * | ||
266 | * @param con_handle the connection handle | ||
267 | * @param url the url | ||
268 | * @param cls the RequestHandle | ||
269 | */ | ||
270 | void | ||
271 | get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
272 | const char* url, | ||
273 | void *cls) | ||
274 | { | ||
275 | struct RequestHandle *handle = cls; | ||
276 | struct GNUNET_HashCode key; | ||
277 | char *record_type; | ||
278 | char *name; | ||
279 | |||
280 | name = NULL; | ||
281 | handle->name = NULL; | ||
282 | if (strlen (GNUNET_REST_API_NS_GNS) < strlen (handle->url)) | ||
283 | { | ||
284 | name = &handle->url[strlen (GNUNET_REST_API_NS_GNS) + 1]; | ||
285 | } | ||
286 | |||
287 | if (NULL == name) | ||
288 | { | ||
289 | handle->response_code = MHD_HTTP_NOT_FOUND; | ||
290 | handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND); | ||
291 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
292 | return; | ||
293 | } | ||
294 | if (0 >= strlen (name)) | ||
295 | { | ||
296 | handle->response_code = MHD_HTTP_NOT_FOUND; | ||
297 | handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND); | ||
298 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
299 | return; | ||
300 | } | ||
301 | handle->name = GNUNET_strdup(name); | ||
302 | |||
303 | handle->record_type = UINT32_MAX; | ||
304 | GNUNET_CRYPTO_hash (GNUNET_REST_GNS_PARAM_RECORD_TYPE, | ||
305 | strlen (GNUNET_REST_GNS_PARAM_RECORD_TYPE), | ||
306 | &key); | ||
307 | if ( GNUNET_YES | ||
308 | == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, | ||
309 | &key)) | ||
310 | { | ||
311 | record_type = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key); | ||
312 | handle->record_type = GNUNET_GNSRECORD_typename_to_number(record_type); | ||
313 | } | ||
314 | |||
315 | if(UINT32_MAX == handle->record_type) | ||
316 | { | ||
317 | handle->record_type = GNUNET_GNSRECORD_TYPE_ANY; | ||
318 | } | ||
319 | |||
320 | handle->gns_lookup = GNUNET_GNS_lookup_with_tld (handle->gns, | ||
321 | handle->name, | ||
322 | handle->record_type, | ||
323 | GNUNET_NO, | ||
324 | &handle_gns_response, | ||
325 | handle); | ||
326 | } | ||
327 | |||
328 | |||
329 | |||
330 | /** | ||
331 | * Respond to OPTIONS request | ||
332 | * | ||
333 | * @param con_handle the connection handle | ||
334 | * @param url the url | ||
335 | * @param cls the RequestHandle | ||
336 | */ | ||
337 | static void | ||
338 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
339 | const char* url, | ||
340 | void *cls) | ||
341 | { | ||
342 | struct MHD_Response *resp; | ||
343 | struct RequestHandle *handle = cls; | ||
344 | |||
345 | //independent of path return all options | ||
346 | resp = GNUNET_REST_create_response (NULL); | ||
347 | MHD_add_response_header (resp, | ||
348 | "Access-Control-Allow-Methods", | ||
349 | allow_methods); | ||
350 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | ||
351 | GNUNET_SCHEDULER_add_now(&cleanup_handle, handle); | ||
352 | return; | ||
353 | } | ||
354 | |||
355 | |||
356 | /** | ||
357 | * Handle rest request | ||
358 | * | ||
359 | * @param handle the request handle | ||
360 | */ | ||
361 | static void | ||
362 | init_cont (struct RequestHandle *handle) | ||
363 | { | ||
364 | struct GNUNET_REST_RequestHandlerError err; | ||
365 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
366 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_GNS, &get_gns_cont}, | ||
367 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_GNS, &options_cont}, | ||
368 | GNUNET_REST_HANDLER_END | ||
369 | }; | ||
370 | |||
371 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, | ||
372 | handlers, | ||
373 | &err, | ||
374 | handle)) | ||
375 | { | ||
376 | handle->response_code = err.error_code; | ||
377 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
378 | } | ||
379 | } | ||
380 | |||
381 | |||
382 | /** | ||
383 | * Function processing the REST call | ||
384 | * | ||
385 | * @param method HTTP method | ||
386 | * @param url URL of the HTTP request | ||
387 | * @param data body of the HTTP request (optional) | ||
388 | * @param data_size length of the body | ||
389 | * @param proc callback function for the result | ||
390 | * @param proc_cls closure for callback function | ||
391 | * @return GNUNET_OK if request accepted | ||
392 | */ | ||
393 | static void | ||
394 | rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle, | ||
395 | GNUNET_REST_ResultProcessor proc, | ||
396 | void *proc_cls) | ||
397 | { | ||
398 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); | ||
399 | |||
400 | handle->response_code = 0; | ||
401 | handle->timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60); | ||
402 | handle->proc_cls = proc_cls; | ||
403 | handle->proc = proc; | ||
404 | handle->rest_handle = rest_handle; | ||
405 | |||
406 | handle->url = GNUNET_strdup (rest_handle->url); | ||
407 | if (handle->url[strlen (handle->url)-1] == '/') | ||
408 | handle->url[strlen (handle->url)-1] = '\0'; | ||
409 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | ||
410 | handle->gns = GNUNET_GNS_connect (cfg); | ||
411 | init_cont(handle); | ||
412 | |||
413 | handle->timeout_task = | ||
414 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | ||
415 | &do_error, | ||
416 | handle); | ||
417 | |||
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | ||
419 | } | ||
420 | |||
421 | |||
422 | /** | ||
423 | * Entry point for the plugin. | ||
424 | * | ||
425 | * @param cls Config info | ||
426 | * @return NULL on error, otherwise the plugin context | ||
427 | */ | ||
428 | void * | ||
429 | libgnunet_plugin_rest_gns_init (void *cls) | ||
430 | { | ||
431 | static struct Plugin plugin; | ||
432 | struct GNUNET_REST_Plugin *api; | ||
433 | |||
434 | cfg = cls; | ||
435 | if (NULL != plugin.cfg) | ||
436 | return NULL; /* can only initialize once! */ | ||
437 | memset (&plugin, 0, sizeof (struct Plugin)); | ||
438 | plugin.cfg = cfg; | ||
439 | api = GNUNET_new (struct GNUNET_REST_Plugin); | ||
440 | api->cls = &plugin; | ||
441 | api->name = GNUNET_REST_API_NS_GNS; | ||
442 | api->process_request = &rest_process_request; | ||
443 | GNUNET_asprintf (&allow_methods, | ||
444 | "%s, %s, %s, %s, %s", | ||
445 | MHD_HTTP_METHOD_GET, | ||
446 | MHD_HTTP_METHOD_POST, | ||
447 | MHD_HTTP_METHOD_PUT, | ||
448 | MHD_HTTP_METHOD_DELETE, | ||
449 | MHD_HTTP_METHOD_OPTIONS); | ||
450 | |||
451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
452 | _("Gns REST API initialized\n")); | ||
453 | return api; | ||
454 | } | ||
455 | |||
456 | |||
457 | /** | ||
458 | * Exit point from the plugin. | ||
459 | * | ||
460 | * @param cls the plugin context (as returned by "init") | ||
461 | * @return always NULL | ||
462 | */ | ||
463 | void * | ||
464 | libgnunet_plugin_rest_gns_done (void *cls) | ||
465 | { | ||
466 | struct GNUNET_REST_Plugin *api = cls; | ||
467 | struct Plugin *plugin = api->cls; | ||
468 | plugin->cfg = NULL; | ||
469 | |||
470 | GNUNET_free_non_null (allow_methods); | ||
471 | GNUNET_free (api); | ||
472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
473 | "Gns REST plugin is finished\n"); | ||
474 | return NULL; | ||
475 | } | ||
476 | |||
477 | /* end of plugin_rest_gns.c */ | ||
478 | |||
diff --git a/src/gns/test_gns_at_lookup.sh b/src/gns/test_gns_at_lookup.sh index d900c070b..bacc63eb0 100755 --- a/src/gns/test_gns_at_lookup.sh +++ b/src/gns/test_gns_at_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -14,7 +14,7 @@ then | |||
14 | exit 77 | 14 | exit 77 |
15 | fi | 15 | fi |
16 | 16 | ||
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 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` | 18 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
19 | 19 | ||
20 | TEST_IP="127.0.0.1" | 20 | TEST_IP="127.0.0.1" |
@@ -31,7 +31,7 @@ gnunet-namestore -z delegatedego -d -n '@' -t A -V $TEST_IP -e never -c test_gn | |||
31 | gnunet-arm -e -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` | 32 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
33 | 33 | ||
34 | if [ "$RES_IP" == "$TEST_IP" ] | 34 | if [ "$RES_IP" = "$TEST_IP" ] |
35 | then | 35 | then |
36 | exit 0 | 36 | exit 0 |
37 | else | 37 | else |
diff --git a/src/gns/test_gns_cname_lookup.sh b/src/gns/test_gns_cname_lookup.sh index de575c561..d97a4fe5e 100755 --- a/src/gns/test_gns_cname_lookup.sh +++ b/src/gns/test_gns_cname_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -16,7 +16,7 @@ fi | |||
16 | 16 | ||
17 | # permissive DNS resolver we will use for the test | 17 | # permissive DNS resolver we will use for the test |
18 | DNS_RESOLVER="8.8.8.8" | 18 | DNS_RESOLVER="8.8.8.8" |
19 | if ! nslookup gnunet.org $DNS_RESOLVER &> /dev/null | 19 | if ! nslookup gnunet.org $DNS_RESOLVER > /dev/null 2>&1 |
20 | then | 20 | then |
21 | echo "Cannot reach DNS, skipping test" | 21 | echo "Cannot reach DNS, skipping test" |
22 | exit 77 | 22 | exit 77 |
@@ -36,7 +36,7 @@ TEST_RECORD_NAME_DNS="www3" | |||
36 | MY_EGO="myego" | 36 | MY_EGO="myego" |
37 | TEST_DOMAIN_PLUS="www.$MY_EGO" | 37 | TEST_DOMAIN_PLUS="www.$MY_EGO" |
38 | TEST_DOMAIN_DNS="www3.$MY_EGO" | 38 | TEST_DOMAIN_DNS="www3.$MY_EGO" |
39 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 39 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
40 | 40 | ||
41 | gnunet-arm -s -c test_gns_lookup.conf | 41 | gnunet-arm -s -c test_gns_lookup.conf |
42 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 42 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
@@ -57,7 +57,7 @@ rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | |||
57 | # make cmp case-insensitive by converting to lower case first | 57 | # make cmp case-insensitive by converting to lower case first |
58 | RES_CNAME_RAW=`echo $RES_CNAME_RAW | tr [A-Z] [a-z]` | 58 | RES_CNAME_RAW=`echo $RES_CNAME_RAW | tr [A-Z] [a-z]` |
59 | TESTEGOZONE=`echo $TESTEGOZONE | tr [A-Z] [a-z]` | 59 | TESTEGOZONE=`echo $TESTEGOZONE | tr [A-Z] [a-z]` |
60 | if [ "$RES_CNAME_RAW" == "server.$TESTEGOZONE" ] | 60 | if [ "$RES_CNAME_RAW" = "server.$TESTEGOZONE" ] |
61 | then | 61 | then |
62 | echo "PASS: CNAME resolution from GNS" | 62 | echo "PASS: CNAME resolution from GNS" |
63 | else | 63 | else |
@@ -65,7 +65,7 @@ else | |||
65 | exit 1 | 65 | exit 1 |
66 | fi | 66 | fi |
67 | 67 | ||
68 | if [ "$RES_CNAME" == "$TEST_IP_PLUS" ] | 68 | if [ "$RES_CNAME" = "$TEST_IP_PLUS" ] |
69 | then | 69 | then |
70 | echo "PASS: IP resolution from GNS" | 70 | echo "PASS: IP resolution from GNS" |
71 | else | 71 | else |
@@ -73,7 +73,7 @@ else | |||
73 | exit 1 | 73 | exit 1 |
74 | fi | 74 | fi |
75 | 75 | ||
76 | if [ "$RES_CNAME_DNS" == "$TEST_IP_DNS" ] | 76 | if [ "$RES_CNAME_DNS" = "$TEST_IP_DNS" ] |
77 | then | 77 | then |
78 | echo "PASS: IP resolution from DNS" | 78 | echo "PASS: IP resolution from DNS" |
79 | exit 0 | 79 | exit 0 |
diff --git a/src/gns/test_gns_config_lookup.sh b/src/gns/test_gns_config_lookup.sh index 35d7c32d9..1c5a62b01 100755 --- a/src/gns/test_gns_config_lookup.sh +++ b/src/gns/test_gns_config_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -18,7 +18,7 @@ MY_EGO="myego" | |||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | 18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` |
19 | CFG=`mktemp --tmpdir=$PWD` | 19 | CFG=`mktemp --tmpdir=$PWD` |
20 | cp test_gns_lookup.conf $CFG || exit 77 | 20 | cp test_gns_lookup.conf $CFG || exit 77 |
21 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 21 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
22 | TEST_IP="dead::beef" | 22 | TEST_IP="dead::beef" |
23 | gnunet-arm -s -c $CFG || exit 77 | 23 | gnunet-arm -s -c $CFG || exit 77 |
24 | gnunet-identity -C $MY_EGO -c $CFG | 24 | gnunet-identity -C $MY_EGO -c $CFG |
@@ -35,7 +35,7 @@ gnunet-arm -e -c $CFG | |||
35 | rm -rf `gnunet-config -c $CFG -f -s paths -o GNUNET_TEST_HOME` | 35 | rm -rf `gnunet-config -c $CFG -f -s paths -o GNUNET_TEST_HOME` |
36 | rm $CFG | 36 | rm $CFG |
37 | 37 | ||
38 | if [ "$RES_IP" == "$TEST_IP" ] | 38 | if [ "$RES_IP" = "$TEST_IP" ] |
39 | then | 39 | then |
40 | exit 0 | 40 | exit 0 |
41 | else | 41 | else |
diff --git a/src/gns/test_gns_delegated_lookup.sh b/src/gns/test_gns_delegated_lookup.sh index 21774ad8d..af9994b34 100755 --- a/src/gns/test_gns_delegated_lookup.sh +++ b/src/gns/test_gns_delegated_lookup.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
5 | 5 | ||
6 | LOCATION=$(which gnunet-config) | 6 | LOCATION=$(which gnunet-config) |
7 | if [ -z $LOCATION ] | 7 | if [ -z $LOCATION ] |
@@ -35,7 +35,7 @@ gnunet-arm -e -c test_gns_lookup.conf | |||
35 | 35 | ||
36 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 36 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
37 | 37 | ||
38 | if [ "$RES_IP" == "$TEST_IP" ] | 38 | if [ "$RES_IP" = "$TEST_IP" ] |
39 | then | 39 | then |
40 | exit 0 | 40 | exit 0 |
41 | else | 41 | else |
diff --git a/src/gns/test_gns_dht_lookup.sh b/src/gns/test_gns_dht_lookup.sh index 07e559752..ac90d58a8 100755 --- a/src/gns/test_gns_dht_lookup.sh +++ b/src/gns/test_gns_dht_lookup.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
5 | 5 | ||
6 | LOCATION=$(which gnunet-config) | 6 | LOCATION=$(which gnunet-config) |
7 | if [ -z $LOCATION ] | 7 | if [ -z $LOCATION ] |
@@ -55,7 +55,7 @@ then | |||
55 | echo "Failed to resolve to proper IP, got $RES_IP_REL. (relative expiration)" | 55 | echo "Failed to resolve to proper IP, got $RES_IP_REL. (relative expiration)" |
56 | #exit 1 | 56 | #exit 1 |
57 | fi | 57 | fi |
58 | if [ "$RES_IP" == "$TEST_IP" ] | 58 | if [ "$RES_IP" = "$TEST_IP" ] |
59 | then | 59 | then |
60 | exit 0 | 60 | exit 0 |
61 | else | 61 | else |
diff --git a/src/gns/test_gns_gns2dns_cname_lookup.sh b/src/gns/test_gns_gns2dns_cname_lookup.sh index c07905d83..fbc1dd7ee 100755 --- a/src/gns/test_gns_gns2dns_cname_lookup.sh +++ b/src/gns/test_gns_gns2dns_cname_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -25,7 +25,7 @@ TEST_RECORD_NAME="homepage" | |||
25 | 25 | ||
26 | XNS=ns.joker.com | 26 | XNS=ns.joker.com |
27 | 27 | ||
28 | if ! nslookup gnunet.org a.$XNS &> /dev/null | 28 | if ! nslookup gnunet.org a.$XNS > /dev/null 2>&1 |
29 | then | 29 | then |
30 | echo "Cannot reach DNS, skipping test" | 30 | echo "Cannot reach DNS, skipping test" |
31 | exit 77 | 31 | exit 77 |
@@ -43,7 +43,7 @@ MY_EGO="myego" | |||
43 | # various names we will use for resolution | 43 | # various names we will use for resolution |
44 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | 44 | TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" |
45 | 45 | ||
46 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 46 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
47 | 47 | ||
48 | gnunet-arm -s -c test_gns_lookup.conf | 48 | gnunet-arm -s -c test_gns_lookup.conf |
49 | OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org` | 49 | OUT=`$DO_TIMEOUT gnunet-resolver -c test_gns_lookup.conf gnunet.org` |
@@ -77,7 +77,7 @@ gnunet-arm -e -c test_gns_lookup.conf | |||
77 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 77 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
78 | 78 | ||
79 | ret=0 | 79 | ret=0 |
80 | if [ "$RES_IP" == "$TEST_IP" ] | 80 | if [ "$RES_IP" = "$TEST_IP" ] |
81 | then | 81 | then |
82 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | 82 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." |
83 | else | 83 | else |
@@ -85,7 +85,7 @@ else | |||
85 | ret=1 | 85 | ret=1 |
86 | fi | 86 | fi |
87 | 87 | ||
88 | if [ "$RES_IP6" == "$TEST_IP6" ] | 88 | if [ "$RES_IP6" = "$TEST_IP6" ] |
89 | then | 89 | then |
90 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | 90 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." |
91 | else | 91 | else |
diff --git a/src/gns/test_gns_gns2dns_lookup.sh b/src/gns/test_gns_gns2dns_lookup.sh index 24fb36b9d..22caa68ff 100755 --- a/src/gns/test_gns_gns2dns_lookup.sh +++ b/src/gns/test_gns_gns2dns_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 2 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
3 | 3 | ||
4 | LOCATION=$(which gnunet-config) | 4 | LOCATION=$(which gnunet-config) |
@@ -26,7 +26,7 @@ TEST_IP_GNS2DNS="8.8.8.8" | |||
26 | # main label used during resolution | 26 | # main label used during resolution |
27 | TEST_RECORD_NAME="homepage" | 27 | TEST_RECORD_NAME="homepage" |
28 | 28 | ||
29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS &> /dev/null | 29 | if ! nslookup gnunet.org $TEST_IP_GNS2DNS > /dev/null 2>&1 |
30 | then | 30 | then |
31 | echo "Cannot reach DNS, skipping test" | 31 | echo "Cannot reach DNS, skipping test" |
32 | exit 77 | 32 | exit 77 |
@@ -44,7 +44,7 @@ TEST_DOMAIN="www.${TEST_RECORD_NAME}.$MY_EGO" | |||
44 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" | 44 | TEST_DOMAIN_ALT="${TEST_RECORD_NAME}.$MY_EGO" |
45 | TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO" | 45 | TEST_DOMAIN_ALT2="docs.${TEST_RECORD_NAME}.$MY_EGO" |
46 | 46 | ||
47 | which timeout &> /dev/null && DO_TIMEOUT="timeout 15" | 47 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 15" |
48 | 48 | ||
49 | 49 | ||
50 | gnunet-arm -s -c test_gns_lookup.conf | 50 | gnunet-arm -s -c test_gns_lookup.conf |
@@ -83,7 +83,7 @@ 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` | 83 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
84 | 84 | ||
85 | ret=0 | 85 | ret=0 |
86 | if [ "$RES_IP" == "$TEST_IP" ] | 86 | if [ "$RES_IP" = "$TEST_IP" ] |
87 | then | 87 | then |
88 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." | 88 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP." |
89 | else | 89 | else |
@@ -91,7 +91,7 @@ else | |||
91 | ret=1 | 91 | ret=1 |
92 | fi | 92 | fi |
93 | 93 | ||
94 | if [ "$RES_IP6" == "$TEST_IP6" ] | 94 | if [ "$RES_IP6" = "$TEST_IP6" ] |
95 | then | 95 | then |
96 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." | 96 | echo "PASS: Resolved $TEST_DOMAIN to $RES_IP6." |
97 | else | 97 | else |
@@ -99,7 +99,7 @@ else | |||
99 | ret=1 | 99 | ret=1 |
100 | fi | 100 | fi |
101 | 101 | ||
102 | if [ "$RES_IP_ALT" == "$TEST_IP" ] | 102 | if [ "$RES_IP_ALT" = "$TEST_IP" ] |
103 | then | 103 | then |
104 | echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT." | 104 | echo "PASS: Resolved $TEST_DOMAIN_ALT to $RES_IP_ALT." |
105 | else | 105 | else |
@@ -107,7 +107,7 @@ else | |||
107 | ret=1 | 107 | ret=1 |
108 | fi | 108 | fi |
109 | 109 | ||
110 | if [ "$RES_IP_ALT2" == "$TEST_IP_ALT2" ] | 110 | if [ "$RES_IP_ALT2" = "$TEST_IP_ALT2" ] |
111 | then | 111 | then |
112 | echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2." | 112 | echo "PASS: Resolved $TEST_DOMAIN_ALT2 to $RES_IP_ALT2." |
113 | else | 113 | else |
diff --git a/src/gns/test_gns_ipv6_lookup.sh b/src/gns/test_gns_ipv6_lookup.sh index 72da5ee2c..5dbb34a2c 100755 --- a/src/gns/test_gns_ipv6_lookup.sh +++ b/src/gns/test_gns_ipv6_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -16,7 +16,7 @@ fi | |||
16 | MY_EGO="myego" | 16 | MY_EGO="myego" |
17 | 17 | ||
18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | 18 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` |
19 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 19 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
20 | TEST_IP="dead::beef" | 20 | TEST_IP="dead::beef" |
21 | gnunet-arm -s -c test_gns_lookup.conf | 21 | gnunet-arm -s -c test_gns_lookup.conf |
22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 22 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
@@ -27,7 +27,7 @@ gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | |||
27 | gnunet-arm -e -c test_gns_lookup.conf | 27 | gnunet-arm -e -c test_gns_lookup.conf |
28 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 28 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
29 | 29 | ||
30 | if [ "$RES_IP" == "$TEST_IP" ] | 30 | if [ "$RES_IP" = "$TEST_IP" ] |
31 | then | 31 | then |
32 | exit 0 | 32 | exit 0 |
33 | else | 33 | else |
diff --git a/src/gns/test_gns_lookup.sh b/src/gns/test_gns_lookup.sh index 2dffa1251..4bd6ae879 100755 --- a/src/gns/test_gns_lookup.sh +++ b/src/gns/test_gns_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -15,7 +15,7 @@ then | |||
15 | fi | 15 | fi |
16 | 16 | ||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` | 17 | rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f` |
18 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
19 | TEST_IP="127.0.0.1" | 19 | TEST_IP="127.0.0.1" |
20 | MY_EGO="myego" | 20 | MY_EGO="myego" |
21 | LABEL="www" | 21 | LABEL="www" |
@@ -27,7 +27,7 @@ gnunet-namestore -z $MY_EGO -d -n $LABEL -t A -V $TEST_IP -e never -c test_gns_l | |||
27 | gnunet-identity -D $MY_EGO -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 | 28 | gnunet-arm -e -c test_gns_lookup.conf |
29 | 29 | ||
30 | if [ "$RES_IP" == "$TEST_IP" ] | 30 | if [ "$RES_IP" = "$TEST_IP" ] |
31 | then | 31 | then |
32 | exit 0 | 32 | exit 0 |
33 | else | 33 | else |
diff --git a/src/gns/test_gns_mx_lookup.sh b/src/gns/test_gns_mx_lookup.sh index 79ac37b0a..4e9d98358 100755 --- a/src/gns/test_gns_mx_lookup.sh +++ b/src/gns/test_gns_mx_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -15,7 +15,7 @@ then | |||
15 | fi | 15 | fi |
16 | 16 | ||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
18 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
19 | 19 | ||
20 | MY_EGO="myego" | 20 | MY_EGO="myego" |
21 | TEST_MX="5,mail.+" | 21 | TEST_MX="5,mail.+" |
@@ -35,7 +35,7 @@ rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | |||
35 | RES_MX=`echo $RES_MX | tr [A-Z] [a-z]` | 35 | RES_MX=`echo $RES_MX | tr [A-Z] [a-z]` |
36 | WANT_MX=`echo $WANT_MX | tr [A-Z] [a-z]` | 36 | WANT_MX=`echo $WANT_MX | tr [A-Z] [a-z]` |
37 | 37 | ||
38 | if [ "$RES_MX" == "$WANT_MX" ] | 38 | if [ "$RES_MX" = "$WANT_MX" ] |
39 | then | 39 | then |
40 | exit 0 | 40 | exit 0 |
41 | else | 41 | else |
diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c index 75fe95617..2a7f8104b 100644 --- a/src/gns/test_gns_proxy.c +++ b/src/gns/test_gns_proxy.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -50,9 +50,9 @@ static int global_ret; | |||
50 | 50 | ||
51 | static struct MHD_Daemon *mhd; | 51 | static struct MHD_Daemon *mhd; |
52 | 52 | ||
53 | static struct GNUNET_SCHEDULER_Task * mhd_task_id; | 53 | static struct GNUNET_SCHEDULER_Task *mhd_task_id; |
54 | 54 | ||
55 | static struct GNUNET_SCHEDULER_Task * curl_task_id; | 55 | static struct GNUNET_SCHEDULER_Task *curl_task_id; |
56 | 56 | ||
57 | static CURL *curl; | 57 | static CURL *curl; |
58 | 58 | ||
@@ -349,6 +349,7 @@ curl_main () | |||
349 | static void | 349 | static void |
350 | start_curl (void *cls) | 350 | start_curl (void *cls) |
351 | { | 351 | { |
352 | curl_task_id = NULL; | ||
352 | GNUNET_asprintf (&url, | 353 | GNUNET_asprintf (&url, |
353 | "https://%s:%d/hello_world", | 354 | "https://%s:%d/hello_world", |
354 | TEST_DOMAIN, port); | 355 | TEST_DOMAIN, port); |
@@ -369,7 +370,9 @@ start_curl (void *cls) | |||
369 | multi = curl_multi_init (); | 370 | multi = curl_multi_init (); |
370 | GNUNET_assert (multi != NULL); | 371 | GNUNET_assert (multi != NULL); |
371 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); | 372 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); |
372 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Beginning HTTP download from `%s'\n", url); | 373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
374 | "Beginning HTTP download from `%s'\n", | ||
375 | url); | ||
373 | curl_main (); | 376 | curl_main (); |
374 | } | 377 | } |
375 | 378 | ||
@@ -391,7 +394,8 @@ commence_testing (void *cls) | |||
391 | { | 394 | { |
392 | curl_task_id = | 395 | curl_task_id = |
393 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 396 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
394 | &start_curl, NULL); | 397 | &start_curl, |
398 | NULL); | ||
395 | } | 399 | } |
396 | 400 | ||
397 | 401 | ||
@@ -561,4 +565,4 @@ main (int argc, char *const *argv) | |||
561 | return global_ret; | 565 | return global_ret; |
562 | } | 566 | } |
563 | 567 | ||
564 | /* end of test_gns_vpn.c */ | 568 | /* end of test_gns_proxy.c */ |
diff --git a/src/gns/test_gns_quickupdate.sh b/src/gns/test_gns_quickupdate.sh index d9807fe22..d2b4bf2cb 100755 --- a/src/gns/test_gns_quickupdate.sh +++ b/src/gns/test_gns_quickupdate.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -19,7 +19,7 @@ OTHER_EGO="delegatedego" | |||
19 | 19 | ||
20 | 20 | ||
21 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 21 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
22 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 22 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
23 | TEST_IP="127.0.0.1" | 23 | TEST_IP="127.0.0.1" |
24 | gnunet-arm -s -c test_gns_lookup.conf | 24 | gnunet-arm -s -c test_gns_lookup.conf |
25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 25 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
@@ -56,7 +56,7 @@ gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf | |||
56 | gnunet-arm -e -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` | 57 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
58 | 58 | ||
59 | if [ "$RES_IP" == "$TEST_IP" ] | 59 | if [ "$RES_IP" = "$TEST_IP" ] |
60 | then | 60 | then |
61 | exit 0 | 61 | exit 0 |
62 | else | 62 | else |
diff --git a/src/gns/test_gns_rel_expiration.sh b/src/gns/test_gns_rel_expiration.sh index c7c66bc27..993c2131e 100755 --- a/src/gns/test_gns_rel_expiration.sh +++ b/src/gns/test_gns_rel_expiration.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -25,7 +25,7 @@ MY_EGO="myego" | |||
25 | OTHER_EGO="delegatedego" | 25 | OTHER_EGO="delegatedego" |
26 | 26 | ||
27 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 27 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
28 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 28 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
29 | TEST_IP="127.0.0.1" | 29 | TEST_IP="127.0.0.1" |
30 | gnunet-arm -s -c test_gns_lookup.conf | 30 | gnunet-arm -s -c test_gns_lookup.conf |
31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 31 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
@@ -48,13 +48,13 @@ gnunet-identity -D $OTHER_EGO -c test_gns_lookup.conf | |||
48 | gnunet-arm -e -c test_gns_lookup.conf | 48 | gnunet-arm -e -c test_gns_lookup.conf |
49 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 49 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
50 | 50 | ||
51 | if [ "$RES_IP_EXP" == "$TEST_IP" ] | 51 | if [ "$RES_IP_EXP" = "$TEST_IP" ] |
52 | then | 52 | then |
53 | echo "Failed to properly expire IP, got $RES_IP_EXP." | 53 | echo "Failed to properly expire IP, got $RES_IP_EXP." |
54 | exit 1 | 54 | exit 1 |
55 | fi | 55 | fi |
56 | 56 | ||
57 | if [ "$RES_IP" == "$TEST_IP" ] | 57 | if [ "$RES_IP" = "$TEST_IP" ] |
58 | then | 58 | then |
59 | exit 0 | 59 | exit 0 |
60 | else | 60 | else |
diff --git a/src/gns/test_gns_revocation.sh b/src/gns/test_gns_revocation.sh index 08a0f8ac1..3c0cf02fb 100755 --- a/src/gns/test_gns_revocation.sh +++ b/src/gns/test_gns_revocation.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
5 | 5 | ||
6 | LOCATION=$(which gnunet-config) | 6 | LOCATION=$(which gnunet-config) |
7 | if [ -z $LOCATION ] | 7 | if [ -z $LOCATION ] |
@@ -40,7 +40,7 @@ then | |||
40 | exit 1 | 40 | exit 1 |
41 | fi | 41 | fi |
42 | 42 | ||
43 | if [ "x$RES_IP_REV" == "x" ] | 43 | if [ "x$RES_IP_REV" = "x" ] |
44 | then | 44 | then |
45 | exit 0 | 45 | exit 0 |
46 | else | 46 | else |
diff --git a/src/gns/test_gns_soa_lookup.sh b/src/gns/test_gns_soa_lookup.sh index 6a09ac8c7..c5b049b72 100755 --- a/src/gns/test_gns_soa_lookup.sh +++ b/src/gns/test_gns_soa_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -14,7 +14,7 @@ then | |||
14 | exit 77 | 14 | exit 77 |
15 | fi | 15 | fi |
16 | 16 | ||
17 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 17 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
18 | 18 | ||
19 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 19 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
20 | MY_EGO="myego" | 20 | MY_EGO="myego" |
@@ -24,7 +24,7 @@ TEST_IP_GNS2DNS="184.172.157.218" | |||
24 | TEST_RECORD_NAME="homepage" | 24 | TEST_RECORD_NAME="homepage" |
25 | TEST_RECORD_GNS2DNS="gnunet.org" | 25 | TEST_RECORD_GNS2DNS="gnunet.org" |
26 | 26 | ||
27 | if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS &> /dev/null | 27 | if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS > /dev/null 2>&1 |
28 | then | 28 | then |
29 | echo "Cannot reach DNS, skipping test" | 29 | echo "Cannot reach DNS, skipping test" |
30 | exit 77 | 30 | exit 77 |
@@ -34,7 +34,7 @@ gnunet-arm -s -c test_gns_lookup.conf | |||
34 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf | 34 | gnunet-identity -C $MY_EGO -c test_gns_lookup.conf |
35 | 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 | 35 | 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 |
36 | RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` | 36 | RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf` |
37 | 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 | 37 | 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 |
38 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | 38 | gnunet-identity -D $MY_EGO -c test_gns_lookup.conf |
39 | gnunet-arm -e -c test_gns_lookup.conf | 39 | gnunet-arm -e -c test_gns_lookup.conf |
40 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 40 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
diff --git a/src/gns/test_gns_txt_lookup.sh b/src/gns/test_gns_txt_lookup.sh index 6c6b4b3f6..b0c9144c2 100755 --- a/src/gns/test_gns_txt_lookup.sh +++ b/src/gns/test_gns_txt_lookup.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | 4 | ||
@@ -15,7 +15,7 @@ then | |||
15 | fi | 15 | fi |
16 | 16 | ||
17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` | 17 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
18 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | 18 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 30" |
19 | TEST_TXT="GNS powered txt record data" | 19 | TEST_TXT="GNS powered txt record data" |
20 | MY_EGO="myego" | 20 | MY_EGO="myego" |
21 | LABEL="testtxt" | 21 | LABEL="testtxt" |
@@ -28,7 +28,7 @@ gnunet-identity -D $MY_EGO -c test_gns_lookup.conf | |||
28 | gnunet-arm -e -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` | 29 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
30 | 30 | ||
31 | if [ "$RES_TXT" == "$TEST_TXT" ] | 31 | if [ "$RES_TXT" = "$TEST_TXT" ] |
32 | then | 32 | then |
33 | exit 0 | 33 | exit 0 |
34 | else | 34 | else |
diff --git a/src/gns/test_gns_zkey_lookup.sh b/src/gns/test_gns_zkey_lookup.sh index b36a16fa2..03118d741 100755 --- a/src/gns/test_gns_zkey_lookup.sh +++ b/src/gns/test_gns_zkey_lookup.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 3 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
4 | which timeout &> /dev/null && DO_TIMEOUT="timeout 5" | 4 | which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5" |
5 | 5 | ||
6 | LOCATION=$(which gnunet-config) | 6 | LOCATION=$(which gnunet-config) |
7 | if [ -z $LOCATION ] | 7 | if [ -z $LOCATION ] |
@@ -30,7 +30,7 @@ gnunet-namestore -z delegatedego -d -n www -t A -V $TEST_IP -e never -c test_gn | |||
30 | gnunet-arm -e -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` | 31 | rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME` |
32 | 32 | ||
33 | if [ "$RES_IP" == "$TEST_IP" ] | 33 | if [ "$RES_IP" = "$TEST_IP" ] |
34 | then | 34 | then |
35 | exit 0 | 35 | exit 0 |
36 | else | 36 | else |
diff --git a/src/gns/test_gnunet_gns.sh b/src/gns/test_gnunet_gns.sh index f6b4e721a..74c49c537 100755 --- a/src/gns/test_gnunet_gns.sh +++ b/src/gns/test_gnunet_gns.sh | |||
@@ -1,15 +1,25 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # This file is in the public domain. | 2 | # This file is in the public domain. |
3 | LOCATION=$(which gnunet-config) | 3 | # test -z being correct was a false assumption here. |
4 | if [ -z $LOCATION ] | 4 | # I have no executable 'fooble', but this will |
5 | then | 5 | # return 1: |
6 | LOCATION="gnunet-config" | 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 | existence() | ||
10 | { | ||
11 | command -v "$1" >/dev/null 2>&1 | ||
12 | } | ||
13 | |||
14 | LOCATION=`existence gnunet-config` | ||
15 | if test -z $LOCATION; then | ||
16 | LOCATION="gnunet-config" | ||
7 | fi | 17 | fi |
8 | $LOCATION --version | 18 | $LOCATION --version |
9 | if test $? != 0 | 19 | if test $? != 0 |
10 | then | 20 | then |
11 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | 21 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" |
12 | exit 77 | 22 | exit 77 |
13 | fi | 23 | fi |
14 | 24 | ||
15 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT | 25 | trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT |
@@ -32,4 +42,5 @@ if [ "$LO" != "Address: 4.5.6.7" ] | |||
32 | then | 42 | then |
33 | echo "Fail: $LO" | 43 | echo "Fail: $LO" |
34 | fi | 44 | fi |
45 | # XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now. | ||
35 | kill `jobs -p` | 46 | kill `jobs -p` |
diff --git a/src/gns/test_plugin_rest_gns.sh b/src/gns/test_plugin_rest_gns.sh new file mode 100755 index 000000000..ec495a04b --- /dev/null +++ b/src/gns/test_plugin_rest_gns.sh | |||
@@ -0,0 +1,50 @@ | |||
1 | #!/usr/bin/bash | ||
2 | |||
3 | #First, start gnunet-arm and the rest-service. | ||
4 | #Exit 0 means success, exit 1 means failed test | ||
5 | |||
6 | gns_link="http://localhost:7776/gns" | ||
7 | wrong_link="http://localhost:7776/gnsandmore" | ||
8 | |||
9 | curl_get () { | ||
10 | #$1 is link | ||
11 | #$2 is grep | ||
12 | cache="$(curl -v "$1" 2>&1 | grep "$2")" | ||
13 | #echo $cache | ||
14 | if [ "" == "$cache" ] | ||
15 | then | ||
16 | exit 1 | ||
17 | fi | ||
18 | } | ||
19 | |||
20 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | ||
21 | |||
22 | curl_get "$gns_link/www.test_plugin_rest_gns" "error" | ||
23 | |||
24 | gnunet-identity -C "test_plugin_rest_gns" | ||
25 | |||
26 | curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]" | ||
27 | |||
28 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A | ||
29 | |||
30 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1" | ||
31 | |||
32 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA | ||
33 | |||
34 | curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1" | ||
35 | |||
36 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A | ||
37 | |||
38 | curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1" | ||
39 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1" | ||
40 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1" | ||
41 | curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1" | ||
42 | |||
43 | gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A | ||
44 | curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1" | ||
45 | |||
46 | gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1 | ||
47 | |||
48 | curl_get "$gns_link/www1.test_plugin_rest_gns" "error" | ||
49 | |||
50 | exit 0 | ||
diff --git a/src/gns/test_proxy.sh b/src/gns/test_proxy.sh index c960d4df9..7c17cd4c5 100755 --- a/src/gns/test_proxy.sh +++ b/src/gns/test_proxy.sh | |||
@@ -1,7 +1,9 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | # This file is in the public domain. | |
3 | TEST_DOMAIN="www.test" | 3 | TEST_DOMAIN="www.test" |
4 | 4 | ||
5 | # Delete old files before starting test | ||
6 | rm -rf /tmp/gnunet/test-gnunet-gns-testing/ | ||
5 | gnunet-arm -s -c test_gns_proxy.conf | 7 | gnunet-arm -s -c test_gns_proxy.conf |
6 | gnunet-gns-proxy-setup-ca -c test_gns_proxy.conf | 8 | gnunet-gns-proxy-setup-ca -c test_gns_proxy.conf |
7 | 9 | ||