diff options
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | README | 4 | ||||
-rwxr-xr-x | bootstrap | 5 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | contrib/Makefile.am | 15 | ||||
-rw-r--r-- | contrib/packages/guix/gnunet-doc.scm | 14 | ||||
-rw-r--r-- | contrib/packages/guix/gnunet.scm | 14 | ||||
-rw-r--r-- | contrib/packages/guix/guix-env.scm | 1 | ||||
-rw-r--r-- | contrib/packages/guix/packages/gnunet/packages/gnunet.scm | 4 | ||||
-rw-r--r-- | doc/.gitignore | 11 | ||||
-rw-r--r-- | doc/Makefile.am | 227 | ||||
-rw-r--r-- | doc/README.txt | 42 | ||||
-rw-r--r-- | doc/chapters/developer.texi | 7487 | ||||
-rw-r--r-- | doc/chapters/installation.texi | 3625 | ||||
-rw-r--r-- | doc/chapters/user.texi | 1819 | ||||
-rw-r--r-- | doc/documentation/Makefile.am | 227 | ||||
-rw-r--r-- | doc/documentation/README.txt | 69 | ||||
-rw-r--r-- | doc/documentation/chapters/configuration.texi | 5 | ||||
-rw-r--r-- | doc/documentation/chapters/developer.texi | 8304 | ||||
-rw-r--r-- | doc/documentation/chapters/installation.texi | 3995 | ||||
-rw-r--r-- | doc/documentation/chapters/philosophy.texi (renamed from doc/chapters/philosophy.texi) | 312 | ||||
-rw-r--r-- | doc/documentation/chapters/user.texi | 2009 | ||||
-rw-r--r-- | doc/documentation/chapters/vocabulary.texi | 57 | ||||
-rw-r--r-- | doc/documentation/docstyle.css | 76 | ||||
-rw-r--r-- | doc/documentation/fdl-1.3.texi (renamed from doc/fdl-1.3.texi) | 0 | ||||
-rwxr-xr-x | doc/documentation/gendocs.sh | 504 | ||||
-rw-r--r-- | doc/documentation/gendocs_template | 91 | ||||
-rw-r--r-- | doc/documentation/gendocs_template_min | 93 | ||||
-rw-r--r-- | doc/documentation/gnunet-c-tutorial.texi (renamed from doc/gnunet-c-tutorial.texi) | 826 | ||||
-rw-r--r-- | doc/documentation/gnunet.texi (renamed from doc/gnunet.texi) | 129 | ||||
-rw-r--r-- | doc/documentation/gpl-3.0.texi (renamed from doc/gpl-3.0.texi) | 0 | ||||
-rw-r--r-- | doc/documentation/htmlxref.cnf | 668 | ||||
-rw-r--r-- | doc/documentation/images/daemon_lego_block.png (renamed from doc/images/daemon_lego_block.png) | bin | 7636 -> 7636 bytes | |||
-rw-r--r-- | doc/documentation/images/daemon_lego_block.svg (renamed from doc/images/daemon_lego_block.svg) | 0 | ||||
-rw-r--r-- | doc/documentation/images/gnunet-0-10-peerinfo.png (renamed from doc/images/gnunet-0-10-peerinfo.png) | bin | 80127 -> 80127 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-fs-gtk-0-10-star-tab.png (renamed from doc/images/gnunet-fs-gtk-0-10-star-tab.png) | bin | 63464 -> 63464 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-download-area.png (renamed from doc/images/gnunet-gtk-0-10-download-area.png) | bin | 7634 -> 7634 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-menu.png (renamed from doc/images/gnunet-gtk-0-10-fs-menu.png) | bin | 8614 -> 8614 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-publish-editing.png (renamed from doc/images/gnunet-gtk-0-10-fs-publish-editing.png) | bin | 55507 -> 55507 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-publish-select.png (renamed from doc/images/gnunet-gtk-0-10-fs-publish-select.png) | bin | 43448 -> 43448 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file.png (renamed from doc/images/gnunet-gtk-0-10-fs-publish-with-file.png) | bin | 27371 -> 27371 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file_0.png (renamed from doc/images/gnunet-gtk-0-10-fs-publish-with-file_0.png) | bin | 27371 -> 27371 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-publish.png (renamed from doc/images/gnunet-gtk-0-10-fs-publish.png) | bin | 26496 -> 26496 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-published.png (renamed from doc/images/gnunet-gtk-0-10-fs-published.png) | bin | 59635 -> 59635 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs-search.png (renamed from doc/images/gnunet-gtk-0-10-fs-search.png) | bin | 72151 -> 72151 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-fs.png (renamed from doc/images/gnunet-gtk-0-10-fs.png) | bin | 55706 -> 55706 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-gns-a-done.png (renamed from doc/images/gnunet-gtk-0-10-gns-a-done.png) | bin | 30880 -> 30880 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-gns-a.png (renamed from doc/images/gnunet-gtk-0-10-gns-a.png) | bin | 29895 -> 29895 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-gns.png (renamed from doc/images/gnunet-gtk-0-10-gns.png) | bin | 63783 -> 63783 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-identity.png (renamed from doc/images/gnunet-gtk-0-10-identity.png) | bin | 62404 -> 62404 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-search-selected.png (renamed from doc/images/gnunet-gtk-0-10-search-selected.png) | bin | 104599 -> 104599 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10-traffic.png (renamed from doc/images/gnunet-gtk-0-10-traffic.png) | bin | 68515 -> 68515 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-gtk-0-10.png (renamed from doc/images/gnunet-gtk-0-10.png) | bin | 72897 -> 72897 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-namestore-gtk-phone.png (renamed from doc/images/gnunet-namestore-gtk-phone.png) | bin | 32631 -> 32631 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-namestore-gtk-vpn.png (renamed from doc/images/gnunet-namestore-gtk-vpn.png) | bin | 35836 -> 35836 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-setup-exit.png (renamed from doc/images/gnunet-setup-exit.png) | bin | 30062 -> 30062 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-tutorial-service.png (renamed from doc/images/gnunet-tutorial-service.png) | bin | 40142 -> 40142 bytes | |||
-rw-r--r-- | doc/documentation/images/gnunet-tutorial-system.png (renamed from doc/images/gnunet-tutorial-system.png) | bin | 46982 -> 46982 bytes | |||
-rw-r--r-- | doc/documentation/images/iceweasel-preferences.png (renamed from doc/images/iceweasel-preferences.png) | bin | 57047 -> 57047 bytes | |||
-rw-r--r-- | doc/documentation/images/iceweasel-proxy.png (renamed from doc/images/iceweasel-proxy.png) | bin | 38773 -> 38773 bytes | |||
-rw-r--r-- | doc/documentation/images/lego_stack.svg (renamed from doc/images/lego_stack.svg) | 0 | ||||
-rw-r--r-- | doc/documentation/images/service_lego_block.png (renamed from doc/images/service_lego_block.png) | bin | 15157 -> 15157 bytes | |||
-rw-r--r-- | doc/documentation/images/service_lego_block.svg (renamed from doc/images/service_lego_block.svg) | 0 | ||||
-rw-r--r-- | doc/documentation/images/service_stack.png (renamed from doc/images/service_stack.png) | bin | 18862 -> 18862 bytes | |||
-rw-r--r-- | doc/documentation/images/structure.dot (renamed from doc/images/structure.dot) | 0 | ||||
-rw-r--r-- | doc/documentation/index.html | 31 | ||||
-rwxr-xr-x | doc/documentation/run-gendocs.sh | 18 | ||||
-rw-r--r-- | doc/documentation/testbed_test.c (renamed from doc/testbed_test.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/001.c (renamed from doc/tutorial-examples/001.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/002.c (renamed from doc/tutorial-examples/002.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/003.c | 11 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/004.c (renamed from doc/tutorial-examples/004.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/005.c (renamed from doc/tutorial-examples/005.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/006.c (renamed from doc/tutorial-examples/006.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/007.c (renamed from doc/tutorial-examples/007.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/008.c (renamed from doc/tutorial-examples/008.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/009.c (renamed from doc/tutorial-examples/009.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/010.c (renamed from doc/tutorial-examples/010.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/011.c (renamed from doc/tutorial-examples/011.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/012.c (renamed from doc/tutorial-examples/012.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/013.1.c | 3 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/013.c (renamed from doc/tutorial-examples/013.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/014.c (renamed from doc/tutorial-examples/014.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/015.c (renamed from doc/tutorial-examples/015.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/016.c (renamed from doc/tutorial-examples/016.c) | 3 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/017.c | 4 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/018.c (renamed from doc/tutorial-examples/018.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/019.c (renamed from doc/tutorial-examples/019.c) | 7 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/020.c (renamed from doc/tutorial-examples/020.c) | 3 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/021.c (renamed from doc/tutorial-examples/021.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/022.c (renamed from doc/tutorial-examples/022.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/023.c (renamed from doc/tutorial-examples/023.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/024.c (renamed from doc/tutorial-examples/024.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/025.c (renamed from doc/tutorial-examples/025.c) | 0 | ||||
-rw-r--r-- | doc/documentation/tutorial-examples/026.c (renamed from doc/tutorial-examples/026.c) | 0 | ||||
-rw-r--r-- | doc/hacks.el | 17 | ||||
-rw-r--r-- | doc/tutorial-examples/003.c | 7 | ||||
-rw-r--r-- | doc/tutorial-examples/017.c | 3 | ||||
-rw-r--r-- | src/arm/Makefile.am | 3 | ||||
-rw-r--r-- | src/dht/Makefile.am | 3 | ||||
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 16 | ||||
-rw-r--r-- | src/integration-tests/Makefile.am | 3 | ||||
-rw-r--r-- | src/statistics/Makefile.am | 3 | ||||
-rw-r--r-- | src/util/scheduler.c | 48 |
104 files changed, 17113 insertions, 13711 deletions
@@ -32,7 +32,6 @@ Werner Koch <wk@gnupg.org> | |||
32 | Contributions also came from: | 32 | Contributions also came from: |
33 | Adam Warrington [ UPnP ] | 33 | Adam Warrington [ UPnP ] |
34 | Adriano Peluso [ Documentation export to Texinfo ] | 34 | Adriano Peluso [ Documentation export to Texinfo ] |
35 | ng0 <ng0@infotropique.org> [ Documentation export to Texinfo ] | ||
36 | Alex Harper [ OS X CPU load ] | 35 | Alex Harper [ OS X CPU load ] |
37 | Andrew McDonald <andrew@mcdonald.org.uk> [ SHA-512] | 36 | Andrew McDonald <andrew@mcdonald.org.uk> [ SHA-512] |
38 | Andy Green <andy@warmcat.com> | 37 | Andy Green <andy@warmcat.com> |
@@ -69,6 +68,7 @@ Marko Räihä | |||
69 | Michael John Wensley <michael@wensley.org.uk> | 68 | Michael John Wensley <michael@wensley.org.uk> |
70 | Milan Bouchet-Valat <nalimilan@club.fr> | 69 | Milan Bouchet-Valat <nalimilan@club.fr> |
71 | Nathan Evans <evans@net.in.tum.de> | 70 | Nathan Evans <evans@net.in.tum.de> |
71 | ng0 <ng0@infotropique.org> [ Documentation export to Texinfo ] | ||
72 | Paul Ruth <ruth@cs.purdue.edu> | 72 | Paul Ruth <ruth@cs.purdue.edu> |
73 | Philipp Tölke <toelke@in.tum.de>, <pt@philipptoelke.de> | 73 | Philipp Tölke <toelke@in.tum.de>, <pt@philipptoelke.de> |
74 | Renaldo Ferreira <rf@cs.purdue.edu> | 74 | Renaldo Ferreira <rf@cs.purdue.edu> |
@@ -51,7 +51,7 @@ These are the direct dependencies for running GNUnet: | |||
51 | - Texinfo >= 5.2 | 51 | - Texinfo >= 5.2 |
52 | - libglpk >= 4.45 (optional for experimental code) | 52 | - libglpk >= 4.45 (optional for experimental code) |
53 | 53 | ||
54 | Recommended autotools for compiling the SVN version are: | 54 | Recommended autotools for compiling the git version are: |
55 | - autoconf >= 2.59 | 55 | - autoconf >= 2.59 |
56 | - automake >= 1.11.1 | 56 | - automake >= 1.11.1 |
57 | - libtool >= 2.2 | 57 | - libtool >= 2.2 |
@@ -135,7 +135,7 @@ install' process with SUDO rights, the libraries will be installed to | |||
135 | "$GNUNET_PREFIX" and you will have to move them to "/lib/" | 135 | "$GNUNET_PREFIX" and you will have to move them to "/lib/" |
136 | manually. | 136 | manually. |
137 | 137 | ||
138 | Finally, if you are compiling the code from subversion, you have to | 138 | Finally, if you are compiling the code from git, you have to |
139 | run ". bootstrap" before ./configure. If you receive an error during | 139 | run ". bootstrap" before ./configure. If you receive an error during |
140 | the running of ". bootstrap" that looks like "macro `AM_PATH_GTK' not | 140 | the running of ". bootstrap" that looks like "macro `AM_PATH_GTK' not |
141 | found in library", you may need to run aclocal by hand with the -I | 141 | found in library", you may need to run aclocal by hand with the -I |
@@ -1,4 +1,9 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | rm -rf libltdl | 2 | rm -rf libltdl |
3 | echo -n "checking for libtoolize / libtool... " | ||
4 | which glibtoolize || which libtoolize || which libtool || { | ||
5 | echo "*** No libtoolize (libtool) or libtool found, please install it ***" | ||
6 | exit 1 | ||
7 | } | ||
3 | autoreconf -if | 8 | autoreconf -if |
4 | contrib/pogen.sh | 9 | contrib/pogen.sh |
diff --git a/configure.ac b/configure.ac index 9d1fb9ab3..c97596971 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -248,6 +248,11 @@ then | |||
248 | fi | 248 | fi |
249 | AC_DEFINE_UNQUOTED([NEED_LIBGCRYPT_VERSION], "$NEED_LIBGCRYPT_VERSION", [required libgcrypt version]) | 249 | AC_DEFINE_UNQUOTED([NEED_LIBGCRYPT_VERSION], "$NEED_LIBGCRYPT_VERSION", [required libgcrypt version]) |
250 | 250 | ||
251 | # TODO: add check for VERSION | ||
252 | # TODO: add check for alternatives | ||
253 | # TODO: add switch to skip documentation building | ||
254 | AM_MISSING_PROG([MAKEINFO], [makeinfo]) | ||
255 | |||
251 | # Adam shostack suggests the following for Windows: | 256 | # Adam shostack suggests the following for Windows: |
252 | # -D_FORTIFY_SOURCE=2 -fstack-protector-all | 257 | # -D_FORTIFY_SOURCE=2 -fstack-protector-all |
253 | AC_ARG_ENABLE(gcc-hardening, | 258 | AC_ARG_ENABLE(gcc-hardening, |
@@ -1526,6 +1531,7 @@ contrib/Makefile | |||
1526 | doc/Makefile | 1531 | doc/Makefile |
1527 | doc/man/Makefile | 1532 | doc/man/Makefile |
1528 | doc/doxygen/Makefile | 1533 | doc/doxygen/Makefile |
1534 | doc/documentation/Makefile | ||
1529 | m4/Makefile | 1535 | m4/Makefile |
1530 | po/Makefile.in | 1536 | po/Makefile.in |
1531 | src/Makefile | 1537 | src/Makefile |
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 07cff424c..ac8b15188 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -70,7 +70,20 @@ CLEANFILES = \ | |||
70 | 70 | ||
71 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 71 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
72 | 72 | ||
73 | %.py: %.py.in Makefile | 73 | # Use SUFFIX Extension rules, they are more portable for every |
74 | # implementation of 'make'. | ||
75 | # You'll also run into the "'%' is a GNU make extension warning" | ||
76 | # if you use this: | ||
77 | # | ||
78 | #%.py: %.py.in Makefile | ||
79 | # $(do_subst) < $< > $@ | ||
80 | # chmod +x $@ | ||
81 | # | ||
82 | # instead of this: | ||
83 | |||
84 | SUFFIXES = .py.in .py | ||
85 | |||
86 | .py.in.py: | ||
74 | $(do_subst) < $< > $@ | 87 | $(do_subst) < $< > $@ |
75 | chmod +x $@ | 88 | chmod +x $@ |
76 | 89 | ||
diff --git a/contrib/packages/guix/gnunet-doc.scm b/contrib/packages/guix/gnunet-doc.scm index 9974c1b51..b1ede6612 100644 --- a/contrib/packages/guix/gnunet-doc.scm +++ b/contrib/packages/guix/gnunet-doc.scm | |||
@@ -94,7 +94,7 @@ | |||
94 | ("gnurl" ,gnurl) | 94 | ("gnurl" ,gnurl) |
95 | ("gstreamer" ,gstreamer) | 95 | ("gstreamer" ,gstreamer) |
96 | ("gst-plugins-base" ,gst-plugins-base) | 96 | ("gst-plugins-base" ,gst-plugins-base) |
97 | ("gnutls" ,gnutls) ;Change to gnutls/dane once it is merged. | 97 | ("gnutls/dane" ,gnutls/dane) |
98 | ("libextractor" ,libextractor) | 98 | ("libextractor" ,libextractor) |
99 | ("libgcrypt" ,libgcrypt) | 99 | ("libgcrypt" ,libgcrypt) |
100 | ("libidn" ,libidn) | 100 | ("libidn" ,libidn) |
@@ -109,7 +109,7 @@ | |||
109 | ("mysql" ,mysql) | 109 | ("mysql" ,mysql) |
110 | ("zlib" ,zlib) | 110 | ("zlib" ,zlib) |
111 | ("perl" ,perl) | 111 | ("perl" ,perl) |
112 | ("python" ,python) ; tests and gnunet-qr | 112 | ("python-2" ,python-2) ; tests and gnunet-qr |
113 | ("jansson" ,jansson) | 113 | ("jansson" ,jansson) |
114 | ("nss" ,nss) | 114 | ("nss" ,nss) |
115 | ("glib" ,glib "bin") | 115 | ("glib" ,glib "bin") |
@@ -126,6 +126,7 @@ | |||
126 | ("gnu-gettext" ,gnu-gettext) | 126 | ("gnu-gettext" ,gnu-gettext) |
127 | ("graphviz" ,graphviz) ; dot | 127 | ("graphviz" ,graphviz) ; dot |
128 | ("texinfo-5" ,texinfo-5) ; Debian stable | 128 | ("texinfo-5" ,texinfo-5) ; Debian stable |
129 | ("which" ,which) | ||
129 | ("libtool" ,libtool))) | 130 | ("libtool" ,libtool))) |
130 | (arguments | 131 | (arguments |
131 | `(#:configure-flags | 132 | `(#:configure-flags |
@@ -142,8 +143,13 @@ | |||
142 | (zero? (system* "sh" "bootstrap")))) | 143 | (zero? (system* "sh" "bootstrap")))) |
143 | (replace 'build | 144 | (replace 'build |
144 | (lambda _ | 145 | (lambda _ |
145 | (chdir "doc") | 146 | (chdir "doc/documentation") |
146 | (zero? (system* "make" "doc-all-give-me-the-noise")))) | 147 | ;;(zero? (system* "make" "dev-build")))) |
148 | (zero? (system* "sh" "run-gendocs.sh")))) | ||
149 | ;; (zero? (system* "make" "pdf")) | ||
150 | ;; (zero? (system* "make" "html")) | ||
151 | ;; (zero? (system* "make" "info")))) | ||
152 | ;;(zero? (system* "make" "doc-all-give-me-the-noise")))) | ||
147 | (replace 'install | 153 | (replace 'install |
148 | (lambda _ | 154 | (lambda _ |
149 | (zero? (system* "make" "doc-all-install"))))))) | 155 | (zero? (system* "make" "doc-all-install"))))))) |
diff --git a/contrib/packages/guix/gnunet.scm b/contrib/packages/guix/gnunet.scm index a358fcecc..d8eee1805 100644 --- a/contrib/packages/guix/gnunet.scm +++ b/contrib/packages/guix/gnunet.scm | |||
@@ -60,6 +60,7 @@ | |||
60 | (gnu packages texinfo) | 60 | (gnu packages texinfo) |
61 | (gnu packages tex) | 61 | (gnu packages tex) |
62 | (gnu packages tls) | 62 | (gnu packages tls) |
63 | (gnu packages upnp) | ||
63 | (gnu packages video) | 64 | (gnu packages video) |
64 | (gnu packages web) | 65 | (gnu packages web) |
65 | (gnu packages xiph) | 66 | (gnu packages xiph) |
@@ -91,7 +92,7 @@ | |||
91 | ("gnurl" ,gnurl) | 92 | ("gnurl" ,gnurl) |
92 | ("gstreamer" ,gstreamer) | 93 | ("gstreamer" ,gstreamer) |
93 | ("gst-plugins-base" ,gst-plugins-base) | 94 | ("gst-plugins-base" ,gst-plugins-base) |
94 | ("gnutls" ,gnutls) ;Change to gnutls/dane once it is merged. | 95 | ("gnutls/dane" ,gnutls/dane) ;Change to gnutls/dane once it is merged. |
95 | ("libextractor" ,libextractor) | 96 | ("libextractor" ,libextractor) |
96 | ("libgcrypt" ,libgcrypt) | 97 | ("libgcrypt" ,libgcrypt) |
97 | ("libidn" ,libidn) | 98 | ("libidn" ,libidn) |
@@ -113,24 +114,25 @@ | |||
113 | ("gmp" ,gmp) | 114 | ("gmp" ,gmp) |
114 | ("bluez" ,bluez) ; for optional bluetooth feature | 115 | ("bluez" ,bluez) ; for optional bluetooth feature |
115 | ("glib" ,glib) | 116 | ("glib" ,glib) |
116 | ;; There are currently no binary substitutes for texlive on | 117 | ;; TODO: figure out the right texlive parts. |
117 | ;; hydra.gnu.org or its mirrors due to its size. Uncomment if you need it. | 118 | ;;("texlive-minimal" ,texlive-minimal) |
118 | ;;("texlive-minimal" ,texlive-minimal) ; optional. | ||
119 | ("texlive" ,texlive) | 119 | ("texlive" ,texlive) |
120 | ("miniupnpc" ,miniupnpc) | ||
120 | ("libogg" ,libogg))) | 121 | ("libogg" ,libogg))) |
121 | (native-inputs | 122 | (native-inputs |
122 | `(("pkg-config" ,pkg-config) | 123 | `(("pkg-config" ,pkg-config) |
123 | ("autoconf" ,autoconf) | 124 | ("autoconf" ,autoconf) |
124 | ("automake" ,automake) | 125 | ("automake" ,automake) |
125 | ("gnu-gettext" ,gnu-gettext) | 126 | ("gnu-gettext" ,gnu-gettext) |
127 | ("which" ,which) | ||
126 | ("texinfo" ,texinfo-5) ; Debian stable: 5.2 | 128 | ("texinfo" ,texinfo-5) ; Debian stable: 5.2 |
127 | ("libtool" ,libtool))) | 129 | ("libtool" ,libtool))) |
128 | (outputs '("out" "debug")) | 130 | (outputs '("out" "debug")) |
129 | (arguments | 131 | (arguments |
130 | `(#:configure-flags | 132 | `(#:configure-flags |
131 | (list (string-append "--with-nssdir=" %output "/lib") | 133 | (list (string-append "--with-nssdir=" %output "/lib") |
132 | "--enable-gcc-hardening" | 134 | ;;"--enable-gcc-hardening" |
133 | "--enable-linker-hardening" | 135 | ;;"--enable-linker-hardening" |
134 | "--enable-logging=verbose" | 136 | "--enable-logging=verbose" |
135 | "CFLAGS=-ggdb -O0") | 137 | "CFLAGS=-ggdb -O0") |
136 | #:phases | 138 | #:phases |
diff --git a/contrib/packages/guix/guix-env.scm b/contrib/packages/guix/guix-env.scm index c62a713a2..da4a60b73 100644 --- a/contrib/packages/guix/guix-env.scm +++ b/contrib/packages/guix/guix-env.scm | |||
@@ -146,6 +146,7 @@ | |||
146 | ("autoconf" ,autoconf) | 146 | ("autoconf" ,autoconf) |
147 | ("automake" ,automake) | 147 | ("automake" ,automake) |
148 | ("gnu-gettext" ,gnu-gettext) | 148 | ("gnu-gettext" ,gnu-gettext) |
149 | ("which" ,which) | ||
149 | ("texinfo" ,texinfo-5) ; Debian stable: 5.2 | 150 | ("texinfo" ,texinfo-5) ; Debian stable: 5.2 |
150 | ("libtool" ,libtool))) | 151 | ("libtool" ,libtool))) |
151 | ;; TODO: To make use of out:debug, which carries the symbols, | 152 | ;; TODO: To make use of out:debug, which carries the symbols, |
diff --git a/contrib/packages/guix/packages/gnunet/packages/gnunet.scm b/contrib/packages/guix/packages/gnunet/packages/gnunet.scm index fbc132d78..be529ec1d 100644 --- a/contrib/packages/guix/packages/gnunet/packages/gnunet.scm +++ b/contrib/packages/guix/packages/gnunet/packages/gnunet.scm | |||
@@ -26,6 +26,7 @@ | |||
26 | #:use-module (gnu packages admin) | 26 | #:use-module (gnu packages admin) |
27 | #:use-module (gnu packages aidc) | 27 | #:use-module (gnu packages aidc) |
28 | #:use-module (gnu packages autotools) | 28 | #:use-module (gnu packages autotools) |
29 | #:use-module (gnu packages base) | ||
29 | #:use-module (gnu packages bison) | 30 | #:use-module (gnu packages bison) |
30 | #:use-module (gnu packages compression) | 31 | #:use-module (gnu packages compression) |
31 | #:use-module (gnu packages databases) | 32 | #:use-module (gnu packages databases) |
@@ -60,6 +61,7 @@ | |||
60 | ;; TODO: Use HEAD without checking sum of it. | 61 | ;; TODO: Use HEAD without checking sum of it. |
61 | ;; Explanation for name scheme: UNIXPATH is capped at 108 characters, | 62 | ;; Explanation for name scheme: UNIXPATH is capped at 108 characters, |
62 | ;; this causes lots of tests to fail. | 63 | ;; this causes lots of tests to fail. |
64 | ;; FIXME: make this file MUCH shorter. | ||
63 | (define-public gnunetg | 65 | (define-public gnunetg |
64 | (let* ((commit "3c3090717610ea787fdd3562901329254a6af0d6") | 66 | (let* ((commit "3c3090717610ea787fdd3562901329254a6af0d6") |
65 | (revision "32")) | 67 | (revision "32")) |
@@ -112,6 +114,7 @@ | |||
112 | ("autoconf" ,autoconf) | 114 | ("autoconf" ,autoconf) |
113 | ("automake" ,automake) | 115 | ("automake" ,automake) |
114 | ("gnu-gettext" ,gnu-gettext) | 116 | ("gnu-gettext" ,gnu-gettext) |
117 | ("which" ,which) | ||
115 | ("texinfo" ,texinfo) | 118 | ("texinfo" ,texinfo) |
116 | ("libtool" ,libtool))) | 119 | ("libtool" ,libtool))) |
117 | (outputs '("out" "debug")) | 120 | (outputs '("out" "debug")) |
@@ -199,6 +202,7 @@ | |||
199 | (native-inputs | 202 | (native-inputs |
200 | `(("pkg-config" ,pkg-config) | 203 | `(("pkg-config" ,pkg-config) |
201 | ("autoconf" ,autoconf) | 204 | ("autoconf" ,autoconf) |
205 | ("which" ,which) | ||
202 | ("automake" ,automake) | 206 | ("automake" ,automake) |
203 | ("gnu-gettext" ,gnu-gettext) | 207 | ("gnu-gettext" ,gnu-gettext) |
204 | ("texinfo" ,texinfo) | 208 | ("texinfo" ,texinfo) |
diff --git a/doc/.gitignore b/doc/.gitignore index 25617d1b0..656026fe7 100644 --- a/doc/.gitignore +++ b/doc/.gitignore | |||
@@ -5,14 +5,17 @@ | |||
5 | *.toc | 5 | *.toc |
6 | *.cp | 6 | *.cp |
7 | *.cps | 7 | *.cps |
8 | *.html | ||
9 | *~ | 8 | *~ |
10 | *.info | 9 | *.info |
10 | *.info-1 | ||
11 | *.info-2 | ||
12 | *.info-3 | ||
11 | \#*\# | 13 | \#*\# |
12 | version.texi | 14 | version.texi |
13 | gnunet.info-1 | ||
14 | gnunet.info-2 | ||
15 | gnunet.info-3 | ||
16 | mdate-sh | 15 | mdate-sh |
17 | stamp-vti | 16 | stamp-vti |
18 | texinfo.tex | 17 | texinfo.tex |
18 | gnunet.t2p/ | ||
19 | gnunet-c-tutorial.t2p/ | ||
20 | *.t2p/ | ||
21 | documentation/manuals \ No newline at end of file | ||
diff --git a/doc/Makefile.am b/doc/Makefile.am index 1a8bb64b9..f84c66753 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am | |||
@@ -1,232 +1,7 @@ | |||
1 | # This Makefile.am is in the public domain | 1 | # This Makefile.am is in the public domain |
2 | SUBDIRS = man doxygen | 2 | SUBDIRS = man doxygen documentation |
3 | |||
4 | docdir = $(datadir)/doc/gnunet/ | ||
5 | |||
6 | infoimagedir = $(infodir)/images | ||
7 | |||
8 | #DOT_FILES = images/$(wildcard *.dot) | ||
9 | |||
10 | #DOT_VECTOR_GRAPHICS = \ | ||
11 | # $(DOT_FILES:%.dot=%.eps) \ | ||
12 | # $(DOT_FILES:%.dot=%.pdf) | ||
13 | |||
14 | dist_infoimage_DATA = \ | ||
15 | images/gnunet-gtk-0-10-gns-a-done.png \ | ||
16 | images/gnunet-gtk-0-10-gns-a.png \ | ||
17 | images/daemon_lego_block.png \ | ||
18 | images/gnunet-gtk-0-10-gns.png \ | ||
19 | images/gnunet-0-10-peerinfo.png \ | ||
20 | images/gnunet-gtk-0-10-identity.png \ | ||
21 | images/gnunet-fs-gtk-0-10-star-tab.png \ | ||
22 | images/gnunet-gtk-0-10.png \ | ||
23 | images/gnunet-gtk-0-10-download-area.png \ | ||
24 | images/gnunet-gtk-0-10-search-selected.png \ | ||
25 | images/gnunet-gtk-0-10-fs-menu.png \ | ||
26 | images/gnunet-gtk-0-10-traffic.png \ | ||
27 | images/gnunet-gtk-0-10-fs.png \ | ||
28 | images/gnunet-namestore-gtk-phone.png \ | ||
29 | images/gnunet-gtk-0-10-fs-publish-editing.png \ | ||
30 | images/gnunet-namestore-gtk-vpn.png \ | ||
31 | images/gnunet-gtk-0-10-fs-published.png \ | ||
32 | images/gnunet-setup-exit.png \ | ||
33 | images/gnunet-gtk-0-10-fs-publish.png \ | ||
34 | images/iceweasel-preferences.png \ | ||
35 | images/gnunet-gtk-0-10-fs-publish-select.png \ | ||
36 | images/iceweasel-proxy.png \ | ||
37 | images/gnunet-gtk-0-10-fs-publish-with-file_0.png \ | ||
38 | images/service_lego_block.png \ | ||
39 | images/gnunet-gtk-0-10-fs-publish-with-file.png \ | ||
40 | images/service_stack.png \ | ||
41 | images/gnunet-gtk-0-10-fs-search.png \ | ||
42 | images/gnunet-tutorial-service.png \ | ||
43 | images/gnunet-tutorial-system.png \ | ||
44 | images/daemon_lego_block.svg \ | ||
45 | images/lego_stack.svg \ | ||
46 | images/service_lego_block.svg \ | ||
47 | images/structure.dot | ||
48 | |||
49 | # images/$(wildcard *.png) \ | ||
50 | # images/$(wildcard *.svg) | ||
51 | # $(DOT_FILES:%.dot=%.png) | ||
52 | |||
53 | #DOT_OPTIONS = \ | ||
54 | # -Gratio=.9 -Gnodesep=.005 -Granksep=.00005 \ | ||
55 | # -Nfontsite=9 -Nheight=.1 -Nwidth=.1 | ||
56 | |||
57 | # .dot.png: | ||
58 | # $(AM_V_DOT)$(DOT) -Tpng $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
59 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
60 | |||
61 | # .dot.pdf: | ||
62 | # $(AM_V_DOT)$(DOT) -Tpdf $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
63 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
64 | |||
65 | # .dot.eps: | ||
66 | # $(AM_V_DOT)$(DOT) -Teps $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
67 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
68 | |||
69 | # .png.eps: | ||
70 | # $(AM_V_GEN)convert "$<" "$@-tmp.eps"; \ | ||
71 | # mv "$@-tmp.eps" "$@" | ||
72 | |||
73 | # pdf-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.pdf) | ||
74 | # info-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.png) | ||
75 | # ps-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.eps) \ | ||
76 | # $(top_srcdir)/%D%/images/coreutils-size-map.eps | ||
77 | # dvi-local: ps-local | ||
78 | |||
79 | gnunet_tutorial_examples = \ | ||
80 | 001.c \ | ||
81 | 002.c \ | ||
82 | 003.c \ | ||
83 | 004.c \ | ||
84 | 005.c \ | ||
85 | 006.c \ | ||
86 | 007.c \ | ||
87 | 008.c \ | ||
88 | 009.c \ | ||
89 | 010.c \ | ||
90 | 011.c \ | ||
91 | 012.c \ | ||
92 | 013.c \ | ||
93 | 014.c \ | ||
94 | 015.c \ | ||
95 | 016.c \ | ||
96 | 017.c \ | ||
97 | 018.c \ | ||
98 | 019.c \ | ||
99 | 020.c \ | ||
100 | 021.c \ | ||
101 | 022.c \ | ||
102 | 023.c \ | ||
103 | 024.c \ | ||
104 | 025.c \ | ||
105 | 026.c | ||
106 | |||
107 | info_TEXINFOS = \ | ||
108 | gnunet.texi \ | ||
109 | gnunet-c-tutorial.texi | ||
110 | |||
111 | gnunet_TEXINFOS = \ | ||
112 | chapters/developer.texi \ | ||
113 | chapters/installation.texi \ | ||
114 | chapters/philosophy.texi \ | ||
115 | chapters/user.texi \ | ||
116 | fdl-1.3.texi \ | ||
117 | gpl-3.0.texi | ||
118 | 3 | ||
119 | EXTRA_DIST = \ | 4 | EXTRA_DIST = \ |
120 | $(gnunet_TEXINFOS) \ | ||
121 | outdated-and-old-installation-instructions.txt \ | 5 | outdated-and-old-installation-instructions.txt \ |
122 | gnunet-c-tutorial-v1.pdf \ | 6 | gnunet-c-tutorial-v1.pdf \ |
123 | $(gnunet_tutorial_examples) \ | ||
124 | README.txt | 7 | README.txt |
125 | |||
126 | |||
127 | # $(DOT_FILES) \ | ||
128 | # $(DOT_VECTOR_GRAPHICS) | ||
129 | |||
130 | DISTCLEANFILES = \ | ||
131 | gnunet.cps \ | ||
132 | gnunet-c-tutorial.cps \ | ||
133 | chapters/developer.cps \ | ||
134 | chapters/installation.cps \ | ||
135 | chapter/philosophy.cps \ | ||
136 | chapters/user.cps \ | ||
137 | fdl-1.3.cps \ | ||
138 | gpl-3.0.cps | ||
139 | |||
140 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING | ||
141 | daemon_lego_block.png: images/daemon_lego_block.svg | ||
142 | convert images/daemon_lego_block.svg images/daemon_lego_block.png && | ||
143 | pngcrush images/daemon_lego_block.png images/daemon_lego_block.png | ||
144 | |||
145 | service_lego_block.png: images/service_lego_block.svg | ||
146 | convert images/service_lego_block.svg images/service_lego_block.png && | ||
147 | pngcrush images/service_lego_block.png images/serivce_lego_block.png | ||
148 | |||
149 | lego_stack.png: images/lego_stack.svg | ||
150 | convert images/lego_stack.svg images/lego_stack.png && | ||
151 | pngcrush images/lego_stack.png images/lego_stack.png | ||
152 | |||
153 | version.texi: | ||
154 | echo "@set UPDATED $(date +'%d %B %Y')" > $@ | ||
155 | echo "@set UPDATED-MONTH $(date +'%B %Y')" >> $@ | ||
156 | echo "@set EDITION $(PACKAGE_VERSION)" >> $@ | ||
157 | echo "@set VERSION $(PACKAGE_VERSION)" >> $@ | ||
158 | |||
159 | doc-pdf: version.texi | ||
160 | @makeinfo --pdf --quiet gnunet.texi | ||
161 | doc-pdf-tutorial: version.texi | ||
162 | @makeinfo --pdf --quiet gnunet-c-tutorial.texi | ||
163 | |||
164 | doc-html: version.texi | ||
165 | @makeinfo --html gnunet.texi | ||
166 | doc-html-tutorial: version.texi | ||
167 | @makeinfo --html gnunet-c-tutorial.texi | ||
168 | |||
169 | doc-info: version.texi | ||
170 | @makeinfo --no-split gnunet.texi | ||
171 | doc-info-tutorial: version.texi | ||
172 | @makeinfo --no-split gnunet-c-tutorial.texi | ||
173 | |||
174 | # FIXME: rm *.html and *.pdf | ||
175 | doc-clean: | ||
176 | @rm *.aux *.log *.toc *.cp *.cps | ||
177 | |||
178 | doc-all: doc-pdf doc-html doc-info doc-pdf-tutorial doc-html-tutorial doc-info-tutorial | ||
179 | |||
180 | doc-pdf-noise: version.texi | ||
181 | @makeinfo --pdf gnunet.texi | ||
182 | doc-pdf-tutorial-noise: version.texi | ||
183 | @makeinfo --pdf gnunet-c-tutorial.texi | ||
184 | |||
185 | doc-html-noise: version.texi | ||
186 | @makeinfo --html gnunet.texi | ||
187 | doc-html-tutorial-noise: version.texi | ||
188 | @makeinfo --html gnunet-c-tutorial.texi | ||
189 | |||
190 | doc-info-noise: version.texi | ||
191 | @makeinfo --no-split gnunet.texi | ||
192 | doc-info-tutorial-noise: version.texi | ||
193 | @makeinfo --no-split gnunet-c-tutorial.texi | ||
194 | |||
195 | doc-all-give-me-the-noise: doc-pdf-noise doc-html-noise doc-info-noise doc-pdf-tutorial-noise doc-html-tutorial-noise doc-info-tutorial-noise | ||
196 | |||
197 | doc-all-install: doc-all-give-me-the-noise | ||
198 | @mkdir -p $(DESTDIR)/$(docdir) | ||
199 | @mkdir -p $(DESTDIR)/$(infoimagedir) | ||
200 | @mkdir -p $(DESTDIR)/$(infodir) | ||
201 | @install -m 0755 gnunet.pdf $(DESTDIR)/$(docdir) | ||
202 | @install -m 0755 gnunet-c-tutorial.pdf $(DESTDIR)/$(docdir) | ||
203 | @install -m 0755 gnunet-c-tutorial.info $(DESTDIR)/$(infodir) | ||
204 | @install -m 0755 gnunet.info $(DESTDIR)/$(infodir) | ||
205 | @cp -r gnunet $(DESTDIR)/$(docdir) | ||
206 | @cp -r gnunet-c-tutorial $(DESTDIR)/$(docdir) | ||
207 | |||
208 | # @cp -r images $(DESTDIR)/$(infoimagedir) | ||
209 | |||
210 | # TODO: Add more to clean. | ||
211 | # clean: | ||
212 | # @rm gnunet.pdf | ||
213 | # @rm gnunet-c-tutorial.pdf | ||
214 | # @rm gnunet.info | ||
215 | # @rm gnunet-c-tutorial.info | ||
216 | |||
217 | # CLEANFILES = \ | ||
218 | # gnunet.log \ | ||
219 | # gnunet-c-tutorial.log \ | ||
220 | # $(wildcard *.aux) \ | ||
221 | # $(wildcard *.toc) \ | ||
222 | # $(wildcard *.cp) \ | ||
223 | # $(wildcard *.cps) | ||
224 | |||
225 | .PHONY: version.texi | ||
226 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING_PDF | ||
227 | |||
228 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING_HTML | ||
229 | |||
230 | # endif | ||
231 | # endif | ||
232 | # endif | ||
diff --git a/doc/README.txt b/doc/README.txt deleted file mode 100644 index fbbc24424..000000000 --- a/doc/README.txt +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | * What's left to do | ||
2 | |||
3 | - Which Texlive modules are needed? Decrease the size. | ||
4 | - Update the content of gnunet documentation. | ||
5 | |||
6 | * How to use (hack) on this | ||
7 | |||
8 | ** with guix | ||
9 | |||
10 | export the environment variable GUIX_PACKAGE_PATH as $GUIX_PACKAGE_PATH:gnunet/contrib/packages/guix/packages | ||
11 | guix environment gnunet-doc | ||
12 | |||
13 | ** without guix | ||
14 | |||
15 | You need to have Texinfo and Texlive in your path. | ||
16 | sh bootstrap | ||
17 | ./configure --enable-documentation | ||
18 | cd doc | ||
19 | make doc-all-give-me-the-noise | ||
20 | |||
21 | * structure (relations) | ||
22 | |||
23 | ** gnunet.texi | ||
24 | -> chapters/developer.texi | ||
25 | -> chapters/installation.texi | ||
26 | -> chapters/philosophy.texi | ||
27 | -> chapters/user.texi | ||
28 | -> images/* | ||
29 | -> gpl-3.0.texi | ||
30 | -> fdl-1.3.texi | ||
31 | |||
32 | ** gnunet-c-tutorial.texi | ||
33 | -> figs/Service.pdf | ||
34 | -> figs/System.pdf | ||
35 | -> tutorial-examples/*.c | ||
36 | -> gpl-3.0.texi | ||
37 | -> fdl-1.3.texi | ||
38 | |||
39 | - gnunet-c-tutorial-v1.pdf: original LaTeX "gnunet-c-tutorial.pdf". | ||
40 | - man folder: the man pages. | ||
41 | - doxygen folder | ||
42 | - outdated-and-old-installation-instructions.txt: self described within the file. | ||
diff --git a/doc/chapters/developer.texi b/doc/chapters/developer.texi deleted file mode 100644 index f5493fd63..000000000 --- a/doc/chapters/developer.texi +++ /dev/null | |||
@@ -1,7487 +0,0 @@ | |||
1 | @c *************************************************************************** | ||
2 | @node GNUnet Developer Handbook | ||
3 | @chapter GNUnet Developer Handbook | ||
4 | |||
5 | This book is intended to be an introduction for programmers that want to | ||
6 | extend the GNUnet framework. GNUnet is more than a simple peer-to-peer | ||
7 | application. For developers, GNUnet is: | ||
8 | |||
9 | @itemize @bullet | ||
10 | @item Free software under the GNU General Public License, with a community | ||
11 | that believes in the GNU philosophy | ||
12 | @item | ||
13 | A set of standards, including coding conventions and architectural rules | ||
14 | @item | ||
15 | A set of layered protocols, both specifying the communication between peers as | ||
16 | well as the communication between components of a single peer. | ||
17 | @item | ||
18 | A set of libraries with well-defined APIs suitable for writing extensions | ||
19 | @end itemize | ||
20 | |||
21 | In particular, the architecture specifies that a peer consists of many | ||
22 | processes communicating via protocols. Processes can be written in almost | ||
23 | any language. C and Java APIs exist for accessing existing services and for | ||
24 | writing extensions. It is possible to write extensions in other languages by | ||
25 | implementing the necessary IPC protocols. | ||
26 | |||
27 | GNUnet can be extended and improved along many possible dimensions, and anyone | ||
28 | interested in free software and freedom-enhancing networking is welcome to | ||
29 | join the effort. This developer handbook attempts to provide an initial | ||
30 | introduction to some of the key design choices and central components of the | ||
31 | system. This manual is far from complete, and we welcome informed | ||
32 | contributions, be it in the form of new chapters or insightful comments. | ||
33 | |||
34 | However, the website is experiencing a constant onslaught of sophisticated | ||
35 | link-spam entered manually by exploited workers solving puzzles and | ||
36 | customizing text. To limit this commercial defacement, we are strictly | ||
37 | moderating comments and have disallowed "normal" users from posting new | ||
38 | content. However, this is really only intended to keep the spam at bay. If | ||
39 | you are a real user or aspiring developer, please drop us a note (IRC, e-mail, | ||
40 | contact form) with your user profile ID number included. We will then relax | ||
41 | these restrictions on your account. We're sorry for this inconvenience; | ||
42 | however, few people would want to read this site if 99% of it was | ||
43 | advertisements for bogus websites. | ||
44 | |||
45 | |||
46 | |||
47 | @c *************************************************************************** | ||
48 | |||
49 | |||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | @menu | ||
57 | * Developer Introduction:: | ||
58 | * Code overview:: | ||
59 | * System Architecture:: | ||
60 | * Subsystem stability:: | ||
61 | * Naming conventions and coding style guide:: | ||
62 | * Build-system:: | ||
63 | * Developing extensions for GNUnet using the gnunet-ext template:: | ||
64 | * Writing testcases:: | ||
65 | * GNUnet's TESTING library:: | ||
66 | * Performance regression analysis with Gauger:: | ||
67 | * GNUnet's TESTBED Subsystem:: | ||
68 | * libgnunetutil:: | ||
69 | * The Automatic Restart Manager (ARM):: | ||
70 | * GNUnet's TRANSPORT Subsystem:: | ||
71 | * NAT library:: | ||
72 | * Distance-Vector plugin:: | ||
73 | * SMTP plugin:: | ||
74 | * Bluetooth plugin:: | ||
75 | * WLAN plugin:: | ||
76 | * The ATS Subsystem:: | ||
77 | * GNUnet's CORE Subsystem:: | ||
78 | * GNUnet's CADET subsystem:: | ||
79 | * GNUnet's NSE subsystem:: | ||
80 | * GNUnet's HOSTLIST subsystem:: | ||
81 | * GNUnet's IDENTITY subsystem:: | ||
82 | * GNUnet's NAMESTORE Subsystem:: | ||
83 | * GNUnet's PEERINFO subsystem:: | ||
84 | * GNUnet's PEERSTORE subsystem:: | ||
85 | * GNUnet's SET Subsystem:: | ||
86 | * GNUnet's STATISTICS subsystem:: | ||
87 | * GNUnet's Distributed Hash Table (DHT):: | ||
88 | * The GNU Name System (GNS):: | ||
89 | * The GNS Namecache:: | ||
90 | * The REVOCATION Subsystem:: | ||
91 | * GNUnet's File-sharing (FS) Subsystem:: | ||
92 | * GNUnet's REGEX Subsystem:: | ||
93 | @end menu | ||
94 | |||
95 | @node Developer Introduction | ||
96 | @section Developer Introduction | ||
97 | |||
98 | This developer handbook is intended as first introduction to GNUnet for new | ||
99 | developers that want to extend the GNUnet framework. After the introduction, | ||
100 | each of the GNUnet subsystems (directories in the @file{src/} tree) is (supposed to | ||
101 | be) covered in its own chapter. In addition to this documentation, GNUnet | ||
102 | developers should be aware of the services available on the GNUnet server to | ||
103 | them. | ||
104 | |||
105 | New developers can have a look a the GNUnet tutorials for C and java available | ||
106 | in the @file{src/} directory of the repository or under the following links: | ||
107 | |||
108 | @c ** FIXME: Link to files in source, not online. | ||
109 | @c ** FIXME: Where is the Java tutorial? | ||
110 | @itemize @bullet | ||
111 | @item @uref{https://gnunet.org/git/gnunet.git/plain/doc/gnunet-c-tutorial.pdf, GNUnet C tutorial} | ||
112 | @item GNUnet Java tutorial | ||
113 | @end itemize | ||
114 | |||
115 | In addition to this book, the GNUnet server contains various resources for | ||
116 | GNUnet developers. They are all conveniently reachable via the "Developer" | ||
117 | entry in the navigation menu. Some additional tools (such as static analysis | ||
118 | reports) require a special developer access to perform certain operations. If | ||
119 | you feel you need access, you should contact | ||
120 | @uref{http://grothoff.org/christian/, Christian Grothoff}, GNUnet's maintainer. | ||
121 | |||
122 | The public subsystems on the GNUnet server that help developers are: | ||
123 | |||
124 | @itemize @bullet | ||
125 | @item The Version control system keeps our code and enables distributed | ||
126 | development. Only developers with write access can commit code, everyone else | ||
127 | is encouraged to submit patches to the | ||
128 | @uref{https://lists.gnu.org/mailman/listinfo/gnunet-developers, GNUnet-developers mailinglist}. | ||
129 | @item The GNUnet bugtracking system is used to track feature requests, open bug | ||
130 | reports and their resolutions. Anyone can report bugs, only developers can | ||
131 | claim to have fixed them. | ||
132 | @item A buildbot is used to check GNUnet builds automatically on a range of | ||
133 | platforms. Builds are triggered automatically after 30 minutes of no changes to | ||
134 | Git. | ||
135 | @item The current quality of our automated test suite is assessed using Code | ||
136 | coverage analysis. This analysis is run daily; however the webpage is only | ||
137 | updated if all automated tests pass at that time. Testcases that improve our | ||
138 | code coverage are always welcome. | ||
139 | @item We try to automatically find bugs using a static analysis scan. This scan | ||
140 | is run daily; however the webpage is only updated if all automated tests pass | ||
141 | at the time. Note that not everything that is flagged by the analysis is a bug, | ||
142 | sometimes even good code can be marked as possibly problematic. Nevertheless, | ||
143 | developers are encouraged to at least be aware of all issues in their code that | ||
144 | are listed. | ||
145 | @item We use Gauger for automatic performance regression visualization. Details | ||
146 | on how to use Gauger are here. | ||
147 | @item We use @uref{http://junit.org/, junit} to automatically test gnunet-java. | ||
148 | Automatically generated, current reports on the test suite are here. | ||
149 | @item We use Cobertura to generate test coverage reports for gnunet-java. | ||
150 | Current reports on test coverage are here. | ||
151 | @end itemize | ||
152 | |||
153 | |||
154 | |||
155 | @c *************************************************************************** | ||
156 | @menu | ||
157 | * Project overview:: | ||
158 | @end menu | ||
159 | |||
160 | @node Project overview | ||
161 | @subsection Project overview | ||
162 | |||
163 | The GNUnet project consists at this point of several sub-projects. This section | ||
164 | is supposed to give an initial overview about the various sub-projects. Note | ||
165 | that this description also lists projects that are far from complete, including | ||
166 | even those that have literally not a single line of code in them yet. | ||
167 | |||
168 | GNUnet sub-projects in order of likely relevance are currently: | ||
169 | |||
170 | @table @asis | ||
171 | |||
172 | @item gnunet Core of the P2P framework, including file-sharing, VPN and | ||
173 | chat applications; this is what the developer handbook covers mostly | ||
174 | @item gnunet-gtk Gtk+-based user interfaces, including gnunet-fs-gtk | ||
175 | (file-sharing), gnunet-statistics-gtk (statistics over time), | ||
176 | gnunet-peerinfo-gtk (information about current connections and known peers), | ||
177 | gnunet-chat-gtk (chat GUI) and gnunet-setup (setup tool for "everything") | ||
178 | @item gnunet-fuse Mounting directories shared via GNUnet's file-sharing on Linux | ||
179 | @item gnunet-update Installation and update tool | ||
180 | @item gnunet-ext Template for starting 'external' GNUnet projects | ||
181 | @item gnunet-java Java APIs for writing GNUnet services and applications | ||
182 | @c ** FIXME: Point to new website repository once we have it: | ||
183 | @c ** @item svn/gnunet-www/ Code and media helping drive the GNUnet website | ||
184 | @item eclectic Code to run | ||
185 | GNUnet nodes on testbeds for research, development, testing and evaluation | ||
186 | @c ** FIXME: Solve the status and location of gnunet-qt | ||
187 | @item gnunet-qt qt-based GNUnet GUI (dead?) | ||
188 | @item gnunet-cocoa cocoa-based GNUnet GUI (dead?) | ||
189 | |||
190 | @end table | ||
191 | |||
192 | We are also working on various supporting libraries and tools: | ||
193 | @c ** FIXME: What about gauger, and what about libmwmodem? | ||
194 | |||
195 | @table @asis | ||
196 | @item libextractor GNU libextractor (meta data extraction) | ||
197 | @item libmicrohttpd GNU libmicrohttpd (embedded HTTP(S) server library) | ||
198 | @item gauger Tool for performance regression analysis | ||
199 | @item monkey Tool for automated debugging of distributed systems | ||
200 | @item libmwmodem Library for accessing satellite connection quality reports | ||
201 | @end table | ||
202 | |||
203 | Finally, there are various external projects (see links for a list of those | ||
204 | that have a public website) which build on top of the GNUnet framework. | ||
205 | |||
206 | @c *************************************************************************** | ||
207 | @node Code overview | ||
208 | @section Code overview | ||
209 | |||
210 | This section gives a brief overview of the GNUnet source code. Specifically, we | ||
211 | sketch the function of each of the subdirectories in the @file{gnunet/src/} | ||
212 | directory. The order given is roughly bottom-up (in terms of the layers of the | ||
213 | system). | ||
214 | @table @asis | ||
215 | |||
216 | @item util/ --- libgnunetutil Library with general utility functions, all | ||
217 | GNUnet binaries link against this library. Anything from memory allocation and | ||
218 | data structures to cryptography and inter-process communication. The goal is to | ||
219 | provide an OS-independent interface and more 'secure' or convenient | ||
220 | implementations of commonly used primitives. The API is spread over more than a | ||
221 | dozen headers, developers should study those closely to avoid duplicating | ||
222 | existing functions. | ||
223 | @item hello/ --- libgnunethello HELLO messages are used to | ||
224 | describe under which addresses a peer can be reached (for example, protocol, | ||
225 | IP, port). This library manages parsing and generating of HELLO messages. | ||
226 | @item block/ --- libgnunetblock The DHT and other components of GNUnet store | ||
227 | information in units called 'blocks'. Each block has a type and the type | ||
228 | defines a particular format and how that binary format is to be linked to a | ||
229 | hash code (the key for the DHT and for databases). The block library is a | ||
230 | wapper around block plugins which provide the necessary functions for each | ||
231 | block type. | ||
232 | @item statistics/ The statistics service enables associating | ||
233 | values (of type uint64_t) with a componenet name and a string. The main uses is | ||
234 | debugging (counting events), performance tracking and user entertainment (what | ||
235 | did my peer do today?). | ||
236 | @item arm/ The automatic-restart-manager (ARM) service | ||
237 | is the GNUnet master service. Its role is to start gnunet-services, to re-start | ||
238 | them when they crashed and finally to shut down the system when requested. | ||
239 | @item peerinfo/ The peerinfo service keeps track of which peers are known to | ||
240 | the local peer and also tracks the validated addresses for each peer (in the | ||
241 | form of a HELLO message) for each of those peers. The peer is not necessarily | ||
242 | connected to all peers known to the peerinfo service. Peerinfo provides | ||
243 | persistent storage for peer identities --- peers are not forgotten just because | ||
244 | of a system restart. | ||
245 | @item datacache/ --- libgnunetdatacache The datacache | ||
246 | library provides (temporary) block storage for the DHT. Existing plugins can | ||
247 | store blocks in Sqlite, Postgres or MySQL databases. All data stored in the | ||
248 | cache is lost when the peer is stopped or restarted (datacache uses temporary | ||
249 | tables). | ||
250 | @item datastore/ The datastore service stores file-sharing blocks in | ||
251 | databases for extended periods of time. In contrast to the datacache, data is | ||
252 | not lost when peers restart. However, quota restrictions may still cause old, | ||
253 | expired or low-priority data to be eventually discarded. Existing plugins can | ||
254 | store blocks in Sqlite, Postgres or MySQL databases. | ||
255 | @item template/ Template | ||
256 | for writing a new service. Does nothing. | ||
257 | @item ats/ The automatic transport | ||
258 | selection (ATS) service is responsible for deciding which address (i.e. which | ||
259 | transport plugin) should be used for communication with other peers, and at | ||
260 | what bandwidth. | ||
261 | @item nat/ --- libgnunetnat Library that provides basic | ||
262 | functions for NAT traversal. The library supports NAT traversal with manual | ||
263 | hole-punching by the user, UPnP and ICMP-based autonomous NAT traversal. The | ||
264 | library also includes an API for testing if the current configuration works and | ||
265 | the @code{gnunet-nat-server} which provides an external service to test the | ||
266 | local configuration. | ||
267 | @item fragmentation/ --- libgnunetfragmentation Some | ||
268 | transports (UDP and WLAN, mostly) have restrictions on the maximum transfer | ||
269 | unit (MTU) for packets. The fragmentation library can be used to break larger | ||
270 | packets into chunks of at most 1k and transmit the resulting fragments | ||
271 | reliabily (with acknowledgement, retransmission, timeouts, etc.). | ||
272 | @item transport/ The transport service is responsible for managing the basic P2P | ||
273 | communication. It uses plugins to support P2P communication over TCP, UDP, | ||
274 | HTTP, HTTPS and other protocols.The transport service validates peer addresses, | ||
275 | enforces bandwidth restrictions, limits the total number of connections and | ||
276 | enforces connectivity restrictions (i.e. friends-only). | ||
277 | @item peerinfo-tool/ | ||
278 | This directory contains the gnunet-peerinfo binary which can be used to inspect | ||
279 | the peers and HELLOs known to the peerinfo service. | ||
280 | @item core/ The core | ||
281 | service is responsible for establishing encrypted, authenticated connections | ||
282 | with other peers, encrypting and decrypting messages and forwarding messages to | ||
283 | higher-level services that are interested in them. | ||
284 | @item testing/ --- | ||
285 | libgnunettesting The testing library allows starting (and stopping) peers for | ||
286 | writing testcases.@ | ||
287 | It also supports automatic generation of configurations for | ||
288 | peers ensuring that the ports and paths are disjoint. libgnunettesting is also | ||
289 | the foundation for the testbed service | ||
290 | @item testbed/ The testbed service is | ||
291 | used for creating small or large scale deployments of GNUnet peers for | ||
292 | evaluation of protocols. It facilitates peer depolyments on multiple hosts (for | ||
293 | example, in a cluster) and establishing varous network topologies (both | ||
294 | underlay and overlay). | ||
295 | @item nse/ The network size estimation (NSE) service | ||
296 | implements a protocol for (securely) estimating the current size of the P2P | ||
297 | network. | ||
298 | @item dht/ The distributed hash table (DHT) service provides a | ||
299 | distributed implementation of a hash table to store blocks under hash keys in | ||
300 | the P2P network. | ||
301 | @item hostlist/ The hostlist service allows learning about | ||
302 | other peers in the network by downloading HELLO messages from an HTTP server, | ||
303 | can be configured to run such an HTTP server and also implements a P2P protocol | ||
304 | to advertise and automatically learn about other peers that offer a public | ||
305 | hostlist server. | ||
306 | @item topology/ The topology service is responsible for | ||
307 | maintaining the mesh topology. It tries to maintain connections to friends | ||
308 | (depending on the configuration) and also tries to ensure that the peer has a | ||
309 | decent number of active connections at all times. If necessary, new connections | ||
310 | are added. All peers should run the topology service, otherwise they may end up | ||
311 | not being connected to any other peer (unless some other service ensures that | ||
312 | core establishes the required connections). The topology service also tells the | ||
313 | transport service which connections are permitted (for friend-to-friend | ||
314 | networking) | ||
315 | @item fs/ The file-sharing (FS) service implements GNUnet's | ||
316 | file-sharing application. Both anonymous file-sharing (using gap) and | ||
317 | non-anonymous file-sharing (using dht) are supported. | ||
318 | @item cadet/ The CADET | ||
319 | service provides a general-purpose routing abstraction to create end-to-end | ||
320 | encrypted tunnels in mesh networks. We wrote a paper documenting key aspects of | ||
321 | the design. | ||
322 | @item tun/ --- libgnunettun Library for building IPv4, IPv6 | ||
323 | packets and creating checksums for UDP, TCP and ICMP packets. The header | ||
324 | defines C structs for common Internet packet formats and in particular structs | ||
325 | for interacting with TUN (virtual network) interfaces. | ||
326 | @item mysql/ --- | ||
327 | libgnunetmysql Library for creating and executing prepared MySQL statements and | ||
328 | to manage the connection to the MySQL database. Essentially a lightweight | ||
329 | wrapper for the interaction between GNUnet components and libmysqlclient. | ||
330 | @item dns/ Service that allows intercepting and modifying DNS requests of the | ||
331 | local machine. Currently used for IPv4-IPv6 protocol translation (DNS-ALG) as | ||
332 | implemented by "pt/" and for the GNUnet naming system. The service can also be | ||
333 | configured to offer an exit service for DNS traffic. | ||
334 | @item vpn/ The virtual | ||
335 | public network (VPN) service provides a virtual tunnel interface (VTUN) for IP | ||
336 | routing over GNUnet. Needs some other peers to run an "exit" service to work. | ||
337 | Can be activated using the "gnunet-vpn" tool or integrated with DNS using the | ||
338 | "pt" daemon. | ||
339 | @item exit/ Daemon to allow traffic from the VPN to exit this | ||
340 | peer to the Internet or to specific IP-based services of the local peer. | ||
341 | Currently, an exit service can only be restricted to IPv4 or IPv6, not to | ||
342 | specific ports and or IP address ranges. If this is not acceptable, additional | ||
343 | firewall rules must be added manually. exit currently only works for normal | ||
344 | UDP, TCP and ICMP traffic; DNS queries need to leave the system via a DNS | ||
345 | service. | ||
346 | @item pt/ protocol translation daemon. This daemon enables 4-to-6, | ||
347 | 6-to-4, 4-over-6 or 6-over-4 transitions for the local system. It essentially | ||
348 | uses "DNS" to intercept DNS replies and then maps results to those offered by | ||
349 | the VPN, which then sends them using mesh to some daemon offering an | ||
350 | appropriate exit service. | ||
351 | @item identity/ Management of egos (alter egos) of a | ||
352 | user; identities are essentially named ECC private keys and used for zones in | ||
353 | the GNU name system and for namespaces in file-sharing, but might find other | ||
354 | uses later | ||
355 | @item revocation/ Key revocation service, can be used to revoke the | ||
356 | private key of an identity if it has been compromised | ||
357 | @item namecache/ Cache | ||
358 | for resolution results for the GNU name system; data is encrypted and can be | ||
359 | shared among users, loss of the data should ideally only result in a | ||
360 | performance degradation (persistence not required) | ||
361 | @item namestore/ Database | ||
362 | for the GNU name system with per-user private information, persistence required | ||
363 | @item gns/ GNU name system, a GNU approach to DNS and PKI. | ||
364 | @item dv/ A plugin | ||
365 | for distance-vector (DV)-based routing. DV consists of a service and a | ||
366 | transport plugin to provide peers with the illusion of a direct P2P connection | ||
367 | for connections that use multiple (typically up to 3) hops in the actual | ||
368 | underlay network. | ||
369 | @item regex/ Service for the (distributed) evaluation of | ||
370 | regular expressions. | ||
371 | @item scalarproduct/ The scalar product service offers an | ||
372 | API to perform a secure multiparty computation which calculates a scalar | ||
373 | product between two peers without exposing the private input vectors of the | ||
374 | peers to each other. | ||
375 | @item consensus/ The consensus service will allow a set | ||
376 | of peers to agree on a set of values via a distributed set union computation. | ||
377 | @item rest/ The rest API allows access to GNUnet services using RESTful | ||
378 | interaction. The services provide plugins that can exposed by the rest server. | ||
379 | @item experimentation/ The experimentation daemon coordinates distributed | ||
380 | experimentation to evaluate transport and ats properties | ||
381 | @end table | ||
382 | |||
383 | @c *************************************************************************** | ||
384 | @node System Architecture | ||
385 | @section System Architecture | ||
386 | |||
387 | GNUnet developers like legos. The blocks are indestructible, can be stacked | ||
388 | together to construct complex buildings and it is generally easy to swap one | ||
389 | block for a different one that has the same shape. GNUnet's architecture is | ||
390 | based on legos: | ||
391 | |||
392 | |||
393 | |||
394 | This chapter documents the GNUnet lego system, also known as GNUnet's system | ||
395 | architecture. | ||
396 | |||
397 | The most common GNUnet component is a service. Services offer an API (or | ||
398 | several, depending on what you count as "an API") which is implemented as a | ||
399 | library. The library communicates with the main process of the service using a | ||
400 | service-specific network protocol. The main process of the service typically | ||
401 | doesn't fully provide everything that is needed --- it has holes to be filled | ||
402 | by APIs to other services. | ||
403 | |||
404 | A special kind of component in GNUnet are user interfaces and daemons. Like | ||
405 | services, they have holes to be filled by APIs of other services. Unlike | ||
406 | services, daemons do not implement their own network protocol and they have no | ||
407 | API: | ||
408 | |||
409 | The GNUnet system provides a range of services, daemons and user interfaces, | ||
410 | which are then combined into a layered GNUnet instance (also known as a peer). | ||
411 | |||
412 | Note that while it is generally possible to swap one service for another | ||
413 | compatible service, there is often only one implementation. However, during | ||
414 | development we often have a "new" version of a service in parallel with an | ||
415 | "old" version. While the "new" version is not working, developers working on | ||
416 | other parts of the service can continue their development by simply using the | ||
417 | "old" service. Alternative design ideas can also be easily investigated by | ||
418 | swapping out individual components. This is typically achieved by simply | ||
419 | changing the name of the "BINARY" in the respective configuration section. | ||
420 | |||
421 | Key properties of GNUnet services are that they must be separate processes and | ||
422 | that they must protect themselves by applying tight error checking against the | ||
423 | network protocol they implement (thereby achieving a certain degree of | ||
424 | robustness). | ||
425 | |||
426 | On the other hand, the APIs are implemented to tolerate failures of the | ||
427 | service, isolating their host process from errors by the service. If the | ||
428 | service process crashes, other services and daemons around it should not also | ||
429 | fail, but instead wait for the service process to be restarted by ARM. | ||
430 | |||
431 | |||
432 | @c *************************************************************************** | ||
433 | @node Subsystem stability | ||
434 | @section Subsystem stability | ||
435 | |||
436 | This page documents the current stability of the various GNUnet subsystems. | ||
437 | Stability here describes the expected degree of compatibility with future | ||
438 | versions of GNUnet. For each subsystem we distinguish between compatibility on | ||
439 | the P2P network level (communication protocol between peers), the IPC level | ||
440 | (communication between the service and the service library) and the API level | ||
441 | (stability of the API). P2P compatibility is relevant in terms of which | ||
442 | applications are likely going to be able to communicate with future versions of | ||
443 | the network. IPC communication is relevant for the implementation of language | ||
444 | bindings that re-implement the IPC messages. Finally, API compatibility is | ||
445 | relevant to developers that hope to be able to avoid changes to applications | ||
446 | build on top of the APIs of the framework. | ||
447 | |||
448 | The following table summarizes our current view of the stability of the | ||
449 | respective protocols or APIs: | ||
450 | |||
451 | @multitable @columnfractions .20 .20 .20 .20 | ||
452 | @headitem Subsystem @tab P2P @tab IPC @tab C API | ||
453 | @item util @tab n/a @tab n/a @tab stable | ||
454 | @item arm @tab n/a @tab stable @tab stable | ||
455 | @item ats @tab n/a @tab unstable @tab testing | ||
456 | @item block @tab n/a @tab n/a @tab stable | ||
457 | @item cadet @tab testing @tab testing @tab testing | ||
458 | @item consensus @tab experimental @tab experimental @tab experimental | ||
459 | @item core @tab stable @tab stable @tab stable | ||
460 | @item datacache @tab n/a @tab n/a @tab stable | ||
461 | @item datastore @tab n/a @tab stable @tab stable | ||
462 | @item dht @tab stable @tab stable @tab stable | ||
463 | @item dns @tab stable @tab stable @tab stable | ||
464 | @item dv @tab testing @tab testing @tab n/a | ||
465 | @item exit @tab testing @tab n/a @tab n/a | ||
466 | @item fragmentation @tab stable @tab n/a @tab stable | ||
467 | @item fs @tab stable @tab stable @tab stable | ||
468 | @item gns @tab stable @tab stable @tab stable | ||
469 | @item hello @tab n/a @tab n/a @tab testing | ||
470 | @item hostlist @tab stable @tab stable @tab n/a | ||
471 | @item identity @tab stable @tab stable @tab n/a | ||
472 | @item multicast @tab experimental @tab experimental @tab experimental | ||
473 | @item mysql @tab stable @tab n/a @tab stable | ||
474 | @item namestore @tab n/a @tab stable @tab stable | ||
475 | @item nat @tab n/a @tab n/a @tab stable | ||
476 | @item nse @tab stable @tab stable @tab stable | ||
477 | @item peerinfo @tab n/a @tab stable @tab stable | ||
478 | @item psyc @tab experimental @tab experimental @tab experimental | ||
479 | @item pt @tab n/a @tab n/a @tab n/a | ||
480 | @item regex @tab stable @tab stable @tab stable | ||
481 | @item revocation @tab stable @tab stable @tab stable | ||
482 | @item social @tab experimental @tab experimental @tab experimental | ||
483 | @item statistics @tab n/a @tab stable @tab stable | ||
484 | @item testbed @tab n/a @tab testing @tab testing | ||
485 | @item testing @tab n/a @tab n/a @tab testing | ||
486 | @item topology @tab n/a @tab n/a @tab n/a | ||
487 | @item transport @tab stable @tab stable @tab stable | ||
488 | @item tun @tab n/a @tab n/a @tab stable | ||
489 | @item vpn @tab testing @tab n/a @tab n/a | ||
490 | @end multitable | ||
491 | |||
492 | Here is a rough explanation of the values: | ||
493 | |||
494 | @table @samp | ||
495 | @item stable | ||
496 | No incompatible changes are planned at this time; for IPC/APIs, if | ||
497 | there are incompatible changes, they will be minor and might only require | ||
498 | minimal changes to existing code; for P2P, changes will be avoided if at all | ||
499 | possible for the 0.10.x-series | ||
500 | |||
501 | @item testing | ||
502 | No incompatible changes are | ||
503 | planned at this time, but the code is still known to be in flux; so while we | ||
504 | have no concrete plans, our expectation is that there will still be minor | ||
505 | modifications; for P2P, changes will likely be extensions that should not break | ||
506 | existing code | ||
507 | |||
508 | @item unstable | ||
509 | Changes are planned and will happen; however, they | ||
510 | will not be totally radical and the result should still resemble what is there | ||
511 | now; nevertheless, anticipated changes will break protocol/API compatibility | ||
512 | |||
513 | @item experimental | ||
514 | Changes are planned and the result may look nothing like | ||
515 | what the API/protocol looks like today | ||
516 | |||
517 | @item unknown | ||
518 | Someone should think about where this subsystem headed | ||
519 | |||
520 | @item n/a | ||
521 | This subsystem does not have an API/IPC-protocol/P2P-protocol | ||
522 | @end table | ||
523 | |||
524 | @c *************************************************************************** | ||
525 | @node Naming conventions and coding style guide | ||
526 | @section Naming conventions and coding style guide | ||
527 | |||
528 | Here you can find some rules to help you write code for GNUnet. | ||
529 | |||
530 | |||
531 | |||
532 | @c *************************************************************************** | ||
533 | @menu | ||
534 | * Naming conventions:: | ||
535 | * Coding style:: | ||
536 | @end menu | ||
537 | |||
538 | @node Naming conventions | ||
539 | @subsection Naming conventions | ||
540 | |||
541 | |||
542 | @c *************************************************************************** | ||
543 | @menu | ||
544 | * include files:: | ||
545 | * binaries:: | ||
546 | * logging:: | ||
547 | * configuration:: | ||
548 | * exported symbols:: | ||
549 | * private (library-internal) symbols (including structs and macros):: | ||
550 | * testcases:: | ||
551 | * performance tests:: | ||
552 | * src/ directories:: | ||
553 | @end menu | ||
554 | |||
555 | @node include files | ||
556 | @subsubsection include files | ||
557 | |||
558 | @itemize @bullet | ||
559 | @item _lib: library without need for a process | ||
560 | @item _service: library that needs a service process | ||
561 | @item _plugin: plugin definition | ||
562 | @item _protocol: structs used in network protocol | ||
563 | @item exceptions: | ||
564 | @itemize @bullet | ||
565 | @item gnunet_config.h --- generated | ||
566 | @item platform.h --- first included | ||
567 | @item plibc.h --- external library | ||
568 | @item gnunet_common.h --- fundamental routines | ||
569 | @item gnunet_directories.h --- generated | ||
570 | @item gettext.h --- external library | ||
571 | @end itemize | ||
572 | @end itemize | ||
573 | |||
574 | @c *************************************************************************** | ||
575 | @node binaries | ||
576 | @subsubsection binaries | ||
577 | |||
578 | @itemize @bullet | ||
579 | @item gnunet-service-xxx: service process (has listen socket) | ||
580 | @item gnunet-daemon-xxx: daemon process (no listen socket) | ||
581 | @item gnunet-helper-xxx[-yyy]: SUID helper for module xxx | ||
582 | @item gnunet-yyy: command-line tool for end-users | ||
583 | @item libgnunet_plugin_xxx_yyy.so: plugin for API xxx | ||
584 | @item libgnunetxxx.so: library for API xxx | ||
585 | @end itemize | ||
586 | |||
587 | @c *************************************************************************** | ||
588 | @node logging | ||
589 | @subsubsection logging | ||
590 | |||
591 | @itemize @bullet | ||
592 | @item services and daemons use their directory name in GNUNET_log_setup (i.e. | ||
593 | 'core') and log using plain 'GNUNET_log'. | ||
594 | @item command-line tools use their full name in GNUNET_log_setup (i.e. | ||
595 | 'gnunet-publish') and log using plain 'GNUNET_log'. | ||
596 | @item service access libraries log using 'GNUNET_log_from' and use | ||
597 | 'DIRNAME-api' for the component (i.e. 'core-api') | ||
598 | @item pure libraries (without associated service) use 'GNUNET_log_from' with | ||
599 | the component set to their library name (without lib or '.so'), which should | ||
600 | also be their directory name (i.e. 'nat') | ||
601 | @item plugins should use 'GNUNET_log_from' with the directory name and the | ||
602 | plugin name combined to produce the component name (i.e. 'transport-tcp'). | ||
603 | @item logging should be unified per-file by defining a LOG macro with the | ||
604 | appropriate arguments, along these lines:@ #define LOG(kind,...) | ||
605 | GNUNET_log_from (kind, "example-api",__VA_ARGS__) | ||
606 | @end itemize | ||
607 | |||
608 | @c *************************************************************************** | ||
609 | @node configuration | ||
610 | @subsubsection configuration | ||
611 | |||
612 | @itemize @bullet | ||
613 | @item paths (that are substituted in all filenames) are in PATHS (have as few | ||
614 | as possible) | ||
615 | @item all options for a particular module (src/MODULE) are under [MODULE] | ||
616 | @item options for a plugin of a module are under [MODULE-PLUGINNAME] | ||
617 | @end itemize | ||
618 | |||
619 | @c *************************************************************************** | ||
620 | @node exported symbols | ||
621 | @subsubsection exported symbols | ||
622 | |||
623 | @itemize @bullet | ||
624 | @item must start with "GNUNET_modulename_" and be defined in "modulename.c" | ||
625 | @item exceptions: those defined in gnunet_common.h | ||
626 | @end itemize | ||
627 | |||
628 | @c *************************************************************************** | ||
629 | @node private (library-internal) symbols (including structs and macros) | ||
630 | @subsubsection private (library-internal) symbols (including structs and macros) | ||
631 | |||
632 | @itemize @bullet | ||
633 | @item must NOT start with any prefix | ||
634 | @item must not be exported in a way that linkers could use them or@ other | ||
635 | libraries might see them via headers; they must be either@ declared/defined in | ||
636 | C source files or in headers that are in@ the respective directory under | ||
637 | src/modulename/ and NEVER be@ declared in src/include/. | ||
638 | @end itemize | ||
639 | |||
640 | @node testcases | ||
641 | @subsubsection testcases | ||
642 | |||
643 | @itemize @bullet | ||
644 | @item must be called "test_module-under-test_case-description.c" | ||
645 | @item "case-description" maybe omitted if there is only one test | ||
646 | @end itemize | ||
647 | |||
648 | @c *************************************************************************** | ||
649 | @node performance tests | ||
650 | @subsubsection performance tests | ||
651 | |||
652 | @itemize @bullet | ||
653 | @item must be called "perf_module-under-test_case-description.c" | ||
654 | @item "case-description" maybe omitted if there is only one performance test | ||
655 | @item Must only be run if HAVE_BENCHMARKS is satisfied | ||
656 | @end itemize | ||
657 | |||
658 | @c *************************************************************************** | ||
659 | @node src/ directories | ||
660 | @subsubsection src/ directories | ||
661 | |||
662 | @itemize @bullet | ||
663 | @item gnunet-NAME: end-user applications (i.e., gnunet-search, gnunet-arm) | ||
664 | @item gnunet-service-NAME: service processes with accessor library (i.e., | ||
665 | gnunet-service-arm) | ||
666 | @item libgnunetNAME: accessor library (_service.h-header) or standalone library | ||
667 | (_lib.h-header) | ||
668 | @item gnunet-daemon-NAME: daemon process without accessor library (i.e., | ||
669 | gnunet-daemon-hostlist) and no GNUnet management port | ||
670 | @item libgnunet_plugin_DIR_NAME: loadable plugins (i.e., | ||
671 | libgnunet_plugin_transport_tcp) | ||
672 | @end itemize | ||
673 | |||
674 | @c *************************************************************************** | ||
675 | @node Coding style | ||
676 | @subsection Coding style | ||
677 | |||
678 | @itemize @bullet | ||
679 | @item GNU guidelines generally apply | ||
680 | @item Indentation is done with spaces, two per level, no tabs | ||
681 | @item C99 struct initialization is fine | ||
682 | @item declare only one variable per line, so@ | ||
683 | |||
684 | @example | ||
685 | int i; int j; | ||
686 | @end example | ||
687 | |||
688 | instead of | ||
689 | |||
690 | @example | ||
691 | int i,j; | ||
692 | @end example | ||
693 | |||
694 | This helps keep diffs small and forces developers to think precisely about the | ||
695 | type of every variable. Note that @code{char *} is different from @code{const | ||
696 | char*} and @code{int} is different from @code{unsigned int} or @code{uint32_t}. | ||
697 | Each variable type should be chosen with care. | ||
698 | |||
699 | @item While @code{goto} should generally be avoided, having a @code{goto} to | ||
700 | the end of a function to a block of clean up statements (free, close, etc.) can | ||
701 | be acceptable. | ||
702 | |||
703 | @item Conditions should be written with constants on the left (to avoid | ||
704 | accidental assignment) and with the 'true' target being either the 'error' case | ||
705 | or the significantly simpler continuation. For example:@ | ||
706 | |||
707 | @example | ||
708 | if (0 != stat ("filename," &sbuf)) @{ error(); @} else @{ | ||
709 | /* handle normal case here */ | ||
710 | @} | ||
711 | @end example | ||
712 | |||
713 | |||
714 | instead of | ||
715 | @example | ||
716 | if (stat ("filename," &sbuf) == 0) @{ | ||
717 | /* handle normal case here */ | ||
718 | @} else @{ error(); @} | ||
719 | @end example | ||
720 | |||
721 | |||
722 | If possible, the error clause should be terminated with a 'return' (or 'goto' | ||
723 | to some cleanup routine) and in this case, the 'else' clause should be omitted: | ||
724 | @example | ||
725 | if (0 != stat ("filename," &sbuf)) @{ error(); return; @} | ||
726 | /* handle normal case here */ | ||
727 | @end example | ||
728 | |||
729 | |||
730 | This serves to avoid deep nesting. The 'constants on the left' rule applies to | ||
731 | all constants (including. @code{GNUNET_SCHEDULER_NO_TASK}), NULL, and enums). | ||
732 | With the two above rules (constants on left, errors in 'true' branch), there is | ||
733 | only one way to write most branches correctly. | ||
734 | |||
735 | @item Combined assignments and tests are allowed if they do not hinder code | ||
736 | clarity. For example, one can write:@ | ||
737 | |||
738 | @example | ||
739 | if (NULL == (value = lookup_function())) @{ error(); return; @} | ||
740 | @end example | ||
741 | |||
742 | |||
743 | @item Use @code{break} and @code{continue} wherever possible to avoid deep(er) | ||
744 | nesting. Thus, we would write:@ | ||
745 | |||
746 | @example | ||
747 | next = head; while (NULL != (pos = next)) @{ next = pos->next; if (! | ||
748 | should_free (pos)) continue; GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
749 | GNUNET_free (pos); @} | ||
750 | @end example | ||
751 | |||
752 | |||
753 | instead of | ||
754 | @example | ||
755 | next = head; while (NULL != (pos = next)) @{ next = | ||
756 | pos->next; if (should_free (pos)) @{ | ||
757 | /* unnecessary nesting! */ | ||
758 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); GNUNET_free (pos); @} @} | ||
759 | @end example | ||
760 | |||
761 | |||
762 | @item We primarily use @code{for} and @code{while} loops. A @code{while} loop | ||
763 | is used if the method for advancing in the loop is not a straightforward | ||
764 | increment operation. In particular, we use:@ | ||
765 | |||
766 | @example | ||
767 | next = head; | ||
768 | while (NULL != (pos = next)) | ||
769 | @{ | ||
770 | next = pos->next; | ||
771 | if (! should_free (pos)) | ||
772 | continue; | ||
773 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
774 | GNUNET_free (pos); | ||
775 | @} | ||
776 | @end example | ||
777 | |||
778 | |||
779 | to free entries in a list (as the iteration changes the structure of the list | ||
780 | due to the free; the equivalent @code{for} loop does no longer follow the | ||
781 | simple @code{for} paradigm of @code{for(INIT;TEST;INC)}). However, for loops | ||
782 | that do follow the simple @code{for} paradigm we do use @code{for}, even if it | ||
783 | involves linked lists: | ||
784 | @example | ||
785 | /* simple iteration over a linked list */ | ||
786 | for (pos = head; NULL != pos; pos = pos->next) | ||
787 | @{ | ||
788 | use (pos); | ||
789 | @} | ||
790 | @end example | ||
791 | |||
792 | |||
793 | @item The first argument to all higher-order functions in GNUnet must be | ||
794 | declared to be of type @code{void *} and is reserved for a closure. We do not | ||
795 | use inner functions, as trampolines would conflict with setups that use | ||
796 | non-executable stacks.@ The first statement in a higher-order function, which | ||
797 | unusually should be part of the variable declarations, should assign the | ||
798 | @code{cls} argument to the precise expected type. For example: | ||
799 | @example | ||
800 | int callback (void *cls, char *args) @{ | ||
801 | struct Foo *foo = cls; int other_variables; | ||
802 | |||
803 | /* rest of function */ | ||
804 | @} | ||
805 | @end example | ||
806 | |||
807 | |||
808 | @item It is good practice to write complex @code{if} expressions instead of | ||
809 | using deeply nested @code{if} statements. However, except for addition and | ||
810 | multiplication, all operators should use parens. This is fine:@ | ||
811 | |||
812 | @example | ||
813 | if ( (1 == foo) || ((0 == bar) && (x != y)) ) | ||
814 | return x; | ||
815 | @end example | ||
816 | |||
817 | |||
818 | However, this is not: | ||
819 | @example | ||
820 | if (1 == foo) | ||
821 | return x; | ||
822 | if (0 == bar && x != y) | ||
823 | return x; | ||
824 | @end example | ||
825 | |||
826 | |||
827 | Note that splitting the @code{if} statement above is debateable as the | ||
828 | @code{return x} is a very trivial statement. However, once the logic after the | ||
829 | branch becomes more complicated (and is still identical), the "or" formulation | ||
830 | should be used for sure. | ||
831 | |||
832 | @item There should be two empty lines between the end of the function and the | ||
833 | comments describing the following function. There should be a single empty line | ||
834 | after the initial variable declarations of a function. If a function has no | ||
835 | local variables, there should be no initial empty line. If a long function | ||
836 | consists of several complex steps, those steps might be separated by an empty | ||
837 | line (possibly followed by a comment describing the following step). The code | ||
838 | should not contain empty lines in arbitrary places; if in doubt, it is likely | ||
839 | better to NOT have an empty line (this way, more code will fit on the screen). | ||
840 | @end itemize | ||
841 | |||
842 | @c *************************************************************************** | ||
843 | @node Build-system | ||
844 | @section Build-system | ||
845 | |||
846 | If you have code that is likely not to compile or build rules you might want to | ||
847 | not trigger for most developers, use "if HAVE_EXPERIMENTAL" in your | ||
848 | Makefile.am. Then it is OK to (temporarily) add non-compiling (or | ||
849 | known-to-not-port) code. | ||
850 | |||
851 | If you want to compile all testcases but NOT run them, run configure with the@ | ||
852 | @code{--enable-test-suppression} option. | ||
853 | |||
854 | If you want to run all testcases, including those that take a while, run | ||
855 | configure with the@ @code{--enable-expensive-testcases} option. | ||
856 | |||
857 | If you want to compile and run benchmarks, run configure with the@ | ||
858 | @code{--enable-benchmarks} option. | ||
859 | |||
860 | If you want to obtain code coverage results, run configure with the@ | ||
861 | @code{--enable-coverage} option and run the coverage.sh script in contrib/. | ||
862 | |||
863 | @c *************************************************************************** | ||
864 | @node Developing extensions for GNUnet using the gnunet-ext template | ||
865 | @section Developing extensions for GNUnet using the gnunet-ext template | ||
866 | |||
867 | |||
868 | For developers who want to write extensions for GNUnet we provide the | ||
869 | gnunet-ext template to provide an easy to use skeleton. | ||
870 | |||
871 | gnunet-ext contains the build environment and template files for the | ||
872 | development of GNUnet services, command line tools, APIs and tests. | ||
873 | |||
874 | First of all you have to obtain gnunet-ext from git: | ||
875 | |||
876 | @code{git clone https://gnunet.org/git/gnunet-ext.git} | ||
877 | |||
878 | The next step is to bootstrap and configure it. For configure you have to | ||
879 | provide the path containing GNUnet with @code{--with-gnunet=/path/to/gnunet} | ||
880 | and the prefix where you want the install the extension using | ||
881 | @code{--prefix=/path/to/install}@ @code{@ ./bootstrap@ ./configure | ||
882 | --prefix=/path/to/install --with-gnunet=/path/to/gnunet@ } | ||
883 | |||
884 | When your GNUnet installation is not included in the default linker search | ||
885 | path, you have to add @code{/path/to/gnunet} to the file @code{/etc/ld.so.conf} | ||
886 | and run @code{ldconfig} or your add it to the environmental variable | ||
887 | @code{LD_LIBRARY_PATH} by using | ||
888 | |||
889 | @code{export LD_LIBRARY_PATH=/path/to/gnunet/lib} | ||
890 | |||
891 | @c *************************************************************************** | ||
892 | @node Writing testcases | ||
893 | @section Writing testcases | ||
894 | |||
895 | Ideally, any non-trivial GNUnet code should be covered by automated testcases. | ||
896 | Testcases should reside in the same place as the code that is being tested. The | ||
897 | name of source files implementing tests should begin with "test_" followed by | ||
898 | the name of the file that contains the code that is being tested. | ||
899 | |||
900 | Testcases in GNUnet should be integrated with the autotools build system. This | ||
901 | way, developers and anyone building binary packages will be able to run all | ||
902 | testcases simply by running @code{make check}. The final testcases shipped with | ||
903 | the distribution should output at most some brief progress information and not | ||
904 | display debug messages by default. The success or failure of a testcase must be | ||
905 | indicated by returning zero (success) or non-zero (failure) from the main | ||
906 | method of the testcase. The integration with the autotools is relatively | ||
907 | straightforward and only requires modifications to the @code{Makefile.am} in | ||
908 | the directory containing the testcase. For a testcase testing the code in | ||
909 | @code{foo.c} the @code{Makefile.am} would contain the following lines: | ||
910 | @example | ||
911 | check_PROGRAMS = test_foo TESTS = $(check_PROGRAMS) test_foo_SOURCES = | ||
912 | test_foo.c test_foo_LDADD = $(top_builddir)/src/util/libgnunetutil.la | ||
913 | @end example | ||
914 | |||
915 | Naturally, other libraries used by the testcase may be specified in the | ||
916 | @code{LDADD} directive as necessary. | ||
917 | |||
918 | Often testcases depend on additional input files, such as a configuration file. | ||
919 | These support files have to be listed using the EXTRA_DIST directive in order | ||
920 | to ensure that they are included in the distribution. Example: | ||
921 | @example | ||
922 | EXTRA_DIST = test_foo_data.conf | ||
923 | @end example | ||
924 | |||
925 | |||
926 | Executing @code{make check} will run all testcases in the current directory and | ||
927 | all subdirectories. Testcases can be compiled individually by running | ||
928 | @code{make test_foo} and then invoked directly using @code{./test_foo}. Note | ||
929 | that due to the use of plugins in GNUnet, it is typically necessary to run | ||
930 | @code{make install} before running any testcases. Thus the canonical command | ||
931 | @code{make check install} has to be changed to @code{make install check} for | ||
932 | GNUnet. | ||
933 | |||
934 | @c *************************************************************************** | ||
935 | @node GNUnet's TESTING library | ||
936 | @section GNUnet's TESTING library | ||
937 | |||
938 | The TESTING library is used for writing testcases which involve starting a | ||
939 | single or multiple peers. While peers can also be started by testcases using | ||
940 | the ARM subsystem, using TESTING library provides an elegant way to do this. | ||
941 | The configurations of the peers are auto-generated from a given template to | ||
942 | have non-conflicting port numbers ensuring that peers' services do not run into | ||
943 | bind errors. This is achieved by testing ports' availability by binding a | ||
944 | listening socket to them before allocating them to services in the generated | ||
945 | configurations. | ||
946 | |||
947 | An another advantage while using TESTING is that it shortens the testcase | ||
948 | startup time as the hostkeys for peers are copied from a pre-computed set of | ||
949 | hostkeys instead of generating them at peer startup which may take a | ||
950 | considerable amount of time when starting multiple peers or on an embedded | ||
951 | processor. | ||
952 | |||
953 | TESTING also allows for certain services to be shared among peers. This feature | ||
954 | is invaluable when testing with multiple peers as it helps to reduce the number | ||
955 | of services run per each peer and hence the total number of processes run per | ||
956 | testcase. | ||
957 | |||
958 | TESTING library only handles creating, starting and stopping peers. Features | ||
959 | useful for testcases such as connecting peers in a topology are not available | ||
960 | in TESTING but are available in the TESTBED subsystem. Furthermore, TESTING | ||
961 | only creates peers on the localhost, however by using TESTBED testcases can | ||
962 | benefit from creating peers across multiple hosts. | ||
963 | |||
964 | @menu | ||
965 | * API:: | ||
966 | * Finer control over peer stop:: | ||
967 | * Helper functions:: | ||
968 | * Testing with multiple processes:: | ||
969 | @end menu | ||
970 | |||
971 | @c *************************************************************************** | ||
972 | @node API | ||
973 | @subsection API | ||
974 | |||
975 | TESTING abstracts a group of peers as a TESTING system. All peers in a system | ||
976 | have common hostname and no two services of these peers have a same port or a | ||
977 | UNIX domain socket path. | ||
978 | |||
979 | TESTING system can be created with the function | ||
980 | @code{GNUNET_TESTING_system_create()} which returns a handle to the system. | ||
981 | This function takes a directory path which is used for generating the | ||
982 | configurations of peers, an IP address from which connections to the peers' | ||
983 | services should be allowed, the hostname to be used in peers' configuration, | ||
984 | and an array of shared service specifications of type @code{struct | ||
985 | GNUNET_TESTING_SharedService}. | ||
986 | |||
987 | The shared service specification must specify the name of the service to share, | ||
988 | the configuration pertaining to that shared service and the maximum number of | ||
989 | peers that are allowed to share a single instance of the shared service. | ||
990 | |||
991 | TESTING system created with @code{GNUNET_TESTING_system_create()} chooses ports | ||
992 | from the default range 12000 - 56000 while auto-generating configurations for | ||
993 | peers. This range can be customised with the function | ||
994 | @code{GNUNET_TESTING_system_create_with_portrange()}. This function is similar | ||
995 | to @code{GNUNET_TESTING_system_create()} except that it take 2 additional | ||
996 | parameters --- the start and end of the port range to use. | ||
997 | |||
998 | A TESTING system is destroyed with the funciton | ||
999 | @code{GNUNET_TESTING_system_destory()}. This function takes the handle of the | ||
1000 | system and a flag to remove the files created in the directory used to generate | ||
1001 | configurations. | ||
1002 | |||
1003 | A peer is created with the function @code{GNUNET_TESTING_peer_configure()}. | ||
1004 | This functions takes the system handle, a configuration template from which the | ||
1005 | configuration for the peer is auto-generated and the index from where the | ||
1006 | hostkey for the peer has to be copied from. When successfull, this function | ||
1007 | returs a handle to the peer which can be used to start and stop it and to | ||
1008 | obtain the identity of the peer. If unsuccessful, a NULL pointer is returned | ||
1009 | with an error message. This function handles the generated configuration to | ||
1010 | have non-conflicting ports and paths. | ||
1011 | |||
1012 | Peers can be started and stopped by calling the functions | ||
1013 | @code{GNUNET_TESTING_peer_start()} and @code{GNUNET_TESTING_peer_stop()} | ||
1014 | respectively. A peer can be destroyed by calling the function | ||
1015 | @code{GNUNET_TESTING_peer_destroy}. When a peer is destroyed, the ports and | ||
1016 | paths in allocated in its configuration are reclaimed for usage in new | ||
1017 | peers. | ||
1018 | |||
1019 | @c *************************************************************************** | ||
1020 | @node Finer control over peer stop | ||
1021 | @subsection Finer control over peer stop | ||
1022 | |||
1023 | Using @code{GNUNET_TESTING_peer_stop()} is normally fine for testcases. | ||
1024 | However, calling this function for each peer is inefficient when trying to | ||
1025 | shutdown multiple peers as this function sends the termination signal to the | ||
1026 | given peer process and waits for it to terminate. It would be faster in this | ||
1027 | case to send the termination signals to the peers first and then wait on them. | ||
1028 | This is accomplished by the functions @code{GNUNET_TESTING_peer_kill()} which | ||
1029 | sends a termination signal to the peer, and the function | ||
1030 | @code{GNUNET_TESTING_peer_wait()} which waits on the peer. | ||
1031 | |||
1032 | Further finer control can be achieved by choosing to stop a peer asynchronously | ||
1033 | with the function @code{GNUNET_TESTING_peer_stop_async()}. This function takes | ||
1034 | a callback parameter and a closure for it in addition to the handle to the peer | ||
1035 | to stop. The callback function is called with the given closure when the peer | ||
1036 | is stopped. Using this function eliminates blocking while waiting for the peer | ||
1037 | to terminate. | ||
1038 | |||
1039 | An asynchronous peer stop can be cancelled by calling the function | ||
1040 | @code{GNUNET_TESTING_peer_stop_async_cancel()}. Note that calling this function | ||
1041 | does not prevent the peer from terminating if the termination signal has | ||
1042 | already been sent to it. It does, however, cancels the callback to be called | ||
1043 | when the peer is stopped. | ||
1044 | |||
1045 | @c *************************************************************************** | ||
1046 | @node Helper functions | ||
1047 | @subsection Helper functions | ||
1048 | |||
1049 | Most of the testcases can benefit from an abstraction which configures a peer | ||
1050 | and starts it. This is provided by the function | ||
1051 | @code{GNUNET_TESTING_peer_run()}. This function takes the testing directory | ||
1052 | pathname, a configuration template, a callback and its closure. This function | ||
1053 | creates a peer in the given testing directory by using the configuration | ||
1054 | template, starts the peer and calls the given callback with the given closure. | ||
1055 | |||
1056 | The function @code{GNUNET_TESTING_peer_run()} starts the ARM service of the | ||
1057 | peer which starts the rest of the configured services. A similar function | ||
1058 | @code{GNUNET_TESTING_service_run} can be used to just start a single service of | ||
1059 | a peer. In this case, the peer's ARM service is not started; instead, only the | ||
1060 | given service is run. | ||
1061 | |||
1062 | @c *************************************************************************** | ||
1063 | @node Testing with multiple processes | ||
1064 | @subsection Testing with multiple processes | ||
1065 | |||
1066 | When testing GNUnet, the splitting of the code into a services and clients | ||
1067 | often complicates testing. The solution to this is to have the testcase fork | ||
1068 | @code{gnunet-service-arm}, ask it to start the required server and daemon | ||
1069 | processes and then execute appropriate client actions (to test the client APIs | ||
1070 | or the core module or both). If necessary, multiple ARM services can be forked | ||
1071 | using different ports (!) to simulate a network. However, most of the time only | ||
1072 | one ARM process is needed. Note that on exit, the testcase should shutdown ARM | ||
1073 | with a @code{TERM} signal (to give it the chance to cleanly stop its child | ||
1074 | processes). | ||
1075 | |||
1076 | The following code illustrates spawning and killing an ARM process from a | ||
1077 | testcase: | ||
1078 | @example | ||
1079 | static void run (void *cls, char *const *args, const char | ||
1080 | *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @{ struct | ||
1081 | GNUNET_OS_Process *arm_pid; arm_pid = GNUNET_OS_start_process (NULL, NULL, | ||
1082 | "gnunet-service-arm", "gnunet-service-arm", "-c", cfgname, NULL); | ||
1083 | /* do real test work here */ | ||
1084 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) GNUNET_log_strerror | ||
1085 | (GNUNET_ERROR_TYPE_WARNING, "kill"); GNUNET_assert (GNUNET_OK == | ||
1086 | GNUNET_OS_process_wait (arm_pid)); GNUNET_OS_process_close (arm_pid); @} | ||
1087 | |||
1088 | GNUNET_PROGRAM_run (argc, argv, "NAME-OF-TEST", "nohelp", options, &run, cls); | ||
1089 | @end example | ||
1090 | |||
1091 | |||
1092 | An alternative way that works well to test plugins is to implement a | ||
1093 | mock-version of the environment that the plugin expects and then to simply load | ||
1094 | the plugin directly. | ||
1095 | |||
1096 | @c *************************************************************************** | ||
1097 | @node Performance regression analysis with Gauger | ||
1098 | @section Performance regression analysis with Gauger | ||
1099 | |||
1100 | To help avoid performance regressions, GNUnet uses Gauger. Gauger is a simple | ||
1101 | logging tool that allows remote hosts to send performance data to a central | ||
1102 | server, where this data can be analyzed and visualized. Gauger shows graphs of | ||
1103 | the repository revisions and the performace data recorded for each revision, so | ||
1104 | sudden performance peaks or drops can be identified and linked to a specific | ||
1105 | revision number. | ||
1106 | |||
1107 | In the case of GNUnet, the buildbots log the performance data obtained during | ||
1108 | the tests after each build. The data can be accesed on GNUnet's Gauger page. | ||
1109 | |||
1110 | The menu on the left allows to select either the results of just one build bot | ||
1111 | (under "Hosts") or review the data from all hosts for a given test result | ||
1112 | (under "Metrics"). In case of very different absolute value of the results, for | ||
1113 | instance arm vs. amd64 machines, the option "Normalize" on a metric view can | ||
1114 | help to get an idea about the performance evolution across all hosts. | ||
1115 | |||
1116 | Using Gauger in GNUnet and having the performance of a module tracked over time | ||
1117 | is very easy. First of course, the testcase must generate some consistent | ||
1118 | metric, which makes sense to have logged. Highly volatile or random dependant | ||
1119 | metrics probably are not ideal candidates for meaningful regression detection. | ||
1120 | |||
1121 | To start logging any value, just include @code{gauger.h} in your testcase code. | ||
1122 | Then, use the macro @code{GAUGER()} to make the buildbots log whatever value is | ||
1123 | of interest for you to @code{gnunet.org}'s Gauger server. No setup is necessary | ||
1124 | as most buildbots have already everything in place and new metrics are created | ||
1125 | on demand. To delete a metric, you need to contact a member of the GNUnet | ||
1126 | development team (a file will need to be removed manually from the respective | ||
1127 | directory). | ||
1128 | |||
1129 | The code in the test should look like this: | ||
1130 | @example | ||
1131 | [other includes] | ||
1132 | #include <gauger.h> | ||
1133 | |||
1134 | int main (int argc, char *argv[]) @{ | ||
1135 | |||
1136 | [run test, generate data] GAUGER("YOUR_MODULE", "METRIC_NAME", (float)value, | ||
1137 | "UNIT"); @} | ||
1138 | @end example | ||
1139 | |||
1140 | |||
1141 | Where: | ||
1142 | @table @asis | ||
1143 | |||
1144 | @item @strong{YOUR_MODULE} is a category in the gauger page and should be the | ||
1145 | name of the module or subsystem like "Core" or "DHT" | ||
1146 | @item @strong{METRIC} is | ||
1147 | the name of the metric being collected and should be concise and descriptive, | ||
1148 | like "PUT operations in sqlite-datastore". | ||
1149 | @item @strong{value} is the value | ||
1150 | of the metric that is logged for this run. | ||
1151 | @item @strong{UNIT} is the unit in | ||
1152 | which the value is measured, for instance "kb/s" or "kb of RAM/node". | ||
1153 | @end table | ||
1154 | |||
1155 | If you wish to use Gauger for your own project, you can grab a copy of the | ||
1156 | latest stable release or check out Gauger's Subversion repository. | ||
1157 | |||
1158 | @c *************************************************************************** | ||
1159 | @node GNUnet's TESTBED Subsystem | ||
1160 | @section GNUnet's TESTBED Subsystem | ||
1161 | |||
1162 | The TESTBED subsystem facilitates testing and measuring of multi-peer | ||
1163 | deployments on a single host or over multiple hosts. | ||
1164 | |||
1165 | The architecture of the testbed module is divided into the following: | ||
1166 | @itemize @bullet | ||
1167 | |||
1168 | @item Testbed API: An API which is used by the testing driver programs. It | ||
1169 | provides with functions for creating, destroying, starting, stopping peers, | ||
1170 | etc. | ||
1171 | |||
1172 | @item Testbed service (controller): A service which is started through the | ||
1173 | Testbed API. This service handles operations to create, destroy, start, stop | ||
1174 | peers, connect them, modify their configurations. | ||
1175 | |||
1176 | @item Testbed helper: When a controller has to be started on a host, the | ||
1177 | testbed API starts the testbed helper on that host which in turn starts the | ||
1178 | controller. The testbed helper receives a configuration for the controller | ||
1179 | through its stdin and changes it to ensure the controller doesn't run into any | ||
1180 | port conflict on that host. | ||
1181 | @end itemize | ||
1182 | |||
1183 | |||
1184 | The testbed service (controller) is different from the other GNUnet services in | ||
1185 | that it is not started by ARM and is not supposed to be run as a daemon. It is | ||
1186 | started by the testbed API through a testbed helper. In a typical scenario | ||
1187 | involving multiple hosts, a controller is started on each host. Controllers | ||
1188 | take up the actual task of creating peers, starting and stopping them on the | ||
1189 | hosts they run. | ||
1190 | |||
1191 | While running deployments on a single localhost the testbed API starts the | ||
1192 | testbed helper directly as a child process. When running deployments on remote | ||
1193 | hosts the testbed API starts Testbed Helpers on each remote host through remote | ||
1194 | shell. By default testbed API uses SSH as a remote shell. This can be changed | ||
1195 | by setting the environmental variable GNUNET_TESTBED_RSH_CMD to the required | ||
1196 | remote shell program. This variable can also contain parameters which are to be | ||
1197 | passed to the remote shell program. For e.g:@ @code{@ export | ||
1198 | GNUNET_TESTBED_RSH_CMD="ssh -o BatchMode=yes -o | ||
1199 | NoHostAuthenticationForLocalhost=yes %h"@ }@ Substitutions are allowed int the | ||
1200 | above command string also allows for substitions. through placemarks which | ||
1201 | begin with a `%'. At present the following substitutions are supported | ||
1202 | @itemize @bullet | ||
1203 | @item | ||
1204 | %h: hostname | ||
1205 | @item | ||
1206 | %u: username | ||
1207 | @item | ||
1208 | %p: port | ||
1209 | @end itemize | ||
1210 | |||
1211 | Note that the substitution placemark is replaced only when the corresponding | ||
1212 | field is available and only once. Specifying @code{%u@@%h} doesn't work either. | ||
1213 | If you want to user username substitutions for SSH use the argument @code{-l} | ||
1214 | before the username substitution. Ex: @code{ssh -l %u -p %p %h} | ||
1215 | |||
1216 | The testbed API and the helper communicate through the helpers stdin and | ||
1217 | stdout. As the helper is started through a remote shell on remote hosts any | ||
1218 | output messages from the remote shell interfere with the communication and | ||
1219 | results in a failure while starting the helper. For this reason, it is | ||
1220 | suggested to use flags to make the remote shells produce no output messages and | ||
1221 | to have password-less logins. The default remote shell, SSH, the default | ||
1222 | options are "-o BatchMode=yes -o NoHostBasedAuthenticationForLocalhost=yes". | ||
1223 | Password-less logins should be ensured by using SSH keys. | ||
1224 | |||
1225 | Since the testbed API executes the remote shell as a non-interactive shell, | ||
1226 | certain scripts like .bashrc, .profiler may not be executed. If this is the | ||
1227 | case testbed API can be forced to execute an interactive shell by setting up | ||
1228 | the environmental variable `GNUNET_TESTBED_RSH_CMD_SUFFIX' to a shell program. | ||
1229 | An example could be:@ @code{@ export GNUNET_TESTBED_RSH_CMD_SUFFIX="sh -lc"@ }@ | ||
1230 | The testbed API will then execute the remote shell program as: @code{ | ||
1231 | $GNUNET_TESTBED_RSH_CMD -p $port $dest $GNUNET_TESTBED_RSH_CMD_SUFFIX | ||
1232 | gnunet-helper-testbed } | ||
1233 | |||
1234 | On some systems, problems may arise while starting testbed helpers if GNUnet is | ||
1235 | installed into a custom location since the helper may not be found in the | ||
1236 | standard path. This can be addressed by setting the variable | ||
1237 | `HELPER_BINARY_PATH' to the path of the testbed helper. Testbed API will then | ||
1238 | use this path to start helper binaries both locally and remotely. | ||
1239 | |||
1240 | Testbed API can accessed by including "gnunet_testbed_service.h" file and | ||
1241 | linking with -lgnunettestbed. | ||
1242 | |||
1243 | |||
1244 | |||
1245 | @c *************************************************************************** | ||
1246 | @menu | ||
1247 | * Supported Topologies:: | ||
1248 | * Hosts file format:: | ||
1249 | * Topology file format:: | ||
1250 | * Testbed Barriers:: | ||
1251 | * Automatic large-scale deployment of GNUnet in the PlanetLab testbed:: | ||
1252 | * TESTBED Caveats:: | ||
1253 | @end menu | ||
1254 | |||
1255 | @node Supported Topologies | ||
1256 | @subsection Supported Topologies | ||
1257 | |||
1258 | While testing multi-peer deployments, it is often needed that the peers are | ||
1259 | connected in some topology. This requirement is addressed by the function | ||
1260 | @code{GNUNET_TESTBED_overlay_connect()} which connects any given two peers in | ||
1261 | the testbed. | ||
1262 | |||
1263 | The API also provides a helper function | ||
1264 | @code{GNUNET_TESTBED_overlay_configure_topology()} to connect a given set of | ||
1265 | peers in any of the following supported topologies: | ||
1266 | @itemize @bullet | ||
1267 | |||
1268 | @item @code{GNUNET_TESTBED_TOPOLOGY_CLIQUE}: All peers are connected with each | ||
1269 | other | ||
1270 | |||
1271 | @item @code{GNUNET_TESTBED_TOPOLOGY_LINE}: Peers are connected to form a line | ||
1272 | |||
1273 | @item @code{GNUNET_TESTBED_TOPOLOGY_RING}: Peers are connected to form a ring | ||
1274 | topology | ||
1275 | |||
1276 | @item @code{GNUNET_TESTBED_TOPOLOGY_2D_TORUS}: Peers are connected to form a 2 | ||
1277 | dimensional torus topology. The number of peers may not be a perfect square, in | ||
1278 | that case the resulting torus may not have the uniform poloidal and toroidal | ||
1279 | lengths | ||
1280 | |||
1281 | @item @code{GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI}: Topology is generated to form | ||
1282 | a random graph. The number of links to be present should be given | ||
1283 | |||
1284 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD}: Peers are connected to form a | ||
1285 | 2D Torus with some random links among them. The number of random links are to | ||
1286 | be given | ||
1287 | |||
1288 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING}: Peers are connected to | ||
1289 | form a ring with some random links among them. The number of random links are | ||
1290 | to be given | ||
1291 | |||
1292 | @item @code{GNUNET_TESTBED_TOPOLOGY_SCALE_FREE}: Connects peers in a topology | ||
1293 | where peer connectivity follows power law - new peers are connected with high | ||
1294 | probabililty to well connected peers. See Emergence of Scaling in Random | ||
1295 | Networks. Science 286, 509-512, 1999. | ||
1296 | |||
1297 | @item @code{GNUNET_TESTBED_TOPOLOGY_FROM_FILE}: The topology information is | ||
1298 | loaded from a file. The path to the file has to be given. See Topology file | ||
1299 | format for the format of this file. | ||
1300 | |||
1301 | @item @code{GNUNET_TESTBED_TOPOLOGY_NONE}: No topology | ||
1302 | @end itemize | ||
1303 | |||
1304 | |||
1305 | The above supported topologies can be specified respectively by setting the | ||
1306 | variable @code{OVERLAY_TOPOLOGY} to the following values in the configuration | ||
1307 | passed to Testbed API functions @code{GNUNET_TESTBED_test_run()} and | ||
1308 | @code{GNUNET_TESTBED_run()}: | ||
1309 | @itemize @bullet | ||
1310 | @item @code{CLIQUE} | ||
1311 | @item @code{RING} | ||
1312 | @item @code{LINE} | ||
1313 | @item @code{2D_TORUS} | ||
1314 | @item @code{RANDOM} | ||
1315 | @item @code{SMALL_WORLD} | ||
1316 | @item @code{SMALL_WORLD_RING} | ||
1317 | @item @code{SCALE_FREE} | ||
1318 | @item @code{FROM_FILE} | ||
1319 | @item @code{NONE} | ||
1320 | @end itemize | ||
1321 | |||
1322 | |||
1323 | Topologies @code{RANDOM}, @code{SMALL_WORLD} and @code{SMALL_WORLD_RING} | ||
1324 | require the option @code{OVERLAY_RANDOM_LINKS} to be set to the number of | ||
1325 | random links to be generated in the configuration. The option will be ignored | ||
1326 | for the rest of the topologies. | ||
1327 | |||
1328 | Topology @code{SCALE_FREE} requires the options @code{SCALE_FREE_TOPOLOGY_CAP} | ||
1329 | to be set to the maximum number of peers which can connect to a peer and | ||
1330 | @code{SCALE_FREE_TOPOLOGY_M} to be set to how many peers a peer should be | ||
1331 | atleast connected to. | ||
1332 | |||
1333 | Similarly, the topology @code{FROM_FILE} requires the option | ||
1334 | @code{OVERLAY_TOPOLOGY_FILE} to contain the path of the file containing the | ||
1335 | topology information. This option is ignored for the rest of the topologies. | ||
1336 | See Topology file format for the format of this file. | ||
1337 | |||
1338 | @c *************************************************************************** | ||
1339 | @node Hosts file format | ||
1340 | @subsection Hosts file format | ||
1341 | |||
1342 | The testbed API offers the function GNUNET_TESTBED_hosts_load_from_file() to | ||
1343 | load from a given file details about the hosts which testbed can use for | ||
1344 | deploying peers. This function is useful to keep the data about hosts separate | ||
1345 | instead of hard coding them in code. | ||
1346 | |||
1347 | Another helper function from testbed API, GNUNET_TESTBED_run() also takes a | ||
1348 | hosts file name as its parameter. It uses the above function to populate the | ||
1349 | hosts data structures and start controllers to deploy peers. | ||
1350 | |||
1351 | These functions require the hosts file to be of the following format: | ||
1352 | @itemize @bullet | ||
1353 | @item Each line is interpreted to have details about a host | ||
1354 | @item Host details should include the username to use for logging into the | ||
1355 | host, the hostname of the host and the port number to use for the remote shell | ||
1356 | program. All thee values should be given. | ||
1357 | @item These details should be given in the following format: | ||
1358 | @code{<username>@@<hostname>:<port>} | ||
1359 | @end itemize | ||
1360 | |||
1361 | Note that having canonical hostnames may cause problems while resolving the IP | ||
1362 | addresses (See this bug). Hence it is advised to provide the hosts' IP | ||
1363 | numerical addresses as hostnames whenever possible. | ||
1364 | |||
1365 | @c *************************************************************************** | ||
1366 | @node Topology file format | ||
1367 | @subsection Topology file format | ||
1368 | |||
1369 | A topology file describes how peers are to be connected. It should adhere to | ||
1370 | the following format for testbed to parse it correctly. | ||
1371 | |||
1372 | Each line should begin with the target peer id. This should be followed by a | ||
1373 | colon(`:') and origin peer ids seperated by `|'. All spaces except for newline | ||
1374 | characters are ignored. The API will then try to connect each origin peer to | ||
1375 | the target peer. | ||
1376 | |||
1377 | For example, the following file will result in 5 overlay connections: [2->1], | ||
1378 | [3->1],[4->3], [0->3], [2->0]@ @code{@ 1:2|3@ 3:4| 0@ 0: 2@ } | ||
1379 | |||
1380 | @c *************************************************************************** | ||
1381 | @node Testbed Barriers | ||
1382 | @subsection Testbed Barriers | ||
1383 | |||
1384 | The testbed subsystem's barriers API facilitates coordination among the peers | ||
1385 | run by the testbed and the experiment driver. The concept is similar to the | ||
1386 | barrier synchronisation mechanism found in parallel programming or | ||
1387 | multi-threading paradigms - a peer waits at a barrier upon reaching it until | ||
1388 | the barrier is reached by a predefined number of peers. This predefined number | ||
1389 | of peers required to cross a barrier is also called quorum. We say a peer has | ||
1390 | reached a barrier if the peer is waiting for the barrier to be crossed. | ||
1391 | Similarly a barrier is said to be reached if the required quorum of peers reach | ||
1392 | the barrier. A barrier which is reached is deemed as crossed after all the | ||
1393 | peers waiting on it are notified. | ||
1394 | |||
1395 | The barriers API provides the following functions: | ||
1396 | @itemize @bullet | ||
1397 | @item @strong{@code{GNUNET_TESTBED_barrier_init()}:} function to initialse a | ||
1398 | barrier in the experiment | ||
1399 | @item @strong{@code{GNUNET_TESTBED_barrier_cancel()}:} function to cancel a | ||
1400 | barrier which has been initialised before | ||
1401 | @item @strong{@code{GNUNET_TESTBED_barrier_wait()}:} function to signal barrier | ||
1402 | service that the caller has reached a barrier and is waiting for it to be | ||
1403 | crossed | ||
1404 | @item @strong{@code{GNUNET_TESTBED_barrier_wait_cancel()}:} function to stop | ||
1405 | waiting for a barrier to be crossed | ||
1406 | @end itemize | ||
1407 | |||
1408 | |||
1409 | Among the above functions, the first two, namely | ||
1410 | @code{GNUNET_TESTBED_barrier_init()} and @code{GNUNET_TESTBED_barrier_cancel()} | ||
1411 | are used by experiment drivers. All barriers should be initialised by the | ||
1412 | experiment driver by calling @code{GNUNET_TESTBED_barrier_init()}. This | ||
1413 | function takes a name to identify the barrier, the quorum required for the | ||
1414 | barrier to be crossed and a notification callback for notifying the experiment | ||
1415 | driver when the barrier is crossed. @code{GNUNET_TESTBED_barrier_cancel()} | ||
1416 | cancels an initialised barrier and frees the resources allocated for it. This | ||
1417 | function can be called upon a initialised barrier before it is crossed. | ||
1418 | |||
1419 | The remaining two functions @code{GNUNET_TESTBED_barrier_wait()} and | ||
1420 | @code{GNUNET_TESTBED_barrier_wait_cancel()} are used in the peer's processes. | ||
1421 | @code{GNUNET_TESTBED_barrier_wait()} connects to the local barrier service | ||
1422 | running on the same host the peer is running on and registers that the caller | ||
1423 | has reached the barrier and is waiting for the barrier to be crossed. Note that | ||
1424 | this function can only be used by peers which are started by testbed as this | ||
1425 | function tries to access the local barrier service which is part of the testbed | ||
1426 | controller service. Calling @code{GNUNET_TESTBED_barrier_wait()} on an | ||
1427 | uninitialised barrier results in failure. | ||
1428 | @code{GNUNET_TESTBED_barrier_wait_cancel()} cancels the notification registered | ||
1429 | by @code{GNUNET_TESTBED_barrier_wait()}. | ||
1430 | |||
1431 | |||
1432 | @c *************************************************************************** | ||
1433 | @menu | ||
1434 | * Implementation:: | ||
1435 | @end menu | ||
1436 | |||
1437 | @node Implementation | ||
1438 | @subsubsection Implementation | ||
1439 | |||
1440 | Since barriers involve coordination between experiment driver and peers, the | ||
1441 | barrier service in the testbed controller is split into two components. The | ||
1442 | first component responds to the message generated by the barrier API used by | ||
1443 | the experiment driver (functions @code{GNUNET_TESTBED_barrier_init()} and | ||
1444 | @code{GNUNET_TESTBED_barrier_cancel()}) and the second component to the | ||
1445 | messages generated by barrier API used by peers (functions | ||
1446 | @code{GNUNET_TESTBED_barrier_wait()} and | ||
1447 | @code{GNUNET_TESTBED_barrier_wait_cancel()}). | ||
1448 | |||
1449 | Calling @code{GNUNET_TESTBED_barrier_init()} sends a | ||
1450 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT} message to the master | ||
1451 | controller. The master controller then registers a barrier and calls | ||
1452 | @code{GNUNET_TESTBED_barrier_init()} for each its subcontrollers. In this way | ||
1453 | barrier initialisation is propagated to the controller hierarchy. While | ||
1454 | propagating initialisation, any errors at a subcontroller such as timeout | ||
1455 | during further propagation are reported up the hierarchy back to the experiment | ||
1456 | driver. | ||
1457 | |||
1458 | Similar to @code{GNUNET_TESTBED_barrier_init()}, | ||
1459 | @code{GNUNET_TESTBED_barrier_cancel()} propagates | ||
1460 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL} message which causes | ||
1461 | controllers to remove an initialised barrier. | ||
1462 | |||
1463 | The second component is implemented as a separate service in the binary | ||
1464 | `gnunet-service-testbed' which already has the testbed controller service. | ||
1465 | Although this deviates from the gnunet process architecture of having one | ||
1466 | service per binary, it is needed in this case as this component needs access to | ||
1467 | barrier data created by the first component. This component responds to | ||
1468 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages from local peers when | ||
1469 | they call @code{GNUNET_TESTBED_barrier_wait()}. Upon receiving | ||
1470 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} message, the service checks if | ||
1471 | the requested barrier has been initialised before and if it was not | ||
1472 | initialised, an error status is sent through | ||
1473 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to the local peer and | ||
1474 | the connection from the peer is terminated. If the barrier is initialised | ||
1475 | before, the barrier's counter for reached peers is incremented and a | ||
1476 | notification is registered to notify the peer when the barrier is reached. The | ||
1477 | connection from the peer is left open. | ||
1478 | |||
1479 | When enough peers required to attain the quorum send | ||
1480 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages, the controller sends | ||
1481 | a @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to its parent | ||
1482 | informing that the barrier is crossed. If the controller has started further | ||
1483 | subcontrollers, it delays this message until it receives a similar notification | ||
1484 | from each of those subcontrollers. Finally, the barriers API at the experiment | ||
1485 | driver receives the @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} when the | ||
1486 | barrier is reached at all the controllers. | ||
1487 | |||
1488 | The barriers API at the experiment driver responds to the | ||
1489 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message by echoing it back to | ||
1490 | the master controller and notifying the experiment controller through the | ||
1491 | notification callback that a barrier has been crossed. The echoed | ||
1492 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message is propagated by the | ||
1493 | master controller to the controller hierarchy. This propagation triggers the | ||
1494 | notifications registered by peers at each of the controllers in the hierarchy. | ||
1495 | Note the difference between this downward propagation of the | ||
1496 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message from its upward | ||
1497 | propagation --- the upward propagation is needed for ensuring that the barrier | ||
1498 | is reached by all the controllers and the downward propagation is for | ||
1499 | triggering that the barrier is crossed. | ||
1500 | |||
1501 | @c *************************************************************************** | ||
1502 | @node Automatic large-scale deployment of GNUnet in the PlanetLab testbed | ||
1503 | @subsection Automatic large-scale deployment of GNUnet in the PlanetLab testbed | ||
1504 | |||
1505 | PlanetLab is as a testbed for computer networking and distributed systems | ||
1506 | research. It was established in 2002 and as of June 2010 was composed of 1090 | ||
1507 | nodes at 507 sites worldwide. | ||
1508 | |||
1509 | To automate the GNUnet we created a set of automation tools to simplify the | ||
1510 | large-scale deployment. We provide you a set of scripts you can use to deploy | ||
1511 | GNUnet on a set of nodes and manage your installation. | ||
1512 | |||
1513 | Please also check @uref{https://gnunet.org/installation-fedora8-svn} and@ | ||
1514 | @uref{https://gnunet.org/installation-fedora12-svn} to find detailled | ||
1515 | instructions how to install GNUnet on a PlanetLab node. | ||
1516 | |||
1517 | |||
1518 | @c *************************************************************************** | ||
1519 | @menu | ||
1520 | * PlanetLab Automation for Fedora8 nodes:: | ||
1521 | * Install buildslave on PlanetLab nodes running fedora core 8:: | ||
1522 | * Setup a new PlanetLab testbed using GPLMT:: | ||
1523 | * Why do i get an ssh error when using the regex profiler?:: | ||
1524 | @end menu | ||
1525 | |||
1526 | @node PlanetLab Automation for Fedora8 nodes | ||
1527 | @subsubsection PlanetLab Automation for Fedora8 nodes | ||
1528 | |||
1529 | @c *************************************************************************** | ||
1530 | @node Install buildslave on PlanetLab nodes running fedora core 8 | ||
1531 | @subsubsection Install buildslave on PlanetLab nodes running fedora core 8 | ||
1532 | @c ** Actually this is a subsubsubsection, but must be fixed differently | ||
1533 | @c ** as subsubsection is the lowest. | ||
1534 | |||
1535 | Since most of the PlanetLab nodes are running the very old fedora core 8 image, | ||
1536 | installing the buildslave software is quite some pain. For our PlanetLab | ||
1537 | testbed we figured out how to install the buildslave software best. | ||
1538 | |||
1539 | Install Distribute for python:@ @code{@ curl | ||
1540 | http://python-distribute.org/distribute_setup.py | sudo python@ } | ||
1541 | |||
1542 | Install Distribute for zope.interface <= 3.8.0 (4.0 and 4.0.1 will not work):@ | ||
1543 | @code{@ wget | ||
1544 | http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.8.0.tar.gz@ | ||
1545 | tar zvfz zope.interface-3.8.0.tar.gz@ cd zope.interface-3.8.0@ sudo python | ||
1546 | setup.py install@ } | ||
1547 | |||
1548 | Install the buildslave software (0.8.6 was the latest version):@ @code{@ wget | ||
1549 | http://buildbot.googlecode.com/files/buildbot-slave-0.8.6p1.tar.gz@ tar xvfz | ||
1550 | buildbot-slave-0.8.6p1.tar.gz@ cd buildslave-0.8.6p1@ sudo python setup.py | ||
1551 | install@ } | ||
1552 | |||
1553 | The setup will download the matching twisted package and install it.@ It will | ||
1554 | also try to install the latest version of zope.interface which will fail to | ||
1555 | install. Buildslave will work anyway since version 3.8.0 was installed before! | ||
1556 | |||
1557 | @c *************************************************************************** | ||
1558 | @node Setup a new PlanetLab testbed using GPLMT | ||
1559 | @subsubsection Setup a new PlanetLab testbed using GPLMT | ||
1560 | |||
1561 | @itemize @bullet | ||
1562 | @item Get a new slice and assign nodes | ||
1563 | Ask your PlanetLab PI to give you a new slice and assign the nodes you need | ||
1564 | @item Install a buildmaster | ||
1565 | You can stick to the buildbot documentation:@ | ||
1566 | @uref{http://buildbot.net/buildbot/docs/current/manual/installation.html} | ||
1567 | @item Install the buildslave software on all nodes | ||
1568 | To install the buildslave on all nodes assigned to your slice you can use the | ||
1569 | tasklist @code{install_buildslave_fc8.xml} provided with GPLMT: | ||
1570 | |||
1571 | @code{@ ./gplmt.py -c contrib/tumple_gnunet.conf -t | ||
1572 | contrib/tasklists/install_buildslave_fc8.xml -a -p <planetlab password>@ } | ||
1573 | |||
1574 | @item Create the buildmaster configuration and the slave setup commands | ||
1575 | |||
1576 | The master and the and the slaves have need to have credentials and the master | ||
1577 | has to have all nodes configured. This can be done with the | ||
1578 | @code{create_buildbot_configuration.py} script in the @code{scripts} directory | ||
1579 | |||
1580 | This scripts takes a list of nodes retrieved directly from PlanetLab or read | ||
1581 | from a file and a configuration template and creates:@ | ||
1582 | - a tasklist which can be executed with gplmt to setup the slaves@ | ||
1583 | - a master.cfg file containing a PlanetLab nodes | ||
1584 | |||
1585 | A configuration template is included in the <contrib>, most important is that | ||
1586 | the script replaces the following tags in the template: | ||
1587 | |||
1588 | %GPLMT_BUILDER_DEFINITION :@ GPLMT_BUILDER_SUMMARY@ GPLMT_SLAVES@ | ||
1589 | %GPLMT_SCHEDULER_BUILDERS | ||
1590 | |||
1591 | Create configuration for all nodes assigned to a slice:@ @code{@ | ||
1592 | ./create_buildbot_configuration.py -u <planetlab username> -p <planetlab | ||
1593 | password> -s <slice> -m <buildmaster+port> -t <template>@ }@ Create | ||
1594 | configuration for some nodes in a file:@ @code{@ | ||
1595 | ./create_buildbot_configuration.p -f <node_file> -m <buildmaster+port> -t | ||
1596 | <template>@ } | ||
1597 | |||
1598 | @item Copy the @code{master.cfg} to the buildmaster and start it | ||
1599 | Use @code{buildbot start <basedir>} to start the server | ||
1600 | @item Setup the buildslaves | ||
1601 | @end itemize | ||
1602 | |||
1603 | @c *************************************************************************** | ||
1604 | @node Why do i get an ssh error when using the regex profiler? | ||
1605 | @subsubsection Why do i get an ssh error when using the regex profiler? | ||
1606 | |||
1607 | Why do i get an ssh error "Permission denied (publickey,password)." when using | ||
1608 | the regex profiler although passwordless ssh to localhost works using publickey | ||
1609 | and ssh-agent? | ||
1610 | |||
1611 | You have to generate a public/private-key pair with no password:@ | ||
1612 | @code{ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_localhost}@ | ||
1613 | and then add the following to your ~/.ssh/config file: | ||
1614 | |||
1615 | @code{Host 127.0.0.1@ IdentityFile ~/.ssh/id_localhost} | ||
1616 | |||
1617 | now make sure your hostsfile looks like@ | ||
1618 | |||
1619 | [USERNAME]@@127.0.0.1:22@ | ||
1620 | [USERNAME]@@127.0.0.1:22 | ||
1621 | |||
1622 | You can test your setup by running `ssh 127.0.0.1` in a terminal and then in | ||
1623 | the opened session run it again. If you were not asked for a password on either | ||
1624 | login, then you should be good to go. | ||
1625 | |||
1626 | @c *************************************************************************** | ||
1627 | @node TESTBED Caveats | ||
1628 | @subsection TESTBED Caveats | ||
1629 | |||
1630 | This section documents a few caveats when using the GNUnet testbed | ||
1631 | subsystem. | ||
1632 | |||
1633 | |||
1634 | @c *************************************************************************** | ||
1635 | @menu | ||
1636 | * CORE must be started:: | ||
1637 | * ATS must want the connections:: | ||
1638 | @end menu | ||
1639 | |||
1640 | @node CORE must be started | ||
1641 | @subsubsection CORE must be started | ||
1642 | |||
1643 | A simple issue is #3993: Your configuration MUST somehow ensure that for each | ||
1644 | peer the CORE service is started when the peer is setup, otherwise TESTBED may | ||
1645 | fail to connect peers when the topology is initialized, as TESTBED will start | ||
1646 | some CORE services but not necessarily all (but it relies on all of them | ||
1647 | running). The easiest way is to set 'FORCESTART = YES' in the '[core]' section | ||
1648 | of the configuration file. Alternatively, having any service that directly or | ||
1649 | indirectly depends on CORE being started with FORCESTART will also do. This | ||
1650 | issue largely arises if users try to over-optimize by not starting any services | ||
1651 | with FORCESTART. | ||
1652 | |||
1653 | @c *************************************************************************** | ||
1654 | @node ATS must want the connections | ||
1655 | @subsubsection ATS must want the connections | ||
1656 | |||
1657 | When TESTBED sets up connections, it only offers the respective HELLO | ||
1658 | information to the TRANSPORT service. It is then up to the ATS service to | ||
1659 | @strong{decide} to use the connection. The ATS service will typically eagerly | ||
1660 | establish any connection if the number of total connections is low (relative to | ||
1661 | bandwidth). Details may further depend on the specific ATS backend that was | ||
1662 | configured. If ATS decides to NOT establish a connection (even though TESTBED | ||
1663 | provided the required information), then that connection will count as failed | ||
1664 | for TESTBED. Note that you can configure TESTBED to tolerate a certain number | ||
1665 | of connection failures (see '-e' option of gnunet-testbed-profiler). This issue | ||
1666 | largely arises for dense overlay topologies, especially if you try to create | ||
1667 | cliques with more than 20 peers. | ||
1668 | |||
1669 | @c *************************************************************************** | ||
1670 | @node libgnunetutil | ||
1671 | @section libgnunetutil | ||
1672 | |||
1673 | libgnunetutil is the fundamental library that all GNUnet code builds upon. | ||
1674 | Ideally, this library should contain most of the platform dependent code | ||
1675 | (except for user interfaces and really special needs that only few applications | ||
1676 | have). It is also supposed to offer basic services that most if not all GNUnet | ||
1677 | binaries require. The code of libgnunetutil is in the src/util/ directory. The | ||
1678 | public interface to the library is in the gnunet_util.h header. The functions | ||
1679 | provided by libgnunetutil fall roughly into the following categories (in | ||
1680 | roughly the order of importance for new developers): | ||
1681 | @itemize @bullet | ||
1682 | @item logging (common_logging.c) | ||
1683 | @item memory allocation (common_allocation.c) | ||
1684 | @item endianess conversion (common_endian.c) | ||
1685 | @item internationalization (common_gettext.c) | ||
1686 | @item String manipulation (string.c) | ||
1687 | @item file access (disk.c) | ||
1688 | @item buffered disk IO (bio.c) | ||
1689 | @item time manipulation (time.c) | ||
1690 | @item configuration parsing (configuration.c) | ||
1691 | @item command-line handling (getopt*.c) | ||
1692 | @item cryptography (crypto_*.c) | ||
1693 | @item data structures (container_*.c) | ||
1694 | @item CPS-style scheduling (scheduler.c) | ||
1695 | @item Program initialization (program.c) | ||
1696 | @item Networking (network.c, client.c, server*.c, service.c) | ||
1697 | @item message queueing (mq.c) | ||
1698 | @item bandwidth calculations (bandwidth.c) | ||
1699 | @item Other OS-related (os*.c, plugin.c, signal.c) | ||
1700 | @item Pseudonym management (pseudonym.c) | ||
1701 | @end itemize | ||
1702 | |||
1703 | It should be noted that only developers that fully understand this entire API | ||
1704 | will be able to write good GNUnet code. | ||
1705 | |||
1706 | Ideally, porting GNUnet should only require porting the gnunetutil library. | ||
1707 | More testcases for the gnunetutil APIs are therefore a great way to make | ||
1708 | porting of GNUnet easier. | ||
1709 | |||
1710 | @menu | ||
1711 | * Logging:: | ||
1712 | * Interprocess communication API (IPC):: | ||
1713 | * Cryptography API:: | ||
1714 | * Message Queue API:: | ||
1715 | * Service API:: | ||
1716 | * Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps:: | ||
1717 | * The CONTAINER_MDLL API:: | ||
1718 | @end menu | ||
1719 | |||
1720 | @c *************************************************************************** | ||
1721 | @node Logging | ||
1722 | @subsection Logging | ||
1723 | |||
1724 | GNUnet is able to log its activity, mostly for the purposes of debugging the | ||
1725 | program at various levels. | ||
1726 | |||
1727 | @file{gnunet_common.h} defines several @strong{log levels}: | ||
1728 | @table @asis | ||
1729 | |||
1730 | @item ERROR for errors (really problematic situations, often leading to | ||
1731 | crashes) | ||
1732 | @item WARNING for warnings (troubling situations that might have | ||
1733 | negative consequences, although not fatal) | ||
1734 | @item INFO for various information. | ||
1735 | Used somewhat rarely, as GNUnet statistics is used to hold and display most of | ||
1736 | the information that users might find interesting. | ||
1737 | @item DEBUG for debugging. | ||
1738 | Does not produce much output on normal builds, but when extra logging is | ||
1739 | enabled at compile time, a staggering amount of data is outputted under this | ||
1740 | log level. | ||
1741 | @end table | ||
1742 | |||
1743 | |||
1744 | Normal builds of GNUnet (configured with @code{--enable-logging[=yes]}) are | ||
1745 | supposed to log nothing under DEBUG level. The @code{--enable-logging=verbose} | ||
1746 | configure option can be used to create a build with all logging enabled. | ||
1747 | However, such build will produce large amounts of log data, which is | ||
1748 | inconvenient when one tries to hunt down a specific problem. | ||
1749 | |||
1750 | To mitigate this problem, GNUnet provides facilities to apply a filter to | ||
1751 | reduce the logs: | ||
1752 | @table @asis | ||
1753 | |||
1754 | @item Logging by default When no log levels are configured in any other way | ||
1755 | (see below), GNUnet will default to the WARNING log level. This mostly applies | ||
1756 | to GNUnet command line utilities, services and daemons; tests will always set | ||
1757 | log level to WARNING or, if @code{--enable-logging=verbose} was passed to | ||
1758 | configure, to DEBUG. The default level is suggested for normal operation. | ||
1759 | @item The -L option Most GNUnet executables accept an "-L loglevel" or | ||
1760 | "--log=loglevel" option. If used, it makes the process set a global log level | ||
1761 | to "loglevel". Thus it is possible to run some processes with -L DEBUG, for | ||
1762 | example, and others with -L ERROR to enable specific settings to diagnose | ||
1763 | problems with a particular process. | ||
1764 | @item Configuration files. Because GNUnet | ||
1765 | service and deamon processes are usually launched by gnunet-arm, it is not | ||
1766 | possible to pass different custom command line options directly to every one of | ||
1767 | them. The options passed to @code{gnunet-arm} only affect gnunet-arm and not | ||
1768 | the rest of GNUnet. However, one can specify a configuration key "OPTIONS" in | ||
1769 | the section that corresponds to a service or a daemon, and put a value of "-L | ||
1770 | loglevel" there. This will make the respective service or daemon set its log | ||
1771 | level to "loglevel" (as the value of OPTIONS will be passed as a command-line | ||
1772 | argument). | ||
1773 | |||
1774 | To specify the same log level for all services without creating separate | ||
1775 | "OPTIONS" entries in the configuration for each one, the user can specify a | ||
1776 | config key "GLOBAL_POSTFIX" in the [arm] section of the configuration file. The | ||
1777 | value of GLOBAL_POSTFIX will be appended to all command lines used by the ARM | ||
1778 | service to run other services. It can contain any option valid for all GNUnet | ||
1779 | commands, thus in particular the "-L loglevel" option. The ARM service itself | ||
1780 | is, however, unaffected by GLOBAL_POSTFIX; to set log level for it, one has to | ||
1781 | specify "OPTIONS" key in the [arm] section. | ||
1782 | @item Environment variables. | ||
1783 | Setting global per-process log levels with "-L loglevel" does not offer | ||
1784 | sufficient log filtering granularity, as one service will call interface | ||
1785 | libraries and supporting libraries of other GNUnet services, potentially | ||
1786 | producing lots of debug log messages from these libraries. Also, changing the | ||
1787 | config file is not always convenient (especially when running the GNUnet test | ||
1788 | suite).@ To fix that, and to allow GNUnet to use different log filtering at | ||
1789 | runtime without re-compiling the whole source tree, the log calls were changed | ||
1790 | to be configurable at run time. To configure them one has to define environment | ||
1791 | variables "GNUNET_FORCE_LOGFILE", "GNUNET_LOG" and/or "GNUNET_FORCE_LOG": | ||
1792 | @itemize @bullet | ||
1793 | |||
1794 | @item "GNUNET_LOG" only affects the logging when no global log level is | ||
1795 | configured by any other means (that is, the process does not explicitly set its | ||
1796 | own log level, there are no "-L loglevel" options on command line or in | ||
1797 | configuration files), and can be used to override the default WARNING log | ||
1798 | level. | ||
1799 | |||
1800 | @item "GNUNET_FORCE_LOG" will completely override any other log configuration | ||
1801 | options given. | ||
1802 | |||
1803 | @item "GNUNET_FORCE_LOGFILE" will completely override the location of the file | ||
1804 | to log messages to. It should contain a relative or absolute file name. Setting | ||
1805 | GNUNET_FORCE_LOGFILE is equivalent to passing "--log-file=logfile" or "-l | ||
1806 | logfile" option (see below). It supports "[]" format in file names, but not | ||
1807 | "@{@}" (see below). | ||
1808 | @end itemize | ||
1809 | |||
1810 | |||
1811 | Because environment variables are inherited by child processes when they are | ||
1812 | launched, starting or re-starting the ARM service with these variables will | ||
1813 | propagate them to all other services. | ||
1814 | |||
1815 | "GNUNET_LOG" and "GNUNET_FORCE_LOG" variables must contain a specially | ||
1816 | formatted @strong{logging definition} string, which looks like this:@ @code{@ | ||
1817 | [component];[file];[function];[from_line[-to_line]];loglevel@emph{[/component...]}@ | ||
1818 | }@ That is, a logging definition consists of definition entries, separated by | ||
1819 | slashes ('/'). If only one entry is present, there is no need to add a slash | ||
1820 | to its end (although it is not forbidden either).@ All definition fields | ||
1821 | (component, file, function, lines and loglevel) are mandatory, but (except for | ||
1822 | the loglevel) they can be empty. An empty field means "match anything". Note | ||
1823 | that even if fields are empty, the semicolon (';') separators must be | ||
1824 | present.@ The loglevel field is mandatory, and must contain one of the log | ||
1825 | level names (ERROR, WARNING, INFO or DEBUG).@ The lines field might contain | ||
1826 | one non-negative number, in which case it matches only one line, or a range | ||
1827 | "from_line-to_line", in which case it matches any line in the interval | ||
1828 | [from_line;to_line] (that is, including both start and end line).@ GNUnet | ||
1829 | mostly defaults component name to the name of the service that is implemented | ||
1830 | in a process ('transport', 'core', 'peerinfo', etc), but logging calls can | ||
1831 | specify custom component names using @code{GNUNET_log_from}.@ File name and | ||
1832 | function name are provided by the compiler (__FILE__ and __FUNCTION__ | ||
1833 | built-ins). | ||
1834 | |||
1835 | Component, file and function fields are interpreted as non-extended regular | ||
1836 | expressions (GNU libc regex functions are used). Matching is case-sensitive, ^ | ||
1837 | and $ will match the beginning and the end of the text. If a field is empty, | ||
1838 | its contents are automatically replaced with a ".*" regular expression, which | ||
1839 | matches anything. Matching is done in the default way, which means that the | ||
1840 | expression matches as long as it's contained anywhere in the string. Thus | ||
1841 | "GNUNET_" will match both "GNUNET_foo" and "BAR_GNUNET_BAZ". Use '^' and/or '$' | ||
1842 | to make sure that the expression matches at the start and/or at the end of the | ||
1843 | string.@ The semicolon (';') can't be escaped, and GNUnet will not use it in | ||
1844 | component names (it can't be used in function names and file names anyway).@ | ||
1845 | |||
1846 | @end table | ||
1847 | |||
1848 | |||
1849 | Every logging call in GNUnet code will be (at run time) matched against the | ||
1850 | log definitions passed to the process. If a log definition fields are matching | ||
1851 | the call arguments, then the call log level is compared the the log level of | ||
1852 | that definition. If the call log level is less or equal to the definition log | ||
1853 | level, the call is allowed to proceed. Otherwise the logging call is | ||
1854 | forbidden, and nothing is logged. If no definitions matched at all, GNUnet | ||
1855 | will use the global log level or (if a global log level is not specified) will | ||
1856 | default to WARNING (that is, it will allow the call to proceed, if its level | ||
1857 | is less or equal to the global log level or to WARNING). | ||
1858 | |||
1859 | That is, definitions are evaluated from left to right, and the first matching | ||
1860 | definition is used to allow or deny the logging call. Thus it is advised to | ||
1861 | place narrow definitions at the beginning of the logdef string, and generic | ||
1862 | definitions - at the end. | ||
1863 | |||
1864 | Whether a call is allowed or not is only decided the first time this particular | ||
1865 | call is made. The evaluation result is then cached, so that any attempts to | ||
1866 | make the same call later will be allowed or disallowed right away. Because of | ||
1867 | that runtime log level evaluation should not significantly affect the process | ||
1868 | performance.@ Log definition parsing is only done once, at the first call to | ||
1869 | GNUNET_log_setup () made by the process (which is usually done soon after it | ||
1870 | starts). | ||
1871 | |||
1872 | At the moment of writing there is no way to specify logging definitions from | ||
1873 | configuration files, only via environment variables. | ||
1874 | |||
1875 | At the moment GNUnet will stop processing a log definition when it encounters | ||
1876 | an error in definition formatting or an error in regular expression syntax, and | ||
1877 | will not report the failure in any way. | ||
1878 | |||
1879 | |||
1880 | @c *************************************************************************** | ||
1881 | @menu | ||
1882 | * Examples:: | ||
1883 | * Log files:: | ||
1884 | * Updated behavior of GNUNET_log:: | ||
1885 | @end menu | ||
1886 | |||
1887 | @node Examples | ||
1888 | @subsubsection Examples | ||
1889 | |||
1890 | @table @asis | ||
1891 | |||
1892 | @item @code{GNUNET_FORCE_LOG=";;;;DEBUG" gnunet-arm -s} Start GNUnet process | ||
1893 | tree, running all processes with DEBUG level (one should be careful with it, as | ||
1894 | log files will grow at alarming rate!) | ||
1895 | @item @code{GNUNET_FORCE_LOG="core;;;;DEBUG" gnunet-arm -s} Start GNUnet process | ||
1896 | tree, running the core service under DEBUG level (everything else will use | ||
1897 | configured or default level). | ||
1898 | @item @code{GNUNET_FORCE_LOG=";gnunet-service-transport_validation.c;;;DEBUG" gnunet-arm -s} | ||
1899 | Start GNUnet process tree, allowing any logging calls from | ||
1900 | gnunet-service-transport_validation.c (everything else will use configured or | ||
1901 | default level). | ||
1902 | @item @code{GNUNET_FORCE_LOG="fs;gnunet-service-fs_push.c;;;DEBUG" gnunet-arm -s} | ||
1903 | Start GNUnet process tree, allowing any logging calls from | ||
1904 | gnunet-gnunet-service-fs_push.c (everything else will use configured or default | ||
1905 | level). | ||
1906 | @item @code{GNUNET_FORCE_LOG=";;GNUNET_NETWORK_socket_select;;DEBUG" gnunet-arm -s} | ||
1907 | Start GNUnet process tree, allowing any logging calls from the | ||
1908 | GNUNET_NETWORK_socket_select function (everything else will use configured or | ||
1909 | default level). | ||
1910 | @item @code{GNUNET_FORCE_LOG="transport.*;;.*send.*;;DEBUG/;;;;WARNING" gnunet-arm -s} | ||
1911 | Start GNUnet process tree, allowing any logging calls from the components | ||
1912 | that have "transport" in their names, and are made from function that have | ||
1913 | "send" in their names. Everything else will be allowed to be logged only if it | ||
1914 | has WARNING level. | ||
1915 | @end table | ||
1916 | |||
1917 | |||
1918 | On Windows, one can use batch files to run GNUnet processes with special | ||
1919 | environment variables, without affecting the whole system. Such batch file will | ||
1920 | look like this:@ @code{@ set GNUNET_FORCE_LOG=;;do_transmit;;DEBUG@ gnunet-arm | ||
1921 | -s@ }@ (note the absence of double quotes in the environment variable | ||
1922 | definition, as opposed to earlier examples, which use the shell).@ Another | ||
1923 | limitation, on Windows, GNUNET_FORCE_LOGFILE @strong{MUST} be set in order to | ||
1924 | GNUNET_FORCE_LOG to work. | ||
1925 | |||
1926 | |||
1927 | @c *************************************************************************** | ||
1928 | @node Log files | ||
1929 | @subsubsection Log files | ||
1930 | |||
1931 | GNUnet can be told to log everything into a file instead of stderr (which is | ||
1932 | the default) using the "--log-file=logfile" or "-l logfile" option. This option | ||
1933 | can also be passed via command line, or from the "OPTION" and "GLOBAL_POSTFIX" | ||
1934 | configuration keys (see above). The file name passed with this option is | ||
1935 | subject to GNUnet filename expansion. If specified in "GLOBAL_POSTFIX", it is | ||
1936 | also subject to ARM service filename expansion, in particular, it may contain | ||
1937 | "@{@}" (left and right curly brace) sequence, which will be replaced by ARM | ||
1938 | with the name of the service. This is used to keep logs from more than one | ||
1939 | service separate, while only specifying one template containing "@{@}" in | ||
1940 | GLOBAL_POSTFIX. | ||
1941 | |||
1942 | As part of a secondary file name expansion, the first occurrence of "[]" | ||
1943 | sequence ("left square brace" followed by "right square brace") in the file | ||
1944 | name will be replaced with a process identifier or the process when it | ||
1945 | initializes its logging subsystem. As a result, all processes will log into | ||
1946 | different files. This is convenient for isolating messages of a particular | ||
1947 | process, and prevents I/O races when multiple processes try to write into the | ||
1948 | file at the same time. This expansion is done independently of "@{@}" | ||
1949 | expansion that ARM service does (see above). | ||
1950 | |||
1951 | The log file name that is specified via "-l" can contain format characters | ||
1952 | from the 'strftime' function family. For example, "%Y" will be replaced with | ||
1953 | the current year. Using "basename-%Y-%m-%d.log" would include the current | ||
1954 | year, month and day in the log file. If a GNUnet process runs for long enough | ||
1955 | to need more than one log file, it will eventually clean up old log files. | ||
1956 | Currently, only the last three log files (plus the current log file) are | ||
1957 | preserved. So once the fifth log file goes into use (so after 4 days if you | ||
1958 | use "%Y-%m-%d" as above), the first log file will be automatically deleted. | ||
1959 | Note that if your log file name only contains "%Y", then log files would be | ||
1960 | kept for 4 years and the logs from the first year would be deleted once year 5 | ||
1961 | begins. If you do not use any date-related string format codes, logs would | ||
1962 | never be automatically deleted by GNUnet. | ||
1963 | |||
1964 | |||
1965 | @c *************************************************************************** | ||
1966 | |||
1967 | @node Updated behavior of GNUNET_log | ||
1968 | @subsubsection Updated behavior of GNUNET_log | ||
1969 | |||
1970 | It's currently quite common to see constructions like this all over the code: | ||
1971 | @example | ||
1972 | #if MESH_DEBUG GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client | ||
1973 | disconnected\n"); #endif | ||
1974 | @end example | ||
1975 | |||
1976 | The reason for the #if is not to avoid displaying the message when disabled | ||
1977 | (GNUNET_ERROR_TYPE takes care of that), but to avoid the compiler including it | ||
1978 | in the binary at all, when compiling GNUnet for platforms with restricted | ||
1979 | storage space / memory (MIPS routers, ARM plug computers / dev boards, etc). | ||
1980 | |||
1981 | This presents several problems: the code gets ugly, hard to write and it is | ||
1982 | very easy to forget to include the #if guards, creating non-consistent code. A | ||
1983 | new change in GNUNET_log aims to solve these problems. | ||
1984 | |||
1985 | @strong{This change requires to @code{./configure} with at least | ||
1986 | @code{--enable-logging=verbose} to see debug messages.} | ||
1987 | |||
1988 | Here is an example of code with dense debug statements: | ||
1989 | @example | ||
1990 | switch (restrict_topology) @{ | ||
1991 | case GNUNET_TESTING_TOPOLOGY_CLIQUE: #if VERBOSE_TESTING | ||
1992 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but clique | ||
1993 | topology\n")); #endif unblacklisted_connections = create_clique (pg, | ||
1994 | &remove_connections, BLACKLIST, GNUNET_NO); break; case | ||
1995 | GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: #if VERBOSE_TESTING GNUNET_log | ||
1996 | (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but small world (ring) | ||
1997 | topology\n")); #endif unblacklisted_connections = create_small_world_ring (pg, | ||
1998 | &remove_connections, BLACKLIST); break; | ||
1999 | @end example | ||
2000 | |||
2001 | |||
2002 | Pretty hard to follow, huh? | ||
2003 | |||
2004 | From now on, it is not necessary to include the #if / #endif statements to | ||
2005 | acheive the same behavior. The GNUNET_log and GNUNET_log_from macros take care | ||
2006 | of it for you, depending on the configure option: | ||
2007 | @itemize @bullet | ||
2008 | @item If @code{--enable-logging} is set to @code{no}, the binary will contain | ||
2009 | no log messages at all. | ||
2010 | @item If @code{--enable-logging} is set to @code{yes}, the binary will contain | ||
2011 | no DEBUG messages, and therefore running with -L DEBUG will have no effect. | ||
2012 | Other messages (ERROR, WARNING, INFO, etc) will be included. | ||
2013 | @item If @code{--enable-logging} is set to @code{verbose}, or | ||
2014 | @code{veryverbose} the binary will contain DEBUG messages (still, it will be | ||
2015 | neccessary to run with -L DEBUG or set the DEBUG config option to show them). | ||
2016 | @end itemize | ||
2017 | |||
2018 | |||
2019 | If you are a developer: | ||
2020 | @itemize @bullet | ||
2021 | @item please make sure that you @code{./configure | ||
2022 | --enable-logging=@{verbose,veryverbose@}}, so you can see DEBUG messages. | ||
2023 | @item please remove the @code{#if} statements around @code{GNUNET_log | ||
2024 | (GNUNET_ERROR_TYPE_DEBUG, ...)} lines, to improve the readibility of your code. | ||
2025 | @end itemize | ||
2026 | |||
2027 | Since now activating DEBUG automatically makes it VERBOSE and activates | ||
2028 | @strong{all} debug messages by default, you probably want to use the | ||
2029 | https://gnunet.org/logging functionality to filter only relevant messages. A | ||
2030 | suitable configuration could be:@ @code{$ export | ||
2031 | GNUNET_FORCE_LOG="^YOUR_SUBSYSTEM$;;;;DEBUG/;;;;WARNING"}@ Which will behave | ||
2032 | almost like enabling DEBUG in that subsytem before the change. Of course you | ||
2033 | can adapt it to your particular needs, this is only a quick example. | ||
2034 | |||
2035 | @c *************************************************************************** | ||
2036 | @node Interprocess communication API (IPC) | ||
2037 | @subsection Interprocess communication API (IPC) | ||
2038 | |||
2039 | In GNUnet a variety of new message types might be defined and used in | ||
2040 | interprocess communication, in this tutorial we use the @code{struct | ||
2041 | AddressLookupMessage} as a example to introduce how to construct our own | ||
2042 | message type in GNUnet and how to implement the message communication between | ||
2043 | service and client.@ (Here, a client uses the @code{struct | ||
2044 | AddressLookupMessage} as a request to ask the server to return the address of | ||
2045 | any other peer connecting to the service.) | ||
2046 | |||
2047 | |||
2048 | @c *************************************************************************** | ||
2049 | @menu | ||
2050 | * Define new message types:: | ||
2051 | * Define message struct:: | ||
2052 | * Client - Establish connection:: | ||
2053 | * Client - Initialize request message:: | ||
2054 | * Client - Send request and receive response:: | ||
2055 | * Server - Startup service:: | ||
2056 | * Server - Add new handles for specified messages:: | ||
2057 | * Server - Process request message:: | ||
2058 | * Server - Response to client:: | ||
2059 | * Server - Notification of clients:: | ||
2060 | * Conversion between Network Byte Order (Big Endian) and Host Byte Order:: | ||
2061 | @end menu | ||
2062 | |||
2063 | @node Define new message types | ||
2064 | @subsubsection Define new message types | ||
2065 | |||
2066 | First of all, you should define the new message type in | ||
2067 | @code{gnunet_protocols.h}: | ||
2068 | @example | ||
2069 | // Request to look addresses of peers in server. | ||
2070 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP 29 | ||
2071 | // Response to the address lookup request. | ||
2072 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY 30 | ||
2073 | @end example | ||
2074 | |||
2075 | @c *************************************************************************** | ||
2076 | @node Define message struct | ||
2077 | @subsubsection Define message struct | ||
2078 | |||
2079 | After the type definition, the specified message structure should also be | ||
2080 | described in the header file, e.g. transport.h in our case. | ||
2081 | @example | ||
2082 | GNUNET_NETWORK_STRUCT_BEGIN | ||
2083 | |||
2084 | struct AddressLookupMessage @{ struct GNUNET_MessageHeader header; int32_t | ||
2085 | numeric_only GNUNET_PACKED; struct GNUNET_TIME_AbsoluteNBO timeout; uint32_t | ||
2086 | addrlen GNUNET_PACKED; | ||
2087 | /* followed by 'addrlen' bytes of the actual address, then | ||
2088 | followed by the 0-terminated name of the transport */ @}; | ||
2089 | GNUNET_NETWORK_STRUCT_END | ||
2090 | @end example | ||
2091 | |||
2092 | |||
2093 | Please note @code{GNUNET_NETWORK_STRUCT_BEGIN} and @code{GNUNET_PACKED} which | ||
2094 | both ensure correct alignment when sending structs over the network | ||
2095 | |||
2096 | @menu | ||
2097 | @end menu | ||
2098 | |||
2099 | @c *************************************************************************** | ||
2100 | @node Client - Establish connection | ||
2101 | @subsubsection Client - Establish connection | ||
2102 | @c %**end of header | ||
2103 | |||
2104 | |||
2105 | At first, on the client side, the underlying API is employed to create a new | ||
2106 | connection to a service, in our example the transport service would be | ||
2107 | connected. | ||
2108 | @example | ||
2109 | struct GNUNET_CLIENT_Connection *client; client = | ||
2110 | GNUNET_CLIENT_connect ("transport", cfg); | ||
2111 | @end example | ||
2112 | |||
2113 | @c *************************************************************************** | ||
2114 | @node Client - Initialize request message | ||
2115 | @subsubsection Client - Initialize request message | ||
2116 | @c %**end of header | ||
2117 | |||
2118 | When the connection is ready, we initialize the message. In this step, all the | ||
2119 | fields of the message should be properly initialized, namely the size, type, | ||
2120 | and some extra user-defined data, such as timeout, name of transport, address | ||
2121 | and name of transport. | ||
2122 | @example | ||
2123 | struct AddressLookupMessage *msg; size_t len = | ||
2124 | sizeof (struct AddressLookupMessage) + addressLen + strlen (nameTrans) + 1; | ||
2125 | msg->header->size = htons (len); msg->header->type = htons | ||
2126 | (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); msg->timeout = | ||
2127 | GNUNET_TIME_absolute_hton (abs_timeout); msg->addrlen = htonl (addressLen); | ||
2128 | char *addrbuf = (char *) &msg[1]; memcpy (addrbuf, address, addressLen); char | ||
2129 | *tbuf = &addrbuf[addressLen]; memcpy (tbuf, nameTrans, strlen (nameTrans) + 1); | ||
2130 | @end example | ||
2131 | |||
2132 | Note that, here the functions @code{htonl}, @code{htons} and | ||
2133 | @code{GNUNET_TIME_absolute_hton} are applied to convert little endian into big | ||
2134 | endian, about the usage of the big/small edian order and the corresponding | ||
2135 | conversion function please refer to Introduction of Big Endian and Little | ||
2136 | Endian. | ||
2137 | |||
2138 | @c *************************************************************************** | ||
2139 | @node Client - Send request and receive response | ||
2140 | @subsubsection Client - Send request and receive response | ||
2141 | @c %**end of header | ||
2142 | |||
2143 | FIXME: This is very outdated, see the tutorial for the | ||
2144 | current API! | ||
2145 | |||
2146 | Next, the client would send the constructed message as a request to the service | ||
2147 | and wait for the response from the service. To accomplish this goal, there are | ||
2148 | a number of API calls that can be used. In this example, | ||
2149 | @code{GNUNET_CLIENT_transmit_and_get_response} is chosen as the most | ||
2150 | appropriate function to use. | ||
2151 | @example | ||
2152 | GNUNET_CLIENT_transmit_and_get_response | ||
2153 | (client, msg->header, timeout, GNUNET_YES, &address_response_processor, | ||
2154 | arp_ctx); | ||
2155 | @end example | ||
2156 | |||
2157 | the argument @code{address_response_processor} is a function with | ||
2158 | @code{GNUNET_CLIENT_MessageHandler} type, which is used to process the reply | ||
2159 | message from the service. | ||
2160 | |||
2161 | @node Server - Startup service | ||
2162 | @subsubsection Server - Startup service | ||
2163 | |||
2164 | After receiving the request message, we run a standard GNUnet service startup | ||
2165 | sequence using @code{GNUNET_SERVICE_run}, as follows, | ||
2166 | @example | ||
2167 | int main(int | ||
2168 | argc, char**argv) @{ GNUNET_SERVICE_run(argc, argv, "transport" | ||
2169 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)); @} | ||
2170 | @end example | ||
2171 | |||
2172 | @c *************************************************************************** | ||
2173 | @node Server - Add new handles for specified messages | ||
2174 | @subsubsection Server - Add new handles for specified messages | ||
2175 | @c %**end of header | ||
2176 | |||
2177 | in the function above the argument @code{run} is used to initiate transport | ||
2178 | service,and defined like this: | ||
2179 | @example | ||
2180 | static void run (void *cls, struct | ||
2181 | GNUNET_SERVER_Handle *serv, const struct GNUNET_CONFIGURATION_Handle *cfg) @{ | ||
2182 | GNUNET_SERVER_add_handlers (serv, handlers); @} | ||
2183 | @end example | ||
2184 | |||
2185 | |||
2186 | Here, @code{GNUNET_SERVER_add_handlers} must be called in the run function to | ||
2187 | add new handlers in the service. The parameter @code{handlers} is a list of | ||
2188 | @code{struct GNUNET_SERVER_MessageHandler} to tell the service which function | ||
2189 | should be called when a particular type of message is received, and should be | ||
2190 | defined in this way: | ||
2191 | @example | ||
2192 | static struct GNUNET_SERVER_MessageHandler | ||
2193 | handlers[] = @{ @{&handle_start, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_START, | ||
2194 | 0@}, @{&handle_send, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0@}, | ||
2195 | @{&handle_try_connect, NULL, GNUNET_MESSAGE_TYPE_TRANSPORT_TRY_CONNECT, sizeof | ||
2196 | (struct TryConnectMessage)@}, @{&handle_address_lookup, NULL, | ||
2197 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, 0@}, @{NULL, NULL, 0, 0@} @}; | ||
2198 | @end example | ||
2199 | |||
2200 | |||
2201 | As shown, the first member of the struct in the first area is a callback | ||
2202 | function, which is called to process the specified message types, given as the | ||
2203 | third member. The second parameter is the closure for the callback function, | ||
2204 | which is set to @code{NULL} in most cases, and the last parameter is the | ||
2205 | expected size of the message of this type, usually we set it to 0 to accept | ||
2206 | variable size, for special cases the exact size of the specified message also | ||
2207 | can be set. In addition, the terminator sign depicted as @code{@{NULL, NULL, 0, | ||
2208 | 0@}} is set in the last aera. | ||
2209 | |||
2210 | @c *************************************************************************** | ||
2211 | @node Server - Process request message | ||
2212 | @subsubsection Server - Process request message | ||
2213 | @c %**end of header | ||
2214 | |||
2215 | After the initialization of transport service, the request message would be | ||
2216 | processed. Before handling the main message data, the validity of this message | ||
2217 | should be checked out, e.g., to check whether the size of message is correct. | ||
2218 | @example | ||
2219 | size = ntohs (message->size); if (size < sizeof (struct | ||
2220 | AddressLookupMessage)) @{ GNUNET_break_op (0); GNUNET_SERVER_receive_done | ||
2221 | (client, GNUNET_SYSERR); return; @} | ||
2222 | @end example | ||
2223 | |||
2224 | |||
2225 | Note that, opposite to the construction method of the request message in the | ||
2226 | client, in the server the function @code{nothl} and @code{ntohs} should be | ||
2227 | employed during the extraction of the data from the message, so that the data | ||
2228 | in big endian order can be converted back into little endian order. See more in | ||
2229 | detail please refer to Introduction of Big Endian and Little Endian. | ||
2230 | |||
2231 | Moreover in this example, the name of the transport stored in the message is a | ||
2232 | 0-terminated string, so we should also check whether the name of the transport | ||
2233 | in the received message is 0-terminated: | ||
2234 | @example | ||
2235 | nameTransport = (const char *) | ||
2236 | &address[addressLen]; if (nameTransport[size - sizeof (struct | ||
2237 | AddressLookupMessage) | ||
2238 | - addressLen - 1] != '\0') @{ GNUNET_break_op | ||
2239 | (0); GNUNET_SERVER_receive_done (client, | ||
2240 | GNUNET_SYSERR); return; @} | ||
2241 | @end example | ||
2242 | |||
2243 | Here, @code{GNUNET_SERVER_receive_done} should be called to tell the service | ||
2244 | that the request is done and can receive the next message. The argument | ||
2245 | @code{GNUNET_SYSERR} here indicates that the service didn't understand the | ||
2246 | request message, and the processing of this request would be terminated. | ||
2247 | |||
2248 | In comparison to the aforementioned situation, when the argument is equal to | ||
2249 | @code{GNUNET_OK}, the service would continue to process the requst message. | ||
2250 | |||
2251 | @c *************************************************************************** | ||
2252 | @node Server - Response to client | ||
2253 | @subsubsection Server - Response to client | ||
2254 | @c %**end of header | ||
2255 | |||
2256 | Once the processing of current request is done, the server should give the | ||
2257 | response to the client. A new @code{struct AddressLookupMessage} would be | ||
2258 | produced by the server in a similar way as the client did and sent to the | ||
2259 | client, but here the type should be | ||
2260 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY} rather than | ||
2261 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP} in client. | ||
2262 | @example | ||
2263 | struct | ||
2264 | AddressLookupMessage *msg; size_t len = sizeof (struct AddressLookupMessage) + | ||
2265 | addressLen + strlen (nameTrans) + 1; msg->header->size = htons (len); | ||
2266 | msg->header->type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
2267 | |||
2268 | // ... | ||
2269 | |||
2270 | struct GNUNET_SERVER_TransmitContext *tc; tc = | ||
2271 | GNUNET_SERVER_transmit_context_create (client); | ||
2272 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | ||
2273 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
2274 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); | ||
2275 | @end example | ||
2276 | |||
2277 | |||
2278 | Note that, there are also a number of other APIs provided to the service to | ||
2279 | send the message. | ||
2280 | |||
2281 | @c *************************************************************************** | ||
2282 | @node Server - Notification of clients | ||
2283 | @subsubsection Server - Notification of clients | ||
2284 | @c %**end of header | ||
2285 | |||
2286 | Often a service needs to (repeatedly) transmit notifications to a client or a | ||
2287 | group of clients. In these cases, the client typically has once registered for | ||
2288 | a set of events and then needs to receive a message whenever such an event | ||
2289 | happens (until the client disconnects). The use of a notification context can | ||
2290 | help manage message queues to clients and handle disconnects. Notification | ||
2291 | contexts can be used to send individualized messages to a particular client or | ||
2292 | to broadcast messages to a group of clients. An individualized notification | ||
2293 | might look like this: | ||
2294 | @example | ||
2295 | GNUNET_SERVER_notification_context_unicast(nc, | ||
2296 | client, msg, GNUNET_YES); | ||
2297 | @end example | ||
2298 | |||
2299 | |||
2300 | Note that after processing the original registration message for notifications, | ||
2301 | the server code still typically needs to call@ | ||
2302 | @code{GNUNET_SERVER_receive_done} so that the client can transmit further | ||
2303 | messages to the server. | ||
2304 | |||
2305 | @c *************************************************************************** | ||
2306 | @node Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
2307 | @subsubsection Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
2308 | @c %** subsub? it's a referenced page on the ipc document. | ||
2309 | @c %**end of header | ||
2310 | |||
2311 | Here we can simply comprehend big endian and little endian as Network Byte | ||
2312 | Order and Host Byte Order respectively. What is the difference between both | ||
2313 | two? | ||
2314 | |||
2315 | Usually in our host computer we store the data byte as Host Byte Order, for | ||
2316 | example, we store a integer in the RAM which might occupies 4 Byte, as Host | ||
2317 | Byte Order the higher Byte would be stored at the lower address of RAM, and | ||
2318 | the lower Byte would be stored at the higher address of RAM. However, contrast | ||
2319 | to this, Network Byte Order just take the totally opposite way to store the | ||
2320 | data, says, it will store the lower Byte at the lower address, and the higher | ||
2321 | Byte will stay at higher address. | ||
2322 | |||
2323 | For the current communication of network, we normally exchange the information | ||
2324 | by surveying the data package, every two host wants to communicate with each | ||
2325 | other must send and receive data package through network. In order to maintain | ||
2326 | the identity of data through the transmission in the network, the order of the | ||
2327 | Byte storage must changed before sending and after receiving the data. | ||
2328 | |||
2329 | There ten convenient functions to realize the conversion of Byte Order in | ||
2330 | GNUnet, as following: | ||
2331 | @table @asis | ||
2332 | |||
2333 | @item uint16_t htons(uint16_t hostshort) Convert host byte order to net byte | ||
2334 | order with short int | ||
2335 | @item uint32_t htonl(uint32_t hostlong) Convert host byte | ||
2336 | order to net byte order with long int | ||
2337 | @item uint16_t ntohs(uint16_t netshort) | ||
2338 | Convert net byte order to host byte order with short int | ||
2339 | @item uint32_t | ||
2340 | ntohl(uint32_t netlong) Convert net byte order to host byte order with long int | ||
2341 | @item unsigned long long GNUNET_ntohll (unsigned long long netlonglong) Convert | ||
2342 | net byte order to host byte order with long long int | ||
2343 | @item unsigned long long | ||
2344 | GNUNET_htonll (unsigned long long hostlonglong) Convert host byte order to net | ||
2345 | byte order with long long int | ||
2346 | @item struct GNUNET_TIME_RelativeNBO | ||
2347 | GNUNET_TIME_relative_hton (struct GNUNET_TIME_Relative a) Convert relative time | ||
2348 | to network byte order. | ||
2349 | @item struct GNUNET_TIME_Relative | ||
2350 | GNUNET_TIME_relative_ntoh (struct GNUNET_TIME_RelativeNBO a) Convert relative | ||
2351 | time from network byte order. | ||
2352 | @item struct GNUNET_TIME_AbsoluteNBO | ||
2353 | GNUNET_TIME_absolute_hton (struct GNUNET_TIME_Absolute a) Convert relative time | ||
2354 | to network byte order. | ||
2355 | @item struct GNUNET_TIME_Absolute | ||
2356 | GNUNET_TIME_absolute_ntoh (struct GNUNET_TIME_AbsoluteNBO a) Convert relative | ||
2357 | time from network byte order. | ||
2358 | @end table | ||
2359 | |||
2360 | @c *************************************************************************** | ||
2361 | |||
2362 | @node Cryptography API | ||
2363 | @subsection Cryptography API | ||
2364 | @c %**end of header | ||
2365 | |||
2366 | The gnunetutil APIs provides the cryptographic primitives used in GNUnet. | ||
2367 | GNUnet uses 2048 bit RSA keys for the session key exchange and for signing | ||
2368 | messages by peers and most other public-key operations. Most researchers in | ||
2369 | cryptography consider 2048 bit RSA keys as secure and practically unbreakable | ||
2370 | for a long time. The API provides functions to create a fresh key pair, read a | ||
2371 | private key from a file (or create a new file if the file does not exist), | ||
2372 | encrypt, decrypt, sign, verify and extraction of the public key into a format | ||
2373 | suitable for network transmission. | ||
2374 | |||
2375 | For the encryption of files and the actual data exchanged between peers GNUnet | ||
2376 | uses 256-bit AES encryption. Fresh, session keys are negotiated for every new | ||
2377 | connection.@ Again, there is no published technique to break this cipher in any | ||
2378 | realistic amount of time. The API provides functions for generation of keys, | ||
2379 | validation of keys (important for checking that decryptions using RSA | ||
2380 | succeeded), encryption and decryption. | ||
2381 | |||
2382 | GNUnet uses SHA-512 for computing one-way hash codes. The API provides | ||
2383 | functions to compute a hash over a block in memory or over a file on disk. | ||
2384 | |||
2385 | The crypto API also provides functions for randomizing a block of memory, | ||
2386 | obtaining a single random number and for generating a permuation of the numbers | ||
2387 | 0 to n-1. Random number generation distinguishes between WEAK and STRONG random | ||
2388 | number quality; WEAK random numbers are pseudo-random whereas STRONG random | ||
2389 | numbers use entropy gathered from the operating system. | ||
2390 | |||
2391 | Finally, the crypto API provides a means to deterministically generate a | ||
2392 | 1024-bit RSA key from a hash code. These functions should most likely not be | ||
2393 | used by most applications; most importantly,@ | ||
2394 | GNUNET_CRYPTO_rsa_key_create_from_hash does not create an RSA-key that should | ||
2395 | be considered secure for traditional applications of RSA. | ||
2396 | |||
2397 | @c *************************************************************************** | ||
2398 | @node Message Queue API | ||
2399 | @subsection Message Queue API | ||
2400 | @c %**end of header | ||
2401 | |||
2402 | @strong{ Introduction }@ Often, applications need to queue messages that are to | ||
2403 | be sent to other GNUnet peers, clients or services. As all of GNUnet's | ||
2404 | message-based communication APIs, by design, do not allow messages to be | ||
2405 | queued, it is common to implement custom message queues manually when they are | ||
2406 | needed. However, writing very similar code in multiple places is tedious and | ||
2407 | leads to code duplication. | ||
2408 | |||
2409 | MQ (for Message Queue) is an API that provides the functionality to implement | ||
2410 | and use message queues. We intend to eventually replace all of the custom | ||
2411 | message queue implementations in GNUnet with MQ. | ||
2412 | |||
2413 | @strong{ Basic Concepts }@ The two most important entities in MQ are queues and | ||
2414 | envelopes. | ||
2415 | |||
2416 | Every queue is backed by a specific implementation (e.g. for mesh, stream, | ||
2417 | connection, server client, etc.) that will actually deliver the queued | ||
2418 | messages. For convenience,@ some queues also allow to specify a list of message | ||
2419 | handlers. The message queue will then also wait for incoming messages and | ||
2420 | dispatch them appropriately. | ||
2421 | |||
2422 | An envelope holds the the memory for a message, as well as metadata (Where is | ||
2423 | the envelope queued? What should happen after it has been sent?). Any envelope | ||
2424 | can only be queued in one message queue. | ||
2425 | |||
2426 | @strong{ Creating Queues }@ The following is a list of currently available | ||
2427 | message queues. Note that to avoid layering issues, message queues for higher | ||
2428 | level APIs are not part of @code{libgnunetutil}, but@ the respective API itself | ||
2429 | provides the queue implementation. | ||
2430 | @table @asis | ||
2431 | |||
2432 | @item @code{GNUNET_MQ_queue_for_connection_client} Transmits queued messages | ||
2433 | over a @code{GNUNET_CLIENT_Connection}@ handle. Also supports receiving with | ||
2434 | message handlers.@ | ||
2435 | |||
2436 | @item @code{GNUNET_MQ_queue_for_server_client} Transmits queued messages over a | ||
2437 | @code{GNUNET_SERVER_Client}@ handle. Does not support incoming message | ||
2438 | handlers.@ | ||
2439 | |||
2440 | @item @code{GNUNET_MESH_mq_create} Transmits queued messages over a | ||
2441 | @code{GNUNET_MESH_Tunnel}@ handle. Does not support incoming message handlers.@ | ||
2442 | |||
2443 | @item @code{GNUNET_MQ_queue_for_callbacks} This is the most general | ||
2444 | implementation. Instead of delivering and receiving messages with one of | ||
2445 | GNUnet's communication APIs, implementation callbacks are called. Refer to | ||
2446 | "Implementing Queues" for a more detailed explanation. | ||
2447 | @end table | ||
2448 | |||
2449 | |||
2450 | @strong{ Allocating Envelopes }@ A GNUnet message (as defined by the | ||
2451 | GNUNET_MessageHeader) has three parts: The size, the type, and the body. | ||
2452 | |||
2453 | MQ provides macros to allocate an envelope containing a message conveniently,@ | ||
2454 | automatically setting the size and type fields of the message. | ||
2455 | |||
2456 | Consider the following simple message, with the body consisting of a single | ||
2457 | number value.@ @code{} | ||
2458 | @example | ||
2459 | struct NumberMessage @{ | ||
2460 | /** Type: GNUNET_MESSAGE_TYPE_EXAMPLE_1 */ | ||
2461 | struct GNUNET_MessageHeader header; uint32_t number GNUNET_PACKED; @}; | ||
2462 | @end example | ||
2463 | |||
2464 | An envelope containing an instance of the NumberMessage can be constructed like | ||
2465 | this: | ||
2466 | @example | ||
2467 | struct GNUNET_MQ_Envelope *ev; struct NumberMessage *msg; ev = | ||
2468 | GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_EXAMPLE_1); msg->number = htonl (42); | ||
2469 | @end example | ||
2470 | |||
2471 | |||
2472 | In the above code, @code{GNUNET_MQ_msg} is a macro. The return value is the | ||
2473 | newly allocated envelope. The first argument must be a pointer to some | ||
2474 | @code{struct} containing a @code{struct GNUNET_MessageHeader header} field, | ||
2475 | while the second argument is the desired message type, in host byte order. | ||
2476 | |||
2477 | The @code{msg} pointer now points to an allocated message, where the message | ||
2478 | type and the message size are already set. The message's size is inferred from | ||
2479 | the type of the @code{msg} pointer: It will be set to 'sizeof(*msg)', properly | ||
2480 | converted to network byte order. | ||
2481 | |||
2482 | If the message body's size is dynamic, the the macro @code{GNUNET_MQ_msg_extra} | ||
2483 | can be used to allocate an envelope whose message has additional space | ||
2484 | allocated after the @code{msg} structure. | ||
2485 | |||
2486 | If no structure has been defined for the message, | ||
2487 | @code{GNUNET_MQ_msg_header_extra} can be used to allocate additional space | ||
2488 | after the message header. The first argument then must be a pointer to a | ||
2489 | @code{GNUNET_MessageHeader}. | ||
2490 | |||
2491 | @strong{Envelope Properties}@ A few functions in MQ allow to set additional | ||
2492 | properties on envelopes: | ||
2493 | @table @asis | ||
2494 | |||
2495 | @item @code{GNUNET_MQ_notify_sent} Allows to specify a function that will be | ||
2496 | called once the envelope's message@ has been sent irrevocably. An envelope can | ||
2497 | be canceled precisely up to the@ point where the notify sent callback has been | ||
2498 | called. | ||
2499 | @item @code{GNUNET_MQ_disable_corking} No corking will be used when | ||
2500 | sending the message. Not every@ queue supports this flag, per default, | ||
2501 | envelopes are sent with corking.@ | ||
2502 | |||
2503 | @end table | ||
2504 | |||
2505 | |||
2506 | @strong{Sending Envelopes}@ Once an envelope has been constructed, it can be | ||
2507 | queued for sending with @code{GNUNET_MQ_send}. | ||
2508 | |||
2509 | Note that in order to avoid memory leaks, an envelope must either be sent (the | ||
2510 | queue will free it) or destroyed explicitly with @code{GNUNET_MQ_discard}. | ||
2511 | |||
2512 | @strong{Canceling Envelopes}@ An envelope queued with @code{GNUNET_MQ_send} can | ||
2513 | be canceled with @code{GNUNET_MQ_cancel}. Note that after the notify sent | ||
2514 | callback has been called, canceling a message results in undefined behavior. | ||
2515 | Thus it is unsafe to cancel an envelope that does not have a notify sent | ||
2516 | callback. When canceling an envelope, it is not necessary@ to call | ||
2517 | @code{GNUNET_MQ_discard}, and the envelope can't be sent again. | ||
2518 | |||
2519 | @strong{ Implementing Queues }@ @code{TODO} | ||
2520 | |||
2521 | @c *************************************************************************** | ||
2522 | @node Service API | ||
2523 | @subsection Service API | ||
2524 | @c %**end of header | ||
2525 | |||
2526 | Most GNUnet code lives in the form of services. Services are processes that | ||
2527 | offer an API for other components of the system to build on. Those other | ||
2528 | components can be command-line tools for users, graphical user interfaces or | ||
2529 | other services. Services provide their API using an IPC protocol. For this, | ||
2530 | each service must listen on either a TCP port or a UNIX domain socket; for | ||
2531 | this, the service implementation uses the server API. This use of server is | ||
2532 | exposed directly to the users of the service API. Thus, when using the service | ||
2533 | API, one is usually also often using large parts of the server API. The service | ||
2534 | API provides various convenience functions, such as parsing command-line | ||
2535 | arguments and the configuration file, which are not found in the server API. | ||
2536 | The dual to the service/server API is the client API, which can be used to | ||
2537 | access services. | ||
2538 | |||
2539 | The most common way to start a service is to use the GNUNET_SERVICE_run | ||
2540 | function from the program's main function. GNUNET_SERVICE_run will then parse | ||
2541 | the command line and configuration files and, based on the options found there, | ||
2542 | start the server. It will then give back control to the main program, passing | ||
2543 | the server and the configuration to the GNUNET_SERVICE_Main callback. | ||
2544 | GNUNET_SERVICE_run will also take care of starting the scheduler loop. If this | ||
2545 | is inappropriate (for example, because the scheduler loop is already running), | ||
2546 | GNUNET_SERVICE_start and related functions provide an alternative to | ||
2547 | GNUNET_SERVICE_run. | ||
2548 | |||
2549 | When starting a service, the service_name option is used to determine which | ||
2550 | sections in the configuration file should be used to configure the service. A | ||
2551 | typical value here is the name of the src/ sub-directory, for example | ||
2552 | "statistics". The same string would also be given to GNUNET_CLIENT_connect to | ||
2553 | access the service. | ||
2554 | |||
2555 | Once a service has been initialized, the program should use the@ | ||
2556 | GNUNET_SERVICE_Main callback to register message handlers using | ||
2557 | GNUNET_SERVER_add_handlers. The service will already have registered a handler | ||
2558 | for the "TEST" message. | ||
2559 | |||
2560 | The option bitfield (enum GNUNET_SERVICE_Options) determines how a service | ||
2561 | should behave during shutdown. There are three key strategies: | ||
2562 | @table @asis | ||
2563 | |||
2564 | @item instant (GNUNET_SERVICE_OPTION_NONE) Upon receiving the shutdown signal | ||
2565 | from the scheduler, the service immediately terminates the server, closing all | ||
2566 | existing connections with clients. | ||
2567 | @item manual | ||
2568 | (GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN) The service does nothing by itself | ||
2569 | during shutdown. The main program will need to take the appropriate action by | ||
2570 | calling GNUNET_SERVER_destroy or GNUNET_SERVICE_stop (depending on how the | ||
2571 | service was initialized) to terminate the service. This method is used by | ||
2572 | gnunet-service-arm and rather uncommon. | ||
2573 | @item soft | ||
2574 | (GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN) Upon receiving the shutdown signal from | ||
2575 | the scheduler, the service immediately tells the server to stop listening for | ||
2576 | incoming clients. Requests from normal existing clients are still processed and | ||
2577 | the server/service terminates once all normal clients have disconnected. | ||
2578 | Clients that are not expected to ever disconnect (such as clients that monitor | ||
2579 | performance values) can be marked as 'monitor' clients using | ||
2580 | GNUNET_SERVER_client_mark_monitor. Those clients will continue to be processed | ||
2581 | until all 'normal' clients have disconnected. Then, the server will terminate, | ||
2582 | closing the monitor connections. This mode is for example used by 'statistics', | ||
2583 | allowing existing 'normal' clients to set (possibly persistent) statistic | ||
2584 | values before terminating. | ||
2585 | @end table | ||
2586 | |||
2587 | @c *************************************************************************** | ||
2588 | @node Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
2589 | @subsection Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
2590 | @c %**end of header | ||
2591 | |||
2592 | A commonly used data structure in GNUnet is a (multi-)hash map. It is most | ||
2593 | often used to map a peer identity to some data structure, but also to map | ||
2594 | arbitrary keys to values (for example to track requests in the distributed hash | ||
2595 | table or in file-sharing). As it is commonly used, the DHT is actually | ||
2596 | sometimes responsible for a large share of GNUnet's overall memory consumption | ||
2597 | (for some processes, 30% is not uncommon). The following text documents some | ||
2598 | API quirks (and their implications for applications) that were recently | ||
2599 | introduced to minimize the footprint of the hash map. | ||
2600 | |||
2601 | |||
2602 | @c *************************************************************************** | ||
2603 | @menu | ||
2604 | * Analysis:: | ||
2605 | * Solution:: | ||
2606 | * Migration:: | ||
2607 | * Conclusion:: | ||
2608 | * Availability:: | ||
2609 | @end menu | ||
2610 | |||
2611 | @node Analysis | ||
2612 | @subsubsection Analysis | ||
2613 | @c %**end of header | ||
2614 | |||
2615 | The main reason for the "excessive" memory consumption by the hash map is that | ||
2616 | GNUnet uses 512-bit cryptographic hash codes --- and the (multi-)hash map also | ||
2617 | uses the same 512-bit 'struct GNUNET_HashCode'. As a result, storing just the | ||
2618 | keys requires 64 bytes of memory for each key. As some applications like to | ||
2619 | keep a large number of entries in the hash map (after all, that's what maps | ||
2620 | are good for), 64 bytes per hash is significant: keeping a pointer to the | ||
2621 | value and having a linked list for collisions consume between 8 and 16 bytes, | ||
2622 | and 'malloc' may add about the same overhead per allocation, putting us in the | ||
2623 | 16 to 32 byte per entry ballpark. Adding a 64-byte key then triples the | ||
2624 | overall memory requirement for the hash map. | ||
2625 | |||
2626 | To make things "worse", most of the time storing the key in the hash map is | ||
2627 | not required: it is typically already in memory elsewhere! In most cases, the | ||
2628 | values stored in the hash map are some application-specific struct that _also_ | ||
2629 | contains the hash. Here is a simplified example: | ||
2630 | @example | ||
2631 | struct MyValue @{ | ||
2632 | struct GNUNET_HashCode key; unsigned int my_data; @}; | ||
2633 | |||
2634 | // ... | ||
2635 | val = GNUNET_malloc (sizeof (struct MyValue)); val->key = key; val->my_data = | ||
2636 | 42; GNUNET_CONTAINER_multihashmap_put (map, &key, val, ...); | ||
2637 | @end example | ||
2638 | |||
2639 | |||
2640 | This is a common pattern as later the entries might need to be removed, and at | ||
2641 | that time it is convenient to have the key immediately at hand: | ||
2642 | @example | ||
2643 | GNUNET_CONTAINER_multihashmap_remove (map, &val->key, val); | ||
2644 | @end example | ||
2645 | |||
2646 | |||
2647 | Note that here we end up with two times 64 bytes for the key, plus maybe 64 | ||
2648 | bytes total for the rest of the 'struct MyValue' and the map entry in the hash | ||
2649 | map. The resulting redundant storage of the key increases overall memory | ||
2650 | consumption per entry from the "optimal" 128 bytes to 192 bytes. This is not | ||
2651 | just an extreme example: overheads in practice are actually sometimes close to | ||
2652 | those highlighted in this example. This is especially true for maps with a | ||
2653 | significant number of entries, as there we tend to really try to keep the | ||
2654 | entries small. | ||
2655 | @c *************************************************************************** | ||
2656 | @node Solution | ||
2657 | @subsubsection Solution | ||
2658 | @c %**end of header | ||
2659 | |||
2660 | The solution that has now been implemented is to @strong{optionally} allow the | ||
2661 | hash map to not make a (deep) copy of the hash but instead have a pointer to | ||
2662 | the hash/key in the entry. This reduces the memory consumption for the key | ||
2663 | from 64 bytes to 4 to 8 bytes. However, it can also only work if the key is | ||
2664 | actually stored in the entry (which is the case most of the time) and if the | ||
2665 | entry does not modify the key (which in all of the code I'm aware of has been | ||
2666 | always the case if there key is stored in the entry). Finally, when the client | ||
2667 | stores an entry in the hash map, it @strong{must} provide a pointer to the key | ||
2668 | within the entry, not just a pointer to a transient location of the key. If | ||
2669 | the client code does not meet these requirements, the result is a dangling | ||
2670 | pointer and undefined behavior of the (multi-)hash map API. | ||
2671 | @c *************************************************************************** | ||
2672 | @node Migration | ||
2673 | @subsubsection Migration | ||
2674 | @c %**end of header | ||
2675 | |||
2676 | To use the new feature, first check that the values contain the respective key | ||
2677 | (and never modify it). Then, all calls to | ||
2678 | @code{GNUNET_CONTAINER_multihashmap_put} on the respective map must be audited | ||
2679 | and most likely changed to pass a pointer into the value's struct. For the | ||
2680 | initial example, the new code would look like this: | ||
2681 | @example | ||
2682 | struct MyValue @{ | ||
2683 | struct GNUNET_HashCode key; unsigned int my_data; @}; | ||
2684 | |||
2685 | // ... | ||
2686 | val = GNUNET_malloc (sizeof (struct MyValue)); val->key = key; val->my_data = | ||
2687 | 42; GNUNET_CONTAINER_multihashmap_put (map, &val->key, val, ...); | ||
2688 | @end example | ||
2689 | |||
2690 | |||
2691 | Note that @code{&val} was changed to @code{&val->key} in the argument to the | ||
2692 | @code{put} call. This is critical as often @code{key} is on the stack or in | ||
2693 | some other transient data structure and thus having the hash map keep a pointer | ||
2694 | to @code{key} would not work. Only the key inside of @code{val} has the same | ||
2695 | lifetime as the entry in the map (this must of course be checked as well). | ||
2696 | Naturally, @code{val->key} must be intiialized before the @code{put} call. Once | ||
2697 | all @code{put} calls have been converted and double-checked, you can change the | ||
2698 | call to create the hash map from | ||
2699 | @example | ||
2700 | map = | ||
2701 | GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_NO); | ||
2702 | @end example | ||
2703 | |||
2704 | to | ||
2705 | |||
2706 | @example | ||
2707 | map = GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_YES); | ||
2708 | @end example | ||
2709 | |||
2710 | If everything was done correctly, you now use about 60 bytes less memory per | ||
2711 | entry in @code{map}. However, if now (or in the future) any call to @code{put} | ||
2712 | does not ensure that the given key is valid until the entry is removed from the | ||
2713 | map, undefined behavior is likely to be observed. | ||
2714 | @c *************************************************************************** | ||
2715 | @node Conclusion | ||
2716 | @subsubsection Conclusion | ||
2717 | @c %**end of header | ||
2718 | |||
2719 | The new optimization can is often applicable and can result in a reduction in | ||
2720 | memory consumption of up to 30% in practice. However, it makes the code less | ||
2721 | robust as additional invariants are imposed on the multi hash map client. Thus | ||
2722 | applications should refrain from enabling the new mode unless the resulting | ||
2723 | performance increase is deemed significant enough. In particular, it should | ||
2724 | generally not be used in new code (wait at least until benchmarks exist). | ||
2725 | @c *************************************************************************** | ||
2726 | @node Availability | ||
2727 | @subsubsection Availability | ||
2728 | @c %**end of header | ||
2729 | |||
2730 | The new multi hash map code was committed in SVN 24319 (will be in GNUnet | ||
2731 | 0.9.4). Various subsystems (transport, core, dht, file-sharing) were | ||
2732 | previously audited and modified to take advantage of the new capability. In | ||
2733 | particular, memory consumption of the file-sharing service is expected to drop | ||
2734 | by 20-30% due to this change. | ||
2735 | |||
2736 | @c *************************************************************************** | ||
2737 | @node The CONTAINER_MDLL API | ||
2738 | @subsection The CONTAINER_MDLL API | ||
2739 | @c %**end of header | ||
2740 | |||
2741 | This text documents the GNUNET_CONTAINER_MDLL API. The GNUNET_CONTAINER_MDLL | ||
2742 | API is similar to the GNUNET_CONTAINER_DLL API in that it provides operations | ||
2743 | for the construction and manipulation of doubly-linked lists. The key | ||
2744 | difference to the (simpler) DLL-API is that the MDLL-version allows a single | ||
2745 | element (instance of a "struct") to be in multiple linked lists at the same | ||
2746 | time. | ||
2747 | |||
2748 | Like the DLL API, the MDLL API stores (most of) the data structures for the | ||
2749 | doubly-linked list with the respective elements; only the 'head' and 'tail' | ||
2750 | pointers are stored "elsewhere" --- and the application needs to provide the | ||
2751 | locations of head and tail to each of the calls in the MDLL API. The key | ||
2752 | difference for the MDLL API is that the "next" and "previous" pointers in the | ||
2753 | struct can no longer be simply called "next" and "prev" --- after all, the | ||
2754 | element may be in multiple doubly-linked lists, so we cannot just have one | ||
2755 | "next" and one "prev" pointer! | ||
2756 | |||
2757 | The solution is to have multiple fields that must have a name of the format | ||
2758 | "next_XX" and "prev_XX" where "XX" is the name of one of the doubly-linked | ||
2759 | lists. Here is a simple example: | ||
2760 | @example | ||
2761 | struct MyMultiListElement @{ struct | ||
2762 | MyMultiListElement *next_ALIST; struct MyMultiListElement *prev_ALIST; struct | ||
2763 | MyMultiListElement *next_BLIST; struct MyMultiListElement *prev_BLIST; void | ||
2764 | *data; @}; | ||
2765 | @end example | ||
2766 | |||
2767 | |||
2768 | Note that by convention, we use all-uppercase letters for the list names. In | ||
2769 | addition, the program needs to have a location for the head and tail pointers | ||
2770 | for both lists, for example: | ||
2771 | @example | ||
2772 | static struct MyMultiListElement | ||
2773 | *head_ALIST; static struct MyMultiListElement *tail_ALIST; static struct | ||
2774 | MyMultiListElement *head_BLIST; static struct MyMultiListElement *tail_BLIST; | ||
2775 | @end example | ||
2776 | |||
2777 | |||
2778 | Using the MDLL-macros, we can now insert an element into the ALIST: | ||
2779 | @example | ||
2780 | GNUNET_CONTAINER_MDLL_insert (ALIST, head_ALIST, tail_ALIST, element); | ||
2781 | @end example | ||
2782 | |||
2783 | |||
2784 | Passing "ALIST" as the first argument to MDLL specifies which of the next/prev | ||
2785 | fields in the 'struct MyMultiListElement' should be used. The extra "ALIST" | ||
2786 | argument and the "_ALIST" in the names of the next/prev-members are the only | ||
2787 | differences between the MDDL and DLL-API. Like the DLL-API, the MDLL-API offers | ||
2788 | functions for inserting (at head, at tail, after a given element) and removing | ||
2789 | elements from the list. Iterating over the list should be done by directly | ||
2790 | accessing the "next_XX" and/or "prev_XX" members. | ||
2791 | |||
2792 | @c *************************************************************************** | ||
2793 | @node The Automatic Restart Manager (ARM) | ||
2794 | @section The Automatic Restart Manager (ARM) | ||
2795 | @c %**end of header | ||
2796 | |||
2797 | GNUnet's Automated Restart Manager (ARM) is the GNUnet service responsible for | ||
2798 | system initialization and service babysitting. ARM starts and halts services, | ||
2799 | detects configuration changes and restarts services impacted by the changes as | ||
2800 | needed. It's also responsible for restarting services in case of crashes and is | ||
2801 | planned to incorporate automatic debugging for diagnosing service crashes | ||
2802 | providing developers insights about crash reasons. The purpose of this document | ||
2803 | is to give GNUnet developer an idea about how ARM works and how to interact | ||
2804 | with it. | ||
2805 | |||
2806 | @menu | ||
2807 | * Basic functionality:: | ||
2808 | * Key configuration options:: | ||
2809 | * Availability2:: | ||
2810 | * Reliability:: | ||
2811 | @end menu | ||
2812 | |||
2813 | @c *************************************************************************** | ||
2814 | @node Basic functionality | ||
2815 | @subsection Basic functionality | ||
2816 | @c %**end of header | ||
2817 | |||
2818 | @itemize @bullet | ||
2819 | @item ARM source code can be found under "src/arm".@ Service processes are | ||
2820 | managed by the functions in "gnunet-service-arm.c" which is controlled with | ||
2821 | "gnunet-arm.c" (main function in that file is ARM's entry point). | ||
2822 | |||
2823 | @item The functions responsible for communicating with ARM , starting and | ||
2824 | stopping services -including ARM service itself- are provided by the ARM API | ||
2825 | "arm_api.c".@ Function: GNUNET_ARM_connect() returns to the caller an ARM | ||
2826 | handle after setting it to the caller's context (configuration and scheduler in | ||
2827 | use). This handle can be used afterwards by the caller to communicate with ARM. | ||
2828 | Functions GNUNET_ARM_start_service() and GNUNET_ARM_stop_service() are used for | ||
2829 | starting and stopping services respectively. | ||
2830 | |||
2831 | @item A typical example of using these basic ARM services can be found in file | ||
2832 | test_arm_api.c. The test case connects to ARM, starts it, then uses it to start | ||
2833 | a service "resolver", stops the "resolver" then stops "ARM". | ||
2834 | @end itemize | ||
2835 | |||
2836 | @c *************************************************************************** | ||
2837 | @node Key configuration options | ||
2838 | @subsection Key configuration options | ||
2839 | @c %**end of header | ||
2840 | |||
2841 | Configurations for ARM and services should be available in a .conf file (As an | ||
2842 | example, see test_arm_api_data.conf). When running ARM, the configuration file | ||
2843 | to use should be passed to the command:@ @code{@ $ gnunet-arm -s -c | ||
2844 | configuration_to_use.conf@ }@ If no configuration is passed, the default | ||
2845 | configuration file will be used (see GNUNET_PREFIX/share/gnunet/defaults.conf | ||
2846 | which is created from contrib/defaults.conf).@ Each of the services is having a | ||
2847 | section starting by the service name between square brackets, for example: | ||
2848 | "[arm]". The following options configure how ARM configures or interacts with | ||
2849 | the various services: | ||
2850 | |||
2851 | @table @asis | ||
2852 | |||
2853 | @item PORT Port number on which the service is listening for incoming TCP | ||
2854 | connections. ARM will start the services should it notice a request at this | ||
2855 | port. | ||
2856 | |||
2857 | @item HOSTNAME Specifies on which host the service is deployed. Note | ||
2858 | that ARM can only start services that are running on the local system (but will | ||
2859 | not check that the hostname matches the local machine name). This option is | ||
2860 | used by the @code{gnunet_client_lib.h} implementation to determine which system | ||
2861 | to connect to. The default is "localhost". | ||
2862 | |||
2863 | @item BINARY The name of the service binary file. | ||
2864 | |||
2865 | @item OPTIONS To be passed to the service. | ||
2866 | |||
2867 | @item PREFIX A command to pre-pend to the actual command, for example, running | ||
2868 | a service with "valgrind" or "gdb" | ||
2869 | |||
2870 | @item DEBUG Run in debug mode (much verbosity). | ||
2871 | |||
2872 | @item AUTOSTART ARM will listen to UNIX domain socket and/or TCP port of the | ||
2873 | service and start the service on-demand. | ||
2874 | |||
2875 | @item FORCESTART ARM will always | ||
2876 | start this service when the peer is started. | ||
2877 | |||
2878 | @item ACCEPT_FROM IPv4 addresses the service accepts connections from. | ||
2879 | |||
2880 | @item ACCEPT_FROM6 IPv6 addresses the service accepts connections from. | ||
2881 | |||
2882 | @end table | ||
2883 | |||
2884 | |||
2885 | Options that impact the operation of ARM overall are in the "[arm]" section. | ||
2886 | ARM is a normal service and has (except for AUTOSTART) all of the options that | ||
2887 | other services do. In addition, ARM has the following options: | ||
2888 | @table @asis | ||
2889 | |||
2890 | @item GLOBAL_PREFIX Command to be pre-pended to all services that are going to | ||
2891 | run.@ | ||
2892 | |||
2893 | @item GLOBAL_POSTFIX Global option that will be supplied to all the services | ||
2894 | that are going to run.@ | ||
2895 | |||
2896 | @end table | ||
2897 | |||
2898 | @c *************************************************************************** | ||
2899 | @node Availability2 | ||
2900 | @subsection Availability2 | ||
2901 | @c %**end of header | ||
2902 | |||
2903 | As mentioned before, one of the features provided by ARM is starting services | ||
2904 | on demand. Consider the example of one service "client" that wants to connect | ||
2905 | to another service a "server". The "client" will ask ARM to run the "server". | ||
2906 | ARM starts the "server". The "server" starts listening to incoming connections. | ||
2907 | The "client" will establish a connection with the "server". And then, they will | ||
2908 | start to communicate together.@ One problem with that scheme is that it's | ||
2909 | slow!@ The "client" service wants to communicate with the "server" service at | ||
2910 | once and is not willing wait for it to be started and listening to incoming | ||
2911 | connections before serving its request.@ One solution for that problem will be | ||
2912 | that ARM starts all services as default services. That solution will solve the | ||
2913 | problem, yet, it's not quite practical, for some services that are going to be | ||
2914 | started can never be used or are going to be used after a relatively long | ||
2915 | time.@ The approach followed by ARM to solve this problem is as follows: | ||
2916 | @itemize @bullet | ||
2917 | |||
2918 | |||
2919 | @item For each service having a PORT field in the configuration file and that | ||
2920 | is not one of the default services ( a service that accepts incoming | ||
2921 | connections from clients), ARM creates listening sockets for all addresses | ||
2922 | associated with that service. | ||
2923 | |||
2924 | @item The "client" will immediately establish a connection with the "server". | ||
2925 | |||
2926 | @item ARM --- pretending to be the "server" --- will listen on the respective | ||
2927 | port and notice the incoming connection from the "client" (but not accept it), | ||
2928 | instead | ||
2929 | |||
2930 | @item Once there is an incoming connection, ARM will start the "server", | ||
2931 | passing on the listen sockets (now, the service is started and can do its | ||
2932 | work). | ||
2933 | |||
2934 | @item Other client services now can directly connect directly to the "server". | ||
2935 | @end itemize | ||
2936 | |||
2937 | @c *************************************************************************** | ||
2938 | @node Reliability | ||
2939 | @subsection Reliability | ||
2940 | |||
2941 | One of the features provided by ARM, is the automatic restart of crashed | ||
2942 | services.@ ARM needs to know which of the running services died. Function | ||
2943 | "gnunet-service-arm.c/maint_child_death()" is responsible for that. The | ||
2944 | function is scheduled to run upon receiving a SIGCHLD signal. The function, | ||
2945 | then, iterates ARM's list of services running and monitors which service has | ||
2946 | died (crashed). For all crashing services, ARM restarts them.@ Now, considering | ||
2947 | the case of a service having a serious problem causing it to crash each time | ||
2948 | it's started by ARM. If ARM keeps blindly restarting such a service, we are | ||
2949 | going to have the pattern: start-crash-restart-crash-restart-crash and so | ||
2950 | forth!! Which is of course not practical.@ For that reason, ARM schedules the | ||
2951 | service to be restarted after waiting for some delay that grows exponentially | ||
2952 | with each crash/restart of that service.@ To clarify the idea, considering the | ||
2953 | following example: | ||
2954 | @itemize @bullet | ||
2955 | |||
2956 | |||
2957 | @item Service S crashed. | ||
2958 | |||
2959 | @item ARM receives the SIGCHLD and inspects its list of services to find the | ||
2960 | dead one(s). | ||
2961 | |||
2962 | @item ARM finds S dead and schedules it for restarting after "backoff" time | ||
2963 | which is initially set to 1ms. ARM will double the backoff time correspondent | ||
2964 | to S (now backoff(S) = 2ms) | ||
2965 | |||
2966 | @item Because there is a severe problem with S, it crashed again. | ||
2967 | |||
2968 | @item Again ARM receives the SIGCHLD and detects that it's S again that's | ||
2969 | crashed. ARM schedules it for restarting but after its new backoff time (which | ||
2970 | became 2ms), and doubles its backoff time (now backoff(S) = 4). | ||
2971 | |||
2972 | @item and so on, until backoff(S) reaches a certain threshold | ||
2973 | (EXPONENTIAL_BACKOFF_THRESHOLD is set to half an hour), after reaching it, | ||
2974 | backoff(S) will remain half an hour, hence ARM won't be busy for a lot of time | ||
2975 | trying to restart a problematic service. | ||
2976 | @end itemize | ||
2977 | |||
2978 | @c *************************************************************************** | ||
2979 | @node GNUnet's TRANSPORT Subsystem | ||
2980 | @section GNUnet's TRANSPORT Subsystem | ||
2981 | @c %**end of header | ||
2982 | |||
2983 | This chapter documents how the GNUnet transport subsystem works. The GNUnet | ||
2984 | transport subsystem consists of three main components: the transport API (the | ||
2985 | interface used by the rest of the system to access the transport service), the | ||
2986 | transport service itself (most of the interesting functions, such as choosing | ||
2987 | transports, happens here) and the transport plugins. A transport plugin is a | ||
2988 | concrete implementation for how two GNUnet peers communicate; many plugins | ||
2989 | exist, for example for communication via TCP, UDP, HTTP, HTTPS and others. | ||
2990 | Finally, the transport subsystem uses supporting code, especially the NAT/UPnP | ||
2991 | library to help with tasks such as NAT traversal. | ||
2992 | |||
2993 | Key tasks of the transport service include: | ||
2994 | @itemize @bullet | ||
2995 | |||
2996 | |||
2997 | @item Create our HELLO message, notify clients and neighbours if our HELLO | ||
2998 | changes (using NAT library as necessary) | ||
2999 | |||
3000 | @item Validate HELLOs from other peers (send PING), allow other peers to | ||
3001 | validate our HELLO's addresses (send PONG) | ||
3002 | |||
3003 | @item Upon request, establish connections to other peers (using address | ||
3004 | selection from ATS subsystem) and maintain them (again using PINGs and PONGs) | ||
3005 | as long as desired | ||
3006 | |||
3007 | @item Accept incoming connections, give ATS service the opportunity to switch | ||
3008 | communication channels | ||
3009 | |||
3010 | @item Notify clients about peers that have connected to us or that have been | ||
3011 | disconnected from us | ||
3012 | |||
3013 | @item If a (stateful) connection goes down unexpectedly (without explicit | ||
3014 | DISCONNECT), quickly attempt to recover (without notifying clients) but do | ||
3015 | notify clients quickly if reconnecting fails | ||
3016 | |||
3017 | @item Send (payload) messages arriving from clients to other peers via | ||
3018 | transport plugins and receive messages from other peers, forwarding those to | ||
3019 | clients | ||
3020 | |||
3021 | @item Enforce inbound traffic limits (using flow-control if it is applicable); | ||
3022 | outbound traffic limits are enforced by CORE, not by us (!) | ||
3023 | |||
3024 | @item Enforce restrictions on P2P connection as specified by the blacklist | ||
3025 | configuration and blacklisting clients | ||
3026 | @end itemize | ||
3027 | |||
3028 | |||
3029 | Note that the term "clients" in the list above really refers to the GNUnet-CORE | ||
3030 | service, as CORE is typically the only client of the transport service. | ||
3031 | |||
3032 | @menu | ||
3033 | * Address validation protocol:: | ||
3034 | @end menu | ||
3035 | |||
3036 | @node Address validation protocol | ||
3037 | @subsection Address validation protocol | ||
3038 | @c %**end of header | ||
3039 | |||
3040 | This section documents how the GNUnet transport service validates connections | ||
3041 | with other peers. It is a high-level description of the protocol necessary to | ||
3042 | understand the details of the implementation. It should be noted that when we | ||
3043 | talk about PING and PONG messages in this section, we refer to transport-level | ||
3044 | PING and PONG messages, which are different from core-level PING and PONG | ||
3045 | messages (both in implementation and function). | ||
3046 | |||
3047 | The goal of transport-level address validation is to minimize the chances of a | ||
3048 | successful man-in-the-middle attack against GNUnet peers on the transport | ||
3049 | level. Such an attack would not allow the adversary to decrypt the P2P | ||
3050 | transmissions, but a successful attacker could at least measure traffic volumes | ||
3051 | and latencies (raising the adversaries capablities by those of a global passive | ||
3052 | adversary in the worst case). The scenarios we are concerned about is an | ||
3053 | attacker, Mallory, giving a HELLO to Alice that claims to be for Bob, but | ||
3054 | contains Mallory's IP address instead of Bobs (for some transport). Mallory | ||
3055 | would then forward the traffic to Bob (by initiating a connection to Bob and | ||
3056 | claiming to be Alice). As a further complication, the scheme has to work even | ||
3057 | if say Alice is behind a NAT without traversal support and hence has no address | ||
3058 | of her own (and thus Alice must always initiate the connection to Bob). | ||
3059 | |||
3060 | An additional constraint is that HELLO messages do not contain a cryptographic | ||
3061 | signature since other peers must be able to edit (i.e. remove) addresses from | ||
3062 | the HELLO at any time (this was not true in GNUnet 0.8.x). A basic | ||
3063 | @strong{assumption} is that each peer knows the set of possible network | ||
3064 | addresses that it @strong{might} be reachable under (so for example, the | ||
3065 | external IP address of the NAT plus the LAN address(es) with the respective | ||
3066 | ports). | ||
3067 | |||
3068 | The solution is the following. If Alice wants to validate that a given address | ||
3069 | for Bob is valid (i.e. is actually established @strong{directly} with the | ||
3070 | intended target), it sends a PING message over that connection to Bob. Note | ||
3071 | that in this case, Alice initiated the connection so only she knows which | ||
3072 | address was used for sure (Alice maybe behind NAT, so whatever address Bob | ||
3073 | sees may not be an address Alice knows she has). Bob checks that the address | ||
3074 | given in the PING is actually one of his addresses (does not belong to | ||
3075 | Mallory), and if it is, sends back a PONG (with a signature that says that Bob | ||
3076 | owns/uses the address from the PING). Alice checks the signature and is happy | ||
3077 | if it is valid and the address in the PONG is the address she used. This is | ||
3078 | similar to the 0.8.x protocol where the HELLO contained a signature from Bob | ||
3079 | for each address used by Bob. Here, the purpose code for the signature is | ||
3080 | @code{GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN}. After this, Alice will | ||
3081 | remember Bob's address and consider the address valid for a while (12h in the | ||
3082 | current implementation). Note that after this exchange, Alice only considers | ||
3083 | Bob's address to be valid, the connection itself is not considered | ||
3084 | 'established'. In particular, Alice may have many addresses for Bob that she | ||
3085 | considers valid. | ||
3086 | |||
3087 | The PONG message is protected with a nonce/challenge against replay attacks | ||
3088 | and uses an expiration time for the signature (but those are almost | ||
3089 | implementation details). | ||
3090 | |||
3091 | @node NAT library | ||
3092 | @section NAT library | ||
3093 | @c %**end of header | ||
3094 | |||
3095 | The goal of the GNUnet NAT library is to provide a general-purpose API for NAT | ||
3096 | traversal @strong{without} third-party support. So protocols that involve | ||
3097 | contacting a third peer to help establish a connection between two peers are | ||
3098 | outside of the scope of this API. That does not mean that GNUnet doesn't | ||
3099 | support involving a third peer (we can do this with the distance-vector | ||
3100 | transport or using application-level protocols), it just means that the NAT API | ||
3101 | is not concerned with this possibility. The API is written so that it will work | ||
3102 | for IPv6-NAT in the future as well as current IPv4-NAT. Furthermore, the NAT | ||
3103 | API is always used, even for peers that are not behind NAT --- in that case, | ||
3104 | the mapping provided is simply the identity. | ||
3105 | |||
3106 | NAT traversal is initiated by calling @code{GNUNET_NAT_register}. Given a set | ||
3107 | of addresses that the peer has locally bound to (TCP or UDP), the NAT library | ||
3108 | will return (via callback) a (possibly longer) list of addresses the peer | ||
3109 | @strong{might} be reachable under. Internally, depending on the configuration, | ||
3110 | the NAT library will try to punch a hole (using UPnP) or just "know" that the | ||
3111 | NAT was manually punched and generate the respective external IP address (the | ||
3112 | one that should be globally visible) based on the given information. | ||
3113 | |||
3114 | The NAT library also supports ICMP-based NAT traversal. Here, the other peer | ||
3115 | can request connection-reversal by this peer (in this special case, the peer is | ||
3116 | even allowed to configure a port number of zero). If the NAT library detects a | ||
3117 | connection-reversal request, it returns the respective target address to the | ||
3118 | client as well. It should be noted that connection-reversal is currently only | ||
3119 | intended for TCP, so other plugins @strong{must} pass @code{NULL} for the | ||
3120 | reversal callback. Naturally, the NAT library also supports requesting | ||
3121 | connection reversal from a remote peer (@code{GNUNET_NAT_run_client}). | ||
3122 | |||
3123 | Once initialized, the NAT handle can be used to test if a given address is | ||
3124 | possibly a valid address for this peer (@code{GNUNET_NAT_test_address}). This | ||
3125 | is used for validating our addresses when generating PONGs. | ||
3126 | |||
3127 | Finally, the NAT library contains an API to test if our NAT configuration is | ||
3128 | correct. Using @code{GNUNET_NAT_test_start} @strong{before} binding to the | ||
3129 | respective port, the NAT library can be used to test if the configuration | ||
3130 | works. The test function act as a local client, initialize the NAT traversal | ||
3131 | and then contact a @code{gnunet-nat-server} (running by default on | ||
3132 | @code{gnunet.org}) and ask for a connection to be established. This way, it is | ||
3133 | easy to test if the current NAT configuration is valid. | ||
3134 | |||
3135 | @node Distance-Vector plugin | ||
3136 | @section Distance-Vector plugin | ||
3137 | @c %**end of header | ||
3138 | |||
3139 | The Distance Vector (DV) transport is a transport mechanism that allows peers | ||
3140 | to act as relays for each other, thereby connecting peers that would otherwise | ||
3141 | be unable to connect. This gives a larger connection set to applications that | ||
3142 | may work better with more peers to choose from (for example, File Sharing | ||
3143 | and/or DHT). | ||
3144 | |||
3145 | The Distance Vector transport essentially has two functions. The first is | ||
3146 | "gossiping" connection information about more distant peers to directly | ||
3147 | connected peers. The second is taking messages intended for non-directly | ||
3148 | connected peers and encapsulating them in a DV wrapper that contains the | ||
3149 | required information for routing the message through forwarding peers. Via | ||
3150 | gossiping, optimal routes through the known DV neighborhood are discovered and | ||
3151 | utilized and the message encapsulation provides some benefits in addition to | ||
3152 | simply getting the message from the correct source to the proper destination. | ||
3153 | |||
3154 | The gossiping function of DV provides an up to date routing table of peers that | ||
3155 | are available up to some number of hops. We call this a fisheye view of the | ||
3156 | network (like a fish, nearby objects are known while more distant ones | ||
3157 | unknown). Gossip messages are sent only to directly connected peers, but they | ||
3158 | are sent about other knowns peers within the "fisheye distance". Whenever two | ||
3159 | peers connect, they immediately gossip to each other about their appropriate | ||
3160 | other neighbors. They also gossip about the newly connected peer to previously | ||
3161 | connected neighbors. In order to keep the routing tables up to date, disconnect | ||
3162 | notifications are propogated as gossip as well (because disconnects may not be | ||
3163 | sent/received, timeouts are also used remove stagnant routing table entries). | ||
3164 | |||
3165 | Routing of messages via DV is straightforward. When the DV transport is | ||
3166 | notified of a message destined for a non-direct neighbor, the appropriate | ||
3167 | forwarding peer is selected, and the base message is encapsulated in a DV | ||
3168 | message which contains information about the initial peer and the intended | ||
3169 | recipient. At each forwarding hop, the initial peer is validated (the | ||
3170 | forwarding peer ensures that it has the initial peer in its neighborhood, | ||
3171 | otherwise the message is dropped). Next the base message is re-encapsulated in | ||
3172 | a new DV message for the next hop in the forwarding chain (or delivered to the | ||
3173 | current peer, if it has arrived at the destination). | ||
3174 | |||
3175 | Assume a three peer network with peers Alice, Bob and Carol. Assume that Alice | ||
3176 | <-> Bob and Bob <-> Carol are direct (e.g. over TCP or UDP transports) | ||
3177 | connections, but that Alice cannot directly connect to Carol. This may be the | ||
3178 | case due to NAT or firewall restrictions, or perhaps based on one of the peers | ||
3179 | respective configurations. If the Distance Vector transport is enabled on all | ||
3180 | three peers, it will automatically discover (from the gossip protocol) that | ||
3181 | Alice and Carol can connect via Bob and provide a "virtual" Alice <-> Carol | ||
3182 | connection. Routing between Alice and Carol happens as follows; Alice creates a | ||
3183 | message destined for Carol and notifies the DV transport about it. The DV | ||
3184 | transport at Alice looks up Carol in the routing table and finds that the | ||
3185 | message must be sent through Bob for Carol. The message is encapsulated setting | ||
3186 | Alice as the initiator and Carol as the destination and sent to Bob. Bob | ||
3187 | receives the messages, verifies both Alice and Carol are known to Bob, and | ||
3188 | re-wraps the message in a new DV message for Carol. The DV transport at Carol | ||
3189 | receives this message, unwraps the original message, and delivers it to Carol | ||
3190 | as though it came directly from Alice. | ||
3191 | |||
3192 | @node SMTP plugin | ||
3193 | @section SMTP plugin | ||
3194 | @c %**end of header | ||
3195 | |||
3196 | This page describes the new SMTP transport plugin for GNUnet as it exists in | ||
3197 | the 0.7.x and 0.8.x branch. SMTP support is currently not available in GNUnet | ||
3198 | 0.9.x. This page also describes the transport layer abstraction (as it existed | ||
3199 | in 0.7.x and 0.8.x) in more detail and gives some benchmarking results. The | ||
3200 | performance results presented are quite old and maybe outdated at this point. | ||
3201 | @itemize @bullet | ||
3202 | @item Why use SMTP for a peer-to-peer transport? | ||
3203 | @item SMTPHow does it work? | ||
3204 | @item How do I configure my peer? | ||
3205 | @item How do I test if it works? | ||
3206 | @item How fast is it? | ||
3207 | @item Is there any additional documentation? | ||
3208 | @end itemize | ||
3209 | |||
3210 | |||
3211 | @menu | ||
3212 | * Why use SMTP for a peer-to-peer transport?:: | ||
3213 | * How does it work?:: | ||
3214 | * How do I configure my peer?:: | ||
3215 | * How do I test if it works?:: | ||
3216 | * How fast is it?:: | ||
3217 | @end menu | ||
3218 | |||
3219 | @node Why use SMTP for a peer-to-peer transport? | ||
3220 | @subsection Why use SMTP for a peer-to-peer transport? | ||
3221 | @c %**end of header | ||
3222 | |||
3223 | There are many reasons why one would not want to use SMTP: | ||
3224 | @itemize @bullet | ||
3225 | @item SMTP is using more bandwidth than TCP, UDP or HTTP | ||
3226 | @item SMTP has a much higher latency. | ||
3227 | @item SMTP requires significantly more computation (encoding and decoding time) | ||
3228 | for the peers. | ||
3229 | @item SMTP is significantly more complicated to configure. | ||
3230 | @item SMTP may be abused by tricking GNUnet into sending mail to@ | ||
3231 | non-participating third parties. | ||
3232 | @end itemize | ||
3233 | |||
3234 | So why would anybody want to use SMTP? | ||
3235 | @itemize @bullet | ||
3236 | @item SMTP can be used to contact peers behind NAT boxes (in virtual private | ||
3237 | networks). | ||
3238 | @item SMTP can be used to circumvent policies that limit or prohibit | ||
3239 | peer-to-peer traffic by masking as "legitimate" traffic. | ||
3240 | @item SMTP uses E-mail addresses which are independent of a specific IP, which | ||
3241 | can be useful to address peers that use dynamic IP addresses. | ||
3242 | @item SMTP can be used to initiate a connection (e.g. initial address exchange) | ||
3243 | and peers can then negotiate the use of a more efficient protocol (e.g. TCP) | ||
3244 | for the actual communication. | ||
3245 | @end itemize | ||
3246 | |||
3247 | In summary, SMTP can for example be used to send a message to a peer behind a | ||
3248 | NAT box that has a dynamic IP to tell the peer to establish a TCP connection | ||
3249 | to a peer outside of the private network. Even an extraordinary overhead for | ||
3250 | this first message would be irrelevant in this type of situation. | ||
3251 | |||
3252 | @node How does it work? | ||
3253 | @subsection How does it work? | ||
3254 | @c %**end of header | ||
3255 | |||
3256 | When a GNUnet peer needs to send a message to another GNUnet peer that has | ||
3257 | advertised (only) an SMTP transport address, GNUnet base64-encodes the message | ||
3258 | and sends it in an E-mail to the advertised address. The advertisement | ||
3259 | contains a filter which is placed in the E-mail header, such that the | ||
3260 | receiving host can filter the tagged E-mails and forward it to the GNUnet peer | ||
3261 | process. The filter can be specified individually by each peer and be changed | ||
3262 | over time. This makes it impossible to censor GNUnet E-mail messages by | ||
3263 | searching for a generic filter. | ||
3264 | |||
3265 | @node How do I configure my peer? | ||
3266 | @subsection How do I configure my peer? | ||
3267 | @c %**end of header | ||
3268 | |||
3269 | First, you need to configure @code{procmail} to filter your inbound E-mail for | ||
3270 | GNUnet traffic. The GNUnet messages must be delivered into a pipe, for example | ||
3271 | @code{/tmp/gnunet.smtp}. You also need to define a filter that is used by | ||
3272 | procmail to detect GNUnet messages. You are free to choose whichever filter | ||
3273 | you like, but you should make sure that it does not occur in your other | ||
3274 | E-mail. In our example, we will use @code{X-mailer: GNUnet}. The | ||
3275 | @code{~/.procmailrc} configuration file then looks like this: | ||
3276 | @example | ||
3277 | :0: | ||
3278 | * ^X-mailer: GNUnet | ||
3279 | /tmp/gnunet.smtp | ||
3280 | # where do you want your other e-mail delivered to (default: /var/spool/mail/) | ||
3281 | :0: /var/spool/mail/ | ||
3282 | @end example | ||
3283 | |||
3284 | After adding this file, first make sure that your regular E-mail still works | ||
3285 | (e.g. by sending an E-mail to yourself). Then edit the GNUnet configuration. | ||
3286 | In the section @code{SMTP} you need to specify your E-mail address under | ||
3287 | @code{EMAIL}, your mail server (for outgoing mail) under @code{SERVER}, the | ||
3288 | filter (X-mailer: GNUnet in the example) under @code{FILTER} and the name of | ||
3289 | the pipe under @code{PIPE}.@ The completed section could then look like this: | ||
3290 | @example | ||
3291 | EMAIL = me@@mail.gnu.org MTU = 65000 SERVER = mail.gnu.org:25 FILTER = | ||
3292 | "X-mailer: GNUnet" PIPE = /tmp/gnunet.smtp | ||
3293 | @end example | ||
3294 | |||
3295 | Finally, you need to add @code{smtp} to the list of @code{TRANSPORTS} in the | ||
3296 | @code{GNUNETD} section. GNUnet peers will use the E-mail address that you | ||
3297 | specified to contact your peer until the advertisement times out. Thus, if you | ||
3298 | are not sure if everything works properly or if you are not planning to be | ||
3299 | online for a long time, you may want to configure this timeout to be short, | ||
3300 | e.g. just one hour. For this, set @code{HELLOEXPIRES} to @code{1} in the | ||
3301 | @code{GNUNETD} section. | ||
3302 | |||
3303 | This should be it, but you may probably want to test it first.@ | ||
3304 | @node How do I test if it works? | ||
3305 | @subsection How do I test if it works? | ||
3306 | @c %**end of header | ||
3307 | |||
3308 | Any transport can be subjected to some rudimentary tests using the | ||
3309 | @code{gnunet-transport-check} tool. The tool sends a message to the local node | ||
3310 | via the transport and checks that a valid message is received. While this test | ||
3311 | does not involve other peers and can not check if firewalls or other network | ||
3312 | obstacles prohibit proper operation, this is a great testcase for the SMTP | ||
3313 | transport since it tests pretty much nearly all of the functionality. | ||
3314 | |||
3315 | @code{gnunet-transport-check} should only be used without running | ||
3316 | @code{gnunetd} at the same time. By default, @code{gnunet-transport-check} | ||
3317 | tests all transports that are specified in the configuration file. But you can | ||
3318 | specifically test SMTP by giving the option @code{--transport=smtp}. | ||
3319 | |||
3320 | Note that this test always checks if a transport can receive and send. While | ||
3321 | you can configure most transports to only receive or only send messages, this | ||
3322 | test will only work if you have configured the transport to send and receive | ||
3323 | messages. | ||
3324 | |||
3325 | @node How fast is it? | ||
3326 | @subsection How fast is it? | ||
3327 | @c %**end of header | ||
3328 | |||
3329 | We have measured the performance of the UDP, TCP and SMTP transport layer | ||
3330 | directly and when used from an application using the GNUnet core. Measureing | ||
3331 | just the transport layer gives the better view of the actual overhead of the | ||
3332 | protocol, whereas evaluating the transport from the application puts the | ||
3333 | overhead into perspective from a practical point of view. | ||
3334 | |||
3335 | The loopback measurements of the SMTP transport were performed on three | ||
3336 | different machines spanning a range of modern SMTP configurations. We used a | ||
3337 | PIII-800 running RedHat 7.3 with the Purdue Computer Science configuration | ||
3338 | which includes filters for spam. We also used a Xenon 2 GHZ with a vanilla | ||
3339 | RedHat 8.0 sendmail configuration. Furthermore, we used qmail on a PIII-1000 | ||
3340 | running Sorcerer GNU Linux (SGL). The numbers for UDP and TCP are provided | ||
3341 | using the SGL configuration. The qmail benchmark uses qmail's internal | ||
3342 | filtering whereas the sendmail benchmarks relies on procmail to filter and | ||
3343 | deliver the mail. We used the transport layer to send a message of b bytes | ||
3344 | (excluding transport protocol headers) directly to the local machine. This | ||
3345 | way, network latency and packet loss on the wire have no impact on the | ||
3346 | timings. n messages were sent sequentially over the transport layer, sending | ||
3347 | message i+1 after the i-th message was received. All messages were sent over | ||
3348 | the same connection and the time to establish the connection was not taken | ||
3349 | into account since this overhead is miniscule in practice --- as long as a | ||
3350 | connection is used for a significant number of messages. | ||
3351 | |||
3352 | @multitable @columnfractions .20 .15 .15 .15 .15 .15 | ||
3353 | @headitem Transport @tab UDP @tab TCP @tab SMTP (Purdue sendmail) @tab SMTP (RH 8.0) @tab SMTP (SGL qmail) | ||
3354 | @item 11 bytes @tab 31 ms @tab 55 ms @tab 781 s @tab 77 s @tab 24 s | ||
3355 | @item 407 bytes @tab 37 ms @tab 62 ms @tab 789 s @tab 78 s @tab 25 s | ||
3356 | @item 1,221 bytes @tab 46 ms @tab 73 ms @tab 804 s @tab 78 s @tab 25 s | ||
3357 | @end multitable | ||
3358 | |||
3359 | The benchmarks show that UDP and TCP are, as expected, both significantly | ||
3360 | faster compared with any of the SMTP services. Among the SMTP implementations, | ||
3361 | there can be significant differences depending on the SMTP configuration. | ||
3362 | Filtering with an external tool like procmail that needs to re-parse its | ||
3363 | configuration for each mail can be very expensive. Applying spam filters can | ||
3364 | also significantly impact the performance of the underlying SMTP | ||
3365 | implementation. The microbenchmark shows that SMTP can be a viable solution | ||
3366 | for initiating peer-to-peer sessions: a couple of seconds to connect to a peer | ||
3367 | are probably not even going to be noticed by users. The next benchmark | ||
3368 | measures the possible throughput for a transport. Throughput can be measured | ||
3369 | by sending multiple messages in parallel and measuring packet loss. Note that | ||
3370 | not only UDP but also the TCP transport can actually loose messages since the | ||
3371 | TCP implementation drops messages if the @code{write} to the socket would | ||
3372 | block. While the SMTP protocol never drops messages itself, it is often so | ||
3373 | slow that only a fraction of the messages can be sent and received in the | ||
3374 | given time-bounds. For this benchmark we report the message loss after | ||
3375 | allowing t time for sending m messages. If messages were not sent (or | ||
3376 | received) after an overall timeout of t, they were considered lost. The | ||
3377 | benchmark was performed using two Xeon 2 GHZ machines running RedHat 8.0 with | ||
3378 | sendmail. The machines were connected with a direct 100 MBit ethernet | ||
3379 | connection.@ Figures udp1200, tcp1200 and smtp-MTUs show that the throughput | ||
3380 | for messages of size 1,200 octects is 2,343 kbps, 3,310 kbps and 6 kbps for | ||
3381 | UDP, TCP and SMTP respectively. The high per-message overhead of SMTP can be | ||
3382 | improved by increasing the MTU, for example, an MTU of 12,000 octets improves | ||
3383 | the throughput to 13 kbps as figure smtp-MTUs shows. Our research paper) has | ||
3384 | some more details on the benchmarking results. | ||
3385 | |||
3386 | @node Bluetooth plugin | ||
3387 | @section Bluetooth plugin | ||
3388 | @c %**end of header | ||
3389 | |||
3390 | This page describes the new Bluetooth transport plugin for GNUnet. The plugin | ||
3391 | is still in the testing stage so don't expect it to work perfectly. If you | ||
3392 | have any questions or problems just post them here or ask on the IRC channel. | ||
3393 | @itemize @bullet | ||
3394 | @item What do I need to use the Bluetooth plugin transport? | ||
3395 | @item BluetoothHow does it work? | ||
3396 | @item What possible errors should I be aware of? | ||
3397 | @item How do I configure my peer? | ||
3398 | @item How can I test it? | ||
3399 | @end itemize | ||
3400 | |||
3401 | |||
3402 | |||
3403 | @menu | ||
3404 | * What do I need to use the Bluetooth plugin transport?:: | ||
3405 | * How does it work2?:: | ||
3406 | * What possible errors should I be aware of?:: | ||
3407 | * How do I configure my peer2?:: | ||
3408 | * How can I test it?:: | ||
3409 | * The implementation of the Bluetooth transport plugin:: | ||
3410 | @end menu | ||
3411 | |||
3412 | @node What do I need to use the Bluetooth plugin transport? | ||
3413 | @subsection What do I need to use the Bluetooth plugin transport? | ||
3414 | @c %**end of header | ||
3415 | |||
3416 | If you are a Linux user and you want to use the Bluetooth transport plugin you | ||
3417 | should install the BlueZ development libraries (if they aren't already | ||
3418 | installed). For instructions about how to install the libraries you should | ||
3419 | check out the BlueZ site (@uref{http://www.bluez.org/, http://www.bluez.org}). | ||
3420 | If you don't know if you have the necesarry libraries, don't worry, just run | ||
3421 | the GNUnet configure script and you will be able to see a notification at the | ||
3422 | end which will warn you if you don't have the necessary libraries. | ||
3423 | |||
3424 | If you are a Windows user you should have installed the | ||
3425 | @emph{MinGW}/@emph{MSys2} with the latest updates (especially the | ||
3426 | @emph{ws2bth} header). If this is your first build of GNUnet on Windows you | ||
3427 | should check out the SBuild repository. It will semi-automatically assembles a | ||
3428 | @emph{MinGW}/@emph{MSys2} installation with a lot of extra packages which are | ||
3429 | needed for the GNUnet build. So this will ease your work!@ Finally you just | ||
3430 | have to be sure that you have the correct drivers for your Bluetooth device | ||
3431 | installed and that your device is on and in a discoverable mode. The Windows | ||
3432 | Bluetooth Stack supports only the RFCOMM protocol so we cannot turn on your | ||
3433 | device programatically! | ||
3434 | |||
3435 | @node How does it work2? | ||
3436 | @subsection How does it work2? | ||
3437 | @c %**end of header | ||
3438 | |||
3439 | The Bluetooth transport plugin uses virtually the same code as the WLAN plugin | ||
3440 | and only the helper binary is different. The helper takes a single argument, | ||
3441 | which represents the interface name and is specified in the configuration | ||
3442 | file. Here are the basic steps that are followed by the helper binary used on | ||
3443 | Linux: | ||
3444 | |||
3445 | @itemize @bullet | ||
3446 | @item it verifies if the name corresponds to a Bluetooth interface name | ||
3447 | @item it verifies if the iterface is up (if it is not, it tries to bring it up) | ||
3448 | @item it tries to enable the page and inquiry scan in order to make the device | ||
3449 | discoverable and to accept incoming connection requests | ||
3450 | @emph{The above operations require root access so you should start the | ||
3451 | transport plugin with root privileges.} | ||
3452 | @item it finds an available port number and registers a SDP service which will | ||
3453 | be used to find out on which port number is the server listening on and switch | ||
3454 | the socket in listening mode | ||
3455 | @item it sends a HELLO message with its address | ||
3456 | @item finally it forwards traffic from the reading sockets to the STDOUT and | ||
3457 | from the STDIN to the writing socket | ||
3458 | @end itemize | ||
3459 | |||
3460 | Once in a while the device will make an inquiry scan to discover the nearby | ||
3461 | devices and it will send them randomly HELLO messages for peer discovery. | ||
3462 | |||
3463 | @node What possible errors should I be aware of? | ||
3464 | @subsection What possible errors should I be aware of? | ||
3465 | @c %**end of header | ||
3466 | |||
3467 | @emph{This section is dedicated for Linux users} | ||
3468 | |||
3469 | Well there are many ways in which things could go wrong but I will try to | ||
3470 | present some tools that you could use to debug and some scenarios. | ||
3471 | @itemize @bullet | ||
3472 | |||
3473 | @item @code{bluetoothd -n -d} : use this command to enable logging in the | ||
3474 | foreground and to print the logging messages | ||
3475 | |||
3476 | @item @code{hciconfig}: can be used to configure the Bluetooth devices. If you | ||
3477 | run it without any arguments it will print information about the state of the | ||
3478 | interfaces. So if you receive an error that the device couldn't be brought up | ||
3479 | you should try to bring it manually and to see if it works (use @code{hciconfig | ||
3480 | -a hciX up}). If you can't and the Bluetooth address has the form | ||
3481 | 00:00:00:00:00:00 it means that there is something wrong with the D-Bus daemon | ||
3482 | or with the Bluetooth daemon. Use @code{bluetoothd} tool to see the logs | ||
3483 | |||
3484 | @item @code{sdptool} can be used to control and interogate SDP servers. If you | ||
3485 | encounter problems regarding the SDP server (like the SDP server is down) you | ||
3486 | should check out if the D-Bus daemon is running correctly and to see if the | ||
3487 | Bluetooth daemon started correctly(use @code{bluetoothd} tool). Also, sometimes | ||
3488 | the SDP service could work but somehow the device couldn't register his | ||
3489 | service. Use @code{sdptool browse [dev-address]} to see if the service is | ||
3490 | registered. There should be a service with the name of the interface and GNUnet | ||
3491 | as provider. | ||
3492 | |||
3493 | @item @code{hcitool} : another useful tool which can be used to configure the | ||
3494 | device and to send some particular commands to it. | ||
3495 | |||
3496 | @item @code{hcidump} : could be used for low level debugging | ||
3497 | @end itemize | ||
3498 | |||
3499 | @node How do I configure my peer2? | ||
3500 | @subsection How do I configure my peer2? | ||
3501 | @c %**end of header | ||
3502 | |||
3503 | On Linux, you just have to be sure that the interface name corresponds to the | ||
3504 | one that you want to use. Use the @code{hciconfig} tool to check that. By | ||
3505 | default it is set to hci0 but you can change it. | ||
3506 | |||
3507 | A basic configuration looks like this: | ||
3508 | @example | ||
3509 | [transport-bluetooth] | ||
3510 | # Name of the interface (typically hciX) | ||
3511 | INTERFACE = hci0 | ||
3512 | # Real hardware, no testing | ||
3513 | TESTMODE = 0 TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
3514 | @end example | ||
3515 | |||
3516 | |||
3517 | In order to use the Bluetooth transport plugin when the transport service is | ||
3518 | started, you must add the plugin name to the default transport service plugins | ||
3519 | list. For example: | ||
3520 | @example | ||
3521 | [transport] ... PLUGINS = dns bluetooth ... | ||
3522 | @end example | ||
3523 | |||
3524 | If you want to use only the Bluetooth plugin set @emph{PLUGINS = bluetooth} | ||
3525 | |||
3526 | On Windows, you cannot specify which device to use. The only thing that you | ||
3527 | should do is to add @emph{bluetooth} on the plugins list of the transport | ||
3528 | service. | ||
3529 | |||
3530 | @node How can I test it? | ||
3531 | @subsection How can I test it? | ||
3532 | @c %**end of header | ||
3533 | |||
3534 | If you have two Bluetooth devices on the same machine which use Linux you | ||
3535 | must: | ||
3536 | @itemize @bullet | ||
3537 | |||
3538 | @item create two different file configuration (one which will use the first | ||
3539 | interface (@emph{hci0}) and the other which will use the second interface | ||
3540 | (@emph{hci1})). Let's name them @emph{peer1.conf} and @emph{peer2.conf}. | ||
3541 | |||
3542 | @item run @emph{gnunet-peerinfo -c peerX.conf -s} in order to generate the | ||
3543 | peers private keys. The @strong{X} must be replace with 1 or 2. | ||
3544 | |||
3545 | @item run @emph{gnunet-arm -c peerX.conf -s -i=transport} in order to start the | ||
3546 | transport service. (Make sure that you have "bluetooth" on the transport | ||
3547 | plugins list if the Bluetooth transport service doesn't start.) | ||
3548 | |||
3549 | @item run @emph{gnunet-peerinfo -c peer1.conf -s} to get the first peer's ID. | ||
3550 | If you already know your peer ID (you saved it from the first command), this | ||
3551 | can be skipped. | ||
3552 | |||
3553 | @item run @emph{gnunet-transport -c peer2.conf -p=PEER1_ID -s} to start sending | ||
3554 | data for benchmarking to the other peer. | ||
3555 | @end itemize | ||
3556 | |||
3557 | |||
3558 | This scenario will try to connect the second peer to the first one and then | ||
3559 | start sending data for benchmarking. | ||
3560 | |||
3561 | On Windows you cannot test the plugin functionality using two Bluetooth devices | ||
3562 | from the same machine because after you install the drivers there will occur | ||
3563 | some conflicts between the Bluetooth stacks. (At least that is what happend on | ||
3564 | my machine : I wasn't able to use the Bluesoleil stack and the WINDCOMM one in | ||
3565 | the same time). | ||
3566 | |||
3567 | If you have two different machines and your configuration files are good you | ||
3568 | can use the same scenario presented on the begining of this section. | ||
3569 | |||
3570 | Another way to test the plugin functionality is to create your own application | ||
3571 | which will use the GNUnet framework with the Bluetooth transport service. | ||
3572 | |||
3573 | @node The implementation of the Bluetooth transport plugin | ||
3574 | @subsection The implementation of the Bluetooth transport plugin | ||
3575 | @c %**end of header | ||
3576 | |||
3577 | This page describes the implementation of the Bluetooth transport plugin. | ||
3578 | |||
3579 | First I want to remind you that the Bluetooth transport plugin uses virtually | ||
3580 | the same code as the WLAN plugin and only the helper binary is different. Also | ||
3581 | the scope of the helper binary from the Bluetooth transport plugin is the same | ||
3582 | as the one used for the wlan transport plugin: it acceses the interface and | ||
3583 | then it forwards traffic in both directions between the Bluetooth interface | ||
3584 | and stdin/stdout of the process involved. | ||
3585 | |||
3586 | The Bluetooth plugin transport could be used both on Linux and Windows | ||
3587 | platforms. | ||
3588 | |||
3589 | @itemize @bullet | ||
3590 | @item Linux functionality | ||
3591 | @item Windows functionality | ||
3592 | @item Pending Features | ||
3593 | @end itemize | ||
3594 | |||
3595 | |||
3596 | |||
3597 | @menu | ||
3598 | * Linux functionality:: | ||
3599 | * THE INITIALIZATION:: | ||
3600 | * THE LOOP:: | ||
3601 | * Details about the broadcast implementation:: | ||
3602 | * Windows functionality:: | ||
3603 | * Pending features:: | ||
3604 | @end menu | ||
3605 | |||
3606 | @node Linux functionality | ||
3607 | @subsubsection Linux functionality | ||
3608 | @c %**end of header | ||
3609 | |||
3610 | In order to implement the plugin functionality on Linux I used the BlueZ | ||
3611 | stack. For the communication with the other devices I used the RFCOMM | ||
3612 | protocol. Also I used the HCI protocol to gain some control over the device. | ||
3613 | The helper binary takes a single argument (the name of the Bluetooth | ||
3614 | interface) and is separated in two stages: | ||
3615 | |||
3616 | @c %** 'THE INITIALIZATION' should be in bigger letters or stand out, not | ||
3617 | @c %** starting a new section? | ||
3618 | @node THE INITIALIZATION | ||
3619 | @subsubsection THE INITIALIZATION | ||
3620 | |||
3621 | @itemize @bullet | ||
3622 | @item first, it checks if we have root privilegies (@emph{Remember that we need | ||
3623 | to have root privilegies in order to be able to bring the interface up if it is | ||
3624 | down or to change its state.}). | ||
3625 | |||
3626 | @item second, it verifies if the interface with the given name exists. | ||
3627 | |||
3628 | @strong{If the interface with that name exists and it is a Bluetooth | ||
3629 | interface:} | ||
3630 | |||
3631 | @item it creates a RFCOMM socket which will be used for listening and call the | ||
3632 | @emph{open_device} method | ||
3633 | |||
3634 | On the @emph{open_device} method: | ||
3635 | @itemize @bullet | ||
3636 | @item creates a HCI socket used to send control events to the the device | ||
3637 | @item searches for the device ID using the interface name | ||
3638 | @item saves the device MAC address | ||
3639 | @item checks if the interface is down and tries to bring it UP | ||
3640 | @item checks if the interface is in discoverable mode and tries to make it | ||
3641 | discoverable | ||
3642 | @item closes the HCI socket and binds the RFCOMM one | ||
3643 | @item switches the RFCOMM socket in listening mode | ||
3644 | @item registers the SDP service (the service will be used by the other devices | ||
3645 | to get the port on which this device is listening on) | ||
3646 | @end itemize | ||
3647 | |||
3648 | @item drops the root privilegies | ||
3649 | |||
3650 | @strong{If the interface is not a Bluetooth interface the helper exits with a | ||
3651 | suitable error} | ||
3652 | @end itemize | ||
3653 | |||
3654 | @c %** Same as for @node entry above | ||
3655 | @node THE LOOP | ||
3656 | @subsubsection THE LOOP | ||
3657 | |||
3658 | The helper binary uses a list where it saves all the connected neighbour | ||
3659 | devices (@emph{neighbours.devices}) and two buffers (@emph{write_pout} and | ||
3660 | @emph{write_std}). The first message which is send is a control message with | ||
3661 | the device's MAC address in order to announce the peer presence to the | ||
3662 | neighbours. Here are a short description of what happens in the main loop: | ||
3663 | |||
3664 | @itemize @bullet | ||
3665 | @item Every time when it receives something from the STDIN it processes the | ||
3666 | data and saves the message in the first buffer (@emph{write_pout}). When it has | ||
3667 | something in the buffer, it gets the destination address from the buffer, | ||
3668 | searches the destination address in the list (if there is no connection with | ||
3669 | that device, it creates a new one and saves it to the list) and sends the | ||
3670 | message. | ||
3671 | @item Every time when it receives something on the listening socket it accepts | ||
3672 | the connection and saves the socket on a list with the reading sockets. | ||
3673 | @item Every time when it receives something from a reading socket it parses the | ||
3674 | message, verifies the CRC and saves it in the @emph{write_std} buffer in order | ||
3675 | to be sent later to the STDOUT. | ||
3676 | @end itemize | ||
3677 | |||
3678 | So in the main loop we use the select function to wait until one of the file | ||
3679 | descriptor saved in one of the two file descriptors sets used is ready to use. | ||
3680 | The first set (@emph{rfds}) represents the reading set and it could contain the | ||
3681 | list with the reading sockets, the STDIN file descriptor or the listening | ||
3682 | socket. The second set (@emph{wfds}) is the writing set and it could contain | ||
3683 | the sending socket or the STDOUT file descriptor. After the select function | ||
3684 | returns, we check which file descriptor is ready to use and we do what is | ||
3685 | supposed to do on that kind of event. @emph{For example:} if it is the | ||
3686 | listening socket then we accept a new connection and save the socket in the | ||
3687 | reading list; if it is the STDOUT file descriptor, then we write to STDOUT the | ||
3688 | message from the @emph{write_std} buffer. | ||
3689 | |||
3690 | To find out on which port a device is listening on we connect to the local SDP | ||
3691 | server and searche the registered service for that device. | ||
3692 | |||
3693 | @emph{You should be aware of the fact that if the device fails to connect to | ||
3694 | another one when trying to send a message it will attempt one more time. If it | ||
3695 | fails again, then it skips the message.} | ||
3696 | @emph{Also you should know that the | ||
3697 | transport Bluetooth plugin has support for @strong{broadcast messages}.} | ||
3698 | |||
3699 | @node Details about the broadcast implementation | ||
3700 | @subsubsection Details about the broadcast implementation | ||
3701 | @c %**end of header | ||
3702 | |||
3703 | First I want to point out that the broadcast functionality for the CONTROL | ||
3704 | messages is not implemented in a conventional way. Since the inquiry scan time | ||
3705 | is too big and it will take some time to send a message to all the | ||
3706 | discoverable devices I decided to tackle the problem in a different way. Here | ||
3707 | is how I did it: | ||
3708 | |||
3709 | @itemize @bullet | ||
3710 | @item If it is the first time when I have to broadcast a message I make an | ||
3711 | inquiry scan and save all the devices' addresses to a vector. | ||
3712 | @item After the inquiry scan ends I take the first address from the list and I | ||
3713 | try to connect to it. If it fails, I try to connect to the next one. If it | ||
3714 | succeeds, I save the socket to a list and send the message to the device. | ||
3715 | @item When I have to broadcast another message, first I search on the list for | ||
3716 | a new device which I'm not connected to. If there is no new device on the list | ||
3717 | I go to the beginning of the list and send the message to the old devices. | ||
3718 | After 5 cycles I make a new inquiry scan to check out if there are new | ||
3719 | discoverable devices and save them to the list. If there are no new | ||
3720 | discoverable devices I reset the cycling counter and go again through the old | ||
3721 | list and send messages to the devices saved in it. | ||
3722 | @end itemize | ||
3723 | |||
3724 | @strong{Therefore}: | ||
3725 | |||
3726 | @itemize @bullet | ||
3727 | @item every time when I have a broadcast message I look up on the list for a | ||
3728 | new device and send the message to it | ||
3729 | @item if I reached the end of the list for 5 times and I'm connected to all the | ||
3730 | devices from the list I make a new inquiry scan. @emph{The number of the list's | ||
3731 | cycles after an inquiry scan could be increased by redefining the MAX_LOOPS | ||
3732 | variable} | ||
3733 | @item when there are no new devices I send messages to the old ones. | ||
3734 | @end itemize | ||
3735 | |||
3736 | Doing so, the broadcast control messages will reach the devices but with delay. | ||
3737 | |||
3738 | @emph{NOTICE:} When I have to send a message to a certain device first I check | ||
3739 | on the broadcast list to see if we are connected to that device. If not we try | ||
3740 | to connect to it and in case of success we save the address and the socket on | ||
3741 | the list. If we are already connected to that device we simply use the socket. | ||
3742 | |||
3743 | @node Windows functionality | ||
3744 | @subsubsection Windows functionality | ||
3745 | @c %**end of header | ||
3746 | |||
3747 | For Windows I decided to use the Microsoft Bluetooth stack which has the | ||
3748 | advantage of coming standard from Windows XP SP2. The main disadvantage is | ||
3749 | that it only supports the RFCOMM protocol so we will not be able to have a low | ||
3750 | level control over the Bluetooth device. Therefore it is the user | ||
3751 | responsability to check if the device is up and in the discoverable mode. Also | ||
3752 | there are no tools which could be used for debugging in order to read the data | ||
3753 | coming from and going to a Bluetooth device, which obviously hindered my work. | ||
3754 | Another thing that slowed down the implementation of the plugin (besides that | ||
3755 | I wasn't too accomodated with the win32 API) was that there were some bugs on | ||
3756 | MinGW regarding the Bluetooth. Now they are solved but you should keep in mind | ||
3757 | that you should have the latest updates (especially the @emph{ws2bth} header). | ||
3758 | |||
3759 | Besides the fact that it uses the Windows Sockets, the Windows implemenation | ||
3760 | follows the same principles as the Linux one: | ||
3761 | |||
3762 | @itemize @bullet | ||
3763 | @item | ||
3764 | It has a initalization part where it initializes the Windows Sockets, creates a | ||
3765 | RFCOMM socket which will be binded and switched to the listening mode and | ||
3766 | registers a SDP service. | ||
3767 | In the Microsoft Bluetooth API there are two ways to work with the SDP: | ||
3768 | @itemize @bullet | ||
3769 | @item an easy way which works with very simple service records | ||
3770 | @item a hard way which is useful when you need to update or to delete the | ||
3771 | record | ||
3772 | @end itemize | ||
3773 | @end itemize | ||
3774 | |||
3775 | Since I only needed the SDP service to find out on which port the device is | ||
3776 | listening on and that did not change, I decided to use the easy way. In order | ||
3777 | to register the service I used the @emph{WSASetService} function and I | ||
3778 | generated the @emph{Universally Unique Identifier} with the @emph{guidgen.exe} | ||
3779 | Windows's tool. | ||
3780 | |||
3781 | In the loop section the only difference from the Linux implementation is that | ||
3782 | I used the GNUNET_NETWORK library for functions like @emph{accept}, | ||
3783 | @emph{bind}, @emph{connect} or @emph{select}. I decided to use the | ||
3784 | GNUNET_NETWORK library because I also needed to interact with the STDIN and | ||
3785 | STDOUT handles and on Windows the select function is only defined for sockets, | ||
3786 | and it will not work for arbitrary file handles. | ||
3787 | |||
3788 | Another difference between Linux and Windows implementation is that in Linux, | ||
3789 | the Bluetooth address is represented in 48 bits while in Windows is | ||
3790 | represented in 64 bits. Therefore I had to do some changes on | ||
3791 | @emph{plugin_transport_wlan} header. | ||
3792 | |||
3793 | Also, currently on Windows the Bluetooth plugin doesn't have support for | ||
3794 | broadcast messages. When it receives a broadcast message it will skip it. | ||
3795 | |||
3796 | @node Pending features | ||
3797 | @subsubsection Pending features | ||
3798 | @c %**end of header | ||
3799 | |||
3800 | @itemize @bullet | ||
3801 | @item Implement the broadcast functionality on Windows @emph{(currently working | ||
3802 | on)} | ||
3803 | @item Implement a testcase for the helper :@ @emph{@ The testcase consists of a | ||
3804 | program which emaluates the plugin and uses the helper. It will simulate | ||
3805 | connections, disconnections and data transfers.@ } | ||
3806 | @end itemize | ||
3807 | |||
3808 | If you have a new idea about a feature of the plugin or suggestions about how | ||
3809 | I could improve the implementation you are welcome to comment or to contact | ||
3810 | me. | ||
3811 | |||
3812 | @node WLAN plugin | ||
3813 | @section WLAN plugin | ||
3814 | @c %**end of header | ||
3815 | |||
3816 | This section documents how the wlan transport plugin works. Parts which are not | ||
3817 | implemented yet or could be better implemented are described at the end. | ||
3818 | |||
3819 | @node The ATS Subsystem | ||
3820 | @section The ATS Subsystem | ||
3821 | @c %**end of header | ||
3822 | |||
3823 | ATS stands for "automatic transport selection", and the function of ATS in | ||
3824 | GNUnet is to decide on which address (and thus transport plugin) should be used | ||
3825 | for two peers to communicate, and what bandwidth limits should be imposed on | ||
3826 | such an individual connection. To help ATS make an informed decision, | ||
3827 | higher-level services inform the ATS service about their requirements and the | ||
3828 | quality of the service rendered. The ATS service also interacts with the | ||
3829 | transport service to be appraised of working addresses and to communicate its | ||
3830 | resource allocation decisions. Finally, the ATS service's operation can be | ||
3831 | observed using a monitoring API. | ||
3832 | |||
3833 | The main logic of the ATS service only collects the available addresses, their | ||
3834 | performance characteristics and the applications requirements, but does not | ||
3835 | make the actual allocation decision. This last critical step is left to an ATS | ||
3836 | plugin, as we have implemented (currently three) different allocation | ||
3837 | strategies which differ significantly in their performance and maturity, and it | ||
3838 | is still unclear if any particular plugin is generally superior. | ||
3839 | |||
3840 | @node GNUnet's CORE Subsystem | ||
3841 | @section GNUnet's CORE Subsystem | ||
3842 | @c %**end of header | ||
3843 | |||
3844 | The CORE subsystem in GNUnet is responsible for securing link-layer | ||
3845 | communications between nodes in the GNUnet overlay network. CORE builds on the | ||
3846 | TRANSPORT subsystem which provides for the actual, insecure, unreliable | ||
3847 | link-layer communication (for example, via UDP or WLAN), and then adds | ||
3848 | fundamental security to the connections: | ||
3849 | |||
3850 | @itemize @bullet | ||
3851 | @item confidentiality with so-called perfect forward secrecy; we use | ||
3852 | @uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, | ||
3853 | ECDHE} powered by @uref{http://cr.yp.to/ecdh.html, Curve25519} for the key | ||
3854 | exchange and then use symmetric encryption, encrypting with both | ||
3855 | @uref{http://en.wikipedia.org/wiki/Rijndael, AES-256} and | ||
3856 | @uref{http://en.wikipedia.org/wiki/Twofish, Twofish} | ||
3857 | @item @uref{http://en.wikipedia.org/wiki/Authentication, authentication} is | ||
3858 | achieved by signing the ephemeral keys using @uref{http://ed25519.cr.yp.to/, | ||
3859 | Ed25519}, a deterministic variant of @uref{http://en.wikipedia.org/wiki/ECDSA, | ||
3860 | ECDSA} | ||
3861 | @item integrity protection (using @uref{http://en.wikipedia.org/wiki/SHA-2, | ||
3862 | SHA-512} to do @uref{http://en.wikipedia.org/wiki/Authenticated_encryption, | ||
3863 | encrypt-then-MAC)} | ||
3864 | @item @uref{http://en.wikipedia.org/wiki/Replay_attack, replay} protection | ||
3865 | (using nonces, timestamps, challenge-response, message counters and ephemeral | ||
3866 | keys) | ||
3867 | @item liveness (keep-alive messages, timeout) | ||
3868 | @end itemize | ||
3869 | |||
3870 | @menu | ||
3871 | * Limitations:: | ||
3872 | * When is a peer "connected"?:: | ||
3873 | * libgnunetcore:: | ||
3874 | * The CORE Client-Service Protocol:: | ||
3875 | * The CORE Peer-to-Peer Protocol:: | ||
3876 | @end menu | ||
3877 | |||
3878 | @node Limitations | ||
3879 | @subsection Limitations | ||
3880 | @c %**end of header | ||
3881 | |||
3882 | CORE does not perform @uref{http://en.wikipedia.org/wiki/Routing, routing}; | ||
3883 | using CORE it is only possible to communicate with peers that happen to | ||
3884 | already be "directly" connected with each other. CORE also does not have an | ||
3885 | API to allow applications to establish such "direct" connections --- for this, | ||
3886 | applications can ask TRANSPORT, but TRANSPORT might not be able to establish a | ||
3887 | "direct" connection. The TOPOLOGY subsystem is responsible for trying to keep | ||
3888 | a few "direct" connections open at all times. Applications that need to talk | ||
3889 | to particular peers should use the CADET subsystem, as it can establish | ||
3890 | arbitrary "indirect" connections. | ||
3891 | |||
3892 | Because CORE does not perform routing, CORE must only be used directly by | ||
3893 | applications that either perform their own routing logic (such as anonymous | ||
3894 | file-sharing) or that do not require routing, for example because they are | ||
3895 | based on flooding the network. CORE communication is unreliable and delivery | ||
3896 | is possibly out-of-order. Applications that require reliable communication | ||
3897 | should use the CADET service. Each application can only queue one message per | ||
3898 | target peer with the CORE service at any time; messages cannot be larger than | ||
3899 | approximately 63 kilobytes. If messages are small, CORE may group multiple | ||
3900 | messages (possibly from different applications) prior to encryption. If | ||
3901 | permitted by the application (using the @uref{http://baus.net/on-tcp_cork/, | ||
3902 | cork} option), CORE may delay transmissions to facilitate grouping of multiple | ||
3903 | small messages. If cork is not enabled, CORE will transmit the message as soon | ||
3904 | as TRANSPORT allows it (TRANSPORT is responsible for limiting bandwidth and | ||
3905 | congestion control). CORE does not allow flow control; applications are | ||
3906 | expected to process messages at line-speed. If flow control is needed, | ||
3907 | applications should use the CADET service. | ||
3908 | |||
3909 | @node When is a peer "connected"? | ||
3910 | @subsection When is a peer "connected"? | ||
3911 | @c %**end of header | ||
3912 | |||
3913 | In addition to the security features mentioned above, CORE also provides one | ||
3914 | additional key feature to applications using it, and that is a limited form of | ||
3915 | protocol-compatibility checking. CORE distinguishes between TRANSPORT-level | ||
3916 | connections (which enable communication with other peers) and | ||
3917 | application-level connections. Applications using the CORE API will | ||
3918 | (typically) learn about application-level connections from CORE, and not about | ||
3919 | TRANSPORT-level connections. When a typical application uses CORE, it will | ||
3920 | specify a set of message types (from @code{gnunet_protocols.h}) that it | ||
3921 | understands. CORE will then notify the application about connections it has | ||
3922 | with other peers if and only if those applications registered an intersecting | ||
3923 | set of message types with their CORE service. Thus, it is quite possible that | ||
3924 | CORE only exposes a subset of the established direct connections to a | ||
3925 | particular application --- and different applications running above CORE might | ||
3926 | see different sets of connections at the same time. | ||
3927 | |||
3928 | A special case are applications that do not register a handler for any message | ||
3929 | type. CORE assumes that these applications merely want to monitor connections | ||
3930 | (or "all" messages via other callbacks) and will notify those applications | ||
3931 | about all connections. This is used, for example, by the @code{gnunet-core} | ||
3932 | command-line tool to display the active connections. Note that it is also | ||
3933 | possible that the TRANSPORT service has more active connections than the CORE | ||
3934 | service, as the CORE service first has to perform a key exchange with | ||
3935 | connecting peers before exchanging information about supported message types | ||
3936 | and notifying applications about the new connection. | ||
3937 | |||
3938 | @node libgnunetcore | ||
3939 | @subsection libgnunetcore | ||
3940 | @c %**end of header | ||
3941 | |||
3942 | The CORE API (defined in @code{gnunet_core_service.h}) is the basic messaging | ||
3943 | API used by P2P applications built using GNUnet. It provides applications the | ||
3944 | ability to send and receive encrypted messages to the peer's "directly" | ||
3945 | connected neighbours. | ||
3946 | |||
3947 | As CORE connections are generally "direct" connections,@ applications must not | ||
3948 | assume that they can connect to arbitrary peers this way, as "direct" | ||
3949 | connections may not always be possible. Applications using CORE are notified | ||
3950 | about which peers are connected. Creating new "direct" connections must be | ||
3951 | done using the TRANSPORT API. | ||
3952 | |||
3953 | The CORE API provides unreliable, out-of-order delivery. While the | ||
3954 | implementation tries to ensure timely, in-order delivery, both message losses | ||
3955 | and reordering are not detected and must be tolerated by the application. Most | ||
3956 | important, the core will NOT perform retransmission if messages could not be | ||
3957 | delivered. | ||
3958 | |||
3959 | Note that CORE allows applications to queue one message per connected peer. | ||
3960 | The rate at which each connection operates is influenced by the preferences | ||
3961 | expressed by local application as well as restrictions imposed by the other | ||
3962 | peer. Local applications can express their preferences for particular | ||
3963 | connections using the "performance" API of the ATS service. | ||
3964 | |||
3965 | Applications that require more sophisticated transmission capabilities such as | ||
3966 | TCP-like behavior, or if you intend to send messages to arbitrary remote | ||
3967 | peers, should use the CADET API. | ||
3968 | |||
3969 | The typical use of the CORE API is to connect to the CORE service using | ||
3970 | @code{GNUNET_CORE_connect}, process events from the CORE service (such as | ||
3971 | peers connecting, peers disconnecting and incoming messages) and send messages | ||
3972 | to connected peers using @code{GNUNET_CORE_notify_transmit_ready}. Note that | ||
3973 | applications must cancel pending transmission requests if they receive a | ||
3974 | disconnect event for a peer that had a transmission pending; furthermore, | ||
3975 | queueing more than one transmission request per peer per application using the | ||
3976 | service is not permitted. | ||
3977 | |||
3978 | The CORE API also allows applications to monitor all communications of the | ||
3979 | peer prior to encryption (for outgoing messages) or after decryption (for | ||
3980 | incoming messages). This can be useful for debugging, diagnostics or to | ||
3981 | establish the presence of cover traffic (for anonymity). As monitoring | ||
3982 | applications are often not interested in the payload, the monitoring callbacks | ||
3983 | can be configured to only provide the message headers (including the message | ||
3984 | type and size) instead of copying the full data stream to the monitoring | ||
3985 | client. | ||
3986 | |||
3987 | The init callback of the @code{GNUNET_CORE_connect} function is called with | ||
3988 | the hash of the public key of the peer. This public key is used to identify | ||
3989 | the peer globally in the GNUnet network. Applications are encouraged to check | ||
3990 | that the provided hash matches the hash that they are using (as theoretically | ||
3991 | the application may be using a different configuration file with a different | ||
3992 | private key, which would result in hard to find bugs). | ||
3993 | |||
3994 | As with most service APIs, the CORE API isolates applications from crashes of | ||
3995 | the CORE service. If the CORE service crashes, the application will see | ||
3996 | disconnect events for all existing connections. Once the connections are | ||
3997 | re-established, the applications will be receive matching connect events. | ||
3998 | |||
3999 | @node The CORE Client-Service Protocol | ||
4000 | @subsection The CORE Client-Service Protocol | ||
4001 | @c %**end of header | ||
4002 | |||
4003 | This section describes the protocol between an application using the CORE | ||
4004 | service (the client) and the CORE service process itself. | ||
4005 | |||
4006 | |||
4007 | @menu | ||
4008 | * Setup2:: | ||
4009 | * Notifications:: | ||
4010 | * Sending:: | ||
4011 | @end menu | ||
4012 | |||
4013 | @node Setup2 | ||
4014 | @subsubsection Setup2 | ||
4015 | @c %**end of header | ||
4016 | |||
4017 | When a client connects to the CORE service, it first sends a | ||
4018 | @code{InitMessage} which specifies options for the connection and a set of | ||
4019 | message type values which are supported by the application. The options | ||
4020 | bitmask specifies which events the client would like to be notified about. The | ||
4021 | options include: | ||
4022 | |||
4023 | @table @asis | ||
4024 | @item GNUNET_CORE_OPTION_NOTHING No notifications | ||
4025 | @item GNUNET_CORE_OPTION_STATUS_CHANGE Peers connecting and disconnecting | ||
4026 | @item GNUNET_CORE_OPTION_FULL_INBOUND All inbound messages (after decryption) with | ||
4027 | full payload | ||
4028 | @item GNUNET_CORE_OPTION_HDR_INBOUND Just the @code{MessageHeader} | ||
4029 | of all inbound messages | ||
4030 | @item GNUNET_CORE_OPTION_FULL_OUTBOUND All outbound | ||
4031 | messages (prior to encryption) with full payload | ||
4032 | @item GNUNET_CORE_OPTION_HDR_OUTBOUND Just the @code{MessageHeader} of all outbound | ||
4033 | messages | ||
4034 | @end table | ||
4035 | |||
4036 | Typical applications will only monitor for connection status changes. | ||
4037 | |||
4038 | The CORE service responds to the @code{InitMessage} with an | ||
4039 | @code{InitReplyMessage} which contains the peer's identity. Afterwards, both | ||
4040 | CORE and the client can send messages. | ||
4041 | |||
4042 | @node Notifications | ||
4043 | @subsubsection Notifications | ||
4044 | @c %**end of header | ||
4045 | |||
4046 | The CORE will send @code{ConnectNotifyMessage}s and | ||
4047 | @code{DisconnectNotifyMessage}s whenever peers connect or disconnect from the | ||
4048 | CORE (assuming their type maps overlap with the message types registered by | ||
4049 | the client). When the CORE receives a message that matches the set of message | ||
4050 | types specified during the @code{InitMessage} (or if monitoring is enabled in | ||
4051 | for inbound messages in the options), it sends a @code{NotifyTrafficMessage} | ||
4052 | with the peer identity of the sender and the decrypted payload. The same | ||
4053 | message format (except with @code{GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND} | ||
4054 | for the message type) is used to notify clients monitoring outbound messages; | ||
4055 | here, the peer identity given is that of the receiver. | ||
4056 | |||
4057 | @node Sending | ||
4058 | @subsubsection Sending | ||
4059 | @c %**end of header | ||
4060 | |||
4061 | When a client wants to transmit a message, it first requests a transmission | ||
4062 | slot by sending a @code{SendMessageRequest} which specifies the priority, | ||
4063 | deadline and size of the message. Note that these values may be ignored by | ||
4064 | CORE. When CORE is ready for the message, it answers with a | ||
4065 | @code{SendMessageReady} response. The client can then transmit the payload | ||
4066 | with a @code{SendMessage} message. Note that the actual message size in the | ||
4067 | @code{SendMessage} is allowed to be smaller than the size in the original | ||
4068 | request. A client may at any time send a fresh @code{SendMessageRequest}, | ||
4069 | which then superceeds the previous @code{SendMessageRequest}, which is then no | ||
4070 | longer valid. The client can tell which @code{SendMessageRequest} the CORE | ||
4071 | service's @code{SendMessageReady} message is for as all of these messages | ||
4072 | contain a "unique" request ID (based on a counter incremented by the client | ||
4073 | for each request). | ||
4074 | |||
4075 | @node The CORE Peer-to-Peer Protocol | ||
4076 | @subsection The CORE Peer-to-Peer Protocol | ||
4077 | @c %**end of header | ||
4078 | |||
4079 | |||
4080 | @menu | ||
4081 | * Creating the EphemeralKeyMessage:: | ||
4082 | * Establishing a connection:: | ||
4083 | * Encryption and Decryption:: | ||
4084 | * Type maps:: | ||
4085 | @end menu | ||
4086 | |||
4087 | @node Creating the EphemeralKeyMessage | ||
4088 | @subsubsection Creating the EphemeralKeyMessage | ||
4089 | @c %**end of header | ||
4090 | |||
4091 | When the CORE service starts, each peer creates a fresh ephemeral (ECC) | ||
4092 | public-private key pair and signs the corresponding @code{EphemeralKeyMessage} | ||
4093 | with its long-term key (which we usually call the peer's identity; the hash of | ||
4094 | the public long term key is what results in a @code{struct | ||
4095 | GNUNET_PeerIdentity} in all GNUnet APIs. The ephemeral key is ONLY used for an | ||
4096 | @uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, | ||
4097 | ECDHE} exchange by the CORE service to establish symmetric session keys. A | ||
4098 | peer will use the same @code{EphemeralKeyMessage} for all peers for | ||
4099 | @code{REKEY_FREQUENCY}, which is usually 12 hours. After that time, it will | ||
4100 | create a fresh ephemeral key (forgetting the old one) and broadcast the new | ||
4101 | @code{EphemeralKeyMessage} to all connected peers, resulting in fresh | ||
4102 | symmetric session keys. Note that peers independently decide on when to | ||
4103 | discard ephemeral keys; it is not a protocol violation to discard keys more | ||
4104 | often. Ephemeral keys are also never stored to disk; restarting a peer will | ||
4105 | thus always create a fresh ephemeral key. The use of ephemeral keys is what | ||
4106 | provides @uref{http://en.wikipedia.org/wiki/Forward_secrecy, forward secrecy}. | ||
4107 | |||
4108 | Just before transmission, the @code{EphemeralKeyMessage} is patched to reflect | ||
4109 | the current sender_status, which specifies the current state of the connection | ||
4110 | from the point of view of the sender. The possible values are: | ||
4111 | |||
4112 | @table @asis | ||
4113 | @item KX_STATE_DOWN Initial value, never used on the network | ||
4114 | @item KX_STATE_KEY_SENT We sent our ephemeral key, do not know the key of the other | ||
4115 | peer | ||
4116 | @item KX_STATE_KEY_RECEIVED This peer has received a valid ephemeral key | ||
4117 | of the other peer, but we are waiting for the other peer to confirm it's | ||
4118 | authenticity (ability to decode) via challenge-response. | ||
4119 | @item KX_STATE_UP The | ||
4120 | connection is fully up from the point of view of the sender (now performing | ||
4121 | keep-alives) | ||
4122 | @item KX_STATE_REKEY_SENT The sender has initiated a rekeying | ||
4123 | operation; the other peer has so far failed to confirm a working connection | ||
4124 | using the new ephemeral key | ||
4125 | @end table | ||
4126 | |||
4127 | @node Establishing a connection | ||
4128 | @subsubsection Establishing a connection | ||
4129 | @c %**end of header | ||
4130 | |||
4131 | Peers begin their interaction by sending a @code{EphemeralKeyMessage} to the | ||
4132 | other peer once the TRANSPORT service notifies the CORE service about the | ||
4133 | connection. A peer receiving an @code{EphemeralKeyMessage} with a status | ||
4134 | indicating that the sender does not have the receiver's ephemeral key, the | ||
4135 | receiver's @code{EphemeralKeyMessage} is sent in response.@ Additionally, if | ||
4136 | the receiver has not yet confirmed the authenticity of the sender, it also | ||
4137 | sends an (encrypted)@code{PingMessage} with a challenge (and the identity of | ||
4138 | the target) to the other peer. Peers receiving a @code{PingMessage} respond | ||
4139 | with an (encrypted) @code{PongMessage} which includes the challenge. Peers | ||
4140 | receiving a @code{PongMessage} check the challenge, and if it matches set the | ||
4141 | connection to @code{KX_STATE_UP}. | ||
4142 | |||
4143 | @node Encryption and Decryption | ||
4144 | @subsubsection Encryption and Decryption | ||
4145 | @c %**end of header | ||
4146 | |||
4147 | All functions related to the key exchange and encryption/decryption of | ||
4148 | messages can be found in @code{gnunet-service-core_kx.c} (except for the | ||
4149 | cryptographic primitives, which are in @code{util/crypto*.c}).@ Given the key | ||
4150 | material from ECDHE, a | ||
4151 | @uref{http://en.wikipedia.org/wiki/Key_derivation_function, Key derivation | ||
4152 | function} is used to derive two pairs of encryption and decryption keys for | ||
4153 | AES-256 and TwoFish, as well as initialization vectors and authentication keys | ||
4154 | (for @uref{http://en.wikipedia.org/wiki/HMAC, HMAC}). The HMAC is computed | ||
4155 | over the encrypted payload. Encrypted messages include an iv_seed and the HMAC | ||
4156 | in the header. | ||
4157 | |||
4158 | Each encrypted message in the CORE service includes a sequence number and a | ||
4159 | timestamp in the encrypted payload. The CORE service remembers the largest | ||
4160 | observed sequence number and a bit-mask which represents which of the previous | ||
4161 | 32 sequence numbers were already used. Messages with sequence numbers lower | ||
4162 | than the largest observed sequence number minus 32 are discarded. Messages | ||
4163 | with a timestamp that is less than @code{REKEY_TOLERANCE} off (5 minutes) are | ||
4164 | also discarded. This of course means that system clocks need to be reasonably | ||
4165 | synchronized for peers to be able to communicate. Additionally, as the | ||
4166 | ephemeral key changes every 12h, a peer would not even be able to decrypt | ||
4167 | messages older than 12h. | ||
4168 | |||
4169 | @node Type maps | ||
4170 | @subsubsection Type maps | ||
4171 | @c %**end of header | ||
4172 | |||
4173 | Once an encrypted connection has been established, peers begin to exchange | ||
4174 | type maps. Type maps are used to allow the CORE service to determine which | ||
4175 | (encrypted) connections should be shown to which applications. A type map is | ||
4176 | an array of 65536 bits representing the different types of messages understood | ||
4177 | by applications using the CORE service. Each CORE service maintains this map, | ||
4178 | simply by setting the respective bit for each message type supported by any of | ||
4179 | the applications using the CORE service. Note that bits for message types | ||
4180 | embedded in higher-level protocols (such as MESH) will not be included in | ||
4181 | these type maps. | ||
4182 | |||
4183 | Typically, the type map of a peer will be sparse. Thus, the CORE service | ||
4184 | attempts to compress its type map using @code{gzip}-style compression | ||
4185 | ("deflate") prior to transmission. However, if the compression fails to | ||
4186 | compact the map, the map may also be transmitted without compression | ||
4187 | (resulting in @code{GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP} or | ||
4188 | @code{GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP} messages respectively). Upon | ||
4189 | receiving a type map, the respective CORE service notifies applications about | ||
4190 | the connection to the other peer if they support any message type indicated in | ||
4191 | the type map (or no message type at all). If the CORE service experience a | ||
4192 | connect or disconnect event from an application, it updates its type map | ||
4193 | (setting or unsetting the respective bits) and notifies its neighbours about | ||
4194 | the change. The CORE services of the neighbours then in turn generate connect | ||
4195 | and disconnect events for the peer that sent the type map for their respective | ||
4196 | applications. As CORE messages may be lost, the CORE service confirms | ||
4197 | receiving a type map by sending back a | ||
4198 | @code{GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP}. If such a confirmation (with | ||
4199 | the correct hash of the type map) is not received, the sender will retransmit | ||
4200 | the type map (with exponential back-off). | ||
4201 | |||
4202 | @node GNUnet's CADET subsystem | ||
4203 | @section GNUnet's CADET subsystem | ||
4204 | |||
4205 | The CADET subsystem in GNUnet is responsible for secure end-to-end | ||
4206 | communications between nodes in the GNUnet overlay network. CADET builds on the | ||
4207 | CORE subsystem which provides for the link-layer communication and then adds | ||
4208 | routing, forwarding and additional security to the connections. CADET offers | ||
4209 | the same cryptographic services as CORE, but on an end-to-end level. This is | ||
4210 | done so peers retransmitting traffic on behalf of other peers cannot access the | ||
4211 | payload data. | ||
4212 | |||
4213 | @itemize @bullet | ||
4214 | @item CADET provides confidentiality with so-called perfect forward secrecy; we | ||
4215 | use ECDHE powered by Curve25519 for the key exchange and then use symmetric | ||
4216 | encryption, encrypting with both AES-256 and Twofish | ||
4217 | @item authentication is achieved by signing the ephemeral keys using Ed25519, a | ||
4218 | deterministic variant of ECDSA | ||
4219 | @item integrity protection (using SHA-512 to do encrypt-then-MAC, although only | ||
4220 | 256 bits are sent to reduce overhead) | ||
4221 | @item replay protection (using nonces, timestamps, challenge-response, message | ||
4222 | counters and ephemeral keys) | ||
4223 | @item liveness (keep-alive messages, timeout) | ||
4224 | @end itemize | ||
4225 | |||
4226 | Additional to the CORE-like security benefits, CADET offers other properties | ||
4227 | that make it a more universal service than CORE. | ||
4228 | |||
4229 | @itemize @bullet | ||
4230 | @item CADET can establish channels to arbitrary peers in GNUnet. If a peer is | ||
4231 | not immediately reachable, CADET will find a path through the network and ask | ||
4232 | other peers to retransmit the traffic on its behalf. | ||
4233 | @item CADET offers (optional) reliability mechanisms. In a reliable channel | ||
4234 | traffic is guaranteed to arrive complete, unchanged and in-order. | ||
4235 | @item CADET takes care of flow and congestion control mechanisms, not allowing | ||
4236 | the sender to send more traffic than the receiver or the network are able to | ||
4237 | process. | ||
4238 | @end itemize | ||
4239 | |||
4240 | @menu | ||
4241 | * libgnunetcadet:: | ||
4242 | @end menu | ||
4243 | |||
4244 | @node libgnunetcadet | ||
4245 | @subsection libgnunetcadet | ||
4246 | |||
4247 | |||
4248 | The CADET API (defined in gnunet_cadet_service.h) is the messaging API used by | ||
4249 | P2P applications built using GNUnet. It provides applications the ability to | ||
4250 | send and receive encrypted messages to any peer participating in GNUnet. The | ||
4251 | API is heavily base on the CORE API. | ||
4252 | |||
4253 | CADET delivers messages to other peers in "channels". A channel is a permanent | ||
4254 | connection defined by a destination peer (identified by its public key) and a | ||
4255 | port number. Internally, CADET tunnels all channels towards a destiantion peer | ||
4256 | using one session key and relays the data on multiple "connections", | ||
4257 | independent from the channels. | ||
4258 | |||
4259 | Each channel has optional paramenters, the most important being the reliability | ||
4260 | flag. Should a message get lost on TRANSPORT/CORE level, if a channel is | ||
4261 | created with as reliable, CADET will retransmit the lost message and deliver it | ||
4262 | in order to the destination application. | ||
4263 | |||
4264 | To communicate with other peers using CADET, it is necessary to first connect | ||
4265 | to the service using @code{GNUNET_CADET_connect}. This function takes several | ||
4266 | parameters in form of callbacks, to allow the client to react to various | ||
4267 | events, like incoming channels or channels that terminate, as well as specify a | ||
4268 | list of ports the client wishes to listen to (at the moment it is not possible | ||
4269 | to start listening on further ports once connected, but nothing prevents a | ||
4270 | client to connect several times to CADET, even do one connection per listening | ||
4271 | port). The function returns a handle which has to be used for any further | ||
4272 | interaction with the service. | ||
4273 | |||
4274 | To connect to a remote peer a client has to call the | ||
4275 | @code{GNUNET_CADET_channel_create} function. The most important parameters | ||
4276 | given are the remote peer's identity (it public key) and a port, which | ||
4277 | specifies which application on the remote peer to connect to, similar to | ||
4278 | TCP/UDP ports. CADET will then find the peer in the GNUnet network and | ||
4279 | establish the proper low-level connections and do the necessary key exchanges | ||
4280 | to assure and authenticated, secure and verified communication. Similar to | ||
4281 | @code{GNUNET_CADET_connect},@code{GNUNET_CADET_create_channel} returns a handle | ||
4282 | to interact with the created channel. | ||
4283 | |||
4284 | For every message the client wants to send to the remote application, | ||
4285 | @code{GNUNET_CADET_notify_transmit_ready} must be called, indicating the | ||
4286 | channel on which the message should be sent and the size of the message (but | ||
4287 | not the message itself!). Once CADET is ready to send the message, the provided | ||
4288 | callback will fire, and the message contents are provided to this callback. | ||
4289 | |||
4290 | Please note the CADET does not provide an explicit notification of when a | ||
4291 | channel is connected. In loosely connected networks, like big wireless mesh | ||
4292 | networks, this can take several seconds, even minutes in the worst case. To be | ||
4293 | alerted when a channel is online, a client can call | ||
4294 | @code{GNUNET_CADET_notify_transmit_ready} immediately after | ||
4295 | @code{GNUNET_CADET_create_channel}. When the callback is activated, it means | ||
4296 | that the channel is online. The callback can give 0 bytes to CADET if no | ||
4297 | message is to be sent, this is ok. | ||
4298 | |||
4299 | If a transmission was requested but before the callback fires it is no longer | ||
4300 | needed, it can be cancelled with | ||
4301 | @code{GNUNET_CADET_notify_transmit_ready_cancel}, which uses the handle given | ||
4302 | back by @code{GNUNET_CADET_notify_transmit_ready}. As in the case of CORE, only | ||
4303 | one message can be requested at a time: a client must not call | ||
4304 | @code{GNUNET_CADET_notify_transmit_ready} again until the callback is called or | ||
4305 | the request is cancelled. | ||
4306 | |||
4307 | When a channel is no longer needed, a client can call | ||
4308 | @code{GNUNET_CADET_channel_destroy} to get rid of it. Note that CADET will try | ||
4309 | to transmit all pending traffic before notifying the remote peer of the | ||
4310 | destruction of the channel, including retransmitting lost messages if the | ||
4311 | channel was reliable. | ||
4312 | |||
4313 | Incoming channels, channels being closed by the remote peer, and traffic on any | ||
4314 | incoming or outgoing channels are given to the client when CADET executes the | ||
4315 | callbacks given to it at the time of @code{GNUNET_CADET_connect}. | ||
4316 | |||
4317 | Finally, when an application no longer wants to use CADET, it should call | ||
4318 | @code{GNUNET_CADET_disconnect}, but first all channels and pending | ||
4319 | transmissions must be closed (otherwise CADET will complain). | ||
4320 | |||
4321 | @node GNUnet's NSE subsystem | ||
4322 | @section GNUnet's NSE subsystem | ||
4323 | |||
4324 | |||
4325 | NSE stands for Network Size Estimation. The NSE subsystem provides other | ||
4326 | subsystems and users with a rough estimate of the number of peers currently | ||
4327 | participating in the GNUnet overlay. The computed value is not a precise number | ||
4328 | as producing a precise number in a decentralized, efficient and secure way is | ||
4329 | impossible. While NSE's estimate is inherently imprecise, NSE also gives the | ||
4330 | expected range. For a peer that has been running in a stable network for a | ||
4331 | while, the real network size will typically (99.7% of the time) be in the range | ||
4332 | of [2/3 estimate, 3/2 estimate]. We will now give an overview of the algorithm | ||
4333 | used to calcualte the estimate; all of the details can be found in this | ||
4334 | technical report. | ||
4335 | |||
4336 | @menu | ||
4337 | * Motivation:: | ||
4338 | * Principle:: | ||
4339 | * libgnunetnse:: | ||
4340 | * The NSE Client-Service Protocol:: | ||
4341 | * The NSE Peer-to-Peer Protocol:: | ||
4342 | @end menu | ||
4343 | |||
4344 | @node Motivation | ||
4345 | @subsection Motivation | ||
4346 | |||
4347 | |||
4348 | Some subsytems, like DHT, need to know the size of the GNUnet network to | ||
4349 | optimize some parameters of their own protocol. The decentralized nature of | ||
4350 | GNUnet makes efficient and securely counting the exact number of peers | ||
4351 | infeasable. Although there are several decentralized algorithms to count the | ||
4352 | number of peers in a system, so far there is none to do so securely. Other | ||
4353 | protocols may allow any malicious peer to manipulate the final result or to | ||
4354 | take advantage of the system to perform DoS (Denial of Service) attacks against | ||
4355 | the network. GNUnet's NSE protocol avoids these drawbacks. | ||
4356 | |||
4357 | |||
4358 | |||
4359 | @menu | ||
4360 | * Security:: | ||
4361 | @end menu | ||
4362 | |||
4363 | @node Security | ||
4364 | @subsubsection Security | ||
4365 | |||
4366 | |||
4367 | The NSE subsystem is designed to be resilient against these attacks. It uses | ||
4368 | @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proofs of work} to | ||
4369 | prevent one peer from impersonating a large number of participants, which would | ||
4370 | otherwise allow an adversary to artifically inflate the estimate. The DoS | ||
4371 | protection comes from the time-based nature of the protocol: the estimates are | ||
4372 | calculated periodically and out-of-time traffic is either ignored or stored for | ||
4373 | later retransmission by benign peers. In particular, peers cannot trigger | ||
4374 | global network communication at will. | ||
4375 | |||
4376 | @node Principle | ||
4377 | @subsection Principle | ||
4378 | |||
4379 | |||
4380 | The algorithm calculates the estimate by finding the globally closest peer ID | ||
4381 | to a random, time-based value. | ||
4382 | |||
4383 | The idea is that the closer the ID is to the random value, the more "densely | ||
4384 | packed" the ID space is, and therefore, more peers are in the network. | ||
4385 | |||
4386 | |||
4387 | |||
4388 | @menu | ||
4389 | * Example:: | ||
4390 | * Algorithm:: | ||
4391 | * Target value:: | ||
4392 | * Timing:: | ||
4393 | * Controlled Flooding:: | ||
4394 | * Calculating the estimate:: | ||
4395 | @end menu | ||
4396 | |||
4397 | @node Example | ||
4398 | @subsubsection Example | ||
4399 | |||
4400 | |||
4401 | Suppose all peers have IDs between 0 and 100 (our ID space), and the random | ||
4402 | value is 42. If the closest peer has the ID 70 we can imagine that the average | ||
4403 | "distance" between peers is around 30 and therefore the are around 3 peers in | ||
4404 | the whole ID space. On the other hand, if the closest peer has the ID 44, we | ||
4405 | can imagine that the space is rather packed with peers, maybe as much as 50 of | ||
4406 | them. Naturally, we could have been rather unlucky, and there is only one peer | ||
4407 | and happens to have the ID 44. Thus, the current estimate is calculated as the | ||
4408 | average over multiple rounds, and not just a single sample. | ||
4409 | |||
4410 | @node Algorithm | ||
4411 | @subsubsection Algorithm | ||
4412 | |||
4413 | |||
4414 | Given that example, one can imagine that the job of the subsystem is to | ||
4415 | efficiently communicate the ID of the closest peer to the target value to all | ||
4416 | the other peers, who will calculate the estimate from it. | ||
4417 | |||
4418 | @node Target value | ||
4419 | @subsubsection Target value | ||
4420 | |||
4421 | @c %**end of header | ||
4422 | |||
4423 | The target value itself is generated by hashing the current time, rounded down | ||
4424 | to an agreed value. If the rounding amount is 1h (default) and the time is | ||
4425 | 12:34:56, the time to hash would be 12:00:00. The process is repeated each | ||
4426 | rouning amount (in this example would be every hour). Every repetition is | ||
4427 | called a round. | ||
4428 | |||
4429 | @node Timing | ||
4430 | @subsubsection Timing | ||
4431 | @c %**end of header | ||
4432 | |||
4433 | The NSE subsystem has some timing control to avoid everybody broadcasting its | ||
4434 | ID all at one. Once each peer has the target random value, it compares its own | ||
4435 | ID to the target and calculates the hypothetical size of the network if that | ||
4436 | peer were to be the closest. Then it compares the hypothetical size with the | ||
4437 | estimate from the previous rounds. For each value there is an assiciated point | ||
4438 | in the period, let's call it "broadcast time". If its own hypothetical estimate | ||
4439 | is the same as the previous global estimate, its "broadcast time" will be in | ||
4440 | the middle of the round. If its bigger it will be earlier and if its smaler | ||
4441 | (the most likely case) it will be later. This ensures that the peers closests | ||
4442 | to the target value start broadcasting their ID the first. | ||
4443 | |||
4444 | @node Controlled Flooding | ||
4445 | @subsubsection Controlled Flooding | ||
4446 | |||
4447 | @c %**end of header | ||
4448 | |||
4449 | When a peer receives a value, first it verifies that it is closer than the | ||
4450 | closest value it had so far, otherwise it answers the incoming message with a | ||
4451 | message containing the better value. Then it checks a proof of work that must | ||
4452 | be included in the incoming message, to ensure that the other peer's ID is not | ||
4453 | made up (otherwise a malicious peer could claim to have an ID of exactly the | ||
4454 | target value every round). Once validated, it compares the brodcast time of the | ||
4455 | received value with the current time and if it's not too early, sends the | ||
4456 | received value to its neighbors. Otherwise it stores the value until the | ||
4457 | correct broadcast time comes. This prevents unnecessary traffic of sub-optimal | ||
4458 | values, since a better value can come before the broadcast time, rendering the | ||
4459 | previous one obsolete and saving the traffic that would have been used to | ||
4460 | broadcast it to the neighbors. | ||
4461 | |||
4462 | @node Calculating the estimate | ||
4463 | @subsubsection Calculating the estimate | ||
4464 | |||
4465 | @c %**end of header | ||
4466 | |||
4467 | Once the closest ID has been spread across the network each peer gets the exact | ||
4468 | distance betweed this ID and the target value of the round and calculates the | ||
4469 | estimate with a mathematical formula described in the tech report. The estimate | ||
4470 | generated with this method for a single round is not very precise. Remember the | ||
4471 | case of the example, where the only peer is the ID 44 and we happen to generate | ||
4472 | the target value 42, thinking there are 50 peers in the network. Therefore, the | ||
4473 | NSE subsystem remembers the last 64 estimates and calculates an average over | ||
4474 | them, giving a result of which usually has one bit of uncertainty (the real | ||
4475 | size could be half of the estimate or twice as much). Note that the actual | ||
4476 | network size is calculated in powers of two of the raw input, thus one bit of | ||
4477 | uncertainty means a factor of two in the size estimate. | ||
4478 | |||
4479 | @node libgnunetnse | ||
4480 | @subsection libgnunetnse | ||
4481 | |||
4482 | @c %**end of header | ||
4483 | |||
4484 | The NSE subsystem has the simplest API of all services, with only two calls: | ||
4485 | @code{GNUNET_NSE_connect} and @code{GNUNET_NSE_disconnect}. | ||
4486 | |||
4487 | The connect call gets a callback function as a parameter and this function is | ||
4488 | called each time the network agrees on an estimate. This usually is once per | ||
4489 | round, with some exceptions: if the closest peer has a late local clock and | ||
4490 | starts spreading his ID after everyone else agreed on a value, the callback | ||
4491 | might be activated twice in a round, the second value being always bigger than | ||
4492 | the first. The default round time is set to 1 hour. | ||
4493 | |||
4494 | The disconnect call disconnects from the NSE subsystem and the callback is no | ||
4495 | longer called with new estimates. | ||
4496 | |||
4497 | |||
4498 | |||
4499 | @menu | ||
4500 | * Results:: | ||
4501 | * Examples2:: | ||
4502 | @end menu | ||
4503 | |||
4504 | @node Results | ||
4505 | @subsubsection Results | ||
4506 | |||
4507 | @c %**end of header | ||
4508 | |||
4509 | The callback provides two values: the average and the | ||
4510 | @uref{http://en.wikipedia.org/wiki/Standard_deviation, standard deviation} of | ||
4511 | the last 64 rounds. The values provided by the callback function are | ||
4512 | logarithmic, this means that the real estimate numbers can be obtained by | ||
4513 | calculating 2 to the power of the given value (2average). From a statistics | ||
4514 | point of view this means that: | ||
4515 | |||
4516 | @itemize @bullet | ||
4517 | @item 68% of the time the real size is included in the interval | ||
4518 | [(2average-stddev), 2] | ||
4519 | @item 95% of the time the real size is included in the interval | ||
4520 | [(2average-2*stddev, 2^average+2*stddev] | ||
4521 | @item 99.7% of the time the real size is included in the interval | ||
4522 | [(2average-3*stddev, 2average+3*stddev] | ||
4523 | @end itemize | ||
4524 | |||
4525 | The expected standard variation for 64 rounds in a network of stable size is | ||
4526 | 0.2. Thus, we can say that normally: | ||
4527 | |||
4528 | @itemize @bullet | ||
4529 | @item 68% of the time the real size is in the range [-13%, +15%] | ||
4530 | @item 95% of the time the real size is in the range [-24%, +32%] | ||
4531 | @item 99.7% of the time the real size is in the range [-34%, +52%] | ||
4532 | @end itemize | ||
4533 | |||
4534 | As said in the introduction, we can be quite sure that usually the real size is | ||
4535 | between one third and three times the estimate. This can of course vary with | ||
4536 | network conditions. Thus, applications may want to also consider the provided | ||
4537 | standard deviation value, not only the average (in particular, if the standard | ||
4538 | veriation is very high, the average maybe meaningless: the network size is | ||
4539 | changing rapidly). | ||
4540 | |||
4541 | @node Examples2 | ||
4542 | @subsubsection Examples2 | ||
4543 | |||
4544 | @c %**end of header | ||
4545 | |||
4546 | Let's close with a couple examples. | ||
4547 | |||
4548 | @table @asis | ||
4549 | |||
4550 | @item Average: 10, std dev: 1 Here the estimate would be 2^10 = 1024 peers.@ | ||
4551 | The range in which we can be 95% sure is: [2^8, 2^12] = [256, 4096]. We can be | ||
4552 | very (>99.7%) sure that the network is not a hundred peers and absolutely sure | ||
4553 | that it is not a million peers, but somewhere around a thousand. | ||
4554 | |||
4555 | @item Average 22, std dev: 0.2 Here the estimate would be 2^22 = 4 Million peers.@ | ||
4556 | The range in which we can be 99.7% sure is: [2^21.4, 2^22.6] = [2.8M, 6.3M]. | ||
4557 | We can be sure that the network size is around four million, with absolutely | ||
4558 | way of it being 1 million. | ||
4559 | |||
4560 | @end table | ||
4561 | |||
4562 | To put this in perspective, if someone remembers the LHC Higgs boson results, | ||
4563 | were announced with "5 sigma" and "6 sigma" certainties. In this case a 5 sigma | ||
4564 | minimum would be 2 million and a 6 sigma minimum, 1.8 million. | ||
4565 | |||
4566 | @node The NSE Client-Service Protocol | ||
4567 | @subsection The NSE Client-Service Protocol | ||
4568 | |||
4569 | @c %**end of header | ||
4570 | |||
4571 | As with the API, the client-service protocol is very simple, only has 2 | ||
4572 | different messages, defined in @code{src/nse/nse.h}: | ||
4573 | |||
4574 | @itemize @bullet | ||
4575 | @item @code{GNUNET_MESSAGE_TYPE_NSE_START}@ This message has no parameters and | ||
4576 | is sent from the client to the service upon connection. | ||
4577 | @item @code{GNUNET_MESSAGE_TYPE_NSE_ESTIMATE}@ This message is sent from the | ||
4578 | service to the client for every new estimate and upon connection. Contains a | ||
4579 | timestamp for the estimate, the average and the standard deviation for the | ||
4580 | respective round. | ||
4581 | @end itemize | ||
4582 | |||
4583 | When the @code{GNUNET_NSE_disconnect} API call is executed, the client simply | ||
4584 | disconnects from the service, with no message involved. | ||
4585 | |||
4586 | @node The NSE Peer-to-Peer Protocol | ||
4587 | @subsection The NSE Peer-to-Peer Protocol | ||
4588 | |||
4589 | @c %**end of header | ||
4590 | |||
4591 | The NSE subsystem only has one message in the P2P protocol, the | ||
4592 | @code{GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD} message. | ||
4593 | |||
4594 | This message key contents are the timestamp to identify the round (differences | ||
4595 | in system clocks may cause some peers to send messages way too early or way too | ||
4596 | late, so the timestamp allows other peers to identify such messages easily), | ||
4597 | the @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proof of work} | ||
4598 | used to make it difficult to mount a | ||
4599 | @uref{http://en.wikipedia.org/wiki/Sybil_attack, Sybil attack}, and the public | ||
4600 | key, which is used to verify the signature on the message. | ||
4601 | |||
4602 | Every peer stores a message for the previous, current and next round. The | ||
4603 | messages for the previous and current round are given to peers that connect to | ||
4604 | us. The message for the next round is simply stored until our system clock | ||
4605 | advances to the next round. The message for the current round is what we are | ||
4606 | flooding the network with right now. At the beginning of each round the peer | ||
4607 | does the following: | ||
4608 | |||
4609 | @itemize @bullet | ||
4610 | @item calculates his own distance to the target value | ||
4611 | @item creates, signs and stores the message for the current round (unless it | ||
4612 | has a better message in the "next round" slot which came early in the previous | ||
4613 | round) | ||
4614 | @item calculates, based on the stored round message (own or received) when to | ||
4615 | stard flooding it to its neighbors | ||
4616 | @end itemize | ||
4617 | |||
4618 | Upon receiving a message the peer checks the validity of the message (round, | ||
4619 | proof of work, signature). The next action depends on the contents of the | ||
4620 | incoming message: | ||
4621 | |||
4622 | @itemize @bullet | ||
4623 | @item if the message is worse than the current stored message, the peer sends | ||
4624 | the current message back immediately, to stop the other peer from spreading | ||
4625 | suboptimal results | ||
4626 | @item if the message is better than the current stored message, the peer stores | ||
4627 | the new message and calculates the new target time to start spreading it to its | ||
4628 | neighbors (excluding the one the message came from) | ||
4629 | @item if the message is for the previous round, it is compared to the message | ||
4630 | stored in the "previous round slot", which may then be updated | ||
4631 | @item if the message is for the next round, it is compared to the message | ||
4632 | stored in the "next round slot", which again may then be updated | ||
4633 | @end itemize | ||
4634 | |||
4635 | Finally, when it comes to send the stored message for the current round to the | ||
4636 | neighbors there is a random delay added for each neighbor, to avoid traffic | ||
4637 | spikes and minimize cross-messages. | ||
4638 | |||
4639 | @node GNUnet's HOSTLIST subsystem | ||
4640 | @section GNUnet's HOSTLIST subsystem | ||
4641 | |||
4642 | @c %**end of header | ||
4643 | |||
4644 | Peers in the GNUnet overlay network need address information so that they can | ||
4645 | connect with other peers. GNUnet uses so called HELLO messages to store and | ||
4646 | exchange peer addresses. GNUnet provides several methods for peers to obtain | ||
4647 | this information: | ||
4648 | |||
4649 | @itemize @bullet | ||
4650 | @item out-of-band exchange of HELLO messages (manually, using for example | ||
4651 | gnunet-peerinfo) | ||
4652 | @item HELLO messages shipped with GNUnet (automatic with distribution) | ||
4653 | @item UDP neighbor discovery in LAN (IPv4 broadcast, IPv6 multicast) | ||
4654 | @item topology gossiping (learning from other peers we already connected to), | ||
4655 | and | ||
4656 | @item the HOSTLIST daemon covered in this section, which is particularly | ||
4657 | relevant for bootstrapping new peers. | ||
4658 | @end itemize | ||
4659 | |||
4660 | New peers have no existing connections (and thus cannot learn from gossip among | ||
4661 | peers), may not have other peers in their LAN and might be started with an | ||
4662 | outdated set of HELLO messages from the distribution. In this case, getting new | ||
4663 | peers to connect to the network requires either manual effort or the use of a | ||
4664 | HOSTLIST to obtain HELLOs. | ||
4665 | |||
4666 | @menu | ||
4667 | * HELLOs:: | ||
4668 | * Overview for the HOSTLIST subsystem:: | ||
4669 | * Interacting with the HOSTLIST daemon:: | ||
4670 | * Hostlist security address validation:: | ||
4671 | * The HOSTLIST daemon:: | ||
4672 | * The HOSTLIST server:: | ||
4673 | * The HOSTLIST client:: | ||
4674 | * Usage:: | ||
4675 | @end menu | ||
4676 | |||
4677 | @node HELLOs | ||
4678 | @subsection HELLOs | ||
4679 | |||
4680 | @c %**end of header | ||
4681 | |||
4682 | The basic information peers require to connect to other peers are contained in | ||
4683 | so called HELLO messages you can think of as a business card. Besides the | ||
4684 | identity of the peer (based on the cryptographic public key) a HELLO message | ||
4685 | may contain address information that specifies ways to contact a peer. By | ||
4686 | obtaining HELLO messages, a peer can learn how to contact other peers. | ||
4687 | |||
4688 | @node Overview for the HOSTLIST subsystem | ||
4689 | @subsection Overview for the HOSTLIST subsystem | ||
4690 | |||
4691 | @c %**end of header | ||
4692 | |||
4693 | The HOSTLIST subsystem provides a way to distribute and obtain contact | ||
4694 | information to connect to other peers using a simple HTTP GET request. It's | ||
4695 | implementation is split in three parts, the main file for the daemon itself | ||
4696 | (gnunet-daemon-hostlist.c), the HTTP client used to download peer information | ||
4697 | (hostlist-client.c) and the server component used to provide this information | ||
4698 | to other peers (hostlist-server.c). The server is basically a small HTTP web | ||
4699 | server (based on GNU libmicrohttpd) which provides a list of HELLOs known to | ||
4700 | the local peer for download. The client component is basically a HTTP client | ||
4701 | (based on libcurl) which can download hostlists from one or more websites. The | ||
4702 | hostlist format is a binary blob containing a sequence of HELLO messages. Note | ||
4703 | that any HTTP server can theoretically serve a hostlist, the build-in hostlist | ||
4704 | server makes it simply convenient to offer this service. | ||
4705 | |||
4706 | |||
4707 | @menu | ||
4708 | * Features:: | ||
4709 | * Limitations2:: | ||
4710 | @end menu | ||
4711 | |||
4712 | @node Features | ||
4713 | @subsubsection Features | ||
4714 | |||
4715 | @c %**end of header | ||
4716 | |||
4717 | The HOSTLIST daemon can: | ||
4718 | |||
4719 | @itemize @bullet | ||
4720 | @item provide HELLO messages with validated addresses obtained from PEERINFO to | ||
4721 | download for other peers | ||
4722 | @item download HELLO messages and forward these message to the TRANSPORT | ||
4723 | subsystem for validation | ||
4724 | @item advertises the URL of this peer's hostlist address to other peers via | ||
4725 | gossip | ||
4726 | @item automatically learn about hostlist servers from the gossip of other peers | ||
4727 | @end itemize | ||
4728 | |||
4729 | @node Limitations2 | ||
4730 | @subsubsection Limitations2 | ||
4731 | |||
4732 | @c %**end of header | ||
4733 | |||
4734 | The HOSTLIST daemon does not: | ||
4735 | |||
4736 | @itemize @bullet | ||
4737 | @item verify the cryptographic information in the HELLO messages | ||
4738 | @item verify the address information in the HELLO messages | ||
4739 | @end itemize | ||
4740 | |||
4741 | @node Interacting with the HOSTLIST daemon | ||
4742 | @subsection Interacting with the HOSTLIST daemon | ||
4743 | |||
4744 | @c %**end of header | ||
4745 | |||
4746 | The HOSTLIST subsystem is currently implemented as a daemon, so there is no | ||
4747 | need for the user to interact with it and therefore there is no command line | ||
4748 | tool and no API to communicate with the daemon. In the future, we can envision | ||
4749 | changing this to allow users to manually trigger the download of a hostlist. | ||
4750 | |||
4751 | Since there is no command line interface to interact with HOSTLIST, the only | ||
4752 | way to interact with the hostlist is to use STATISTICS to obtain or modify | ||
4753 | information about the status of HOSTLIST: | ||
4754 | @example | ||
4755 | $ gnunet-statistics -s hostlist | ||
4756 | @end example | ||
4757 | |||
4758 | In particular, HOSTLIST includes a @strong{persistent} value in statistics that | ||
4759 | specifies when the hostlist server might be queried next. As this value is | ||
4760 | exponentially increasing during runtime, developers may want to reset or | ||
4761 | manually adjust it. Note that HOSTLIST (but not STATISTICS) needs to be | ||
4762 | shutdown if changes to this value are to have any effect on the daemon (as | ||
4763 | HOSTLIST does not monitor STATISTICS for changes to the download | ||
4764 | frequency). | ||
4765 | |||
4766 | @node Hostlist security address validation | ||
4767 | @subsection Hostlist security address validation | ||
4768 | |||
4769 | @c %**end of header | ||
4770 | |||
4771 | Since information obtained from other parties cannot be trusted without | ||
4772 | validation, we have to distinguish between @emph{validated} and @emph{not | ||
4773 | validated} addresses. Before using (and so trusting) information from other | ||
4774 | parties, this information has to be double-checked (validated). Address | ||
4775 | validation is not done by HOSTLIST but by the TRANSPORT service. | ||
4776 | |||
4777 | The HOSTLIST component is functionally located between the PEERINFO and the | ||
4778 | TRANSPORT subsystem. When acting as a server, the daemon obtains valid | ||
4779 | (@emph{validated}) peer information (HELLO messages) from the PEERINFO service | ||
4780 | and provides it to other peers. When acting as a client, it contacts the | ||
4781 | HOSTLIST servers specified in the configuration, downloads the (unvalidated) | ||
4782 | list of HELLO messages and forwards these information to the TRANSPORT server | ||
4783 | to validate the addresses. | ||
4784 | |||
4785 | @node The HOSTLIST daemon | ||
4786 | @subsection The HOSTLIST daemon | ||
4787 | |||
4788 | @c %**end of header | ||
4789 | |||
4790 | The hostlist daemon is the main component of the HOSTLIST subsystem. It is | ||
4791 | started by the ARM service and (if configured) starts the HOSTLIST client and | ||
4792 | server components. | ||
4793 | |||
4794 | If the daemon provides a hostlist itself it can advertise it's own hostlist to | ||
4795 | other peers. To do so it sends a GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT | ||
4796 | message to other peers when they connect to this peer on the CORE level. This | ||
4797 | hostlist advertisement message contains the URL to access the HOSTLIST HTTP | ||
4798 | server of the sender. The daemon may also subscribe to this type of message | ||
4799 | from CORE service, and then forward these kind of message to the HOSTLIST | ||
4800 | client. The client then uses all available URLs to download peer information | ||
4801 | when necessary. | ||
4802 | |||
4803 | When starting, the HOSTLIST daemon first connects to the CORE subsystem and if | ||
4804 | hostlist learning is enabled, registers a CORE handler to receive this kind of | ||
4805 | messages. Next it starts (if configured) the client and server. It passes | ||
4806 | pointers to CORE connect and disconnect and receive handlers where the client | ||
4807 | and server store their functions, so the daemon can notify them about CORE | ||
4808 | events. | ||
4809 | |||
4810 | To clean up on shutdown, the daemon has a cleaning task, shutting down all | ||
4811 | subsystems and disconnecting from CORE. | ||
4812 | |||
4813 | @node The HOSTLIST server | ||
4814 | @subsection The HOSTLIST server | ||
4815 | |||
4816 | @c %**end of header | ||
4817 | |||
4818 | The server provides a way for other peers to obtain HELLOs. Basically it is a | ||
4819 | small web server other peers can connect to and download a list of HELLOs using | ||
4820 | standard HTTP; it may also advertise the URL of the hostlist to other peers | ||
4821 | connecting on CORE level. | ||
4822 | |||
4823 | |||
4824 | @menu | ||
4825 | * The HTTP Server:: | ||
4826 | * Advertising the URL:: | ||
4827 | @end menu | ||
4828 | |||
4829 | @node The HTTP Server | ||
4830 | @subsubsection The HTTP Server | ||
4831 | |||
4832 | @c %**end of header | ||
4833 | |||
4834 | During startup, the server starts a web server listening on the port specified | ||
4835 | with the HTTPPORT value (default 8080). In addition it connects to the PEERINFO | ||
4836 | service to obtain peer information. The HOSTLIST server uses the | ||
4837 | GNUNET_PEERINFO_iterate function to request HELLO information for all peers and | ||
4838 | adds their information to a new hostlist if they are suitable (expired | ||
4839 | addresses and HELLOs without addresses are both not suitable) and the maximum | ||
4840 | size for a hostlist is not exceeded (MAX_BYTES_PER_HOSTLISTS = 500000). When | ||
4841 | PEERINFO finishes (with a last NULL callback), the server destroys the previous | ||
4842 | hostlist response available for download on the web server and replaces it with | ||
4843 | the updated hostlist. The hostlist format is basically a sequence of HELLO | ||
4844 | messages (as obtained from PEERINFO) without any special tokenization. Since | ||
4845 | each HELLO message contains a size field, the response can easily be split into | ||
4846 | separate HELLO messages by the client. | ||
4847 | |||
4848 | A HOSTLIST client connecting to the HOSTLIST server will receive the hostlist | ||
4849 | as a HTTP response and the the server will terminate the connection with the | ||
4850 | result code HTTP 200 OK. The connection will be closed immediately if no | ||
4851 | hostlist is available. | ||
4852 | |||
4853 | @node Advertising the URL | ||
4854 | @subsubsection Advertising the URL | ||
4855 | |||
4856 | @c %**end of header | ||
4857 | |||
4858 | The server also advertises the URL to download the hostlist to other peers if | ||
4859 | hostlist advertisement is enabled. When a new peer connects and has hostlist | ||
4860 | learning enabled, the server sends a GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT | ||
4861 | message to this peer using the CORE service. | ||
4862 | |||
4863 | @node The HOSTLIST client | ||
4864 | @subsection The HOSTLIST client | ||
4865 | |||
4866 | @c %**end of header | ||
4867 | |||
4868 | The client provides the functionality to download the list of HELLOs from a set | ||
4869 | of URLs. It performs a standard HTTP request to the URLs configured and learned | ||
4870 | from advertisement messages received from other peers. When a HELLO is | ||
4871 | downloaded, the HOSTLIST client forwards the HELLO to the TRANSPORT service for | ||
4872 | validation. | ||
4873 | |||
4874 | The client supports two modes of operation: download of HELLOs (bootstrapping) | ||
4875 | and learning of URLs. | ||
4876 | |||
4877 | |||
4878 | @menu | ||
4879 | * Bootstrapping:: | ||
4880 | * Learning:: | ||
4881 | @end menu | ||
4882 | |||
4883 | @node Bootstrapping | ||
4884 | @subsubsection Bootstrapping | ||
4885 | |||
4886 | @c %**end of header | ||
4887 | |||
4888 | For bootstrapping, it schedules a task to download the hostlist from the set of | ||
4889 | known URLs. The downloads are only performed if the number of current | ||
4890 | connections is smaller than a minimum number of connections (at the moment 4). | ||
4891 | The interval between downloads increases exponentially; however, the | ||
4892 | exponential growth is limited if it becomes longer than an hour. At that point, | ||
4893 | the frequency growth is capped at (#number of connections * 1h). | ||
4894 | |||
4895 | Once the decision has been taken to download HELLOs, the daemon chooses a | ||
4896 | random URL from the list of known URLs. URLs can be configured in the | ||
4897 | configuration or be learned from advertisement messages. The client uses a HTTP | ||
4898 | client library (libcurl) to initiate the download using the libcurl multi | ||
4899 | interface. Libcurl passes the data to the callback_download function which | ||
4900 | stores the data in a buffer if space is available and the maximum size for a | ||
4901 | hostlist download is not exceeded (MAX_BYTES_PER_HOSTLISTS = 500000). When a | ||
4902 | full HELLO was downloaded, the HOSTLIST client offers this HELLO message to the | ||
4903 | TRANSPORT service for validation. When the download is finished or failed, | ||
4904 | statistical information about the quality of this URL is updated. | ||
4905 | |||
4906 | @node Learning | ||
4907 | @subsubsection Learning | ||
4908 | |||
4909 | @c %**end of header | ||
4910 | |||
4911 | The client also manages hostlist advertisements from other peers. The HOSTLIST | ||
4912 | daemon forwards GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT messages to the | ||
4913 | client subsystem, which extracts the URL from the message. Next, a test of the | ||
4914 | newly obtained URL is performed by triggering a download from the new URL. If | ||
4915 | the URL works correctly, it is added to the list of working URLs. | ||
4916 | |||
4917 | The size of the list of URLs is restricted, so if an additional server is added | ||
4918 | and the list is full, the URL with the worst quality ranking (determined | ||
4919 | through successful downloads and number of HELLOs e.g.) is discarded. During | ||
4920 | shutdown the list of URLs is saved to a file for persistance and loaded on | ||
4921 | startup. URLs from the configuration file are never discarded. | ||
4922 | |||
4923 | @node Usage | ||
4924 | @subsection Usage | ||
4925 | |||
4926 | @c %**end of header | ||
4927 | |||
4928 | To start HOSTLIST by default, it has to be added to the DEFAULTSERVICES section | ||
4929 | for the ARM services. This is done in the default configuration. | ||
4930 | |||
4931 | For more information on how to configure the HOSTLIST subsystem see the | ||
4932 | installation handbook:@ Configuring the hostlist to bootstrap@ Configuring your | ||
4933 | peer to provide a hostlist | ||
4934 | |||
4935 | @node GNUnet's IDENTITY subsystem | ||
4936 | @section GNUnet's IDENTITY subsystem | ||
4937 | |||
4938 | @c %**end of header | ||
4939 | |||
4940 | Identities of "users" in GNUnet are called egos. Egos can be used as pseudonyms | ||
4941 | (fake names) or be tied to an organization (for example, GNU) or even the | ||
4942 | actual identity of a human. GNUnet users are expected to have many egos. They | ||
4943 | might have one tied to their real identity, some for organizations they manage, | ||
4944 | and more for different domains where they want to operate under a pseudonym. | ||
4945 | |||
4946 | The IDENTITY service allows users to manage their egos. The identity service | ||
4947 | manages the private keys egos of the local user; it does not manage identities | ||
4948 | of other users (public keys). Public keys for other users need names to become | ||
4949 | manageable. GNUnet uses the GNU Name System (GNS) to give names to other users | ||
4950 | and manage their public keys securely. This chapter is about the IDENTITY | ||
4951 | service, which is about the management of private keys. | ||
4952 | |||
4953 | On the network, an ego corresponds to an ECDSA key (over Curve25519, using RFC | ||
4954 | 6979, as required by GNS). Thus, users can perform actions under a particular | ||
4955 | ego by using (signing with) a particular private key. Other users can then | ||
4956 | confirm that the action was really performed by that ego by checking the | ||
4957 | signature against the respective public key. | ||
4958 | |||
4959 | The IDENTITY service allows users to associate a human-readable name with each | ||
4960 | ego. This way, users can use names that will remind them of the purpose of a | ||
4961 | particular ego. The IDENTITY service will store the respective private keys and | ||
4962 | allows applications to access key information by name. Users can change the | ||
4963 | name that is locally (!) associated with an ego. Egos can also be deleted, | ||
4964 | which means that the private key will be removed and it thus will not be | ||
4965 | possible to perform actions with that ego in the future. | ||
4966 | |||
4967 | Additionally, the IDENTITY subsystem can associate service functions with egos. | ||
4968 | For example, GNS requires the ego that should be used for the shorten zone. GNS | ||
4969 | will ask IDENTITY for an ego for the "gns-short" service. The IDENTITY service | ||
4970 | has a mapping of such service strings to the name of the ego that the user | ||
4971 | wants to use for this service, for example "my-short-zone-ego". | ||
4972 | |||
4973 | Finally, the IDENTITY API provides access to a special ego, the anonymous ego. | ||
4974 | The anonymous ego is special in that its private key is not really private, but | ||
4975 | fixed and known to everyone. Thus, anyone can perform actions as anonymous. | ||
4976 | This can be useful as with this trick, code does not have to contain a special | ||
4977 | case to distinguish between anonymous and pseudonymous egos. | ||
4978 | |||
4979 | @menu | ||
4980 | * libgnunetidentity:: | ||
4981 | * The IDENTITY Client-Service Protocol:: | ||
4982 | @end menu | ||
4983 | |||
4984 | @node libgnunetidentity | ||
4985 | @subsection libgnunetidentity | ||
4986 | @c %**end of header | ||
4987 | |||
4988 | |||
4989 | @menu | ||
4990 | * Connecting to the service:: | ||
4991 | * Operations on Egos:: | ||
4992 | * The anonymous Ego:: | ||
4993 | * Convenience API to lookup a single ego:: | ||
4994 | * Associating egos with service functions:: | ||
4995 | @end menu | ||
4996 | |||
4997 | @node Connecting to the service | ||
4998 | @subsubsection Connecting to the service | ||
4999 | |||
5000 | @c %**end of header | ||
5001 | |||
5002 | First, typical clients connect to the identity service using | ||
5003 | @code{GNUNET_IDENTITY_connect}. This function takes a callback as a parameter. | ||
5004 | If the given callback parameter is non-null, it will be invoked to notify the | ||
5005 | application about the current state of the identities in the system. | ||
5006 | |||
5007 | @itemize @bullet | ||
5008 | @item First, it will be invoked on all known egos at the time of the | ||
5009 | connection. For each ego, a handle to the ego and the user's name for the ego | ||
5010 | will be passed to the callback. Furthermore, a @code{void **} context argument | ||
5011 | will be provided which gives the client the opportunity to associate some state | ||
5012 | with the ego. | ||
5013 | @item Second, the callback will be invoked with NULL for the ego, the name and | ||
5014 | the context. This signals that the (initial) iteration over all egos has | ||
5015 | completed. | ||
5016 | @item Then, the callback will be invoked whenever something changes about an | ||
5017 | ego. If an ego is renamed, the callback is invoked with the ego handle of the | ||
5018 | ego that was renamed, and the new name. If an ego is deleted, the callback is | ||
5019 | invoked with the ego handle and a name of NULL. In the deletion case, the | ||
5020 | application should also release resources stored in the context. | ||
5021 | @item When the application destroys the connection to the identity service | ||
5022 | using @code{GNUNET_IDENTITY_disconnect}, the callback is again invoked with the | ||
5023 | ego and a name of NULL (equivalent to deletion of the egos). This should again | ||
5024 | be used to clean up the per-ego context. | ||
5025 | @end itemize | ||
5026 | |||
5027 | The ego handle passed to the callback remains valid until the callback is | ||
5028 | invoked with a name of NULL, so it is safe to store a reference to the ego's | ||
5029 | handle. | ||
5030 | |||
5031 | @node Operations on Egos | ||
5032 | @subsubsection Operations on Egos | ||
5033 | |||
5034 | @c %**end of header | ||
5035 | |||
5036 | Given an ego handle, the main operations are to get its associated private key | ||
5037 | using @code{GNUNET_IDENTITY_ego_get_private_key} or its associated public key | ||
5038 | using @code{GNUNET_IDENTITY_ego_get_public_key}. | ||
5039 | |||
5040 | The other operations on egos are pretty straightforward. Using | ||
5041 | @code{GNUNET_IDENTITY_create}, an application can request the creation of an | ||
5042 | ego by specifying the desired name. The operation will fail if that name is | ||
5043 | already in use. Using @code{GNUNET_IDENTITY_rename} the name of an existing ego | ||
5044 | can be changed. Finally, egos can be deleted using | ||
5045 | @code{GNUNET_IDENTITY_delete}. All of these operations will trigger updates to | ||
5046 | the callback given to the @code{GNUNET_IDENTITY_connect} function of all | ||
5047 | applications that are connected with the identity service at the time. | ||
5048 | @code{GNUNET_IDENTITY_cancel} can be used to cancel the operations before the | ||
5049 | respective continuations would be called. It is not guaranteed that the | ||
5050 | operation will not be completed anyway, only the continuation will no longer be | ||
5051 | called. | ||
5052 | |||
5053 | @node The anonymous Ego | ||
5054 | @subsubsection The anonymous Ego | ||
5055 | |||
5056 | @c %**end of header | ||
5057 | |||
5058 | A special way to obtain an ego handle is to call | ||
5059 | @code{GNUNET_IDENTITY_ego_get_anonymous}, which returns an ego for the | ||
5060 | "anonymous" user --- anyone knows and can get the private key for this user, so | ||
5061 | it is suitable for operations that are supposed to be anonymous but require | ||
5062 | signatures (for example, to avoid a special path in the code). The anonymous | ||
5063 | ego is always valid and accessing it does not require a connection to the | ||
5064 | identity service. | ||
5065 | |||
5066 | @node Convenience API to lookup a single ego | ||
5067 | @subsubsection Convenience API to lookup a single ego | ||
5068 | |||
5069 | |||
5070 | As applications commonly simply have to lookup a single ego, there is a | ||
5071 | convenience API to do just that. Use @code{GNUNET_IDENTITY_ego_lookup} to | ||
5072 | lookup a single ego by name. Note that this is the user's name for the ego, not | ||
5073 | the service function. The resulting ego will be returned via a callback and | ||
5074 | will only be valid during that callback. The operation can be cancelled via | ||
5075 | @code{GNUNET_IDENTITY_ego_lookup_cancel} (cancellation is only legal before the | ||
5076 | callback is invoked). | ||
5077 | |||
5078 | @node Associating egos with service functions | ||
5079 | @subsubsection Associating egos with service functions | ||
5080 | |||
5081 | |||
5082 | The @code{GNUNET_IDENTITY_set} function is used to associate a particular ego | ||
5083 | with a service function. The name used by the service and the ego are given as | ||
5084 | arguments. Afterwards, the service can use its name to lookup the associated | ||
5085 | ego using @code{GNUNET_IDENTITY_get}. | ||
5086 | |||
5087 | @node The IDENTITY Client-Service Protocol | ||
5088 | @subsection The IDENTITY Client-Service Protocol | ||
5089 | |||
5090 | @c %**end of header | ||
5091 | |||
5092 | A client connecting to the identity service first sends a message with type | ||
5093 | @code{GNUNET_MESSAGE_TYPE_IDENTITY_START} to the service. After that, the | ||
5094 | client will receive information about changes to the egos by receiving messages | ||
5095 | of type @code{GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE}. Those messages contain the | ||
5096 | private key of the ego and the user's name of the ego (or zero bytes for the | ||
5097 | name to indicate that the ego was deleted). A special bit @code{end_of_list} is | ||
5098 | used to indicate the end of the initial iteration over the identity service's | ||
5099 | egos. | ||
5100 | |||
5101 | The client can trigger changes to the egos by sending CREATE, RENAME or DELETE | ||
5102 | messages. The CREATE message contains the private key and the desired name. The | ||
5103 | RENAME message contains the old name and the new name. The DELETE message only | ||
5104 | needs to include the name of the ego to delete. The service responds to each of | ||
5105 | these messages with a RESULT_CODE message which indicates success or error of | ||
5106 | the operation, and possibly a human-readable error message. | ||
5107 | |||
5108 | Finally, the client can bind the name of a service function to an ego by | ||
5109 | sending a SET_DEFAULT message with the name of the service function and the | ||
5110 | private key of the ego. Such bindings can then be resolved using a GET_DEFAULT | ||
5111 | message, which includes the name of the service function. The identity service | ||
5112 | will respond to a GET_DEFAULT request with a SET_DEFAULT message containing the | ||
5113 | respective information, or with a RESULT_CODE to indicate an error. | ||
5114 | |||
5115 | @node GNUnet's NAMESTORE Subsystem | ||
5116 | @section GNUnet's NAMESTORE Subsystem | ||
5117 | |||
5118 | @c %**end of header | ||
5119 | |||
5120 | The NAMESTORE subsystem provides persistent storage for local GNS zone | ||
5121 | information. All local GNS zone information are managed by NAMESTORE. It | ||
5122 | provides both the functionality to administer local GNS information (e.g. | ||
5123 | delete and add records) as well as to retrieve GNS information (e.g to list | ||
5124 | name information in a client). NAMESTORE does only manage the persistent | ||
5125 | storage of zone information belonging to the user running the service: GNS | ||
5126 | information from other users obtained from the DHT are stored by the NAMECACHE | ||
5127 | subsystem. | ||
5128 | |||
5129 | NAMESTORE uses a plugin-based database backend to store GNS information with | ||
5130 | good performance. Here sqlite, MySQL and PostgreSQL are supported database | ||
5131 | backends. NAMESTORE clients interact with the IDENTITY subsystem to obtain | ||
5132 | cryptographic information about zones based on egos as described with the | ||
5133 | IDENTITY subsystem., but internally NAMESTORE refers to zones using the ECDSA | ||
5134 | private key. In addition, it collaborates with the NAMECACHE subsystem and | ||
5135 | stores zone information when local information are modified in the GNS cache to | ||
5136 | increase look-up performance for local information. | ||
5137 | |||
5138 | NAMESTORE provides functionality to look-up and store records, to iterate over | ||
5139 | a specific or all zones and to monitor zones for changes. NAMESTORE | ||
5140 | functionality can be accessed using the NAMESTORE api or the NAMESTORE command | ||
5141 | line tool. | ||
5142 | |||
5143 | @menu | ||
5144 | * libgnunetnamestore:: | ||
5145 | @end menu | ||
5146 | |||
5147 | @node libgnunetnamestore | ||
5148 | @subsection libgnunetnamestore | ||
5149 | |||
5150 | @c %**end of header | ||
5151 | |||
5152 | To interact with NAMESTORE clients first connect to the NAMESTORE service using | ||
5153 | the @code{GNUNET_NAMESTORE_connect} passing a configuration handle. As a result | ||
5154 | they obtain a NAMESTORE handle, they can use for operations, or NULL is | ||
5155 | returned if the connection failed. | ||
5156 | |||
5157 | To disconnect from NAMESTORE, clients use @code{GNUNET_NAMESTORE_disconnect} | ||
5158 | and specify the handle to disconnect. | ||
5159 | |||
5160 | NAMESTORE internally uses the ECDSA private key to refer to zones. These | ||
5161 | private keys can be obtained from the IDENTITY subsytem. Here @emph{egos@emph{ | ||
5162 | can be used to refer to zones or the default ego assigned to the GNS subsystem | ||
5163 | can be used to obtained the master zone's private key.}} | ||
5164 | |||
5165 | |||
5166 | @menu | ||
5167 | * Editing Zone Information:: | ||
5168 | * Iterating Zone Information:: | ||
5169 | * Monitoring Zone Information:: | ||
5170 | @end menu | ||
5171 | |||
5172 | @node Editing Zone Information | ||
5173 | @subsubsection Editing Zone Information | ||
5174 | |||
5175 | @c %**end of header | ||
5176 | |||
5177 | NAMESTORE provides functions to lookup records stored under a label in a zone | ||
5178 | and to store records under a label in a zone. | ||
5179 | |||
5180 | To store (and delete) records, the client uses the | ||
5181 | @code{GNUNET_NAMESTORE_records_store} function and has to provide namestore | ||
5182 | handle to use, the private key of the zone, the label to store the records | ||
5183 | under, the records and number of records plus an callback function. After the | ||
5184 | operation is performed NAMESTORE will call the provided callback function with | ||
5185 | the result GNUNET_SYSERR on failure (including timeout/queue drop/failure to | ||
5186 | validate), GNUNET_NO if content was already there or not found GNUNET_YES (or | ||
5187 | other positive value) on success plus an additional error message. | ||
5188 | |||
5189 | Records are deleted by using the store command with 0 records to store. It is | ||
5190 | important to note, that records are not merged when records exist with the | ||
5191 | label. So a client has first to retrieve records, merge with existing records | ||
5192 | and then store the result. | ||
5193 | |||
5194 | To perform a lookup operation, the client uses the | ||
5195 | @code{GNUNET_NAMESTORE_records_store} function. Here he has to pass the | ||
5196 | namestore handle, the private key of the zone and the label. He also has to | ||
5197 | provide a callback function which will be called with the result of the lookup | ||
5198 | operation: the zone for the records, the label, and the records including the | ||
5199 | number of records included. | ||
5200 | |||
5201 | A special operation is used to set the preferred nickname for a zone. This | ||
5202 | nickname is stored with the zone and is automatically merged with all labels | ||
5203 | and records stored in a zone. Here the client uses the | ||
5204 | @code{GNUNET_NAMESTORE_set_nick} function and passes the private key of the | ||
5205 | zone, the nickname as string plus a the callback with the result of the | ||
5206 | operation. | ||
5207 | |||
5208 | @node Iterating Zone Information | ||
5209 | @subsubsection Iterating Zone Information | ||
5210 | |||
5211 | @c %**end of header | ||
5212 | |||
5213 | A client can iterate over all information in a zone or all zones managed by | ||
5214 | NAMESTORE. Here a client uses the @code{GNUNET_NAMESTORE_zone_iteration_start} | ||
5215 | function and passes the namestore handle, the zone to iterate over and a | ||
5216 | callback function to call with the result. If the client wants to iterate over | ||
5217 | all the, he passes NULL for the zone. A @code{GNUNET_NAMESTORE_ZoneIterator} | ||
5218 | handle is returned to be used to continue iteration. | ||
5219 | |||
5220 | NAMESTORE calls the callback for every result and expects the client to call@ | ||
5221 | @code{GNUNET_NAMESTORE_zone_iterator_next} to continue to iterate or | ||
5222 | @code{GNUNET_NAMESTORE_zone_iterator_stop} to interrupt the iteration. When | ||
5223 | NAMESTORE reached the last item it will call the callback with a NULL value to | ||
5224 | indicate. | ||
5225 | |||
5226 | @node Monitoring Zone Information | ||
5227 | @subsubsection Monitoring Zone Information | ||
5228 | |||
5229 | @c %**end of header | ||
5230 | |||
5231 | Clients can also monitor zones to be notified about changes. Here the clients | ||
5232 | uses the @code{GNUNET_NAMESTORE_zone_monitor_start} function and passes the | ||
5233 | private key of the zone and and a callback function to call with updates for a | ||
5234 | zone. The client can specify to obtain zone information first by iterating over | ||
5235 | the zone and specify a synchronization callback to be called when the client | ||
5236 | and the namestore are synced. | ||
5237 | |||
5238 | On an update, NAMESTORE will call the callback with the private key of the | ||
5239 | zone, the label and the records and their number. | ||
5240 | |||
5241 | To stop monitoring, the client call @code{GNUNET_NAMESTORE_zone_monitor_stop} | ||
5242 | and passes the handle obtained from the function to start the monitoring. | ||
5243 | |||
5244 | @node GNUnet's PEERINFO subsystem | ||
5245 | @section GNUnet's PEERINFO subsystem | ||
5246 | |||
5247 | @c %**end of header | ||
5248 | |||
5249 | The PEERINFO subsystem is used to store verified (validated) information about | ||
5250 | known peers in a persistent way. It obtains these addresses for example from | ||
5251 | TRANSPORT service which is in charge of address validation. Validation means | ||
5252 | that the information in the HELLO message are checked by connecting to the | ||
5253 | addresses and performing a cryptographic handshake to authenticate the peer | ||
5254 | instance stating to be reachable with these addresses. Peerinfo does not | ||
5255 | validate the HELLO messages itself but only stores them and gives them to | ||
5256 | interested clients. | ||
5257 | |||
5258 | As future work, we think about moving from storing just HELLO messages to | ||
5259 | providing a generic persistent per-peer information store. More and more | ||
5260 | subsystems tend to need to store per-peer information in persistent way. To not | ||
5261 | duplicate this functionality we plan to provide a PEERSTORE service providing | ||
5262 | this functionality | ||
5263 | |||
5264 | @menu | ||
5265 | * Features2:: | ||
5266 | * Limitations3:: | ||
5267 | * DeveloperPeer Information:: | ||
5268 | * Startup:: | ||
5269 | * Managing Information:: | ||
5270 | * Obtaining Information:: | ||
5271 | * The PEERINFO Client-Service Protocol:: | ||
5272 | * libgnunetpeerinfo:: | ||
5273 | @end menu | ||
5274 | |||
5275 | @node Features2 | ||
5276 | @subsection Features2 | ||
5277 | |||
5278 | @c %**end of header | ||
5279 | |||
5280 | @itemize @bullet | ||
5281 | @item Persistent storage | ||
5282 | @item Client notification mechanism on update | ||
5283 | @item Periodic clean up for expired information | ||
5284 | @item Differentiation between public and friend-only HELLO | ||
5285 | @end itemize | ||
5286 | |||
5287 | @node Limitations3 | ||
5288 | @subsection Limitations3 | ||
5289 | |||
5290 | |||
5291 | @itemize @bullet | ||
5292 | @item Does not perform HELLO validation | ||
5293 | @end itemize | ||
5294 | |||
5295 | @node DeveloperPeer Information | ||
5296 | @subsection DeveloperPeer Information | ||
5297 | |||
5298 | @c %**end of header | ||
5299 | |||
5300 | The PEERINFO subsystem stores these information in the form of HELLO messages | ||
5301 | you can think of as business cards. These HELLO messages contain the public key | ||
5302 | of a peer and the addresses a peer can be reached under. The addresses include | ||
5303 | an expiration date describing how long they are valid. This information is | ||
5304 | updated regularly by the TRANSPORT service by revalidating the address. If an | ||
5305 | address is expired and not renewed, it can be removed from the HELLO message. | ||
5306 | |||
5307 | Some peer do not want to have their HELLO messages distributed to other peers , | ||
5308 | especially when GNUnet's friend-to-friend modus is enabled. To prevent this | ||
5309 | undesired distribution. PEERINFO distinguishes between @emph{public} and | ||
5310 | @emph{friend-only} HELLO messages. Public HELLO messages can be freely | ||
5311 | distributed to other (possibly unknown) peers (for example using the hostlist, | ||
5312 | gossiping, broadcasting), whereas friend-only HELLO messages may not be | ||
5313 | distributed to other peers. Friend-only HELLO messages have an additional flag | ||
5314 | @code{friend_only} set internally. For public HELLO message this flag is not | ||
5315 | set. PEERINFO does and cannot not check if a client is allowed to obtain a | ||
5316 | specific HELLO type. | ||
5317 | |||
5318 | The HELLO messages can be managed using the GNUnet HELLO library. Other GNUnet | ||
5319 | systems can obtain these information from PEERINFO and use it for their | ||
5320 | purposes. Clients are for example the HOSTLIST component providing these | ||
5321 | information to other peers in form of a hostlist or the TRANSPORT subsystem | ||
5322 | using these information to maintain connections to other peers. | ||
5323 | |||
5324 | @node Startup | ||
5325 | @subsection Startup | ||
5326 | |||
5327 | @c %**end of header | ||
5328 | |||
5329 | During startup the PEERINFO services loads persistent HELLOs from disk. First | ||
5330 | PEERINFO parses the directory configured in the HOSTS value of the | ||
5331 | @code{PEERINFO} configuration section to store PEERINFO information.@ For all | ||
5332 | files found in this directory valid HELLO messages are extracted. In addition | ||
5333 | it loads HELLO messages shipped with the GNUnet distribution. These HELLOs are | ||
5334 | used to simplify network bootstrapping by providing valid peer information with | ||
5335 | the distribution. The use of these HELLOs can be prevented by setting the | ||
5336 | @code{USE_INCLUDED_HELLOS} in the @code{PEERINFO} configuration section to | ||
5337 | @code{NO}. Files containing invalid information are removed. | ||
5338 | |||
5339 | @node Managing Information | ||
5340 | @subsection Managing Information | ||
5341 | |||
5342 | @c %**end of header | ||
5343 | |||
5344 | The PEERINFO services stores information about known PEERS and a single HELLO | ||
5345 | message for every peer. A peer does not need to have a HELLO if no information | ||
5346 | are available. HELLO information from different sources, for example a HELLO | ||
5347 | obtained from a remote HOSTLIST and a second HELLO stored on disk, are combined | ||
5348 | and merged into one single HELLO message per peer which will be given to | ||
5349 | clients. During this merge process the HELLO is immediately written to disk to | ||
5350 | ensure persistence. | ||
5351 | |||
5352 | PEERINFO in addition periodically scans the directory where information are | ||
5353 | stored for empty HELLO messages with expired TRANSPORT addresses.@ This | ||
5354 | periodic task scans all files in the directory and recreates the HELLO messages | ||
5355 | it finds. Expired TRANSPORT addresses are removed from the HELLO and if the | ||
5356 | HELLO does not contain any valid addresses, it is discarded and removed from | ||
5357 | disk. | ||
5358 | |||
5359 | @node Obtaining Information | ||
5360 | @subsection Obtaining Information | ||
5361 | |||
5362 | @c %**end of header | ||
5363 | |||
5364 | When a client requests information from PEERINFO, PEERINFO performs a lookup | ||
5365 | for the respective peer or all peers if desired and transmits this information | ||
5366 | to the client. The client can specify if friend-only HELLOs have to be included | ||
5367 | or not and PEERINFO filters the respective HELLO messages before transmitting | ||
5368 | information. | ||
5369 | |||
5370 | To notify clients about changes to PEERINFO information, PEERINFO maintains a | ||
5371 | list of clients interested in this notifications. Such a notification occurs if | ||
5372 | a HELLO for a peer was updated (due to a merge for example) or a new peer was | ||
5373 | added. | ||
5374 | |||
5375 | @node The PEERINFO Client-Service Protocol | ||
5376 | @subsection The PEERINFO Client-Service Protocol | ||
5377 | |||
5378 | @c %**end of header | ||
5379 | |||
5380 | To connect and disconnect to and from the PEERINFO Service PEERINFO utilizes | ||
5381 | the util client/server infrastructure, so no special messages types are used | ||
5382 | here. | ||
5383 | |||
5384 | To add information for a peer, the plain HELLO message is transmitted to the | ||
5385 | service without any wrapping. Alle information required are stored within the | ||
5386 | HELLO message. The PEERINFO service provides a message handler accepting and | ||
5387 | processing these HELLO messages. | ||
5388 | |||
5389 | When obtaining PEERINFO information using the iterate functionality specific | ||
5390 | messages are used. To obtain information for all peers, a @code{struct | ||
5391 | ListAllPeersMessage} with message type | ||
5392 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL} and a flag include_friend_only to | ||
5393 | indicate if friend-only HELLO messages should be included are transmitted. If | ||
5394 | information for a specific peer is required a @code{struct ListAllPeersMessage} | ||
5395 | with @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET} containing the peer identity is | ||
5396 | used. | ||
5397 | |||
5398 | For both variants the PEERINFO service replies for each HELLO message he wants | ||
5399 | to transmit with a @code{struct ListAllPeersMessage} with type | ||
5400 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO} containing the plain HELLO. The final | ||
5401 | message is @code{struct GNUNET_MessageHeader} with type | ||
5402 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO}. If the client receives this message, | ||
5403 | he can proceed with the next request if any is pending | ||
5404 | |||
5405 | @node libgnunetpeerinfo | ||
5406 | @subsection libgnunetpeerinfo | ||
5407 | |||
5408 | @c %**end of header | ||
5409 | |||
5410 | The PEERINFO API consists mainly of three different functionalities: | ||
5411 | maintaining a connection to the service, adding new information and retrieving | ||
5412 | information form the PEERINFO service. | ||
5413 | |||
5414 | |||
5415 | @menu | ||
5416 | * Connecting to the Service:: | ||
5417 | * Adding Information:: | ||
5418 | * Obtaining Information2:: | ||
5419 | @end menu | ||
5420 | |||
5421 | @node Connecting to the Service | ||
5422 | @subsubsection Connecting to the Service | ||
5423 | |||
5424 | @c %**end of header | ||
5425 | |||
5426 | To connect to the PEERINFO service the function @code{GNUNET_PEERINFO_connect} | ||
5427 | is used, taking a configuration handle as an argument, and to disconnect from | ||
5428 | PEERINFO the function @code{GNUNET_PEERINFO_disconnect}, taking the PEERINFO | ||
5429 | handle returned from the connect function has to be called. | ||
5430 | |||
5431 | @node Adding Information | ||
5432 | @subsubsection Adding Information | ||
5433 | |||
5434 | @c %**end of header | ||
5435 | |||
5436 | @code{GNUNET_PEERINFO_add_peer} adds a new peer to the PEERINFO subsystem | ||
5437 | storage. This function takes the PEERINFO handle as an argument, the HELLO | ||
5438 | message to store and a continuation with a closure to be called with the result | ||
5439 | of the operation. The @code{GNUNET_PEERINFO_add_peer} returns a handle to this | ||
5440 | operation allowing to cancel the operation with the respective cancel function | ||
5441 | @code{GNUNET_PEERINFO_add_peer_cancel}. To retrieve information from PEERINFO | ||
5442 | you can iterate over all information stored with PEERINFO or you can tell | ||
5443 | PEERINFO to notify if new peer information are available. | ||
5444 | |||
5445 | @node Obtaining Information2 | ||
5446 | @subsubsection Obtaining Information2 | ||
5447 | |||
5448 | @c %**end of header | ||
5449 | |||
5450 | To iterate over information in PEERINFO you use @code{GNUNET_PEERINFO_iterate}. | ||
5451 | This function expects the PEERINFO handle, a flag if HELLO messages intended | ||
5452 | for friend only mode should be included, a timeout how long the operation | ||
5453 | should take and a callback with a callback closure to be called for the | ||
5454 | results. If you want to obtain information for a specific peer, you can specify | ||
5455 | the peer identity, if this identity is NULL, information for all peers are | ||
5456 | returned. The function returns a handle to allow to cancel the operation using | ||
5457 | @code{GNUNET_PEERINFO_iterate_cancel}. | ||
5458 | |||
5459 | To get notified when peer information changes, you can use | ||
5460 | @code{GNUNET_PEERINFO_notify}. This function expects a configuration handle and | ||
5461 | a flag if friend-only HELLO messages should be included. The PEERINFO service | ||
5462 | will notify you about every change and the callback function will be called to | ||
5463 | notify you about changes. The function returns a handle to cancel notifications | ||
5464 | with @code{GNUNET_PEERINFO_notify_cancel}. | ||
5465 | |||
5466 | |||
5467 | @node GNUnet's PEERSTORE subsystem | ||
5468 | @section GNUnet's PEERSTORE subsystem | ||
5469 | |||
5470 | @c %**end of header | ||
5471 | |||
5472 | GNUnet's PEERSTORE subsystem offers persistent per-peer storage for other | ||
5473 | GNUnet subsystems. GNUnet subsystems can use PEERSTORE to persistently store | ||
5474 | and retrieve arbitrary data. Each data record stored with PEERSTORE contains | ||
5475 | the following fields: | ||
5476 | |||
5477 | @itemize @bullet | ||
5478 | @item subsystem: Name of the subsystem responsible for the record. | ||
5479 | @item peerid: Identity of the peer this record is related to. | ||
5480 | @item key: a key string identifying the record. | ||
5481 | @item value: binary record value. | ||
5482 | @item expiry: record expiry date. | ||
5483 | @end itemize | ||
5484 | |||
5485 | @menu | ||
5486 | * Functionality:: | ||
5487 | * Architecture:: | ||
5488 | * libgnunetpeerstore:: | ||
5489 | @end menu | ||
5490 | |||
5491 | @node Functionality | ||
5492 | @subsection Functionality | ||
5493 | |||
5494 | @c %**end of header | ||
5495 | |||
5496 | Subsystems can store any type of value under a (subsystem, peerid, key) | ||
5497 | combination. A "replace" flag set during store operations forces the PEERSTORE | ||
5498 | to replace any old values stored under the same (subsystem, peerid, key) | ||
5499 | combination with the new value. Additionally, an expiry date is set after which | ||
5500 | the record is *possibly* deleted by PEERSTORE. | ||
5501 | |||
5502 | Subsystems can iterate over all values stored under any of the following | ||
5503 | combination of fields: | ||
5504 | |||
5505 | @itemize @bullet | ||
5506 | @item (subsystem) | ||
5507 | @item (subsystem, peerid) | ||
5508 | @item (subsystem, key) | ||
5509 | @item (subsystem, peerid, key) | ||
5510 | @end itemize | ||
5511 | |||
5512 | Subsystems can also request to be notified about any new values stored under a | ||
5513 | (subsystem, peerid, key) combination by sending a "watch" request to | ||
5514 | PEERSTORE. | ||
5515 | |||
5516 | @node Architecture | ||
5517 | @subsection Architecture | ||
5518 | |||
5519 | @c %**end of header | ||
5520 | |||
5521 | PEERSTORE implements the following components: | ||
5522 | |||
5523 | @itemize @bullet | ||
5524 | @item PEERSTORE service: Handles store, iterate and watch operations. | ||
5525 | @item PEERSTORE API: API to be used by other subsystems to communicate and | ||
5526 | issue commands to the PEERSTORE service. | ||
5527 | @item PEERSTORE plugins: Handles the persistent storage. At the moment, only an | ||
5528 | "sqlite" plugin is implemented. | ||
5529 | @end itemize | ||
5530 | |||
5531 | @node libgnunetpeerstore | ||
5532 | @subsection libgnunetpeerstore | ||
5533 | |||
5534 | @c %**end of header | ||
5535 | |||
5536 | libgnunetpeerstore is the library containing the PEERSTORE API. Subsystems | ||
5537 | wishing to communicate with the PEERSTORE service use this API to open a | ||
5538 | connection to PEERSTORE. This is done by calling | ||
5539 | @code{GNUNET_PEERSTORE_connect} which returns a handle to the newly created | ||
5540 | connection. This handle has to be used with any further calls to the API. | ||
5541 | |||
5542 | To store a new record, the function @code{GNUNET_PEERSTORE_store} is to be used | ||
5543 | which requires the record fields and a continuation function that will be | ||
5544 | called by the API after the STORE request is sent to the PEERSTORE service. | ||
5545 | Note that calling the continuation function does not mean that the record is | ||
5546 | successfully stored, only that the STORE request has been successfully sent to | ||
5547 | the PEERSTORE service. @code{GNUNET_PEERSTORE_store_cancel} can be called to | ||
5548 | cancel the STORE request only before the continuation function has been called. | ||
5549 | |||
5550 | To iterate over stored records, the function @code{GNUNET_PEERSTORE_iterate} is | ||
5551 | to be used. @emph{peerid} and @emph{key} can be set to NULL. An iterator | ||
5552 | callback function will be called with each matching record found and a NULL | ||
5553 | record at the end to signal the end of result set. | ||
5554 | @code{GNUNET_PEERSTORE_iterate_cancel} can be used to cancel the ITERATE | ||
5555 | request before the iterator callback is called with a NULL record. | ||
5556 | |||
5557 | To be notified with new values stored under a (subsystem, peerid, key) | ||
5558 | combination, the function @code{GNUNET_PEERSTORE_watch} is to be used. This | ||
5559 | will register the watcher with the PEERSTORE service, any new records matching | ||
5560 | the given combination will trigger the callback function passed to | ||
5561 | @code{GNUNET_PEERSTORE_watch}. This continues until | ||
5562 | @code{GNUNET_PEERSTORE_watch_cancel} is called or the connection to the service | ||
5563 | is destroyed. | ||
5564 | |||
5565 | After the connection is no longer needed, the function | ||
5566 | @code{GNUNET_PEERSTORE_disconnect} can be called to disconnect from the | ||
5567 | PEERSTORE service. Any pending ITERATE or WATCH requests will be destroyed. If | ||
5568 | the @code{sync_first} flag is set to @code{GNUNET_YES}, the API will delay the | ||
5569 | disconnection until all pending STORE requests are sent to the PEERSTORE | ||
5570 | service, otherwise, the pending STORE requests will be destroyed as well. | ||
5571 | |||
5572 | @node GNUnet's SET Subsystem | ||
5573 | @section GNUnet's SET Subsystem | ||
5574 | |||
5575 | @c %**end of header | ||
5576 | |||
5577 | The SET service implements efficient set operations between two peers over a | ||
5578 | mesh tunnel. Currently, set union and set intersection are the only supported | ||
5579 | operations. Elements of a set consist of an @emph{element type} and arbitrary | ||
5580 | binary @emph{data}. The size of an element's data is limited to around 62 | ||
5581 | KB. | ||
5582 | |||
5583 | @menu | ||
5584 | * Local Sets:: | ||
5585 | * Set Modifications:: | ||
5586 | * Set Operations:: | ||
5587 | * Result Elements:: | ||
5588 | * libgnunetset:: | ||
5589 | * The SET Client-Service Protocol:: | ||
5590 | * The SET Intersection Peer-to-Peer Protocol:: | ||
5591 | * The SET Union Peer-to-Peer Protocol:: | ||
5592 | @end menu | ||
5593 | |||
5594 | @node Local Sets | ||
5595 | @subsection Local Sets | ||
5596 | |||
5597 | @c %**end of header | ||
5598 | |||
5599 | Sets created by a local client can be modified and reused for multiple | ||
5600 | operations. As each set operation requires potentially expensive special | ||
5601 | auxilliary data to be computed for each element of a set, a set can only | ||
5602 | participate in one type of set operation (i.e. union or intersection). The type | ||
5603 | of a set is determined upon its creation. If a the elements of a set are needed | ||
5604 | for an operation of a different type, all of the set's element must be copied | ||
5605 | to a new set of appropriate type. | ||
5606 | |||
5607 | @node Set Modifications | ||
5608 | @subsection Set Modifications | ||
5609 | |||
5610 | @c %**end of header | ||
5611 | |||
5612 | Even when set operations are active, one can add to and remove elements from a | ||
5613 | set. However, these changes will only be visible to operations that have been | ||
5614 | created after the changes have taken place. That is, every set operation only | ||
5615 | sees a snapshot of the set from the time the operation was started. This | ||
5616 | mechanism is @emph{not} implemented by copying the whole set, but by attaching | ||
5617 | @emph{generation information} to each element and operation. | ||
5618 | |||
5619 | @node Set Operations | ||
5620 | @subsection Set Operations | ||
5621 | |||
5622 | @c %**end of header | ||
5623 | |||
5624 | Set operations can be started in two ways: Either by accepting an operation | ||
5625 | request from a remote peer, or by requesting a set operation from a remote | ||
5626 | peer. Set operations are uniquely identified by the involved @emph{peers}, an | ||
5627 | @emph{application id} and the @emph{operation type}. | ||
5628 | |||
5629 | The client is notified of incoming set operations by @emph{set listeners}. A | ||
5630 | set listener listens for incoming operations of a specific operation type and | ||
5631 | application id. Once notified of an incoming set request, the client can | ||
5632 | accept the set request (providing a local set for the operation) or reject | ||
5633 | it. | ||
5634 | |||
5635 | @node Result Elements | ||
5636 | @subsection Result Elements | ||
5637 | |||
5638 | @c %**end of header | ||
5639 | |||
5640 | The SET service has three @emph{result modes} that determine how an operation's | ||
5641 | result set is delivered to the client: | ||
5642 | |||
5643 | @itemize @bullet | ||
5644 | @item @strong{Full Result Set.} All elements of set resulting from the set | ||
5645 | operation are returned to the client. | ||
5646 | @item @strong{Added Elements.} Only elements that result from the operation and | ||
5647 | are not already in the local peer's set are returned. Note that for some | ||
5648 | operations (like set intersection) this result mode will never return any | ||
5649 | elements. This can be useful if only the remove peer is actually interested in | ||
5650 | the result of the set operation. | ||
5651 | @item @strong{Removed Elements.} Only elements that are in the local peer's | ||
5652 | initial set but not in the operation's result set are returned. Note that for | ||
5653 | some operations (like set union) this result mode will never return any | ||
5654 | elements. This can be useful if only the remove peer is actually interested in | ||
5655 | the result of the set operation. | ||
5656 | @end itemize | ||
5657 | |||
5658 | @node libgnunetset | ||
5659 | @subsection libgnunetset | ||
5660 | |||
5661 | @c %**end of header | ||
5662 | |||
5663 | @menu | ||
5664 | * Sets:: | ||
5665 | * Listeners:: | ||
5666 | * Operations:: | ||
5667 | * Supplying a Set:: | ||
5668 | * The Result Callback:: | ||
5669 | @end menu | ||
5670 | |||
5671 | @node Sets | ||
5672 | @subsubsection Sets | ||
5673 | |||
5674 | @c %**end of header | ||
5675 | |||
5676 | New sets are created with @code{GNUNET_SET_create}. Both the local peer's | ||
5677 | configuration (as each set has its own client connection) and the operation | ||
5678 | type must be specified. The set exists until either the client calls | ||
5679 | @code{GNUNET_SET_destroy} or the client's connection to the service is | ||
5680 | disrupted. In the latter case, the client is notified by the return value of | ||
5681 | functions dealing with sets. This return value must always be checked. | ||
5682 | |||
5683 | Elements are added and removed with @code{GNUNET_SET_add_element} and | ||
5684 | @code{GNUNET_SET_remove_element}. | ||
5685 | |||
5686 | @node Listeners | ||
5687 | @subsubsection Listeners | ||
5688 | |||
5689 | @c %**end of header | ||
5690 | |||
5691 | Listeners are created with @code{GNUNET_SET_listen}. Each time time a remote | ||
5692 | peer suggests a set operation with an application id and operation type | ||
5693 | matching a listener, the listener's callack is invoked. The client then must | ||
5694 | synchronously call either @code{GNUNET_SET_accept} or @code{GNUNET_SET_reject}. | ||
5695 | Note that the operation will not be started until the client calls | ||
5696 | @code{GNUNET_SET_commit} (see Section "Supplying a Set"). | ||
5697 | |||
5698 | @node Operations | ||
5699 | @subsubsection Operations | ||
5700 | |||
5701 | @c %**end of header | ||
5702 | |||
5703 | Operations to be initiated by the local peer are created with | ||
5704 | @code{GNUNET_SET_prepare}. Note that the operation will not be started until | ||
5705 | the client calls @code{GNUNET_SET_commit} (see Section "Supplying a | ||
5706 | Set"). | ||
5707 | |||
5708 | @node Supplying a Set | ||
5709 | @subsubsection Supplying a Set | ||
5710 | |||
5711 | @c %**end of header | ||
5712 | |||
5713 | To create symmetry between the two ways of starting a set operation (accepting | ||
5714 | and nitiating it), the operation handles returned by @code{GNUNET_SET_accept} | ||
5715 | and @code{GNUNET_SET_prepare} do not yet have a set to operate on, thus they | ||
5716 | can not do any work yet. | ||
5717 | |||
5718 | The client must call @code{GNUNET_SET_commit} to specify a set to use for an | ||
5719 | operation. @code{GNUNET_SET_commit} may only be called once per set | ||
5720 | operation. | ||
5721 | |||
5722 | @node The Result Callback | ||
5723 | @subsubsection The Result Callback | ||
5724 | |||
5725 | @c %**end of header | ||
5726 | |||
5727 | Clients must specify both a result mode and a result callback with | ||
5728 | @code{GNUNET_SET_accept} and @code{GNUNET_SET_prepare}. The result callback | ||
5729 | with a status indicating either that an element was received, or the operation | ||
5730 | failed or succeeded. The interpretation of the received element depends on the | ||
5731 | result mode. The callback needs to know which result mode it is used in, as the | ||
5732 | arguments do not indicate if an element is part of the full result set, or if | ||
5733 | it is in the difference between the original set and the final set. | ||
5734 | |||
5735 | @node The SET Client-Service Protocol | ||
5736 | @subsection The SET Client-Service Protocol | ||
5737 | |||
5738 | @c %**end of header | ||
5739 | |||
5740 | @menu | ||
5741 | * Creating Sets:: | ||
5742 | * Listeners2:: | ||
5743 | * Initiating Operations:: | ||
5744 | * Modifying Sets:: | ||
5745 | * Results and Operation Status:: | ||
5746 | * Iterating Sets:: | ||
5747 | @end menu | ||
5748 | |||
5749 | @node Creating Sets | ||
5750 | @subsubsection Creating Sets | ||
5751 | |||
5752 | @c %**end of header | ||
5753 | |||
5754 | For each set of a client, there exists a client connection to the service. Sets | ||
5755 | are created by sending the @code{GNUNET_SERVICE_SET_CREATE} message over a new | ||
5756 | client connection. Multiple operations for one set are multiplexed over one | ||
5757 | client connection, using a request id supplied by the client. | ||
5758 | |||
5759 | @node Listeners2 | ||
5760 | @subsubsection Listeners2 | ||
5761 | |||
5762 | @c %**end of header | ||
5763 | |||
5764 | Each listener also requires a seperate client connection. By sending the | ||
5765 | @code{GNUNET_SERVICE_SET_LISTEN} message, the client notifies the service of | ||
5766 | the application id and operation type it is interested in. A client rejects an | ||
5767 | incoming request by sending @code{GNUNET_SERVICE_SET_REJECT} on the listener's | ||
5768 | client connection. In contrast, when accepting an incoming request, a a | ||
5769 | @code{GNUNET_SERVICE_SET_ACCEPT} message must be sent over the@ set that is | ||
5770 | supplied for the set operation. | ||
5771 | |||
5772 | @node Initiating Operations | ||
5773 | @subsubsection Initiating Operations | ||
5774 | |||
5775 | @c %**end of header | ||
5776 | |||
5777 | Operations with remote peers are initiated by sending a | ||
5778 | @code{GNUNET_SERVICE_SET_EVALUATE} message to the service. The@ client | ||
5779 | connection that this message is sent by determines the set to use. | ||
5780 | |||
5781 | @node Modifying Sets | ||
5782 | @subsubsection Modifying Sets | ||
5783 | |||
5784 | @c %**end of header | ||
5785 | |||
5786 | Sets are modified with the @code{GNUNET_SERVICE_SET_ADD} and | ||
5787 | @code{GNUNET_SERVICE_SET_REMOVE} messages. | ||
5788 | |||
5789 | |||
5790 | @c %@menu | ||
5791 | @c %* Results and Operation Status:: | ||
5792 | @c %* Iterating Sets:: | ||
5793 | @c %@end menu | ||
5794 | |||
5795 | @node Results and Operation Status | ||
5796 | @subsubsection Results and Operation Status | ||
5797 | @c %**end of header | ||
5798 | |||
5799 | The service notifies the client of result elements and success/failure of a set | ||
5800 | operation with the @code{GNUNET_SERVICE_SET_RESULT} message. | ||
5801 | |||
5802 | @node Iterating Sets | ||
5803 | @subsubsection Iterating Sets | ||
5804 | |||
5805 | @c %**end of header | ||
5806 | |||
5807 | All elements of a set can be requested by sending | ||
5808 | @code{GNUNET_SERVICE_SET_ITER_REQUEST}. The server responds with | ||
5809 | @code{GNUNET_SERVICE_SET_ITER_ELEMENT} and eventually terminates the iteration | ||
5810 | with @code{GNUNET_SERVICE_SET_ITER_DONE}. After each received element, the | ||
5811 | client@ must send @code{GNUNET_SERVICE_SET_ITER_ACK}. Note that only one set | ||
5812 | iteration may be active for a set at any given time. | ||
5813 | |||
5814 | @node The SET Intersection Peer-to-Peer Protocol | ||
5815 | @subsection The SET Intersection Peer-to-Peer Protocol | ||
5816 | |||
5817 | @c %**end of header | ||
5818 | |||
5819 | The intersection protocol operates over CADET and starts with a | ||
5820 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer initiating | ||
5821 | the operation to the peer listening for inbound requests. It includes the | ||
5822 | number of elements of the initiating peer, which is used to decide which side | ||
5823 | will send a Bloom filter first. | ||
5824 | |||
5825 | The listening peer checks if the operation type and application identifier are | ||
5826 | acceptable for its current state. If not, it responds with a | ||
5827 | GNUNET_MESSAGE_TYPE_SET_RESULT and a status of GNUNET_SET_STATUS_FAILURE (and | ||
5828 | terminates the CADET channel). | ||
5829 | |||
5830 | If the application accepts the request, the listener sends back a@ | ||
5831 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO if it has more elements | ||
5832 | in the set than the client. Otherwise, it immediately starts with the Bloom | ||
5833 | filter exchange. If the initiator receives a | ||
5834 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO response, it beings the | ||
5835 | Bloom filter exchange, unless the set size is indicated to be zero, in which | ||
5836 | case the intersection is considered finished after just the initial | ||
5837 | handshake. | ||
5838 | |||
5839 | |||
5840 | @menu | ||
5841 | * The Bloom filter exchange:: | ||
5842 | * Salt:: | ||
5843 | @end menu | ||
5844 | |||
5845 | @node The Bloom filter exchange | ||
5846 | @subsubsection The Bloom filter exchange | ||
5847 | |||
5848 | @c %**end of header | ||
5849 | |||
5850 | In this phase, each peer transmits a Bloom filter over the remaining keys of | ||
5851 | the local set to the other peer using a | ||
5852 | GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF message. This message additionally | ||
5853 | includes the number of elements left in the sender's set, as well as the XOR | ||
5854 | over all of the keys in that set. | ||
5855 | |||
5856 | The number of bits 'k' set per element in the Bloom filter is calculated based | ||
5857 | on the relative size of the two sets. Furthermore, the size of the Bloom filter | ||
5858 | is calculated based on 'k' and the number of elements in the set to maximize | ||
5859 | the amount of data filtered per byte transmitted on the wire (while avoiding an | ||
5860 | excessively high number of iterations). | ||
5861 | |||
5862 | The receiver of the message removes all elements from its local set that do not | ||
5863 | pass the Bloom filter test. It then checks if the set size of the sender and | ||
5864 | the XOR over the keys match what is left of his own set. If they do, he sends | ||
5865 | a@ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE back to indicate that the | ||
5866 | latest set is the final result. Otherwise, the receiver starts another Bloom | ||
5867 | fitler exchange, except this time as the sender. | ||
5868 | |||
5869 | @node Salt | ||
5870 | @subsubsection Salt | ||
5871 | |||
5872 | @c %**end of header | ||
5873 | |||
5874 | Bloomfilter operations are probablistic: With some non-zero probability the | ||
5875 | test may incorrectly say an element is in the set, even though it is not. | ||
5876 | |||
5877 | To mitigate this problem, the intersection protocol iterates exchanging Bloom | ||
5878 | filters using a different random 32-bit salt in each iteration (the salt is | ||
5879 | also included in the message). With different salts, set operations may fail | ||
5880 | for different elements. Merging the results from the executions, the | ||
5881 | probability of failure drops to zero. | ||
5882 | |||
5883 | The iterations terminate once both peers have established that they have sets | ||
5884 | of the same size, and where the XOR over all keys computes the same 512-bit | ||
5885 | value (leaving a failure probability of 2-511). | ||
5886 | |||
5887 | @node The SET Union Peer-to-Peer Protocol | ||
5888 | @subsection The SET Union Peer-to-Peer Protocol | ||
5889 | |||
5890 | @c %**end of header | ||
5891 | |||
5892 | The SET union protocol is based on Eppstein's efficient set reconciliation | ||
5893 | without prior context. You should read this paper first if you want to | ||
5894 | understand the protocol. | ||
5895 | |||
5896 | The union protocol operates over CADET and starts with a | ||
5897 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer initiating | ||
5898 | the operation to the peer listening for inbound requests. It includes the | ||
5899 | number of elements of the initiating peer, which is currently not used. | ||
5900 | |||
5901 | The listening peer checks if the operation type and application identifier are | ||
5902 | acceptable for its current state. If not, it responds with a | ||
5903 | GNUNET_MESSAGE_TYPE_SET_RESULT and a status of GNUNET_SET_STATUS_FAILURE (and | ||
5904 | terminates the CADET channel). | ||
5905 | |||
5906 | If the application accepts the request, it sends back a strata estimator using | ||
5907 | a message of type GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE. The initiator evaluates | ||
5908 | the strata estimator and initiates the exchange of invertible Bloom filters, | ||
5909 | sending a GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
5910 | |||
5911 | During the IBF exchange, if the receiver cannot invert the Bloom filter or | ||
5912 | detects a cycle, it sends a larger IBF in response (up to a defined maximum | ||
5913 | limit; if that limit is reached, the operation fails). Elements decoded while | ||
5914 | processing the IBF are transmitted to the other peer using | ||
5915 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, or requested from the other peer using | ||
5916 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS messages, depending on the sign | ||
5917 | observed during decoding of the IBF. Peers respond to a | ||
5918 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS message with the respective | ||
5919 | element in a GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS message. If the IBF fully | ||
5920 | decodes, the peer responds with a GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE | ||
5921 | message instead of another GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
5922 | |||
5923 | All Bloom filter operations use a salt to mingle keys before hasing them into | ||
5924 | buckets, such that future iterations have a fresh chance of succeeding if they | ||
5925 | failed due to collisions before. | ||
5926 | |||
5927 | @node GNUnet's STATISTICS subsystem | ||
5928 | @section GNUnet's STATISTICS subsystem | ||
5929 | |||
5930 | @c %**end of header | ||
5931 | |||
5932 | In GNUnet, the STATISTICS subsystem offers a central place for all subsystems | ||
5933 | to publish unsigned 64-bit integer run-time statistics. Keeping this | ||
5934 | information centrally means that there is a unified way for the user to obtain | ||
5935 | data on all subsystems, and individual subsystems do not have to always include | ||
5936 | a custom data export method for performance metrics and other statistics. For | ||
5937 | example, the TRANSPORT system uses STATISTICS to update information about the | ||
5938 | number of directly connected peers and the bandwidth that has been consumed by | ||
5939 | the various plugins. This information is valuable for diagnosing connectivity | ||
5940 | and performance issues. | ||
5941 | |||
5942 | Following the GNUnet service architecture, the STATISTICS subsystem is divided | ||
5943 | into an API which is exposed through the header | ||
5944 | @strong{gnunet_statistics_service.h} and the STATISTICS service | ||
5945 | @strong{gnunet-service-statistics}. The @strong{gnunet-statistics} command-line | ||
5946 | tool can be used to obtain (and change) information about the values stored by | ||
5947 | the STATISTICS service. The STATISTICS service does not communicate with other | ||
5948 | peers. | ||
5949 | |||
5950 | Data is stored in the STATISTICS service in the form of tuples | ||
5951 | @strong{(subsystem, name, value, persistence)}. The subsystem determines to | ||
5952 | which other GNUnet's subsystem the data belongs. name is the name through which | ||
5953 | value is associated. It uniquely identifies the record from among other records | ||
5954 | belonging to the same subsystem. In some parts of the code, the pair | ||
5955 | @strong{(subsystem, name)} is called a @strong{statistic} as it identifies the | ||
5956 | values stored in the STATISTCS service.The persistence flag determines if the | ||
5957 | record has to be preserved across service restarts. A record is said to be | ||
5958 | persistent if this flag is set for it; if not, the record is treated as a | ||
5959 | non-persistent record and it is lost after service restart. Persistent records | ||
5960 | are written to and read from the file @strong{statistics.data} before shutdown | ||
5961 | and upon startup. The file is located in the HOME directory of the peer. | ||
5962 | |||
5963 | An anomaly of the STATISTICS service is that it does not terminate immediately | ||
5964 | upon receiving a shutdown signal if it has any clients connected to it. It | ||
5965 | waits for all the clients that are not monitors to close their connections | ||
5966 | before terminating itself. This is to prevent the loss of data during peer | ||
5967 | shutdown --- delaying the STATISTICS service shutdown helps other services to | ||
5968 | store important data to STATISTICS during shutdown. | ||
5969 | |||
5970 | @menu | ||
5971 | * libgnunetstatistics:: | ||
5972 | * The STATISTICS Client-Service Protocol:: | ||
5973 | @end menu | ||
5974 | |||
5975 | @node libgnunetstatistics | ||
5976 | @subsection libgnunetstatistics | ||
5977 | |||
5978 | @c %**end of header | ||
5979 | |||
5980 | @strong{libgnunetstatistics} is the library containing the API for the | ||
5981 | STATISTICS subsystem. Any process requiring to use STATISTICS should use this | ||
5982 | API by to open a connection to the STATISTICS service. This is done by calling | ||
5983 | the function @code{GNUNET_STATISTICS_create()}. This function takes the | ||
5984 | subsystem's name which is trying to use STATISTICS and a configuration. All | ||
5985 | values written to STATISTICS with this connection will be placed in the section | ||
5986 | corresponding to the given subsystem's name. The connection to STATISTICS can | ||
5987 | be destroyed with the function GNUNET_STATISTICS_destroy(). This function | ||
5988 | allows for the connection to be destroyed immediately or upon transferring all | ||
5989 | pending write requests to the service. | ||
5990 | |||
5991 | Note: STATISTICS subsystem can be disabled by setting @code{DISABLE = YES} | ||
5992 | under the @code{[STATISTICS]} section in the configuration. With such a | ||
5993 | configuration all calls to @code{GNUNET_STATISTICS_create()} return @code{NULL} | ||
5994 | as the STATISTICS subsystem is unavailable and no other functions from the API | ||
5995 | can be used. | ||
5996 | |||
5997 | |||
5998 | @menu | ||
5999 | * Statistics retrieval:: | ||
6000 | * Setting statistics and updating them:: | ||
6001 | * Watches:: | ||
6002 | @end menu | ||
6003 | |||
6004 | @node Statistics retrieval | ||
6005 | @subsubsection Statistics retrieval | ||
6006 | |||
6007 | @c %**end of header | ||
6008 | |||
6009 | Once a connection to the statistics service is obtained, information about any | ||
6010 | other system which uses statistics can be retrieved with the function | ||
6011 | GNUNET_STATISTICS_get(). This function takes the connection handle, the name of | ||
6012 | the subsystem whose information we are interested in (a @code{NULL} value will | ||
6013 | retrieve information of all available subsystems using STATISTICS), the name of | ||
6014 | the statistic we are interested in (a @code{NULL} value will retrieve all | ||
6015 | available statistics), a continuation callback which is called when all of | ||
6016 | requested information is retrieved, an iterator callback which is called for | ||
6017 | each parameter in the retrieved information and a closure for the | ||
6018 | aforementioned callbacks. The library then invokes the iterator callback for | ||
6019 | each value matching the request. | ||
6020 | |||
6021 | Call to @code{GNUNET_STATISTICS_get()} is asynchronous and can be canceled with | ||
6022 | the function @code{GNUNET_STATISTICS_get_cancel()}. This is helpful when | ||
6023 | retrieving statistics takes too long and especially when we want to shutdown | ||
6024 | and cleanup everything. | ||
6025 | |||
6026 | @node Setting statistics and updating them | ||
6027 | @subsubsection Setting statistics and updating them | ||
6028 | |||
6029 | @c %**end of header | ||
6030 | |||
6031 | So far we have seen how to retrieve statistics, here we will learn how we can | ||
6032 | set statistics and update them so that other subsystems can retrieve them. | ||
6033 | |||
6034 | A new statistic can be set using the function @code{GNUNET_STATISTICS_set()}. | ||
6035 | This function takes the name of the statistic and its value and a flag to make | ||
6036 | the statistic persistent. The value of the statistic should be of the type | ||
6037 | @code{uint64_t}. The function does not take the name of the subsystem; it is | ||
6038 | determined from the previous @code{GNUNET_STATISTICS_create()} invocation. If | ||
6039 | the given statistic is already present, its value is overwritten. | ||
6040 | |||
6041 | An existing statistics can be updated, i.e its value can be increased or | ||
6042 | decreased by an amount with the function @code{GNUNET_STATISTICS_update()}. The | ||
6043 | parameters to this function are similar to @code{GNUNET_STATISTICS_set()}, | ||
6044 | except that it takes the amount to be changed as a type @code{int64_t} instead | ||
6045 | of the value. | ||
6046 | |||
6047 | The library will combine multiple set or update operations into one message if | ||
6048 | the client performs requests at a rate that is faster than the available IPC | ||
6049 | with the STATISTICS service. Thus, the client does not have to worry about | ||
6050 | sending requests too quickly. | ||
6051 | |||
6052 | @node Watches | ||
6053 | @subsubsection Watches | ||
6054 | |||
6055 | @c %**end of header | ||
6056 | |||
6057 | As interesting feature of STATISTICS lies in serving notifications whenever a | ||
6058 | statistic of our interest is modified. This is achieved by registering a watch | ||
6059 | through the function @code{GNUNET_STATISTICS_watch()}. The parameters of this | ||
6060 | function are similar to those of @code{GNUNET_STATISTICS_get()}. Changes to the | ||
6061 | respective statistic's value will then cause the given iterator callback to be | ||
6062 | called. Note: A watch can only be registered for a specific statistic. Hence | ||
6063 | the subsystem name and the parameter name cannot be @code{NULL} in a call to | ||
6064 | @code{GNUNET_STATISTICS_watch()}. | ||
6065 | |||
6066 | A registered watch will keep notifying any value changes until | ||
6067 | @code{GNUNET_STATISTICS_watch_cancel()} is called with the same parameters that | ||
6068 | are used for registering the watch. | ||
6069 | |||
6070 | @node The STATISTICS Client-Service Protocol | ||
6071 | @subsection The STATISTICS Client-Service Protocol | ||
6072 | @c %**end of header | ||
6073 | |||
6074 | |||
6075 | @menu | ||
6076 | * Statistics retrieval2:: | ||
6077 | * Setting and updating statistics:: | ||
6078 | * Watching for updates:: | ||
6079 | @end menu | ||
6080 | |||
6081 | @node Statistics retrieval2 | ||
6082 | @subsubsection Statistics retrieval2 | ||
6083 | |||
6084 | @c %**end of header | ||
6085 | |||
6086 | To retrieve statistics, the client transmits a message of type | ||
6087 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_GET} containing the given subsystem name | ||
6088 | and statistic parameter to the STATISTICS service. The service responds with a | ||
6089 | message of type @code{GNUNET_MESSAGE_TYPE_STATISTICS_VALUE} for each of the | ||
6090 | statistics parameters that match the client request for the client. The end of | ||
6091 | information retrieved is signaled by the service by sending a message of type | ||
6092 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_END}. | ||
6093 | |||
6094 | @node Setting and updating statistics | ||
6095 | @subsubsection Setting and updating statistics | ||
6096 | |||
6097 | @c %**end of header | ||
6098 | |||
6099 | The subsystem name, parameter name, its value and the persistence flag are | ||
6100 | communicated to the service through the message | ||
6101 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}. | ||
6102 | |||
6103 | When the service receives a message of type | ||
6104 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}, it retrieves the subsystem name and | ||
6105 | checks for a statistic parameter with matching the name given in the message. | ||
6106 | If a statistic parameter is found, the value is overwritten by the new value | ||
6107 | from the message; if not found then a new statistic parameter is created with | ||
6108 | the given name and value. | ||
6109 | |||
6110 | In addition to just setting an absolute value, it is possible to perform a | ||
6111 | relative update by sending a message of type | ||
6112 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET} with an update flag | ||
6113 | (@code{GNUNET_STATISTICS_SETFLAG_RELATIVE}) signifying that the value in the | ||
6114 | message should be treated as an update value. | ||
6115 | |||
6116 | @node Watching for updates | ||
6117 | @subsubsection Watching for updates | ||
6118 | |||
6119 | @c %**end of header | ||
6120 | |||
6121 | The function registers the watch at the service by sending a message of type | ||
6122 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH}. The service then sends | ||
6123 | notifications through messages of type | ||
6124 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE} whenever the statistic | ||
6125 | parameter's value is changed. | ||
6126 | |||
6127 | @node GNUnet's Distributed Hash Table (DHT) | ||
6128 | @section GNUnet's Distributed Hash Table (DHT) | ||
6129 | |||
6130 | @c %**end of header | ||
6131 | |||
6132 | GNUnet includes a generic distributed hash table that can be used by developers | ||
6133 | building P2P applications in the framework. This section documents high-level | ||
6134 | features and how developers are expected to use the DHT. We have a research | ||
6135 | paper detailing how the DHT works. Also, Nate's thesis includes a detailed | ||
6136 | description and performance analysis (in chapter 6). | ||
6137 | |||
6138 | Key features of GNUnet's DHT include: | ||
6139 | |||
6140 | @itemize @bullet | ||
6141 | @item stores key-value pairs with values up to (approximately) 63k in size | ||
6142 | @item works with many underlay network topologies (small-world, random graph), | ||
6143 | underlay does not need to be a full mesh / clique | ||
6144 | @item support for extended queries (more than just a simple 'key'), filtering | ||
6145 | duplicate replies within the network (bloomfilter) and content validation (for | ||
6146 | details, please read the subsection on the block library) | ||
6147 | @item can (optionally) return paths taken by the PUT and GET operations to the | ||
6148 | application | ||
6149 | @item provides content replication to handle churn | ||
6150 | @end itemize | ||
6151 | |||
6152 | GNUnet's DHT is randomized and unreliable. Unreliable means that there is no | ||
6153 | strict guarantee that a value stored in the DHT is always found --- values are | ||
6154 | only found with high probability. While this is somewhat true in all P2P DHTs, | ||
6155 | GNUnet developers should be particularly wary of this fact (this will help you | ||
6156 | write secure, fault-tolerant code). Thus, when writing any application using | ||
6157 | the DHT, you should always consider the possibility that a value stored in the | ||
6158 | DHT by you or some other peer might simply not be returned, or returned with a | ||
6159 | significant delay. Your application logic must be written to tolerate this | ||
6160 | (naturally, some loss of performance or quality of service is expected in this | ||
6161 | case). | ||
6162 | |||
6163 | @menu | ||
6164 | * Block library and plugins:: | ||
6165 | * libgnunetdht:: | ||
6166 | * The DHT Client-Service Protocol:: | ||
6167 | * The DHT Peer-to-Peer Protocol:: | ||
6168 | @end menu | ||
6169 | |||
6170 | @node Block library and plugins | ||
6171 | @subsection Block library and plugins | ||
6172 | |||
6173 | @c %**end of header | ||
6174 | |||
6175 | @menu | ||
6176 | * What is a Block?:: | ||
6177 | * The API of libgnunetblock:: | ||
6178 | * Queries:: | ||
6179 | * Sample Code:: | ||
6180 | * Conclusion2:: | ||
6181 | @end menu | ||
6182 | |||
6183 | @node What is a Block? | ||
6184 | @subsubsection What is a Block? | ||
6185 | |||
6186 | @c %**end of header | ||
6187 | |||
6188 | Blocks are small (< 63k) pieces of data stored under a key (struct | ||
6189 | GNUNET_HashCode). Blocks have a type (enum GNUNET_BlockType) which defines | ||
6190 | their data format. Blocks are used in GNUnet as units of static data exchanged | ||
6191 | between peers and stored (or cached) locally. Uses of blocks include | ||
6192 | file-sharing (the files are broken up into blocks), the VPN (DNS information is | ||
6193 | stored in blocks) and the DHT (all information in the DHT and meta-information | ||
6194 | for the maintenance of the DHT are both stored using blocks). The block | ||
6195 | subsystem provides a few common functions that must be available for any type | ||
6196 | of block. | ||
6197 | |||
6198 | @node The API of libgnunetblock | ||
6199 | @subsubsection The API of libgnunetblock | ||
6200 | |||
6201 | @c %**end of header | ||
6202 | |||
6203 | The block library requires for each (family of) block type(s) a block plugin | ||
6204 | (implementing gnunet_block_plugin.h) that provides basic functions that are | ||
6205 | needed by the DHT (and possibly other subsystems) to manage the block. These | ||
6206 | block plugins are typically implemented within their respective subsystems.@ | ||
6207 | The main block library is then used to locate, load and query the appropriate | ||
6208 | block plugin. Which plugin is appropriate is determined by the block type | ||
6209 | (which is just a 32-bit integer). Block plugins contain code that specifies | ||
6210 | which block types are supported by a given plugin. The block library loads all | ||
6211 | block plugins that are installed at the local peer and forwards the application | ||
6212 | request to the respective plugin. | ||
6213 | |||
6214 | The central functions of the block APIs (plugin and main library) are to allow | ||
6215 | the mapping of blocks to their respective key (if possible) and the ability to | ||
6216 | check that a block is well-formed and matches a given request (again, if | ||
6217 | possible). This way, GNUnet can avoid storing invalid blocks, storing blocks | ||
6218 | under the wrong key and forwarding blocks in response to a query that they do | ||
6219 | not answer. | ||
6220 | |||
6221 | One key function of block plugins is that it allows GNUnet to detect duplicate | ||
6222 | replies (via the Bloom filter). All plugins MUST support detecting duplicate | ||
6223 | replies (by adding the current response to the Bloom filter and rejecting it if | ||
6224 | it is encountered again). If a plugin fails to do this, responses may loop in | ||
6225 | the network. | ||
6226 | |||
6227 | @node Queries | ||
6228 | @subsubsection Queries | ||
6229 | @c %**end of header | ||
6230 | |||
6231 | The query format for any block in GNUnet consists of four main components. | ||
6232 | First, the type of the desired block must be specified. Second, the query must | ||
6233 | contain a hash code. The hash code is used for lookups in hash tables and | ||
6234 | databases and must not be unique for the block (however, if possible a unique | ||
6235 | hash should be used as this would be best for performance). Third, an optional | ||
6236 | Bloom filter can be specified to exclude known results; replies that hash to | ||
6237 | the bits set in the Bloom filter are considered invalid. False-positives can be | ||
6238 | eliminated by sending the same query again with a different Bloom filter | ||
6239 | mutator value, which parameterizes the hash function that is used. Finally, an | ||
6240 | optional application-specific "eXtended query" (xquery) can be specified to | ||
6241 | further constrain the results. It is entirely up to the type-specific plugin to | ||
6242 | determine whether or not a given block matches a query (type, hash, Bloom | ||
6243 | filter, and xquery). Naturally, not all xquery's are valid and some types of | ||
6244 | blocks may not support Bloom filters either, so the plugin also needs to check | ||
6245 | if the query is valid in the first place. | ||
6246 | |||
6247 | Depending on the results from the plugin, the DHT will then discard the | ||
6248 | (invalid) query, forward the query, discard the (invalid) reply, cache the | ||
6249 | (valid) reply, and/or forward the (valid and non-duplicate) reply. | ||
6250 | |||
6251 | @node Sample Code | ||
6252 | @subsubsection Sample Code | ||
6253 | |||
6254 | @c %**end of header | ||
6255 | |||
6256 | The source code in @strong{plugin_block_test.c} is a good starting point for | ||
6257 | new block plugins --- it does the minimal work by implementing a plugin that | ||
6258 | performs no validation at all. The respective @strong{Makefile.am} shows how to | ||
6259 | build and install a block plugin. | ||
6260 | |||
6261 | @node Conclusion2 | ||
6262 | @subsubsection Conclusion2 | ||
6263 | |||
6264 | @c %**end of header | ||
6265 | |||
6266 | In conclusion, GNUnet subsystems that want to use the DHT need to define a | ||
6267 | block format and write a plugin to match queries and replies. For testing, the | ||
6268 | "GNUNET_BLOCK_TYPE_TEST" block type can be used; it accepts any query as valid | ||
6269 | and any reply as matching any query. This type is also used for the DHT command | ||
6270 | line tools. However, it should NOT be used for normal applications due to the | ||
6271 | lack of error checking that results from this primitive implementation. | ||
6272 | |||
6273 | @node libgnunetdht | ||
6274 | @subsection libgnunetdht | ||
6275 | |||
6276 | @c %**end of header | ||
6277 | |||
6278 | The DHT API itself is pretty simple and offers the usual GET and PUT functions | ||
6279 | that work as expected. The specified block type refers to the block library | ||
6280 | which allows the DHT to run application-specific logic for data stored in the | ||
6281 | network. | ||
6282 | |||
6283 | |||
6284 | @menu | ||
6285 | * GET:: | ||
6286 | * PUT:: | ||
6287 | * MONITOR:: | ||
6288 | * DHT Routing Options:: | ||
6289 | @end menu | ||
6290 | |||
6291 | @node GET | ||
6292 | @subsubsection GET | ||
6293 | |||
6294 | @c %**end of header | ||
6295 | |||
6296 | When using GET, the main consideration for developers (other than the block | ||
6297 | library) should be that after issuing a GET, the DHT will continuously cause | ||
6298 | (small amounts of) network traffic until the operation is explicitly canceled. | ||
6299 | So GET does not simply send out a single network request once; instead, the | ||
6300 | DHT will continue to search for data. This is needed to achieve good success | ||
6301 | rates and also handles the case where the respective PUT operation happens | ||
6302 | after the GET operation was started. Developers should not cancel an existing | ||
6303 | GET operation and then explicitly re-start it to trigger a new round of | ||
6304 | network requests; this is simply inefficient, especially as the internal | ||
6305 | automated version can be more efficient, for example by filtering results in | ||
6306 | the network that have already been returned. | ||
6307 | |||
6308 | If an application that performs a GET request has a set of replies that it | ||
6309 | already knows and would like to filter, it can call@ | ||
6310 | @code{GNUNET_DHT_get_filter_known_results} with an array of hashes over the | ||
6311 | respective blocks to tell the DHT that these results are not desired (any | ||
6312 | more). This way, the DHT will filter the respective blocks using the block | ||
6313 | library in the network, which may result in a significant reduction in | ||
6314 | bandwidth consumption. | ||
6315 | |||
6316 | @node PUT | ||
6317 | @subsubsection PUT | ||
6318 | |||
6319 | @c %**end of header | ||
6320 | |||
6321 | In contrast to GET operations, developers @strong{must} manually re-run PUT | ||
6322 | operations periodically (if they intend the content to continue to be | ||
6323 | available). Content stored in the DHT expires or might be lost due to churn. | ||
6324 | Furthermore, GNUnet's DHT typically requires multiple rounds of PUT operations | ||
6325 | before a key-value pair is consistently available to all peers (the DHT | ||
6326 | randomizes paths and thus storage locations, and only after multiple rounds of | ||
6327 | PUTs there will be a sufficient number of replicas in large DHTs). An explicit | ||
6328 | PUT operation using the DHT API will only cause network traffic once, so in | ||
6329 | order to ensure basic availability and resistance to churn (and adversaries), | ||
6330 | PUTs must be repeated. While the exact frequency depends on the application, a | ||
6331 | rule of thumb is that there should be at least a dozen PUT operations within | ||
6332 | the content lifetime. Content in the DHT typically expires after one day, so | ||
6333 | DHT PUT operations should be repeated at least every 1-2 hours. | ||
6334 | |||
6335 | @node MONITOR | ||
6336 | @subsubsection MONITOR | ||
6337 | |||
6338 | @c %**end of header | ||
6339 | |||
6340 | The DHT API also allows applications to monitor messages crossing the local | ||
6341 | DHT service. The types of messages used by the DHT are GET, PUT and RESULT | ||
6342 | messages. Using the monitoring API, applications can choose to monitor these | ||
6343 | requests, possibly limiting themselves to requests for a particular block | ||
6344 | type. | ||
6345 | |||
6346 | The monitoring API is not only usefu only for diagnostics, it can also be used | ||
6347 | to trigger application operations based on PUT operations. For example, an | ||
6348 | application may use PUTs to distribute work requests to other peers. The | ||
6349 | workers would then monitor for PUTs that give them work, instead of looking | ||
6350 | for work using GET operations. This can be beneficial, especially if the | ||
6351 | workers have no good way to guess the keys under which work would be stored. | ||
6352 | Naturally, additional protocols might be needed to ensure that the desired | ||
6353 | number of workers will process the distributed workload. | ||
6354 | |||
6355 | @node DHT Routing Options | ||
6356 | @subsubsection DHT Routing Options | ||
6357 | |||
6358 | @c %**end of header | ||
6359 | |||
6360 | There are two important options for GET and PUT requests: | ||
6361 | |||
6362 | @table @asis | ||
6363 | @item GNUNET_DHT_RO_DEMULITPLEX_EVERYWHERE This option means that all peers | ||
6364 | should process the request, even if their peer ID is not closest to the key. | ||
6365 | For a PUT request, this means that all peers that a request traverses may make | ||
6366 | a copy of the data. Similarly for a GET request, all peers will check their | ||
6367 | local database for a result. Setting this option can thus significantly improve | ||
6368 | caching and reduce bandwidth consumption --- at the expense of a larger DHT | ||
6369 | database. If in doubt, we recommend that this option should be used. | ||
6370 | @item GNUNET_DHT_RO_RECORD_ROUTE This option instructs the DHT to record the path | ||
6371 | that a GET or a PUT request is taking through the overlay network. The | ||
6372 | resulting paths are then returned to the application with the respective | ||
6373 | result. This allows the receiver of a result to construct a path to the | ||
6374 | originator of the data, which might then be used for routing. Naturally, | ||
6375 | setting this option requires additional bandwidth and disk space, so | ||
6376 | applications should only set this if the paths are needed by the application | ||
6377 | logic. | ||
6378 | @item GNUNET_DHT_RO_FIND_PEER This option is an internal option used by | ||
6379 | the DHT's peer discovery mechanism and should not be used by applications. | ||
6380 | @item GNUNET_DHT_RO_BART This option is currently not implemented. It may in | ||
6381 | the future offer performance improvements for clique topologies. | ||
6382 | @end table | ||
6383 | |||
6384 | @node The DHT Client-Service Protocol | ||
6385 | @subsection The DHT Client-Service Protocol | ||
6386 | |||
6387 | @c %**end of header | ||
6388 | |||
6389 | @menu | ||
6390 | * PUTting data into the DHT:: | ||
6391 | * GETting data from the DHT:: | ||
6392 | * Monitoring the DHT:: | ||
6393 | @end menu | ||
6394 | |||
6395 | @node PUTting data into the DHT | ||
6396 | @subsubsection PUTting data into the DHT | ||
6397 | |||
6398 | @c %**end of header | ||
6399 | |||
6400 | To store (PUT) data into the DHT, the client sends a@ @code{struct | ||
6401 | GNUNET_DHT_ClientPutMessage} to the service. This message specifies the block | ||
6402 | type, routing options, the desired replication level, the expiration time, key, | ||
6403 | value and a 64-bit unique ID for the operation. The service responds with a@ | ||
6404 | @code{struct GNUNET_DHT_ClientPutConfirmationMessage} with the same 64-bit | ||
6405 | unique ID. Note that the service sends the confirmation as soon as it has | ||
6406 | locally processed the PUT request. The PUT may still be propagating through the | ||
6407 | network at this time. | ||
6408 | |||
6409 | In the future, we may want to change this to provide (limited) feedback to the | ||
6410 | client, for example if we detect that the PUT operation had no effect because | ||
6411 | the same key-value pair was already stored in the DHT. However, changing this | ||
6412 | would also require additional state and messages in the P2P | ||
6413 | interaction. | ||
6414 | |||
6415 | @node GETting data from the DHT | ||
6416 | @subsubsection GETting data from the DHT | ||
6417 | |||
6418 | @c %**end of header | ||
6419 | |||
6420 | To retrieve (GET) data from the DHT, the client sends a@ @code{struct | ||
6421 | GNUNET_DHT_ClientGetMessage} to the service. The message specifies routing | ||
6422 | options, a replication level (for replicating the GET, not the content), the | ||
6423 | desired block type, the key, the (optional) extended query and unique 64-bit | ||
6424 | request ID. | ||
6425 | |||
6426 | Additionally, the client may send any number of@ @code{struct | ||
6427 | GNUNET_DHT_ClientGetResultSeenMessage}s to notify the service about results | ||
6428 | that the client is already aware of. These messages consist of the key, the | ||
6429 | unique 64-bit ID of the request, and an arbitrary number of hash codes over the | ||
6430 | blocks that the client is already aware of. As messages are restricted to 64k, | ||
6431 | a client that already knows more than about a thousand blocks may need to send | ||
6432 | several of these messages. Naturally, the client should transmit these messages | ||
6433 | as quickly as possible after the original GET request such that the DHT can | ||
6434 | filter those results in the network early on. Naturally, as these messages are | ||
6435 | send after the original request, it is conceivalbe that the DHT service may | ||
6436 | return blocks that match those already known to the client anyway. | ||
6437 | |||
6438 | In response to a GET request, the service will send @code{struct | ||
6439 | GNUNET_DHT_ClientResultMessage}s to the client. These messages contain the | ||
6440 | block type, expiration, key, unique ID of the request and of course the value | ||
6441 | (a block). Depending on the options set for the respective operations, the | ||
6442 | replies may also contain the path the GET and/or the PUT took through the | ||
6443 | network. | ||
6444 | |||
6445 | A client can stop receiving replies either by disconnecting or by sending a | ||
6446 | @code{struct GNUNET_DHT_ClientGetStopMessage} which must contain the key and | ||
6447 | the 64-bit unique ID of the original request. Using an explicit "stop" message | ||
6448 | is more common as this allows a client to run many concurrent GET operations | ||
6449 | over the same connection with the DHT service --- and to stop them | ||
6450 | individually. | ||
6451 | |||
6452 | @node Monitoring the DHT | ||
6453 | @subsubsection Monitoring the DHT | ||
6454 | |||
6455 | @c %**end of header | ||
6456 | |||
6457 | To begin monitoring, the client sends a @code{struct | ||
6458 | GNUNET_DHT_MonitorStartStop} message to the DHT service. In this message, flags | ||
6459 | can be set to enable (or disable) monitoring of GET, PUT and RESULT messages | ||
6460 | that pass through a peer. The message can also restrict monitoring to a | ||
6461 | particular block type or a particular key. Once monitoring is enabled, the DHT | ||
6462 | service will notify the client about any matching event using @code{struct | ||
6463 | GNUNET_DHT_MonitorGetMessage}s for GET events, @code{struct | ||
6464 | GNUNET_DHT_MonitorPutMessage} for PUT events and@ @code{struct | ||
6465 | GNUNET_DHT_MonitorGetRespMessage} for RESULTs. Each of these messages contains | ||
6466 | all of the information about the event. | ||
6467 | |||
6468 | @node The DHT Peer-to-Peer Protocol | ||
6469 | @subsection The DHT Peer-to-Peer Protocol | ||
6470 | @c %**end of header | ||
6471 | |||
6472 | |||
6473 | @menu | ||
6474 | * Routing GETs or PUTs:: | ||
6475 | * PUTting data into the DHT2:: | ||
6476 | * GETting data from the DHT2:: | ||
6477 | @end menu | ||
6478 | |||
6479 | @node Routing GETs or PUTs | ||
6480 | @subsubsection Routing GETs or PUTs | ||
6481 | |||
6482 | @c %**end of header | ||
6483 | |||
6484 | When routing GETs or PUTs, the DHT service selects a suitable subset of | ||
6485 | neighbours for forwarding. The exact number of neighbours can be zero or more | ||
6486 | and depends on the hop counter of the query (initially zero) in relation to the | ||
6487 | (log of) the network size estimate, the desired replication level and the | ||
6488 | peer's connectivity. Depending on the hop counter and our network size | ||
6489 | estimate, the selection of the peers maybe randomized or by proximity to the | ||
6490 | key. Furthermore, requests include a set of peers that a request has already | ||
6491 | traversed; those peers are also excluded from the selection. | ||
6492 | |||
6493 | @node PUTting data into the DHT2 | ||
6494 | @subsubsection PUTting data into the DHT2 | ||
6495 | |||
6496 | @c %**end of header | ||
6497 | |||
6498 | To PUT data into the DHT, the service sends a @code{struct PeerPutMessage} of | ||
6499 | type @code{GNUNET_MESSAGE_TYPE_DHT_P2P_PUT} to the respective neighbour. In | ||
6500 | addition to the usual information about the content (type, routing options, | ||
6501 | desired replication level for the content, expiration time, key and value), the | ||
6502 | message contains a fixed-size Bloom filter with information about which peers | ||
6503 | (may) have already seen this request. This Bloom filter is used to ensure that | ||
6504 | DHT messages never loop back to a peer that has already processed the request. | ||
6505 | Additionally, the message includes the current hop counter and, depending on | ||
6506 | the routing options, the message may include the full path that the message has | ||
6507 | taken so far. The Bloom filter should already contain the identity of the | ||
6508 | previous hop; however, the path should not include the identity of the previous | ||
6509 | hop and the receiver should append the identity of the sender to the path, not | ||
6510 | its own identity (this is done to reduce bandwidth). | ||
6511 | |||
6512 | @node GETting data from the DHT2 | ||
6513 | @subsubsection GETting data from the DHT2 | ||
6514 | |||
6515 | @c %**end of header | ||
6516 | |||
6517 | A peer can search the DHT by sending @code{struct PeerGetMessage}s of type | ||
6518 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_GET} to other peers. In addition to the usual | ||
6519 | information about the request (type, routing options, desired replication level | ||
6520 | for the request, the key and the extended query), a GET request also again | ||
6521 | contains a hop counter, a Bloom filter over the peers that have processed the | ||
6522 | request already and depending on the routing options the full path traversed by | ||
6523 | the GET. Finally, a GET request includes a variable-size second Bloom filter | ||
6524 | and a so-called Bloom filter mutator value which together indicate which | ||
6525 | replies the sender has already seen. During the lookup, each block that matches | ||
6526 | they block type, key and extended query is additionally subjected to a test | ||
6527 | against this Bloom filter. The block plugin is expected to take the hash of the | ||
6528 | block and combine it with the mutator value and check if the result is not yet | ||
6529 | in the Bloom filter. The originator of the query will from time to time modify | ||
6530 | the mutator to (eventually) allow false-positives filtered by the Bloom filter | ||
6531 | to be returned. | ||
6532 | |||
6533 | Peers that receive a GET request perform a local lookup (depending on their | ||
6534 | proximity to the key and the query options) and forward the request to other | ||
6535 | peers. They then remember the request (including the Bloom filter for blocking | ||
6536 | duplicate results) and when they obtain a matching, non-filtered response a | ||
6537 | @code{struct PeerResultMessage} of type@ | ||
6538 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT} is forwarded to the previous hop. | ||
6539 | Whenver a result is forwarded, the block plugin is used to update the Bloom | ||
6540 | filter accordingly, to ensure that the same result is never forwarded more than | ||
6541 | once. The DHT service may also cache forwarded results locally if the | ||
6542 | "CACHE_RESULTS" option is set to "YES" in the configuration. | ||
6543 | |||
6544 | @node The GNU Name System (GNS) | ||
6545 | @section The GNU Name System (GNS) | ||
6546 | |||
6547 | @c %**end of header | ||
6548 | |||
6549 | The GNU Name System (GNS) is a decentralized database that enables users to | ||
6550 | securely resolve names to values. Names can be used to identify other users | ||
6551 | (for example, in social networking), or network services (for example, VPN | ||
6552 | services running at a peer in GNUnet, or purely IP-based services on the | ||
6553 | Internet). Users interact with GNS by typing in a hostname that ends in ".gnu" | ||
6554 | or ".zkey". | ||
6555 | |||
6556 | Videos giving an overview of most of the GNS and the motivations behind it is | ||
6557 | available here and here. The remainder of this chapter targets developers that | ||
6558 | are familiar with high level concepts of GNS as presented in these talks. | ||
6559 | |||
6560 | GNS-aware applications should use the GNS resolver to obtain the respective | ||
6561 | records that are stored under that name in GNS. Each record consists of a type, | ||
6562 | value, expiration time and flags. | ||
6563 | |||
6564 | The type specifies the format of the value. Types below 65536 correspond to DNS | ||
6565 | record types, larger values are used for GNS-specific records. Applications can | ||
6566 | define new GNS record types by reserving a number and implementing a plugin | ||
6567 | (which mostly needs to convert the binary value representation to a | ||
6568 | human-readable text format and vice-versa). The expiration time specifies how | ||
6569 | long the record is to be valid. The GNS API ensures that applications are only | ||
6570 | given non-expired values. The flags are typically irrelevant for applications, | ||
6571 | as GNS uses them internally to control visibility and validity of records. | ||
6572 | |||
6573 | Records are stored along with a signature. The signature is generated using the | ||
6574 | private key of the authoritative zone. This allows any GNS resolver to verify | ||
6575 | the correctness of a name-value mapping. | ||
6576 | |||
6577 | Internally, GNS uses the NAMECACHE to cache information obtained from other | ||
6578 | users, the NAMESTORE to store information specific to the local users, and the | ||
6579 | DHT to exchange data between users. A plugin API is used to enable applications | ||
6580 | to define new GNS record types. | ||
6581 | |||
6582 | @menu | ||
6583 | * libgnunetgns:: | ||
6584 | * libgnunetgnsrecord:: | ||
6585 | * GNS plugins:: | ||
6586 | * The GNS Client-Service Protocol:: | ||
6587 | * Hijacking the DNS-Traffic using gnunet-service-dns:: | ||
6588 | * Serving DNS lookups via GNS on W32:: | ||
6589 | @end menu | ||
6590 | |||
6591 | @node libgnunetgns | ||
6592 | @subsection libgnunetgns | ||
6593 | |||
6594 | @c %**end of header | ||
6595 | |||
6596 | The GNS API itself is extremely simple. Clients first connec to the GNS service | ||
6597 | using @code{GNUNET_GNS_connect}. They can then perform lookups using | ||
6598 | @code{GNUNET_GNS_lookup} or cancel pending lookups using | ||
6599 | @code{GNUNET_GNS_lookup_cancel}. Once finished, clients disconnect using | ||
6600 | @code{GNUNET_GNS_disconnect}. | ||
6601 | |||
6602 | |||
6603 | @menu | ||
6604 | * Looking up records:: | ||
6605 | * Accessing the records:: | ||
6606 | * Creating records:: | ||
6607 | * Future work:: | ||
6608 | @end menu | ||
6609 | |||
6610 | @node Looking up records | ||
6611 | @subsubsection Looking up records | ||
6612 | |||
6613 | @c %**end of header | ||
6614 | |||
6615 | @code{GNUNET_GNS_lookup} takes a number of arguments: | ||
6616 | |||
6617 | @table @asis | ||
6618 | @item handle This is simply the GNS connection handle from | ||
6619 | @code{GNUNET_GNS_connect}. | ||
6620 | @item name The client needs to specify the name to | ||
6621 | be resolved. This can be any valid DNS or GNS hostname. | ||
6622 | @item zone The client | ||
6623 | needs to specify the public key of the GNS zone against which the resolution | ||
6624 | should be done (the ".gnu" zone). Note that a key must be provided, even if the | ||
6625 | name ends in ".zkey". This should typically be the public key of the | ||
6626 | master-zone of the user. | ||
6627 | @item type This is the desired GNS or DNS record type | ||
6628 | to look for. While all records for the given name will be returned, this can be | ||
6629 | important if the client wants to resolve record types that themselves delegate | ||
6630 | resolution, such as CNAME, PKEY or GNS2DNS. Resolving a record of any of these | ||
6631 | types will only work if the respective record type is specified in the request, | ||
6632 | as the GNS resolver will otherwise follow the delegation and return the records | ||
6633 | from the respective destination, instead of the delegating record. | ||
6634 | @item only_cached This argument should typically be set to @code{GNUNET_NO}. Setting | ||
6635 | it to @code{GNUNET_YES} disables resolution via the overlay network. | ||
6636 | @item shorten_zone_key If GNS encounters new names during resolution, their | ||
6637 | respective zones can automatically be learned and added to the "shorten zone". | ||
6638 | If this is desired, clients must pass the private key of the shorten zone. If | ||
6639 | NULL is passed, shortening is disabled. | ||
6640 | @item proc This argument identifies | ||
6641 | the function to call with the result. It is given proc_cls, the number of | ||
6642 | records found (possilby zero) and the array of the records as arguments. proc | ||
6643 | will only be called once. After proc,> has been called, the lookup must no | ||
6644 | longer be cancelled. | ||
6645 | @item proc_cls The closure for proc. | ||
6646 | @end table | ||
6647 | |||
6648 | @node Accessing the records | ||
6649 | @subsubsection Accessing the records | ||
6650 | |||
6651 | @c %**end of header | ||
6652 | |||
6653 | The @code{libgnunetgnsrecord} library provides an API to manipulate the GNS | ||
6654 | record array that is given to proc. In particular, it offers functions such as | ||
6655 | converting record values to human-readable strings (and back). However, most | ||
6656 | @code{libgnunetgnsrecord} functions are not interesting to GNS client | ||
6657 | applications. | ||
6658 | |||
6659 | For DNS records, the @code{libgnunetdnsparser} library provides functions for | ||
6660 | parsing (and serializing) common types of DNS records. | ||
6661 | |||
6662 | @node Creating records | ||
6663 | @subsubsection Creating records | ||
6664 | |||
6665 | @c %**end of header | ||
6666 | |||
6667 | Creating GNS records is typically done by building the respective record | ||
6668 | information (possibly with the help of @code{libgnunetgnsrecord} and | ||
6669 | @code{libgnunetdnsparser}) and then using the @code{libgnunetnamestore} to | ||
6670 | publish the information. The GNS API is not involved in this | ||
6671 | operation. | ||
6672 | |||
6673 | @node Future work | ||
6674 | @subsubsection Future work | ||
6675 | |||
6676 | @c %**end of header | ||
6677 | |||
6678 | In the future, we want to expand @code{libgnunetgns} to allow applications to | ||
6679 | observe shortening operations performed during GNS resolution, for example so | ||
6680 | that users can receive visual feedback when this happens. | ||
6681 | |||
6682 | @node libgnunetgnsrecord | ||
6683 | @subsection libgnunetgnsrecord | ||
6684 | |||
6685 | @c %**end of header | ||
6686 | |||
6687 | The @code{libgnunetgnsrecord} library is used to manipulate GNS records (in | ||
6688 | plaintext or in their encrypted format). Applications mostly interact with | ||
6689 | @code{libgnunetgnsrecord} by using the functions to convert GNS record values | ||
6690 | to strings or vice-versa, or to lookup a GNS record type number by name (or | ||
6691 | vice-versa). The library also provides various other functions that are mostly | ||
6692 | used internally within GNS, such as converting keys to names, checking for | ||
6693 | expiration, encrypting GNS records to GNS blocks, verifying GNS block | ||
6694 | signatures and decrypting GNS records from GNS blocks. | ||
6695 | |||
6696 | We will now discuss the four commonly used functions of the API.@ | ||
6697 | @code{libgnunetgnsrecord} does not perform these operations itself, but instead | ||
6698 | uses plugins to perform the operation. GNUnet includes plugins to support | ||
6699 | common DNS record types as well as standard GNS record types. | ||
6700 | |||
6701 | |||
6702 | @menu | ||
6703 | * Value handling:: | ||
6704 | * Type handling:: | ||
6705 | @end menu | ||
6706 | |||
6707 | @node Value handling | ||
6708 | @subsubsection Value handling | ||
6709 | |||
6710 | @c %**end of header | ||
6711 | |||
6712 | @code{GNUNET_GNSRECORD_value_to_string} can be used to convert the (binary) | ||
6713 | representation of a GNS record value to a human readable, 0-terminated UTF-8 | ||
6714 | string. NULL is returned if the specified record type is not supported by any | ||
6715 | available plugin. | ||
6716 | |||
6717 | @code{GNUNET_GNSRECORD_string_to_value} can be used to try to convert a human | ||
6718 | readable string to the respective (binary) representation of a GNS record | ||
6719 | value. | ||
6720 | |||
6721 | @node Type handling | ||
6722 | @subsubsection Type handling | ||
6723 | |||
6724 | @c %**end of header | ||
6725 | |||
6726 | @code{GNUNET_GNSRECORD_typename_to_number} can be used to obtain the numeric | ||
6727 | value associated with a given typename. For example, given the typename "A" | ||
6728 | (for DNS A reocrds), the function will return the number 1. A list of common | ||
6729 | DNS record types is | ||
6730 | @uref{http://en.wikipedia.org/wiki/List_of_DNS_record_types, here. Note that | ||
6731 | not all DNS record types are supported by GNUnet GNSRECORD plugins at this | ||
6732 | time.} | ||
6733 | |||
6734 | @code{GNUNET_GNSRECORD_number_to_typename} can be used to obtain the typename | ||
6735 | associated with a given numeric value. For example, given the type number 1, | ||
6736 | the function will return the typename "A". | ||
6737 | |||
6738 | @node GNS plugins | ||
6739 | @subsection GNS plugins | ||
6740 | |||
6741 | @c %**end of header | ||
6742 | |||
6743 | Adding a new GNS record type typically involves writing (or extending) a | ||
6744 | GNSRECORD plugin. The plugin needs to implement the | ||
6745 | @code{gnunet_gnsrecord_plugin.h} API which provides basic functions that are | ||
6746 | needed by GNSRECORD to convert typenames and values of the respective record | ||
6747 | type to strings (and back). These gnsrecord plugins are typically implemented | ||
6748 | within their respective subsystems. Examples for such plugins can be found in | ||
6749 | the GNSRECORD, GNS and CONVERSATION subsystems. | ||
6750 | |||
6751 | The @code{libgnunetgnsrecord} library is then used to locate, load and query | ||
6752 | the appropriate gnsrecord plugin. Which plugin is appropriate is determined by | ||
6753 | the record type (which is just a 32-bit integer). The @code{libgnunetgnsrecord} | ||
6754 | library loads all block plugins that are installed at the local peer and | ||
6755 | forwards the application request to the plugins. If the record type is not | ||
6756 | supported by the plugin, it should simply return an error code. | ||
6757 | |||
6758 | The central functions of the block APIs (plugin and main library) are the same | ||
6759 | four functions for converting between values and strings, and typenames and | ||
6760 | numbers documented in the previous subsection. | ||
6761 | |||
6762 | @node The GNS Client-Service Protocol | ||
6763 | @subsection The GNS Client-Service Protocol | ||
6764 | |||
6765 | @c %**end of header | ||
6766 | |||
6767 | The GNS client-service protocol consists of two simple messages, the | ||
6768 | @code{LOOKUP} message and the @code{LOOKUP_RESULT}. Each @code{LOOKUP} message | ||
6769 | contains a unique 32-bit identifier, which will be included in the | ||
6770 | corresponding response. Thus, clients can send many lookup requests in parallel | ||
6771 | and receive responses out-of-order. A @code{LOOKUP} request also includes the | ||
6772 | public key of the GNS zone, the desired record type and fields specifying | ||
6773 | whether shortening is enabled or networking is disabled. Finally, the | ||
6774 | @code{LOOKUP} message includes the name to be resolved. | ||
6775 | |||
6776 | The response includes the number of records and the records themselves in the | ||
6777 | format created by @code{GNUNET_GNSRECORD_records_serialize}. They can thus be | ||
6778 | deserialized using @code{GNUNET_GNSRECORD_records_deserialize}. | ||
6779 | |||
6780 | @node Hijacking the DNS-Traffic using gnunet-service-dns | ||
6781 | @subsection Hijacking the DNS-Traffic using gnunet-service-dns | ||
6782 | |||
6783 | @c %**end of header | ||
6784 | |||
6785 | This section documents how the gnunet-service-dns (and the gnunet-helper-dns) | ||
6786 | intercepts DNS queries from the local system.@ This is merely one method for | ||
6787 | how we can obtain GNS queries. It is also possible to change @code{resolv.conf} | ||
6788 | to point to a machine running @code{gnunet-dns2gns} or to modify libc's name | ||
6789 | system switch (NSS) configuration to include a GNS resolution plugin. The | ||
6790 | method described in this chaper is more of a last-ditch catch-all approach. | ||
6791 | |||
6792 | @code{gnunet-service-dns} enables intercepting DNS traffic using policy based | ||
6793 | routing. We MARK every outgoing DNS-packet if it was not sent by our | ||
6794 | application. Using a second routing table in the Linux kernel these marked | ||
6795 | packets are then routed through our virtual network interface and can thus be | ||
6796 | captured unchanged. | ||
6797 | |||
6798 | Our application then reads the query and decides how to handle it: A query to | ||
6799 | an address ending in ".gnu" or ".zkey" is hijacked by @code{gnunet-service-gns} | ||
6800 | and resolved internally using GNS. In the future, a reverse query for an | ||
6801 | address of the configured virtual network could be answered with records kept | ||
6802 | about previous forward queries. Queries that are not hijacked by some | ||
6803 | application using the DNS service will be sent to the original recipient. The | ||
6804 | answer to the query will always be sent back through the virtual interface with | ||
6805 | the original nameserver as source address. | ||
6806 | |||
6807 | |||
6808 | @menu | ||
6809 | * Network Setup Details:: | ||
6810 | @end menu | ||
6811 | |||
6812 | @node Network Setup Details | ||
6813 | @subsubsection Network Setup Details | ||
6814 | |||
6815 | @c %**end of header | ||
6816 | |||
6817 | The DNS interceptor adds the following rules to the Linux kernel: | ||
6818 | @example | ||
6819 | iptables -t mangle -I OUTPUT 1 -p udp --sport $LOCALPORT --dport 53 -j | ||
6820 | ACCEPT iptables -t mangle -I OUTPUT 2 -p udp --dport 53 -j MARK --set-mark 3 ip | ||
6821 | rule add fwmark 3 table2 ip route add default via $VIRTUALDNS table2 | ||
6822 | @end example | ||
6823 | |||
6824 | Line 1 makes sure that all packets coming from a port our application opened | ||
6825 | beforehand (@code{$LOCALPORT}) will be routed normally. Line 2 marks every | ||
6826 | other packet to a DNS-Server with mark 3 (chosen arbitrarily). The third line | ||
6827 | adds a routing policy based on this mark 3 via the routing table. | ||
6828 | |||
6829 | @node Serving DNS lookups via GNS on W32 | ||
6830 | @subsection Serving DNS lookups via GNS on W32 | ||
6831 | |||
6832 | @c %**end of header | ||
6833 | |||
6834 | This section documents how the libw32nsp (and gnunet-gns-helper-service-w32) do | ||
6835 | DNS resolutions of DNS queries on the local system. This only applies to GNUnet | ||
6836 | running on W32. | ||
6837 | |||
6838 | W32 has a concept of "Namespaces" and "Namespace providers". These are used to | ||
6839 | present various name systems to applications in a generic way. Namespaces | ||
6840 | include DNS, mDNS, NLA and others. For each namespace any number of providers | ||
6841 | could be registered, and they are queried in an order of priority (which is | ||
6842 | adjustable). | ||
6843 | |||
6844 | Applications can resolve names by using WSALookupService*() family of | ||
6845 | functions. | ||
6846 | |||
6847 | However, these are WSA-only facilities. Common BSD socket functions for | ||
6848 | namespace resolutions are gethostbyname and getaddrinfo (among others). These | ||
6849 | functions are implemented internally (by default - by mswsock, which also | ||
6850 | implements the default DNS provider) as wrappers around WSALookupService*() | ||
6851 | functions (see "Sample Code for a Service Provider" on MSDN). | ||
6852 | |||
6853 | On W32 GNUnet builds a libw32nsp - a namespace provider, which can then be | ||
6854 | installed into the system by using w32nsp-install (and uninstalled by | ||
6855 | w32nsp-uninstall), as described in "Installation Handbook". | ||
6856 | |||
6857 | libw32nsp is very simple and has almost no dependencies. As a response to | ||
6858 | NSPLookupServiceBegin(), it only checks that the provider GUID passed to it by | ||
6859 | the caller matches GNUnet DNS Provider GUID, checks that name being resolved | ||
6860 | ends in ".gnu" or ".zkey", then connects to gnunet-gns-helper-service-w32 at | ||
6861 | 127.0.0.1:5353 (hardcoded) and sends the name resolution request there, | ||
6862 | returning the connected socket to the caller. | ||
6863 | |||
6864 | When the caller invokes NSPLookupServiceNext(), libw32nsp reads a completely | ||
6865 | formed reply from that socket, unmarshalls it, then gives it back to the | ||
6866 | caller. | ||
6867 | |||
6868 | At the moment gnunet-gns-helper-service-w32 is implemented to ever give only | ||
6869 | one reply, and subsequent calls to NSPLookupServiceNext() will fail with | ||
6870 | WSA_NODATA (first call to NSPLookupServiceNext() might also fail if GNS failed | ||
6871 | to find the name, or there was an error connecting to it). | ||
6872 | |||
6873 | gnunet-gns-helper-service-w32 does most of the processing: | ||
6874 | |||
6875 | @itemize @bullet | ||
6876 | @item Maintains a connection to GNS. | ||
6877 | @item Reads GNS config and loads appropriate keys. | ||
6878 | @item Checks service GUID and decides on the type of record to look up, | ||
6879 | refusing to make a lookup outright when unsupported service GUID is passed. | ||
6880 | @item Launches the lookup | ||
6881 | @end itemize | ||
6882 | |||
6883 | When lookup result arrives, gnunet-gns-helper-service-w32 forms a complete | ||
6884 | reply (including filling a WSAQUERYSETW structure and, possibly, a binary blob | ||
6885 | with a hostent structure for gethostbyname() client), marshalls it, and sends | ||
6886 | it back to libw32nsp. If no records were found, it sends an empty header. | ||
6887 | |||
6888 | This works for most normal applications that use gethostbyname() or | ||
6889 | getaddrinfo() to resolve names, but fails to do anything with applications that | ||
6890 | use alternative means of resolving names (such as sending queries to a DNS | ||
6891 | server directly by themselves). This includes some of well known utilities, | ||
6892 | like "ping" and "nslookup". | ||
6893 | |||
6894 | @node The GNS Namecache | ||
6895 | @section The GNS Namecache | ||
6896 | |||
6897 | @c %**end of header | ||
6898 | |||
6899 | The NAMECACHE subsystem is responsible for caching (encrypted) resolution | ||
6900 | results of the GNU Name System (GNS). GNS makes zone information available to | ||
6901 | other users via the DHT. However, as accessing the DHT for every lookup is | ||
6902 | expensive (and as the DHT's local cache is lost whenever the peer is | ||
6903 | restarted), GNS uses the NAMECACHE as a more persistent cache for DHT lookups. | ||
6904 | Thus, instead of always looking up every name in the DHT, GNS first checks if | ||
6905 | the result is already available locally in the NAMECACHE. Only if there is no | ||
6906 | result in the NAMECACHE, GNS queries the DHT. The NAMECACHE stores data in the | ||
6907 | same (encrypted) format as the DHT. It thus makes no sense to iterate over all | ||
6908 | items in the NAMECACHE --- the NAMECACHE does not have a way to provide the | ||
6909 | keys required to decrypt the entries. | ||
6910 | |||
6911 | Blocks in the NAMECACHE share the same expiration mechanism as blocks in the | ||
6912 | DHT --- the block expires wheneever any of the records in the (encrypted) block | ||
6913 | expires. The expiration time of the block is the only information stored in | ||
6914 | plaintext. The NAMECACHE service internally performs all of the required work | ||
6915 | to expire blocks, clients do not have to worry about this. Also, given that | ||
6916 | NAMECACHE stores only GNS blocks that local users requested, there is no | ||
6917 | configuration option to limit the size of the NAMECACHE. It is assumed to be | ||
6918 | always small enough (a few MB) to fit on the drive. | ||
6919 | |||
6920 | The NAMECACHE supports the use of different database backends via a plugin API. | ||
6921 | |||
6922 | @menu | ||
6923 | * libgnunetnamecache:: | ||
6924 | * The NAMECACHE Client-Service Protocol:: | ||
6925 | * The NAMECACHE Plugin API:: | ||
6926 | @end menu | ||
6927 | |||
6928 | @node libgnunetnamecache | ||
6929 | @subsection libgnunetnamecache | ||
6930 | |||
6931 | @c %**end of header | ||
6932 | |||
6933 | The NAMECACHE API consists of five simple functions. First, there is | ||
6934 | @code{GNUNET_NAMECACHE_connect} to connect to the NAMECACHE service. This | ||
6935 | returns the handle required for all other operations on the NAMECACHE. Using | ||
6936 | @code{GNUNET_NAMECACHE_block_cache} clients can insert a block into the cache. | ||
6937 | @code{GNUNET_NAMECACHE_lookup_block} can be used to lookup blocks that were | ||
6938 | stored in the NAMECACHE. Both operations can be cancelled using | ||
6939 | @code{GNUNET_NAMECACHE_cancel}. Note that cancelling a | ||
6940 | @code{GNUNET_NAMECACHE_block_cache} operation can result in the block being | ||
6941 | stored in the NAMECACHE --- or not. Cancellation primarily ensures that the | ||
6942 | continuation function with the result of the operation will no longer be | ||
6943 | invoked. Finally, @code{GNUNET_NAMECACHE_disconnect} closes the connection to | ||
6944 | the NAMECACHE. | ||
6945 | |||
6946 | The maximum size of a block that can be stored in the NAMECACHE is | ||
6947 | @code{GNUNET_NAMECACHE_MAX_VALUE_SIZE}, which is defined to be 63 kB. | ||
6948 | |||
6949 | @node The NAMECACHE Client-Service Protocol | ||
6950 | @subsection The NAMECACHE Client-Service Protocol | ||
6951 | |||
6952 | @c %**end of header | ||
6953 | |||
6954 | All messages in the NAMECACHE IPC protocol start with the @code{struct | ||
6955 | GNUNET_NAMECACHE_Header} which adds a request ID (32-bit integer) to the | ||
6956 | standard message header. The request ID is used to match requests with the | ||
6957 | respective responses from the NAMECACHE, as they are allowed to happen | ||
6958 | out-of-order. | ||
6959 | |||
6960 | |||
6961 | @menu | ||
6962 | * Lookup:: | ||
6963 | * Store:: | ||
6964 | @end menu | ||
6965 | |||
6966 | @node Lookup | ||
6967 | @subsubsection Lookup | ||
6968 | |||
6969 | @c %**end of header | ||
6970 | |||
6971 | The @code{struct LookupBlockMessage} is used to lookup a block stored in the | ||
6972 | cache. It contains the query hash. The NAMECACHE always responds with a | ||
6973 | @code{struct LookupBlockResponseMessage}. If the NAMECACHE has no response, it | ||
6974 | sets the expiration time in the response to zero. Otherwise, the response is | ||
6975 | expected to contain the expiration time, the ECDSA signature, the derived key | ||
6976 | and the (variable-size) encrypted data of the block. | ||
6977 | |||
6978 | @node Store | ||
6979 | @subsubsection Store | ||
6980 | |||
6981 | @c %**end of header | ||
6982 | |||
6983 | The @code{struct BlockCacheMessage} is used to cache a block in the NAMECACHE. | ||
6984 | It has the same structure as the @code{struct LookupBlockResponseMessage}. The | ||
6985 | service responds with a @code{struct BlockCacheResponseMessage} which contains | ||
6986 | the result of the operation (success or failure). In the future, we might want | ||
6987 | to make it possible to provide an error message as well. | ||
6988 | |||
6989 | @node The NAMECACHE Plugin API | ||
6990 | @subsection The NAMECACHE Plugin API | ||
6991 | @c %**end of header | ||
6992 | |||
6993 | The NAMECACHE plugin API consists of two functions, @code{cache_block} to store | ||
6994 | a block in the database, and @code{lookup_block} to lookup a block in the | ||
6995 | database. | ||
6996 | |||
6997 | |||
6998 | @menu | ||
6999 | * Lookup2:: | ||
7000 | * Store2:: | ||
7001 | @end menu | ||
7002 | |||
7003 | @node Lookup2 | ||
7004 | @subsubsection Lookup2 | ||
7005 | |||
7006 | @c %**end of header | ||
7007 | |||
7008 | The @code{lookup_block} function is expected to return at most one block to the | ||
7009 | iterator, and return @code{GNUNET_NO} if there were no non-expired results. If | ||
7010 | there are multiple non-expired results in the cache, the lookup is supposed to | ||
7011 | return the result with the largest expiration time. | ||
7012 | |||
7013 | @node Store2 | ||
7014 | @subsubsection Store2 | ||
7015 | |||
7016 | @c %**end of header | ||
7017 | |||
7018 | The @code{cache_block} function is expected to try to store the block in the | ||
7019 | database, and return @code{GNUNET_SYSERR} if this was not possible for any | ||
7020 | reason. Furthermore, @code{cache_block} is expected to implicitly perform cache | ||
7021 | maintenance and purge blocks from the cache that have expired. Note that | ||
7022 | @code{cache_block} might encounter the case where the database already has | ||
7023 | another block stored under the same key. In this case, the plugin must ensure | ||
7024 | that the block with the larger expiration time is preserved. Obviously, this | ||
7025 | can done either by simply adding new blocks and selecting for the most recent | ||
7026 | expiration time during lookup, or by checking which block is more recent during | ||
7027 | the store operation. | ||
7028 | |||
7029 | @node The REVOCATION Subsystem | ||
7030 | @section The REVOCATION Subsystem | ||
7031 | @c %**end of header | ||
7032 | |||
7033 | The REVOCATION subsystem is responsible for key revocation of Egos. If a user | ||
7034 | learns that his private key has been compromised or has lost it, he can use the | ||
7035 | REVOCATION system to inform all of the other users that this private key is no | ||
7036 | longer valid. The subsystem thus includes ways to query for the validity of | ||
7037 | keys and to propagate revocation messages. | ||
7038 | |||
7039 | @menu | ||
7040 | * Dissemination:: | ||
7041 | * Revocation Message Design Requirements:: | ||
7042 | * libgnunetrevocation:: | ||
7043 | * The REVOCATION Client-Service Protocol:: | ||
7044 | * The REVOCATION Peer-to-Peer Protocol:: | ||
7045 | @end menu | ||
7046 | |||
7047 | @node Dissemination | ||
7048 | @subsection Dissemination | ||
7049 | |||
7050 | @c %**end of header | ||
7051 | |||
7052 | When a revocation is performed, the revocation is first of all disseminated by | ||
7053 | flooding the overlay network. The goal is to reach every peer, so that when a | ||
7054 | peer needs to check if a key has been revoked, this will be purely a local | ||
7055 | operation where the peer looks at his local revocation list. Flooding the | ||
7056 | network is also the most robust form of key revocation --- an adversary would | ||
7057 | have to control a separator of the overlay graph to restrict the propagation of | ||
7058 | the revocation message. Flooding is also very easy to implement --- peers that | ||
7059 | receive a revocation message for a key that they have never seen before simply | ||
7060 | pass the message to all of their neighbours. | ||
7061 | |||
7062 | Flooding can only distribute the revocation message to peers that are online. | ||
7063 | In order to notify peers that join the network later, the revocation service | ||
7064 | performs efficient set reconciliation over the sets of known revocation | ||
7065 | messages whenever two peers (that both support REVOCATION dissemination) | ||
7066 | connect. The SET service is used to perform this operation | ||
7067 | efficiently. | ||
7068 | |||
7069 | @node Revocation Message Design Requirements | ||
7070 | @subsection Revocation Message Design Requirements | ||
7071 | |||
7072 | @c %**end of header | ||
7073 | |||
7074 | However, flooding is also quite costly, creating O(|E|) messages on a network | ||
7075 | with |E| edges. Thus, revocation messages are required to contain a | ||
7076 | proof-of-work, the result of an expensive computation (which, however, is cheap | ||
7077 | to verify). Only peers that have expended the CPU time necessary to provide | ||
7078 | this proof will be able to flood the network with the revocation message. This | ||
7079 | ensures that an attacker cannot simply flood the network with millions of | ||
7080 | revocation messages. The proof-of-work required by GNUnet is set to take days | ||
7081 | on a typical PC to compute; if the ability to quickly revoke a key is needed, | ||
7082 | users have the option to pre-compute revocation messages to store off-line and | ||
7083 | use instantly after their key has expired. | ||
7084 | |||
7085 | Revocation messages must also be signed by the private key that is being | ||
7086 | revoked. Thus, they can only be created while the private key is in the | ||
7087 | possession of the respective user. This is another reason to create a | ||
7088 | revocation message ahead of time and store it in a secure location. | ||
7089 | |||
7090 | @node libgnunetrevocation | ||
7091 | @subsection libgnunetrevocation | ||
7092 | |||
7093 | @c %**end of header | ||
7094 | |||
7095 | The REVOCATION API consists of two parts, to query and to issue | ||
7096 | revocations. | ||
7097 | |||
7098 | |||
7099 | @menu | ||
7100 | * Querying for revoked keys:: | ||
7101 | * Preparing revocations:: | ||
7102 | * Issuing revocations:: | ||
7103 | @end menu | ||
7104 | |||
7105 | @node Querying for revoked keys | ||
7106 | @subsubsection Querying for revoked keys | ||
7107 | |||
7108 | @c %**end of header | ||
7109 | |||
7110 | @code{GNUNET_REVOCATION_query} is used to check if a given ECDSA public key has | ||
7111 | been revoked. The given callback will be invoked with the result of the check. | ||
7112 | The query can be cancelled using @code{GNUNET_REVOCATION_query_cancel} on the | ||
7113 | return value. | ||
7114 | |||
7115 | @node Preparing revocations | ||
7116 | @subsubsection Preparing revocations | ||
7117 | |||
7118 | @c %**end of header | ||
7119 | |||
7120 | It is often desirable to create a revocation record ahead-of-time and store it | ||
7121 | in an off-line location to be used later in an emergency. This is particularly | ||
7122 | true for GNUnet revocations, where performing the revocation operation itself | ||
7123 | is computationally expensive and thus is likely to take some time. Thus, if | ||
7124 | users want the ability to perform revocations quickly in an emergency, they | ||
7125 | must pre-compute the revocation message. The revocation API enables this with | ||
7126 | two functions that are used to compute the revocation message, but not trigger | ||
7127 | the actual revocation operation. | ||
7128 | |||
7129 | @code{GNUNET_REVOCATION_check_pow} should be used to calculate the | ||
7130 | proof-of-work required in the revocation message. This function takes the | ||
7131 | public key, the required number of bits for the proof of work (which in GNUnet | ||
7132 | is a network-wide constant) and finally a proof-of-work number as arguments. | ||
7133 | The function then checks if the given proof-of-work number is a valid proof of | ||
7134 | work for the given public key. Clients preparing a revocation are expected to | ||
7135 | call this function repeatedly (typically with a monotonically increasing | ||
7136 | sequence of numbers of the proof-of-work number) until a given number satisfies | ||
7137 | the check. That number should then be saved for later use in the revocation | ||
7138 | operation. | ||
7139 | |||
7140 | @code{GNUNET_REVOCATION_sign_revocation} is used to generate the signature that | ||
7141 | is required in a revocation message. It takes the private key that (possibly in | ||
7142 | the future) is to be revoked and returns the signature. The signature can again | ||
7143 | be saved to disk for later use, which will then allow performing a revocation | ||
7144 | even without access to the private key. | ||
7145 | |||
7146 | @node Issuing revocations | ||
7147 | @subsubsection Issuing revocations | ||
7148 | |||
7149 | |||
7150 | Given a ECDSA public key, the signature from @code{GNUNET_REVOCATION_sign} and | ||
7151 | the proof-of-work, @code{GNUNET_REVOCATION_revoke} can be used to perform the | ||
7152 | actual revocation. The given callback is called upon completion of the | ||
7153 | operation. @code{GNUNET_REVOCATION_revoke_cancel} can be used to stop the | ||
7154 | library from calling the continuation; however, in that case it is undefined | ||
7155 | whether or not the revocation operation will be executed. | ||
7156 | |||
7157 | @node The REVOCATION Client-Service Protocol | ||
7158 | @subsection The REVOCATION Client-Service Protocol | ||
7159 | |||
7160 | |||
7161 | The REVOCATION protocol consists of four simple messages. | ||
7162 | |||
7163 | A @code{QueryMessage} containing a public ECDSA key is used to check if a | ||
7164 | particular key has been revoked. The service responds with a | ||
7165 | @code{QueryResponseMessage} which simply contains a bit that says if the given | ||
7166 | public key is still valid, or if it has been revoked. | ||
7167 | |||
7168 | The second possible interaction is for a client to revoke a key by passing a | ||
7169 | @code{RevokeMessage} to the service. The @code{RevokeMessage} contains the | ||
7170 | ECDSA public key to be revoked, a signature by the corresponding private key | ||
7171 | and the proof-of-work, The service responds with a | ||
7172 | @code{RevocationResponseMessage} which can be used to indicate that the | ||
7173 | @code{RevokeMessage} was invalid (i.e. proof of work incorrect), or otherwise | ||
7174 | indicates that the revocation has been processed successfully. | ||
7175 | |||
7176 | @node The REVOCATION Peer-to-Peer Protocol | ||
7177 | @subsection The REVOCATION Peer-to-Peer Protocol | ||
7178 | |||
7179 | @c %**end of header | ||
7180 | |||
7181 | Revocation uses two disjoint ways to spread revocation information among peers. | ||
7182 | First of all, P2P gossip exchanged via CORE-level neighbours is used to quickly | ||
7183 | spread revocations to all connected peers. Second, whenever two peers (that | ||
7184 | both support revocations) connect, the SET service is used to compute the union | ||
7185 | of the respective revocation sets. | ||
7186 | |||
7187 | In both cases, the exchanged messages are @code{RevokeMessage}s which contain | ||
7188 | the public key that is being revoked, a matching ECDSA signature, and a | ||
7189 | proof-of-work. Whenever a peer learns about a new revocation this way, it first | ||
7190 | validates the signature and the proof-of-work, then stores it to disk | ||
7191 | (typically to a file $GNUNET_DATA_HOME/revocation.dat) and finally spreads the | ||
7192 | information to all directly connected neighbours. | ||
7193 | |||
7194 | For computing the union using the SET service, the peer with the smaller hashed | ||
7195 | peer identity will connect (as a "client" in the two-party set protocol) to the | ||
7196 | other peer after one second (to reduce traffic spikes on connect) and initiate | ||
7197 | the computation of the set union. All revocation services use a common hash to | ||
7198 | identify the SET operation over revocation sets. | ||
7199 | |||
7200 | The current implementation accepts revocation set union operations from all | ||
7201 | peers at any time; however, well-behaved peers should only initiate this | ||
7202 | operation once after establishing a connection to a peer with a larger hashed | ||
7203 | peer identity. | ||
7204 | |||
7205 | @node GNUnet's File-sharing (FS) Subsystem | ||
7206 | @section GNUnet's File-sharing (FS) Subsystem | ||
7207 | |||
7208 | @c %**end of header | ||
7209 | |||
7210 | This chapter describes the details of how the file-sharing service works. As | ||
7211 | with all services, it is split into an API (libgnunetfs), the service process | ||
7212 | (gnunet-service-fs) and user interface(s). The file-sharing service uses the | ||
7213 | datastore service to store blocks and the DHT (and indirectly datacache) for | ||
7214 | lookups for non-anonymous file-sharing.@ Furthermore, the file-sharing service | ||
7215 | uses the block library (and the block fs plugin) for validation of DHT | ||
7216 | operations. | ||
7217 | |||
7218 | In contrast to many other services, libgnunetfs is rather complex since the | ||
7219 | client library includes a large number of high-level abstractions; this is | ||
7220 | necessary since the Fs service itself largely only operates on the block level. | ||
7221 | The FS library is responsible for providing a file-based abstraction to | ||
7222 | applications, including directories, meta data, keyword search, verification, | ||
7223 | and so on. | ||
7224 | |||
7225 | The method used by GNUnet to break large files into blocks and to use keyword | ||
7226 | search is called the "Encoding for Censorship Resistant Sharing" (ECRS). ECRS | ||
7227 | is largely implemented in the fs library; block validation is also reflected in | ||
7228 | the block FS plugin and the FS service. ECRS on-demand encoding is implemented | ||
7229 | in the FS service. | ||
7230 | |||
7231 | NOTE: The documentation in this chapter is quite incomplete. | ||
7232 | |||
7233 | @menu | ||
7234 | * Encoding for Censorship-Resistant Sharing (ECRS):: | ||
7235 | * File-sharing persistence directory structure:: | ||
7236 | @end menu | ||
7237 | |||
7238 | @node Encoding for Censorship-Resistant Sharing (ECRS) | ||
7239 | @subsection Encoding for Censorship-Resistant Sharing (ECRS) | ||
7240 | |||
7241 | @c %**end of header | ||
7242 | |||
7243 | When GNUnet shares files, it uses a content encoding that is called ECRS, the | ||
7244 | Encoding for Censorship-Resistant Sharing. Most of ECRS is described in the | ||
7245 | (so far unpublished) research paper attached to this page. ECRS obsoletes the | ||
7246 | previous ESED and ESED II encodings which were used in GNUnet before version | ||
7247 | 0.7.0.@ @ The rest of this page assumes that the reader is familiar with the | ||
7248 | attached paper. What follows is a description of some minor extensions that | ||
7249 | GNUnet makes over what is described in the paper. The reason why these | ||
7250 | extensions are not in the paper is that we felt that they were obvious or | ||
7251 | trivial extensions to the original scheme and thus did not warrant space in | ||
7252 | the research report. | ||
7253 | |||
7254 | |||
7255 | @menu | ||
7256 | * Namespace Advertisements:: | ||
7257 | * KSBlocks:: | ||
7258 | @end menu | ||
7259 | |||
7260 | @node Namespace Advertisements | ||
7261 | @subsubsection Namespace Advertisements | ||
7262 | |||
7263 | @c %**end of header | ||
7264 | @c %**FIXME: all zeroses -> ? | ||
7265 | |||
7266 | An @code{SBlock} with identifier all zeros is a signed | ||
7267 | advertisement for a namespace. This special @code{SBlock} contains metadata | ||
7268 | describing the content of the namespace. Instead of the name of the identifier | ||
7269 | for a potential update, it contains the identifier for the root of the | ||
7270 | namespace. The URI should always be empty. The @code{SBlock} is signed with | ||
7271 | the content provder's RSA private key (just like any other SBlock). Peers | ||
7272 | can search for @code{SBlock}s in order to find out more about a namespace. | ||
7273 | |||
7274 | @node KSBlocks | ||
7275 | @subsubsection KSBlocks | ||
7276 | |||
7277 | @c %**end of header | ||
7278 | |||
7279 | GNUnet implements @code{KSBlocks} which are @code{KBlocks} that, instead of | ||
7280 | encrypting a CHK and metadata, encrypt an @code{SBlock} instead. In other | ||
7281 | words, @code{KSBlocks} enable GNUnet to find @code{SBlocks} using the global | ||
7282 | keyword search. Usually the encrypted @code{SBlock} is a namespace | ||
7283 | advertisement. The rationale behind @code{KSBlock}s and @code{SBlock}s is to | ||
7284 | enable peers to discover namespaces via keyword searches, and, to associate | ||
7285 | useful information with namespaces. When GNUnet finds @code{KSBlocks} during a | ||
7286 | normal keyword search, it adds the information to an internal list of | ||
7287 | discovered namespaces. Users looking for interesting namespaces can then | ||
7288 | inspect this list, reducing the need for out-of-band discovery of namespaces. | ||
7289 | Naturally, namespaces (or more specifically, namespace advertisements) can | ||
7290 | also be referenced from directories, but @code{KSBlock}s should make it easier | ||
7291 | to advertise namespaces for the owner of the pseudonym since they eliminate | ||
7292 | the need to first create a directory. | ||
7293 | |||
7294 | Collections are also advertised using @code{KSBlock}s. | ||
7295 | |||
7296 | @table @asis | ||
7297 | @item Attachment Size | ||
7298 | @item ecrs.pdf 270.68 KB | ||
7299 | @item https://gnunet.org/sites/default/files/ecrs.pdf | ||
7300 | @end table | ||
7301 | |||
7302 | @node File-sharing persistence directory structure | ||
7303 | @subsection File-sharing persistence directory structure | ||
7304 | |||
7305 | @c %**end of header | ||
7306 | |||
7307 | This section documents how the file-sharing library implements persistence of | ||
7308 | file-sharing operations and specifically the resulting directory structure. | ||
7309 | This code is only active if the @code{GNUNET_FS_FLAGS_PERSISTENCE} flag was set | ||
7310 | when calling @code{GNUNET_FS_start}. In this case, the file-sharing library | ||
7311 | will try hard to ensure that all major operations (searching, downloading, | ||
7312 | publishing, unindexing) are persistent, that is, can live longer than the | ||
7313 | process itself. More specifically, an operation is supposed to live until it is | ||
7314 | explicitly stopped. | ||
7315 | |||
7316 | If @code{GNUNET_FS_stop} is called before an operation has been stopped, a | ||
7317 | @code{SUSPEND} event is generated and then when the process calls | ||
7318 | @code{GNUNET_FS_start} next time, a @code{RESUME} event is generated. | ||
7319 | Additionally, even if an application crashes (segfault, SIGKILL, system crash) | ||
7320 | and hence @code{GNUNET_FS_stop} is never called and no @code{SUSPEND} events | ||
7321 | are generated, operations are still resumed (with @code{RESUME} events). This | ||
7322 | is implemented by constantly writing the current state of the file-sharing | ||
7323 | operations to disk. Specifically, the current state is always written to disk | ||
7324 | whenever anything significant changes (the exception are block-wise progress in | ||
7325 | publishing and unindexing, since those operations would be slowed down | ||
7326 | significantly and can be resumed cheaply even without detailed accounting). | ||
7327 | Note that@ if the process crashes (or is killed) during a serialization | ||
7328 | operation, FS does not guarantee that this specific operation is recoverable | ||
7329 | (no strict transactional semantics, again for performance reasons). However, | ||
7330 | all other unrelated operations should resume nicely. | ||
7331 | |||
7332 | Since we need to serialize the state continuously and want to recover as much | ||
7333 | as possible even after crashing during a serialization operation, we do not use | ||
7334 | one large file for serialization. Instead, several directories are used for the | ||
7335 | various operations. When @code{GNUNET_FS_start} executes, the master | ||
7336 | directories are scanned for files describing operations to resume. Sometimes, | ||
7337 | these operations can refer to related operations in child directories which may | ||
7338 | also be resumed at this point. Note that corrupted files are cleaned up | ||
7339 | automatically. However, dangling files in child directories (those that are not | ||
7340 | referenced by files from the master directories) are not automatically removed. | ||
7341 | |||
7342 | Persistence data is kept in a directory that begins with the "STATE_DIR" prefix | ||
7343 | from the configuration file (by default, "$SERVICEHOME/persistence/") followed | ||
7344 | by the name of the client as given to @code{GNUNET_FS_start} (for example, | ||
7345 | "gnunet-gtk") followed by the actual name of the master or child directory. | ||
7346 | |||
7347 | The names for the master directories follow the names of the operations: | ||
7348 | |||
7349 | @itemize @bullet | ||
7350 | @item "search" | ||
7351 | @item "download" | ||
7352 | @item "publish" | ||
7353 | @item "unindex" | ||
7354 | @end itemize | ||
7355 | |||
7356 | Each of the master directories contains names (chosen at random) for each | ||
7357 | active top-level (master) operation. Note that a download that is associated | ||
7358 | with a search result is not a top-level operation. | ||
7359 | |||
7360 | In contrast to the master directories, the child directories are only consulted | ||
7361 | when another operation refers to them. For each search, a subdirectory (named | ||
7362 | after the master search synchronization file) contains the search results. | ||
7363 | Search results can have an associated download, which is then stored in the | ||
7364 | general "download-child" directory. Downloads can be recursive, in which case | ||
7365 | children are stored in subdirectories mirroring the structure of the recursive | ||
7366 | download (either starting in the master "download" directory or in the | ||
7367 | "download-child" directory depending on how the download was initiated). For | ||
7368 | publishing operations, the "publish-file" directory contains information about | ||
7369 | the individual files and directories that are part of the publication. However, | ||
7370 | this directory structure is flat and does not mirror the structure of the | ||
7371 | publishing operation. Note that unindex operations cannot have associated child | ||
7372 | operations. | ||
7373 | |||
7374 | @node GNUnet's REGEX Subsystem | ||
7375 | @section GNUnet's REGEX Subsystem | ||
7376 | |||
7377 | @c %**end of header | ||
7378 | |||
7379 | Using the REGEX subsystem, you can discover peers that offer a particular | ||
7380 | service using regular expressions. The peers that offer a service specify it | ||
7381 | using a regular expressions. Peers that want to patronize a service search | ||
7382 | using a string. The REGEX subsystem will then use the DHT to return a set of | ||
7383 | matching offerers to the patrons. | ||
7384 | |||
7385 | For the technical details, we have "Max's defense talk and Max's Master's | ||
7386 | thesis. An additional publication is under preparation and available to team | ||
7387 | members (in Git). | ||
7388 | |||
7389 | @menu | ||
7390 | * How to run the regex profiler:: | ||
7391 | @end menu | ||
7392 | |||
7393 | @node How to run the regex profiler | ||
7394 | @subsection How to run the regex profiler | ||
7395 | |||
7396 | @c %**end of header | ||
7397 | |||
7398 | The gnunet-regex-profiler can be used to profile the usage of mesh/regex for a | ||
7399 | given set of regular expressions and strings. Mesh/regex allows you to announce | ||
7400 | your peer ID under a certain regex and search for peers matching a particular | ||
7401 | regex using a string. See https://gnunet.org/szengel2012ms for a full | ||
7402 | introduction. | ||
7403 | |||
7404 | First of all, the regex profiler uses GNUnet testbed, thus all the implications | ||
7405 | for testbed also apply to the regex profiler (for example you need | ||
7406 | password-less ssh login to the machines listed in your hosts file). | ||
7407 | |||
7408 | @strong{Configuration} | ||
7409 | |||
7410 | Moreover, an appropriate configuration file is needed. Generally you can refer | ||
7411 | to SVN HEAD: contrib/regex_profiler_infiniband.conf for an example | ||
7412 | configuration. In the following paragraph the important details are | ||
7413 | highlighted. | ||
7414 | |||
7415 | Announcing of the regular expressions is done by the | ||
7416 | gnunet-daemon-regexprofiler, therefore you have to make sure it is started, by | ||
7417 | adding it to the AUTOSTART set of ARM:@ | ||
7418 | @code{ | ||
7419 | [regexprofiler]@ | ||
7420 | AUTOSTART = YES@ | ||
7421 | } | ||
7422 | |||
7423 | Furthermore you have to specify the location of the binary: | ||
7424 | @example | ||
7425 | [regexprofiler] | ||
7426 | # Location of the gnunet-daemon-regexprofiler binary. | ||
7427 | BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-daemon-regexprofiler | ||
7428 | # Regex prefix that will be applied to all regular expressions and | ||
7429 | # search string. | ||
7430 | REGEX_PREFIX = "GNVPN-0001-PAD" | ||
7431 | @end example | ||
7432 | |||
7433 | When running the profiler with a large scale deployment, you probably want to | ||
7434 | reduce the workload of each peer. Use the following options to do this.@ | ||
7435 | @example | ||
7436 | [dht]@ | ||
7437 | # Force network size estimation@ | ||
7438 | FORCE_NSE = 1 | ||
7439 | |||
7440 | [dhtcache] | ||
7441 | DATABASE = heap@ | ||
7442 | # Disable RC-file for Bloom filter? (for benchmarking with limited IO | ||
7443 | # availability)@ | ||
7444 | DISABLE_BF_RC = YES@ | ||
7445 | # Disable Bloom filter entirely@ | ||
7446 | DISABLE_BF = YES | ||
7447 | |||
7448 | [nse]@ | ||
7449 | # Minimize proof-of-work CPU consumption by NSE@ | ||
7450 | WORKBITS = 1 | ||
7451 | @end example | ||
7452 | |||
7453 | |||
7454 | @strong{Options} | ||
7455 | |||
7456 | To finally run the profiler some options and the input data need to be | ||
7457 | specified on the command line. | ||
7458 | @code{@ gnunet-regex-profiler -c config-file -d | ||
7459 | log-file -n num-links -p@ path-compression-length -s search-delay -t | ||
7460 | matching-timeout -a num-search-strings hosts-file policy-dir | ||
7461 | search-strings-file@ } | ||
7462 | |||
7463 | @code{config-file} the configuration file created earlier.@ @code{log-file} | ||
7464 | file where to write statistics output.@ @code{num-links} number of random links | ||
7465 | between started peers.@ @code{path-compression-length} maximum path compression | ||
7466 | length in the DFA.@ @code{search-delay} time to wait between peers finished | ||
7467 | linking and@ starting to match strings.@ @code{matching-timeout} timeout after | ||
7468 | witch to cancel the searching.@ @code{num-search-strings} number of strings in | ||
7469 | the search-strings-file. | ||
7470 | |||
7471 | The @code{hosts-file} should contain a list of hosts for the testbed, one per | ||
7472 | line in the following format. @code{user@@host_ip:port}. | ||
7473 | |||
7474 | The @code{policy-dir} is a folder containing text files containing one or more | ||
7475 | regular expressions. A peer is started for each file in that folder and the | ||
7476 | regular expressions in the corresponding file are announced by this peer. | ||
7477 | |||
7478 | The @code{search-strings-file} is a text file containing search strings, one in | ||
7479 | each line. | ||
7480 | |||
7481 | You can create regular expressions and search strings for every AS in the@ | ||
7482 | Internet using the attached scripts. You need one of the | ||
7483 | @uref{http://data.caida.org/datasets/routing/routeviews-prefix2as/, CAIDA | ||
7484 | routeviews prefix2as} data files for this. Run @code{create_regex.py <filename> | ||
7485 | <output path>} to create the regular expressions and @code{create_strings.py | ||
7486 | <input path> <outfile>} to create a search strings file from the previously | ||
7487 | created regular expressions. | ||
diff --git a/doc/chapters/installation.texi b/doc/chapters/installation.texi deleted file mode 100644 index 14c10d2b0..000000000 --- a/doc/chapters/installation.texi +++ /dev/null | |||
@@ -1,3625 +0,0 @@ | |||
1 | @node GNUnet Installation Handbook | ||
2 | @chapter GNUnet Installation Handbook | ||
3 | |||
4 | This handbook describes how to install (build setup, compilation) and setup | ||
5 | (configuration, start) GNUnet 0.10.x. After following these instructions you | ||
6 | should be able to install and then start user-interfaces to interact with the | ||
7 | network. | ||
8 | |||
9 | This manual is far from complete, and we welcome informed contributions, be it | ||
10 | in the form of new chapters or insightful comments. | ||
11 | |||
12 | |||
13 | |||
14 | @menu | ||
15 | * Dependencies:: | ||
16 | * Pre-installation notes:: | ||
17 | * Generic installation instructions:: | ||
18 | * Build instructions for Ubuntu 12.04 using Git:: | ||
19 | * Build Instructions for Microsoft Windows Platforms:: | ||
20 | * Build instructions for Debian 7.5:: | ||
21 | * Installing GNUnet from Git on Ubuntu 14.4:: | ||
22 | * Build instructions for Debian 8:: | ||
23 | * Outdated build instructions for previous revisions:: | ||
24 | * Portable GNUnet:: | ||
25 | * The graphical configuration interface:: | ||
26 | * How to start and stop a GNUnet peer:: | ||
27 | @end menu | ||
28 | |||
29 | @node Dependencies | ||
30 | @section Dependencies | ||
31 | @c %**end of header | ||
32 | |||
33 | This document lists the various known dependencies for GNUnet 0.10.x. | ||
34 | Suggestions for missing dependencies or wrong version numbers are welcome. | ||
35 | |||
36 | |||
37 | |||
38 | @menu | ||
39 | * External dependencies:: | ||
40 | * Fixing libgnurl build issues:: | ||
41 | * Internal dependencies:: | ||
42 | @end menu | ||
43 | |||
44 | @node External dependencies | ||
45 | @subsection External dependencies | ||
46 | @c %**end of header | ||
47 | |||
48 | These packages must be installed before a typical GNUnet installation | ||
49 | can be performed: | ||
50 | |||
51 | @table @asis | ||
52 | @item GNU libmicrohttpd 0.9.30 or higher | ||
53 | @item GNU libextractor 1.0 or higher | ||
54 | @item GNU libtool 2.2 or higher | ||
55 | @item GNU libunistring 0.9.1.1 or higher | ||
56 | @item GNU libidn 1.0.0 or higher | ||
57 | @item @uref{https://gnupg.org/software/libgcrypt/index.html, GNU libgcrypt} | ||
58 | @uref{https://gnupg.org/ftp/gcrypt/libgcrypt/, 1.6.0} or higher | ||
59 | @item @uref{https://gnutls.org/, GnuTLS} | ||
60 | @uref{https://www.gnupg.org/ftp/gcrypt/gnutls/v3.2/, 3.2.7} or higher, | ||
61 | compile with libunbound for DANE support; GnuTLS also requires GNU | ||
62 | nettle 2.7 (update: GnuTLS 3.2.7 appears NOT to work against GNU nettle | ||
63 | > 2.7, due to some API updatings done by nettle. Thus it should be compiled | ||
64 | against nettle 2.7 and, in case you get some error on the reference to | ||
65 | `rpl_strerror' being undefined, follow the instructions on@ | ||
66 | @uref{http://lists.gnupg.org/pipermail/gnutls-devel/2013-November/006588.html, this} | ||
67 | post (and the link inside it)). | ||
68 | @item @uref{https://gnunet.org/gnurl, gnURL} libgnurl 7.34.0 or higher, | ||
69 | must be compiled after @code{GnuTLS} | ||
70 | @item libglpk 4.45 or higher | ||
71 | @item @uref{http://www.openssl.org/, OpenSSL} (binary) 1.0 or higher | ||
72 | @item TeX Live 2012 or higher, optional (for gnunet-bcd) | ||
73 | @item libpulse 2.0 or higher, optional (for gnunet-conversation) | ||
74 | @item libopus 1.0.1 or higher, optional (for gnunet-conversation) | ||
75 | @item libogg 1.3.0 or higher, optional (for gnunet-conversation) | ||
76 | @item certool (binary) | ||
77 | optional for convenient installation of the GNS proxy | ||
78 | (available as part of Debian's libnss3-tools) | ||
79 | @item python-zbar 0.10 or higher, optional (for gnunet-qr) | ||
80 | @item libsqlite 3.8.0 or higher (note that the code will compile and often work with lower | ||
81 | version numbers, but you may get subtle bugs with respect to quota management | ||
82 | in certain rare cases); alternatively, MySQL or Postgres can also be installed, | ||
83 | but those databases will require more complex configurations (not recommended | ||
84 | for first-time users) | ||
85 | @item zlib any version we tested worked | ||
86 | @item Gtk+ 3.0 or higher, optional (for gnunet-gtk) | ||
87 | @item libgladeui must match Gtk+ version, optional (for gnunet-gtk) | ||
88 | @item libqrencode 3.0 or higher, optional (for gnunet-namestore-gtk) | ||
89 | @end table | ||
90 | |||
91 | |||
92 | @node Fixing libgnurl build issues | ||
93 | @subsection Fixing libgnurl build issues | ||
94 | |||
95 | If you have to compile libgnurl from source since the version included in your | ||
96 | distribution is to old you perhaps get an error message while running the | ||
97 | @file{configure} script: | ||
98 | |||
99 | @code{@ | ||
100 | $ configure@ | ||
101 | ...@ | ||
102 | checking for 64-bit curl_off_t data type... unknown@ | ||
103 | checking for 32-bit curl_off_t data type... unknown@ | ||
104 | checking for 16-bit curl_off_t data type... unknown@ | ||
105 | configure: error: cannot find data type for curl_off_t.@ | ||
106 | } | ||
107 | |||
108 | Solution: | ||
109 | |||
110 | Before running the configure script, set: | ||
111 | |||
112 | @code{CFLAGS="-I. -I$BUILD_ROOT/include" } | ||
113 | |||
114 | |||
115 | |||
116 | @node Internal dependencies | ||
117 | @subsection Internal dependencies | ||
118 | |||
119 | This section tries to give an overview of what processes a typical GNUnet peer | ||
120 | running a particular application would consist of. All of the processes listed | ||
121 | here should be automatically started by @code{gnunet-arm -s}. The list is given | ||
122 | as a rough first guide to users for failure diagnostics. Ideally, end-users | ||
123 | should never have to worry about these internal dependencies. | ||
124 | |||
125 | In terms of internal dependencies, a minimum file-sharing system consists of | ||
126 | the following GNUnet processes (in order of dependency): | ||
127 | |||
128 | @itemize @bullet | ||
129 | @item gnunet-service-arm | ||
130 | @item gnunet-service-resolver (required by all) | ||
131 | @item gnunet-service-statistics (required by all) | ||
132 | @item gnunet-service-peerinfo | ||
133 | @item gnunet-service-transport (requires peerinfo) | ||
134 | @item gnunet-service-core (requires transport) | ||
135 | @item gnunet-daemon-hostlist (requires core) | ||
136 | @item gnunet-daemon-topology (requires hostlist, peerinfo) | ||
137 | @item gnunet-service-datastore | ||
138 | @item gnunet-service-dht (requires core) | ||
139 | @item gnunet-service-identity | ||
140 | @item gnunet-service-fs (requires identity, mesh, dht, datastore, core) | ||
141 | @end itemize | ||
142 | |||
143 | |||
144 | A minimum VPN system consists of the following GNUnet processes (in order of | ||
145 | dependency): | ||
146 | |||
147 | @itemize @bullet | ||
148 | @item gnunet-service-arm | ||
149 | @item gnunet-service-resolver (required by all) | ||
150 | @item gnunet-service-statistics (required by all) | ||
151 | @item gnunet-service-peerinfo | ||
152 | @item gnunet-service-transport (requires peerinfo) | ||
153 | @item gnunet-service-core (requires transport) | ||
154 | @item gnunet-daemon-hostlist (requires core) | ||
155 | @item gnunet-service-dht (requires core) | ||
156 | @item gnunet-service-mesh (requires dht, core) | ||
157 | @item gnunet-service-dns (requires dht) | ||
158 | @item gnunet-service-regex (requires dht) | ||
159 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
160 | @end itemize | ||
161 | |||
162 | |||
163 | A minimum GNS system consists of the following GNUnet processes (in order of | ||
164 | dependency): | ||
165 | @itemize @bullet | ||
166 | @item gnunet-service-arm | ||
167 | @item gnunet-service-resolver (required by all) | ||
168 | @item gnunet-service-statistics (required by all) | ||
169 | @item gnunet-service-peerinfo | ||
170 | @item gnunet-service-transport (requires peerinfo) | ||
171 | @item gnunet-service-core (requires transport) | ||
172 | @item gnunet-daemon-hostlist (requires core) | ||
173 | @item gnunet-service-dht (requires core) | ||
174 | @item gnunet-service-mesh (requires dht, core) | ||
175 | @item gnunet-service-dns (requires dht) | ||
176 | @item gnunet-service-regex (requires dht) | ||
177 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
178 | @item gnunet-service-identity | ||
179 | @item gnunet-service-namestore (requires identity) | ||
180 | @item gnunet-service-gns (requires vpn, dns, dht, namestore, identity) | ||
181 | @end itemize | ||
182 | |||
183 | @node Pre-installation notes | ||
184 | @section Pre-installation notes | ||
185 | |||
186 | Please note that in the code instructions for the installation, | ||
187 | @emph{#} indicates commands run as privileged root user and | ||
188 | @emph{$} shows commands run as unprivileged ("normal") system user. | ||
189 | |||
190 | |||
191 | @node Generic installation instructions | ||
192 | @section Generic installation instructions | ||
193 | |||
194 | First, in addition to the GNUnet sources you must download the latest version | ||
195 | of various dependencies. Most distributions do not include sufficiently recent | ||
196 | versions of these dependencies. Thus, a typically installation on a "modern" | ||
197 | GNU/Linux distribution requires you to install the following | ||
198 | dependencies (ideally in this order): | ||
199 | |||
200 | @itemize @bullet | ||
201 | @item libgpgerror and libgcrypt | ||
202 | @item libnettle and libunbound (possibly from distribution), GnuTLS | ||
203 | @item libgnurl (read the README) | ||
204 | @item GNU libmicrohttpd | ||
205 | @item GNU libextractor (make sure to first install the various mandatory and optional | ||
206 | dependencies including development headers from your distribution) | ||
207 | @end itemize | ||
208 | |||
209 | Other dependencies that you should strongly consider to install is a | ||
210 | database (MySQL, sqlite or Postgres). The following instructions will assume | ||
211 | that you installed at least sqlite. For most distributions you should be able | ||
212 | to find pre-build packages for the database. Again, make sure to install the | ||
213 | client libraries and the respective development headers (if they are | ||
214 | packaged separately) as well. | ||
215 | |||
216 | You can find specific, detailed instructions for installing of the dependencies | ||
217 | (and possibly the rest of the GNUnet installation) in the platform-specific | ||
218 | descriptions, which are linked from the bottom of this page. Please consult | ||
219 | them now. If your distribution is not listed, please study the instructions for | ||
220 | Debian stable carefully as you try to install the dependencies for your own | ||
221 | distribution. Contributing additional instructions for further platforms is | ||
222 | always appreciated. | ||
223 | |||
224 | Before proceeding further, please double-check the dependency list. Note that | ||
225 | in addition to satisfying the dependencies, you might have to make sure that | ||
226 | development headers for the various libraries are also installed. There maybe | ||
227 | files for other distributions, or you might be able to find equivalent packages | ||
228 | for your distribution. | ||
229 | |||
230 | While it is possible to build and install GNUnet without having root access, | ||
231 | we will assume that you have full control over your system in these | ||
232 | instructions. First, you should create a system user @emph{gnunet} and an additional | ||
233 | group @emph{gnunetdns}. On Debian and Ubuntu GNU/Linux, type:@ | ||
234 | @code{@ | ||
235 | # adduser --system --home /var/lib/gnunet --group --disabled-password gnunet@ | ||
236 | # addgroup --system gnunetdns@ | ||
237 | }@ | ||
238 | On other Unixes, this should have the same effect:@ | ||
239 | @code{@ | ||
240 | # useradd --system --groups gnunet --home-dir /var/lib/gnunet@ | ||
241 | # addgroup --system gnunetdns@ | ||
242 | }@ | ||
243 | Now compile and install GNUnet using:@ | ||
244 | @code{@ | ||
245 | $ tar xvf gnunet-0.10.?.tar.gz@ | ||
246 | $ cd gnunet-0.10.?@ | ||
247 | $ ./configure --with-sudo=sudo --with-nssdir=/lib@ | ||
248 | $ make@ | ||
249 | $ sudo make install@ | ||
250 | }@ | ||
251 | |||
252 | If you want to be able to enable DEBUG-level log messages, add | ||
253 | @code{--enable-logging=verbose} to the end of the @code{./configure} command. | ||
254 | DEBUG-level log messages are in English-only and should only be useful for | ||
255 | developers (or for filing really detailed bug reports). | ||
256 | |||
257 | Finally, you probably want to compile @code{gnunet-gtk}, which includes gnunet-setup | ||
258 | (graphical tool for configuration) and @code{gnunet-fs-gtk} (graphical tool for | ||
259 | file-sharing):@ | ||
260 | |||
261 | @code{@ | ||
262 | $ tar xvf gnunet-gtk-0.10.?.tar.gz@ | ||
263 | $ cd gnunet-gtk-0.10.?@ | ||
264 | $ ./configure --with-gnunet=/usr/local/@ | ||
265 | $ make@ | ||
266 | $ sudo make install@ | ||
267 | $ cd ..@ | ||
268 | $ sudo ldconfig # just to be safe@ | ||
269 | }@ | ||
270 | Next, edit the file @file{/etc/gnunet.conf} to contain the following:@ | ||
271 | @code{@ | ||
272 | [arm]@ | ||
273 | SYSTEM_ONLY = YES@ | ||
274 | USER_ONLY = NO@ | ||
275 | }@ | ||
276 | You may need to update your ld.so cache to include files installed in | ||
277 | @file{/usr/local/lib}:@ | ||
278 | |||
279 | @code{@ | ||
280 | # ldconfig@ | ||
281 | }@ | ||
282 | |||
283 | Then, switch from user root to user gnunet to start the peer:@ | ||
284 | |||
285 | @code{@ | ||
286 | # su -s /bin/sh - gnunet@ | ||
287 | $ gnunet-arm -c /etc/gnunet.conf -s@ | ||
288 | }@ | ||
289 | |||
290 | You may also want to add the last line in the gnunet users @file{crontab} | ||
291 | prefixed with @code{@@reboot} so that it is executed whenever the system is | ||
292 | booted:@ | ||
293 | |||
294 | @code{@ | ||
295 | @@reboot /usr/local/bin/gnunet-arm -c /etc/gnunet.conf -s@ | ||
296 | }@ | ||
297 | |||
298 | This will only start the system-wide GNUnet services. Type exit to get back | ||
299 | your root shell. Now, you need to configure the per-user part. For each | ||
300 | $USER on the system, run:@ | ||
301 | |||
302 | @code{@ | ||
303 | # adduser $USER gnunet@ | ||
304 | }@ | ||
305 | |||
306 | to allow them to access the system-wide GNUnet services. Then, each user should | ||
307 | create a configuration file @file{~/.config/gnunet.conf} with the lines:@ | ||
308 | |||
309 | @code{@ | ||
310 | [arm]@ | ||
311 | SYSTEM_ONLY = NO@ | ||
312 | USER_ONLY = YES@ | ||
313 | DEFAULTSERVICES = gns@ | ||
314 | }@ | ||
315 | |||
316 | and start the per-user services using@ | ||
317 | |||
318 | @code{@ | ||
319 | $ gnunet-arm -c ~/.config/gnunet.conf -s@ | ||
320 | }@ | ||
321 | |||
322 | Again, adding a @code{crontab} entry to autostart the peer is advised:@ | ||
323 | @code{@ | ||
324 | @@reboot /usr/local/bin/gnunet-arm -c $HOME/.config/gnunet.conf -s@ | ||
325 | }@ | ||
326 | |||
327 | Note that some GNUnet services (such as SOCKS5 proxies) may need a system-wide | ||
328 | TCP port for each user. For those services, systems with more than one user may | ||
329 | require each user to specify a different port number in their personal | ||
330 | configuration file. | ||
331 | |||
332 | Finally, the user should perform the basic initial setup for the GNU Name | ||
333 | System. This is done by running two commands:@ | ||
334 | |||
335 | @example | ||
336 | $ gnunet-gns-import.sh@ | ||
337 | $ gnunet-gns-proxy-setup-ca@ | ||
338 | @end example | ||
339 | |||
340 | The first generates the default zones, wheras the second setups the GNS | ||
341 | Certificate Authority with the user's browser. Now, to actiave GNS in the | ||
342 | normal DNS resolution process, you need to edit your @file{/etc/nsswitch.conf} | ||
343 | where you should find a line like this: | ||
344 | @example | ||
345 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
346 | @end example | ||
347 | |||
348 | |||
349 | The exact details may differ a bit, which is fine. Add the text | ||
350 | @emph{"gns [NOTFOUND=return]"} after @emph{"files"}: | ||
351 | @example | ||
352 | hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
353 | @end example | ||
354 | |||
355 | |||
356 | You might want to make sure that @file{/lib/libnss_gns.so.2} exists on your | ||
357 | system, it should have been created during the installation. | ||
358 | |||
359 | |||
360 | |||
361 | @node Build instructions for Ubuntu 12.04 using Git | ||
362 | @section Build instructions for Ubuntu 12.04 using Git | ||
363 | |||
364 | |||
365 | @menu | ||
366 | * Install the required build tools:: | ||
367 | * Install libgcrypt 1.6 and libgpg-error:: | ||
368 | * Install gnutls with DANE support:: | ||
369 | * Install libgnurl:: | ||
370 | * Install libmicrohttpd from Git:: | ||
371 | * Install libextractor from Git:: | ||
372 | * Install GNUnet dependencies:: | ||
373 | * Build GNUnet:: | ||
374 | * Install the GNUnet-gtk user interface from Git:: | ||
375 | @end menu | ||
376 | |||
377 | @node Install the required build tools | ||
378 | @subsection Install the required build tools | ||
379 | |||
380 | First, make sure Git is installed on your system:@ | ||
381 | |||
382 | $ sudo apt-get install git@ | ||
383 | |||
384 | Install the essential buildtools:@ | ||
385 | |||
386 | $ sudo apt-get install automake autopoint autoconf libtool | ||
387 | |||
388 | @node Install libgcrypt 1.6 and libgpg-error | ||
389 | @subsection Install libgcrypt 1.6 and libgpg-error | ||
390 | |||
391 | $ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.12.tar.bz2@ | ||
392 | $ tar xf libgpg-error-1.12.tar.bz2@ | ||
393 | $ cd libgpg-error-1.12@ | ||
394 | $ ./configure@ | ||
395 | $ sudo make install@ | ||
396 | $ cd ..@ | ||
397 | |||
398 | @node Install gnutls with DANE support | ||
399 | @subsection Install gnutls with DANE support | ||
400 | |||
401 | @example | ||
402 | $ wget http://www.lysator.liu.se/~nisse/archive/nettle-2.7.1.tar.gz@ | ||
403 | $ tar xf nettle-2.7.1.tar.gz@ | ||
404 | $ cd nettle-2.7.1@ | ||
405 | $ ./configure@ | ||
406 | $ sudo make install@ | ||
407 | $ cd .. | ||
408 | @end example | ||
409 | |||
410 | @example | ||
411 | $ wget https://www.nlnetlabs.nl/downloads/ldns/ldns-1.6.16.tar.gz@ | ||
412 | $ tar xf ldns-1.6.16.tar.gz@ | ||
413 | $ cd ldns-1.6.16@ | ||
414 | $ ./configure@ | ||
415 | $ sudo make install@ | ||
416 | $ cd .. | ||
417 | @end example | ||
418 | |||
419 | @example | ||
420 | $ wget https://unbound.net/downloads/unbound-1.4.21.tar.gz@ | ||
421 | $ tar xf unbound-1.4.21.tar.gz@ | ||
422 | $ cd unbound-1.4.21@ | ||
423 | $ ./configure@ | ||
424 | $ sudo make install@ | ||
425 | $ cd .. | ||
426 | @end example | ||
427 | |||
428 | @example | ||
429 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.17.tar.xz@ | ||
430 | $ tar xf gnutls-3.1.17.tar.xz@ | ||
431 | $ cd gnutls-3.1.17@ | ||
432 | $ ./configure@ | ||
433 | $ sudo make install@ | ||
434 | $ cd .. | ||
435 | @end example | ||
436 | |||
437 | @example | ||
438 | $ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.0.tar.bz2@ | ||
439 | $ tar xf libgcrypt-1.6.0.tar.bz2@ | ||
440 | $ cd libgcrypt-1.6.0@ | ||
441 | $ ./configure@ | ||
442 | $ sudo make install@ | ||
443 | $ cd ..@ | ||
444 | @end example | ||
445 | |||
446 | @node Install libgnurl | ||
447 | @subsection Install libgnurl | ||
448 | |||
449 | @example | ||
450 | $ wget https://gnunet.org/sites/default/files/gnurl-7.34.0.tar.bz2@ | ||
451 | $ tar xf gnurl-7.34.0.tar.bz2@ | ||
452 | $ cd gnurl-7.34.0@ | ||
453 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
454 | --without-libmetalink --without-winidn --without-librtmp \ | ||
455 | --without-nghttp2 --without-nss --without-cyassl \ | ||
456 | --without-polarssl --without-ssl --without-winssl \ | ||
457 | --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
458 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet \ | ||
459 | --disable-tftp --disable-pop3 --disable-imap --disable-smtp \ | ||
460 | --disable-gopher --disable-file --disable-ftp@ | ||
461 | $ sudo make install@ | ||
462 | $ cd ..@ | ||
463 | @end example | ||
464 | |||
465 | @node Install libmicrohttpd from Git | ||
466 | @subsection Install libmicrohttpd from Git | ||
467 | |||
468 | @example | ||
469 | $ git clone https://gnunet.org/git/libmicrohttpd@ | ||
470 | $ cd libmicrohttpd/@ | ||
471 | $ ./bootstrap@ | ||
472 | $ ./configure@ | ||
473 | $ sudo make install@ | ||
474 | $ cd ..@ | ||
475 | @end example | ||
476 | |||
477 | @node Install libextractor from Git | ||
478 | @subsection Install libextractor from Git | ||
479 | |||
480 | Install libextractor dependencies:@ | ||
481 | |||
482 | @example | ||
483 | $ sudo apt-get install zlib1g-dev libgsf-1-dev libmpeg2-4-dev libpoppler-dev \ | ||
484 | libvorbis-dev libexiv2-dev libjpeg-dev libtiff-dev libgif-dev libvorbis-dev \ | ||
485 | libflac-dev libsmf-dev g++@ | ||
486 | @end example | ||
487 | |||
488 | Build libextractor:@ | ||
489 | |||
490 | @example | ||
491 | $ git clone https://gnunet.org/git/libextractor@ | ||
492 | $ cd libextractor@ | ||
493 | $ ./bootstrap@ | ||
494 | $ ./configure@ | ||
495 | $ sudo make install@ | ||
496 | $ cd ..@ | ||
497 | @end example | ||
498 | |||
499 | @node Install GNUnet dependencies | ||
500 | @subsection Install GNUnet dependencies | ||
501 | |||
502 | @example | ||
503 | $ sudo apt-get install libidn11-dev libunistring-dev libglpk-dev \ | ||
504 | libpulse-dev libbluetooth-dev libsqlite-dev@ | ||
505 | @end example | ||
506 | |||
507 | Install libopus@ | ||
508 | |||
509 | @example | ||
510 | $ wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz@ | ||
511 | $ tar xf opus-1.1.tar.gz@ | ||
512 | $ cd opus-1.1/@ | ||
513 | $ ./configure@ | ||
514 | $ sudo make install@ | ||
515 | @end example | ||
516 | |||
517 | Choose one or more database backends@ | ||
518 | |||
519 | @itemize @bullet | ||
520 | |||
521 | @item | ||
522 | SQLite3 @code{$ sudo apt-get install libsqlite3-dev} | ||
523 | |||
524 | @item | ||
525 | MySQL @code{$ sudo apt-get install libmysqlclient-dev} | ||
526 | |||
527 | @item | ||
528 | PostgreSQL @code{$ sudo apt-get install libpq-dev postgresql} | ||
529 | |||
530 | @end itemize | ||
531 | |||
532 | |||
533 | |||
534 | @node Build GNUnet | ||
535 | @subsection Build GNUnet | ||
536 | |||
537 | |||
538 | |||
539 | @menu | ||
540 | * Configuring the installation path:: | ||
541 | * Configuring the system:: | ||
542 | * Installing components requiring sudo permission:: | ||
543 | * Build:: | ||
544 | @end menu | ||
545 | |||
546 | @node Configuring the installation path | ||
547 | @subsubsection Configuring the installation path | ||
548 | |||
549 | You can specify the location of the GNUnet installation by setting the prefix | ||
550 | when calling the configure script:@code{ --prefix=DIRECTORY} | ||
551 | |||
552 | @code{@ | ||
553 | $ export PATH=$PATH:DIRECTORY/bin@ | ||
554 | } | ||
555 | |||
556 | @node Configuring the system | ||
557 | @subsubsection Configuring the system | ||
558 | |||
559 | Please make sure NOW that you have created a user and group 'gnunet'@ | ||
560 | and additionally a group 'gnunetdns':@ | ||
561 | @code{@ | ||
562 | $ sudo addgroup gnunet@ | ||
563 | $ sudo addgroup gnunetdns@ | ||
564 | $ sudo adduser gnunet@ | ||
565 | } | ||
566 | |||
567 | Each GNUnet user should be added to the 'gnunet' group (may@ | ||
568 | require fresh login to come into effect): | ||
569 | @code{@ | ||
570 | $ sudo useradd -G gnunet@ | ||
571 | } | ||
572 | |||
573 | @node Installing components requiring sudo permission | ||
574 | @subsubsection Installing components requiring sudo permission | ||
575 | |||
576 | Some components, like the nss plugin required for GNS, may require root | ||
577 | permissions. To allow these few components to be installed use:@ | ||
578 | @code{@ | ||
579 | $ ./configure --with-sudo} | ||
580 | |||
581 | @node Build | ||
582 | @subsubsection Build | ||
583 | |||
584 | |||
585 | @code{@ | ||
586 | $ git clone https://gnunet.org/git/gnunet/@ | ||
587 | $ cd gnunet/@ | ||
588 | $ ./bootstrap@ | ||
589 | } | ||
590 | Use the required configure call including the optional installation prefix | ||
591 | PREFIX or the sudo permissions@ | ||
592 | @code{$ ./configure [ --with-sudo | --with-prefix=PREFIX ]}@ | ||
593 | @code{$ make; sudo make install} | ||
594 | |||
595 | After installing it, you need to create an empty configuration file:@ | ||
596 | @code{mkdir ~/.gnunet; touch ~/.gnunet/gnunet.conf} | ||
597 | |||
598 | And finally you can start GNUnet with@ | ||
599 | @code{$ gnunet-arm -s} | ||
600 | |||
601 | @node Install the GNUnet-gtk user interface from Git | ||
602 | @subsection Install the GNUnet-gtk user interface from Git | ||
603 | |||
604 | |||
605 | Install depencies:@ | ||
606 | @code{$ sudo apt-get install libgtk-3-dev libunique-3.0-dev libgladeui-dev libqrencode-dev} | ||
607 | |||
608 | To build GNUnet (with an optional prefix)and execute:@ | ||
609 | @code{@ | ||
610 | $ git clone https://gnunet.org/git/gnunet-gtk/@ | ||
611 | $ cd gnunet-gtk/@ | ||
612 | $ ./bootstrap@ | ||
613 | $ ./configure [--prefix=PREFIX] --with-gnunet=DIRECTORY@ | ||
614 | $ make; sudo make install@ | ||
615 | } | ||
616 | |||
617 | @node Build Instructions for Microsoft Windows Platforms | ||
618 | @section Build Instructions for Microsoft Windows Platforms | ||
619 | |||
620 | |||
621 | |||
622 | @menu | ||
623 | * Introduction to building on MS Windows:: | ||
624 | * Requirements:: | ||
625 | * Dependencies & Initial Setup:: | ||
626 | * GNUnet Installation:: | ||
627 | * Adjusting Windows for running and testing GNUnet:: | ||
628 | * Building the GNUnet Installer:: | ||
629 | * Using GNUnet with Netbeans on Windows:: | ||
630 | @end menu | ||
631 | |||
632 | @node Introduction to building on MS Windows | ||
633 | @subsection Introduction to building on MS Windows | ||
634 | |||
635 | |||
636 | This document is a guide to building GNUnet and its dependencies on Windows | ||
637 | platforms. GNUnet development is mostly done under Linux and especially SVN | ||
638 | checkouts may not build out of the box. We regret any inconvenience, and if you | ||
639 | have problems, please report them. | ||
640 | |||
641 | @node Requirements | ||
642 | @subsection Requirements | ||
643 | |||
644 | The Howto is based upon a @strong{Windows Server 2008 32bit@strong{ | ||
645 | Installation, @strong{sbuild} and thus a @uref{http://www.mingw.org/wiki/MSYS, | ||
646 | MSYS+MinGW} (W32-GCC-Compiler-Suite + Unix-like Userland) installation. sbuild | ||
647 | is a convenient set of scripts which creates a working msys/mingw installation | ||
648 | and installs most dependencies required for GNUnet. }} | ||
649 | |||
650 | As of the point of the creation of this Howto, GNUnet @strong{requires} a | ||
651 | Windows @strong{Server} 2003 or newer for full feature support. Windows Vista | ||
652 | and later will also work, but | ||
653 | @strong{non-server version can not run a VPN-Exit-Node} as the NAT features | ||
654 | have been removed as of Windows Vista. | ||
655 | |||
656 | @node Dependencies & Initial Setup | ||
657 | @subsection Dependencies & Initial Setup | ||
658 | |||
659 | |||
660 | @itemize @bullet | ||
661 | |||
662 | @item | ||
663 | Install a fresh version of @strong{Python 2.x}, even if you are using a x64-OS, | ||
664 | install a 32-bit version for use with sbuild. Python 3.0 currently is | ||
665 | incompatible. | ||
666 | |||
667 | @item | ||
668 | Install your favorite @uref{http://code.google.com/p/tortoisegit/, GIT} & | ||
669 | @uref{http://tortoisesvn.net/, SVN}-clients. | ||
670 | |||
671 | @item | ||
672 | You will also need some archive-manager like @uref{http://www.7-zip.org/, 7zip}. | ||
673 | |||
674 | @item | ||
675 | Pull a copy of sbuild to a directory of your choice, which will be used in the | ||
676 | remainder of this guide. For now, we will use @file{c:\gnunet\sbuild\} | ||
677 | |||
678 | @item | ||
679 | in @file{sbuild\src\mingw\mingw32-buildall.sh}, comment out the packages | ||
680 | @strong{gnunet-svn} and @strong{gnunet-gtk-svn}, as we don't want sbuild to | ||
681 | compile/install those for us. | ||
682 | |||
683 | @item | ||
684 | Follow LRN's sbuild installation instructions.- | ||
685 | @end itemize | ||
686 | |||
687 | Please note that sbuild may (or will most likely) fail during installation, | ||
688 | thus you really HAVE to @strong{check the logfiles} created during the | ||
689 | installation process. Certain packages may fail to build initially due to | ||
690 | missing dependencies, thus you may have to | ||
691 | @strong{substitute those with binary-versions initially}. Later on once | ||
692 | dependencies are satisfied you can re-build the newer package versions. | ||
693 | |||
694 | @strong{It is normal that you may have to repeat this step multiple times and | ||
695 | there is no uniform way to fix all compile-time issues, as the build-process | ||
696 | of many of the dependencies installed are rather unstable on win32 and certain | ||
697 | releases may not even compile at all.} | ||
698 | |||
699 | Most dependencies for GNUnet have been set up by sbuild, thus we now should add | ||
700 | the @file{bin/} directories in your new msys and mingw installations to PATH. | ||
701 | You will want to create a backup of your finished msys-environment by now. | ||
702 | |||
703 | @node GNUnet Installation | ||
704 | @subsection GNUnet Installation | ||
705 | |||
706 | First, we need to launch our msys-shell, you can do this via | ||
707 | |||
708 | @file{C:\gnunet\sbuild\msys\msys.bat} | ||
709 | |||
710 | You might wish to take a look at this file and adjust some login-parameters to | ||
711 | your msys environment. | ||
712 | |||
713 | Also, sbuild added two pointpoints to your msys-environment, though those | ||
714 | might remain invisible: | ||
715 | |||
716 | @itemize @bullet | ||
717 | |||
718 | @item | ||
719 | /mingw, which will mount your mingw-directory from sbuild/mingw and the other one is | ||
720 | |||
721 | @item | ||
722 | /src which contains all the installation sources sbuild just compiled. | ||
723 | @end itemize | ||
724 | |||
725 | Check out the current gnunet-sources (svn-head) from the gnunet-repository, | ||
726 | we will do this in your home directory: | ||
727 | |||
728 | @code{svn checkout https://gnunet.org/svn/gnunet/ ~/gnunet} | ||
729 | |||
730 | Now, we will first need to bootstrap the checked out installation and then | ||
731 | configure it accordingly. | ||
732 | |||
733 | @example | ||
734 | cd ~/gnunet@ | ||
735 | ./bootstrap@ | ||
736 | STRIP=true CPPFLAGS="-DUSE_IPV6=1 -DW32_VEH" CFLAGS="$CFLAGS -g -O2" ./configure --prefix=/ --docdir=/share/doc/gnunet --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --with-libcurl=/mingw --with-extractor=/mingw --with-sqlite=/mingw --with-microhttpd=/mingw --with-plibc=/mingw --enable-benchmarks --enable-expensivetests --enable-experimental --with-qrencode=/mingw --enable-silent-rules --enable-experimental 2>&1 | tee -a ./configure.log | ||
737 | @end example | ||
738 | |||
739 | The parameters above will configure for a reasonable gnunet installation to the | ||
740 | your msys-root directory. Depending on which features your would like to build | ||
741 | or you may need to specify additional dependencies. Sbuild installed most libs | ||
742 | into the /mingw subdirectory, so remember to prefix library locations with | ||
743 | this path. | ||
744 | |||
745 | Like on a unixoid system, you might want to use your home directory as prefix | ||
746 | for your own gnunet installation for development, without tainting the | ||
747 | buildenvironment. Just change the "prefix" parameter to point towards | ||
748 | ~/ in this case. | ||
749 | |||
750 | Now it's time to compile gnunet as usual. Though this will take some time, so | ||
751 | you may fetch yourself a coffee or some Mate now... | ||
752 | |||
753 | @example | ||
754 | make@ | ||
755 | make install | ||
756 | @end example | ||
757 | |||
758 | @node Adjusting Windows for running and testing GNUnet | ||
759 | @subsection Adjusting Windows for running and testing GNUnet | ||
760 | |||
761 | Assuming the build succeeded and you | ||
762 | @strong{added the bin directory of your gnunet to PATH}, you can now use your | ||
763 | gnunet-installation as usual. Remember that UAC or the windows firewall may | ||
764 | popup initially, blocking further execution of gnunet until you acknowledge | ||
765 | them (duh!). | ||
766 | |||
767 | You will also have to take the usual steps to get p2p software running properly | ||
768 | (port forwarding, ...), and gnunet will require administrative permissions as | ||
769 | it may even install a device-driver (in case you are using gnunet-vpn and/or | ||
770 | gnunet-exit). | ||
771 | |||
772 | @node Building the GNUnet Installer | ||
773 | @subsection Building the GNUnet Installer | ||
774 | |||
775 | The GNUnet installer is made with @uref{http://nsis.sourceforge.net/, NSIS}@ | ||
776 | The installer script is located in @file{contrib\win} in the GNUnet source tree. | ||
777 | |||
778 | @node Using GNUnet with Netbeans on Windows | ||
779 | @subsection Using GNUnet with Netbeans on Windows | ||
780 | |||
781 | TODO | ||
782 | |||
783 | @node Build instructions for Debian 7.5 | ||
784 | @section Build instructions for Debian 7.5 | ||
785 | |||
786 | |||
787 | These are the installation instructions for Debian 7.5. They were tested using | ||
788 | a minimal, fresh Debian 7.5 AMD64 installation without non-free software | ||
789 | (no contrib or non-free). By "minimal", we mean that during installation, we | ||
790 | did not select any desktop environment, servers or system utilities during the | ||
791 | "tasksel" step. Note that the packages and the dependencies that we will | ||
792 | install during this chapter take about 1.5 GB of disk space. Combined with | ||
793 | GNUnet and space for objects during compilation, you should not even attempt | ||
794 | this unless you have about 2.5 GB free after the minimal Debian installation. | ||
795 | Using these instructions to build a VM image is likely to require a minimum of | ||
796 | 4-5 GB for the VM (as you will likely also want a desktop manager). | ||
797 | |||
798 | GNUnet's security model assumes that your @file{/home} directory is encrypted. | ||
799 | Thus, if possible, you should encrypt your home partition | ||
800 | (or per-user home directory). | ||
801 | |||
802 | Naturally, the exact details of the starting state for your installation | ||
803 | should not matter much. For example, if you selected any of those installation | ||
804 | groups you might simply already have some of the necessary packages installed. | ||
805 | We did this for testing, as this way we are less likely to forget to mention a | ||
806 | required package. Note that we will not install a desktop environment, but of | ||
807 | course you will need to install one to use GNUnet's graphical user interfaces. | ||
808 | Thus, it is suggested that you simply install the desktop environment of your | ||
809 | choice before beginning with the instructions. | ||
810 | |||
811 | |||
812 | |||
813 | @menu | ||
814 | * Update:: | ||
815 | * Stable? Hah!:: | ||
816 | * Update again:: | ||
817 | * Installing packages:: | ||
818 | * Installing dependencies from source:: | ||
819 | * Installing GNUnet from source:: | ||
820 | * But wait there is more!:: | ||
821 | @end menu | ||
822 | |||
823 | @node Update | ||
824 | @subsection Update | ||
825 | |||
826 | After any installation, you should begin by running | ||
827 | |||
828 | @example | ||
829 | # apt-get update@ | ||
830 | # apt-get upgrade@ | ||
831 | @end example | ||
832 | |||
833 | to ensure that all of your packages are up-to-date. Note that the "#" is used | ||
834 | to indicate that you need to type in this command as "root" | ||
835 | (or prefix with "sudo"), whereas "$" is used to indicate typing in a command | ||
836 | as a normal user. | ||
837 | |||
838 | @node Stable? Hah! | ||
839 | @subsection Stable? Hah! | ||
840 | |||
841 | Yes, we said we start with a Debian 7.5 "stable" system. However, to reduce the | ||
842 | amount of compilation by hand, we will begin by allowing the installation of | ||
843 | packages from the testing and unstable distributions as well. We will stick to | ||
844 | "stable" packages where possible, but some packages will be taken from the | ||
845 | other distributions. Start by modifying @file{/etc/apt/sources.list} to contain | ||
846 | the following (possibly adjusted to point to your mirror of choice): | ||
847 | @example | ||
848 | # These were there before: | ||
849 | deb http://ftp.de.debian.org/debian/ wheezy main | ||
850 | deb-src http://ftp.de.debian.org/debian/ wheezy main | ||
851 | deb http://security.debian.org/ wheezy/updates main | ||
852 | deb-src http://security.debian.org/ wheezy/updates main | ||
853 | deb http://ftp.de.debian.org/debian/ wheezy-updates main | ||
854 | deb-src http://ftp.de.debian.org/debian/ wheezy-updates main | ||
855 | |||
856 | # Add these lines (feel free to adjust the mirror): | ||
857 | deb http://ftp.de.debian.org/debian/ testing main | ||
858 | deb http://ftp.de.debian.org/debian/ unstable main | ||
859 | @end example | ||
860 | |||
861 | The next step is to create/edit your @file{/etc/apt/preferences} file to look | ||
862 | like this: | ||
863 | |||
864 | @example | ||
865 | Package: * | ||
866 | Pin: release a=stable,n=wheezy | ||
867 | Pin-Priority: 700 | ||
868 | |||
869 | Package: * | ||
870 | Pin: release o=Debian,a=testing | ||
871 | Pin-Priority: 650 | ||
872 | |||
873 | Package: * | ||
874 | Pin: release o=Debian,a=unstable | ||
875 | Pin-Priority: 600 | ||
876 | @end example | ||
877 | |||
878 | You can read more about Apt Preferences here and here. Note that other pinnings | ||
879 | are likely to also work for GNUnet, the key thing is that you need some | ||
880 | packages from unstable (as shown below). However, as unstable is unlikely to | ||
881 | be comprehensive (missing packages) or might be problematic (crashing packages), | ||
882 | you probably want others from stable and/or testing. | ||
883 | |||
884 | @node Update again | ||
885 | @subsection Update again | ||
886 | |||
887 | Now, run again@ | ||
888 | |||
889 | @example | ||
890 | # apt-get update@ | ||
891 | # apt-get upgrade@ | ||
892 | @end example | ||
893 | |||
894 | to ensure that all your new distribution indices are downloaded, and that your | ||
895 | pinning is correct: the upgrade step should cause no changes at all. | ||
896 | |||
897 | @node Installing packages | ||
898 | @subsection Installing packages | ||
899 | |||
900 | We begin by installing a few Debian packages from stable:@ | ||
901 | |||
902 | @example | ||
903 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ | ||
904 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev \ | ||
905 | texlive libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev \ | ||
906 | libbz2-dev libexiv2-dev libflac-dev libgif-dev libglib2.0-dev \ | ||
907 | libgtk-3-dev libmagic-dev libjpeg8-dev libmpeg2-4-dev libmp4v2-dev \ | ||
908 | librpm-dev libsmf-dev libtidy-dev libtiff5-dev libvorbis-dev \ | ||
909 | libogg-dev zlib1g-dev g++ gettext libgsf-1-dev libunbound-dev \ | ||
910 | libqrencode-dev libgladeui-dev nasm texlive-latex-extra \ | ||
911 | libunique-3.0-dev gawk miniupnpc libfuse-dev libbluetooth-dev | ||
912 | @end example | ||
913 | |||
914 | After that, we install a few more packages from unstable:@ | ||
915 | |||
916 | @example | ||
917 | # apt-get install -t unstable nettle-dev libgstreamer1.0-dev \ | ||
918 | gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ | ||
919 | libgstreamer-plugins-base1.0-dev | ||
920 | @end example | ||
921 | |||
922 | @node Installing dependencies from source | ||
923 | @subsection Installing dependencies from source | ||
924 | |||
925 | Next, we need to install a few dependencies from source. You might want to do | ||
926 | this as a "normal" user and only run the @code{make install} steps as root | ||
927 | (hence the @code{sudo} in the commands below). Also, you do this from any | ||
928 | directory. We begin by downloading all dependencies, then extracting the | ||
929 | sources, and finally compiling and installing the libraries:@ | ||
930 | |||
931 | @example | ||
932 | $ wget https://libav.org/releases/libav-9.10.tar.xz@ | ||
933 | $ wget http://ftp.gnu.org/gnu/libextractor/libextractor-1.3.tar.gz@ | ||
934 | $ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.12.tar.bz2@ | ||
935 | $ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.0.tar.bz2@ | ||
936 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.2/gnutls-3.2.7.tar.xz@ | ||
937 | $ wget http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.33.tar.gz@ | ||
938 | $ wget https://gnunet.org/sites/default/files/gnurl-7.34.0.tar.bz2@ | ||
939 | $ tar xvf libextractor-1.3.tar.gz@ | ||
940 | $ tar xvf libgpg-error-1.12.tar.bz2@ | ||
941 | $ tar xvf libgcrypt-1.6.0.tar.bz2@ | ||
942 | $ tar xvf gnutls-3.2.7.tar.xz@ | ||
943 | $ tar xvf libmicrohttpd-0.9.33.tar.gz@ | ||
944 | $ tar xvf gnurl-7.34.0.tar.bz2@ | ||
945 | $ cd libav-0.9 ; ./configure --enable-shared; make; sudo make install ; cd ..@ | ||
946 | $ cd libextractor-1.3 ; ./configure; make ; sudo make install; cd ..@ | ||
947 | $ cd libgpg-error-1.12; ./configure ; make ; sudo make install ; cd ..@ | ||
948 | $ cd libgcrypt-1.6.0; ./configure --with-gpg-error-prefix=/usr/local; make ; sudo make install ; cd ..@ | ||
949 | $ cd gnutls-3.2.7 ; ./configure ; make ; sudo make install ; cd ..@ | ||
950 | $ cd libmicrohttpd-0.9.33; ./configure ; make ; sudo make install ; cd ..@ | ||
951 | $ cd gnurl-7.34.0@ | ||
952 | $ ./configure --enable-ipv6 --with-gnutls=/usr/local --without-libssh2 \ | ||
953 | --without-libmetalink --without-winidn --without-librtmp --without-nghttp2 \ | ||
954 | --without-nss --without-cyassl --without-polarssl --without-ssl \ | ||
955 | --without-winssl --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
956 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ | ||
957 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-file \ | ||
958 | --disable-ftp@ | ||
959 | $ make ; sudo make install; cd ..@ | ||
960 | @end example | ||
961 | |||
962 | @node Installing GNUnet from source | ||
963 | @subsection Installing GNUnet from source | ||
964 | |||
965 | |||
966 | For this, simply follow the generic installation instructions from | ||
967 | here. | ||
968 | |||
969 | @node But wait there is more! | ||
970 | @subsection But wait there is more! | ||
971 | |||
972 | So far, we installed all of the packages and dependencies required to ensure | ||
973 | that all of GNUnet would be built. However, while for example the plugins to | ||
974 | interact with the MySQL or Postgres databases have been created, we did not | ||
975 | actually install or configure those databases. Thus, you will need to install | ||
976 | and configure those databases or stick with the default Sqlite database. | ||
977 | Sqlite is usually fine for most applications, but MySQL can offer better | ||
978 | performance and Postgres better resillience. | ||
979 | |||
980 | |||
981 | @node Installing GNUnet from Git on Ubuntu 14.4 | ||
982 | @section Installing GNUnet from Git on Ubuntu 14.4 | ||
983 | |||
984 | @strong{Install the required build tools:} | ||
985 | @code{@ | ||
986 | $ sudo apt-get install git automake autopoint autoconf@ | ||
987 | } | ||
988 | |||
989 | @strong{Install the required dependencies} | ||
990 | @example | ||
991 | $ sudo apt-get install libltdl-dev libgpg-error-dev libidn11-dev \ | ||
992 | libunistring-dev libglpk-dev libbluetooth-dev libextractor-dev \ | ||
993 | libmicrohttpd-dev libgnutls28-dev | ||
994 | @end example | ||
995 | |||
996 | @strong{Choose one or more database backends}@ | ||
997 | SQLite3@ | ||
998 | @code{@ | ||
999 | $ sudo apt-get install libsqlite3-dev@ | ||
1000 | }@ | ||
1001 | MySQL@ | ||
1002 | @code{@ | ||
1003 | $ sudo apt-get install libmysqlclient-dev@ | ||
1004 | }@ | ||
1005 | PostgreSQL@ | ||
1006 | @code{@ | ||
1007 | $ sudo apt-get install libpq-dev postgresql@ | ||
1008 | } | ||
1009 | |||
1010 | @strong{Install the optional dependencies for gnunet-conversation:}@ | ||
1011 | @code{@ | ||
1012 | $ sudo apt-get install gstreamer1.0 libpulse-dev libopus-dev@ | ||
1013 | } | ||
1014 | |||
1015 | @strong{Install the libgrypt 1.6.1:}@ | ||
1016 | For Ubuntu 14.04:@ | ||
1017 | @code{$ sudo apt-get install libgcrypt20-dev}@ | ||
1018 | For Ubuntu older 14.04:@ | ||
1019 | @code{$ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.1.tar.bz2@ | ||
1020 | $ tar xf libgcrypt-1.6.1.tar.bz2@ | ||
1021 | $ cd libgcrypt-1.6.1@ | ||
1022 | $ ./configure@ | ||
1023 | $ sudo make install@ | ||
1024 | $ cd ..}@ | ||
1025 | @strong{Install libgnurl}@ | ||
1026 | @example | ||
1027 | $ wget https://gnunet.org/sites/default/files/gnurl-7.35.0.tar.bz2@ | ||
1028 | $ tar xf gnurl-7.35.0.tar.bz2@ | ||
1029 | $ cd gnurl-7.35.0@ | ||
1030 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
1031 | --without-libmetalink --without-winidn --without-librtmp --without-nghttp2 \ | ||
1032 | --without-nss --without-cyassl --without-polarssl --without-ssl \ | ||
1033 | --without-winssl --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
1034 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ | ||
1035 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-file \ | ||
1036 | --disable-ftp | ||
1037 | $ sudo make install@ | ||
1038 | $ cd ..@ | ||
1039 | @end example | ||
1040 | |||
1041 | @strong{Install GNUnet}@ | ||
1042 | @code{@ | ||
1043 | $ git clone https://gnunet.org/git/gnunet/@ | ||
1044 | $ cd gnunet/@ | ||
1045 | $ ./bootstrap@ | ||
1046 | } | ||
1047 | |||
1048 | If you want to: | ||
1049 | @itemize @bullet | ||
1050 | |||
1051 | |||
1052 | @item | ||
1053 | Install to a different directory:@ | ||
1054 | --prefix=PREFIX | ||
1055 | |||
1056 | @item | ||
1057 | Have sudo permission, but do not want to compile as root:@ | ||
1058 | --with-sudo | ||
1059 | |||
1060 | @item | ||
1061 | Want debug message enabled:@ | ||
1062 | -- enable-logging=verbose | ||
1063 | @end itemize | ||
1064 | |||
1065 | |||
1066 | @code{@ | ||
1067 | $ ./configure [ --with-sudo | --prefix=PREFIX | --- enable-logging=verbose]@ | ||
1068 | $ make; sudo make install@ | ||
1069 | } | ||
1070 | |||
1071 | After installing it, you need to create an empty configuration file:@ | ||
1072 | @code{touch ~/.config/gnunet.conf} | ||
1073 | |||
1074 | And finally you can start GNUnet with@ | ||
1075 | @code{$ gnunet-arm -s} | ||
1076 | |||
1077 | @node Build instructions for Debian 8 | ||
1078 | @section Build instructions for Debian 8 | ||
1079 | |||
1080 | These are the installation instructions for Debian 8. They were tested using a | ||
1081 | fresh Debian 8 AMD64 installation without non-free software (no contrib or | ||
1082 | non-free). During installation, I only selected "lxde" for the desktop | ||
1083 | environment. Note that the packages and the dependencies that we will install | ||
1084 | during this chapter take about 1.5 GB of disk space. Combined with GNUnet and | ||
1085 | space for objects during compilation, you should not even attempt this unless | ||
1086 | you have about 2.5 GB free after the Debian installation. Using these | ||
1087 | instructions to build a VM image is likely to require a minimum of 4-5 GB for | ||
1088 | the VM (as you will likely also want a desktop manager). | ||
1089 | |||
1090 | GNUnet's security model assumes that your @code{/home} directory is encrypted. | ||
1091 | Thus, if possible, you should encrypt your entire disk, or at least just your | ||
1092 | home partition (or per-user home directory). | ||
1093 | |||
1094 | Naturally, the exact details of the starting state for your installation should | ||
1095 | not matter much. For example, if you selected any of those installation groups | ||
1096 | you might simply already have some of the necessary packages installed. Thus, | ||
1097 | it is suggested that you simply install the desktop environment of your choice | ||
1098 | before beginning with the instructions. | ||
1099 | |||
1100 | |||
1101 | @menu | ||
1102 | * Update Debian:: | ||
1103 | * Installing Debian Packages:: | ||
1104 | * Installing Dependencies from Source2:: | ||
1105 | * Installing GNUnet from Source2:: | ||
1106 | * But wait (again) there is more!:: | ||
1107 | @end menu | ||
1108 | |||
1109 | @node Update Debian | ||
1110 | @subsection Update Debian | ||
1111 | |||
1112 | After any installation, you should begin by running@ | ||
1113 | @code{@ | ||
1114 | # apt-get update@ | ||
1115 | # apt-get upgrade@ | ||
1116 | }@ | ||
1117 | to ensure that all of your packages are up-to-date. Note that the "#" is used | ||
1118 | to indicate that you need to type in this command as "root" (or prefix with | ||
1119 | "sudo"), whereas "$" is used to indicate typing in a command as a normal | ||
1120 | user. | ||
1121 | |||
1122 | @node Installing Debian Packages | ||
1123 | @subsection Installing Debian Packages | ||
1124 | |||
1125 | We begin by installing a few Debian packages from stable:@ | ||
1126 | @example | ||
1127 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ | ||
1128 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev texlive \ | ||
1129 | libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev libbz2-dev \ | ||
1130 | libflac-dev libgif-dev libglib2.0-dev libgtk-3-dev libmpeg2-4-dev \ | ||
1131 | libtidy-dev libvorbis-dev libogg-dev zlib1g-dev g++ gettext libgsf-1-dev \ | ||
1132 | libunbound-dev libqrencode-dev libgladeui-dev nasm texlive-latex-extra \ | ||
1133 | libunique-3.0-dev gawk miniupnpc libfuse-dev libbluetooth-dev \ | ||
1134 | gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ | ||
1135 | libgstreamer-plugins-base1.0-dev nettle-dev libextractor-dev libgcrypt20-dev \ | ||
1136 | libmicrohttpd-dev | ||
1137 | @end example | ||
1138 | |||
1139 | @node Installing Dependencies from Source2 | ||
1140 | @subsection Installing Dependencies from Source2 | ||
1141 | |||
1142 | Yes, we said we start with a Debian 8 "stable" system, but because Debian | ||
1143 | linked GnuTLS without support for DANE, we need to compile a few things, in | ||
1144 | addition to GNUnet, still by hand. Yes, you can run GNUnet using the respective | ||
1145 | Debian packages, but then you will not get DANE support. | ||
1146 | |||
1147 | Next, we need to install a few dependencies from source. You might want to do | ||
1148 | this as a "normal" user and only run the @code{make install} steps as root | ||
1149 | (hence the @code{sudo} in the commands below). Also, you do this from any | ||
1150 | directory. We begin by downloading all dependencies, then extracting the | ||
1151 | sources, and finally compiling and installing the libraries:@ | ||
1152 | |||
1153 | @code{@ | ||
1154 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/gnutls-3.3.12.tar.xz@ | ||
1155 | $ wget https://gnunet.org/sites/default/files/gnurl-7.40.0.tar.bz2@ | ||
1156 | $ tar xvf gnutls-3.3.12.tar.xz@ | ||
1157 | $ tar xvf gnurl-7.40.0.tar.bz2@ | ||
1158 | $ cd gnutls-3.3.12 ; ./configure ; make ; sudo make install ; cd ..@ | ||
1159 | $ cd gnurl-7.40.0@ | ||
1160 | $ ./configure --enable-ipv6 --with-gnutls=/usr/local --without-libssh2 \ | ||
1161 | --without-libmetalink --without-winidn --without-librtmp --without-nghttp2 \ | ||
1162 | --without-nss --without-cyassl --without-polarssl --without-ssl \ | ||
1163 | --without-winssl --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
1164 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ | ||
1165 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-file \ | ||
1166 | --disable-ftp --disable-smb | ||
1167 | $ make ; sudo make install; cd ..@ | ||
1168 | } | ||
1169 | |||
1170 | @node Installing GNUnet from Source2 | ||
1171 | @subsection Installing GNUnet from Source2 | ||
1172 | |||
1173 | For this, simply follow the generic installation instructions from@ | ||
1174 | here. | ||
1175 | |||
1176 | @node But wait (again) there is more! | ||
1177 | @subsection But wait (again) there is more! | ||
1178 | |||
1179 | So far, we installed all of the packages and dependencies required to ensure | ||
1180 | that all of GNUnet would be built. However, while for example the plugins to | ||
1181 | interact with the MySQL or Postgres databases have been created, we did not | ||
1182 | actually install or configure those databases. Thus, you will need to install | ||
1183 | and configure those databases or stick with the default Sqlite database. Sqlite | ||
1184 | is usually fine for most applications, but MySQL can offer better performance | ||
1185 | and Postgres better resillience. | ||
1186 | |||
1187 | @node Outdated build instructions for previous revisions | ||
1188 | @section Outdated build instructions for previous revisions | ||
1189 | |||
1190 | This chapter contains a collection of outdated, older installation guides. They | ||
1191 | are mostly intended to serve as a starting point for writing up-to-date | ||
1192 | instructions and should not be expected to work for GNUnet 0.10.x. | ||
1193 | A set of older installation instructions can also be found in the | ||
1194 | @file{doc/outdated-and-old-installation-instructions.txt} in the source | ||
1195 | of GNUnet. This file covers old instructions which no longer receive | ||
1196 | security updates or any kind of support. | ||
1197 | |||
1198 | |||
1199 | @menu | ||
1200 | * Installing GNUnet 0.10.1 on Ubuntu 14.04:: | ||
1201 | * Building GLPK for MinGW:: | ||
1202 | * GUI build instructions for Ubuntu 12.04 using Subversion:: | ||
1203 | * Installation with gnunet-update:: | ||
1204 | * Instructions for Microsoft Windows Platforms (Old):: | ||
1205 | @end menu | ||
1206 | |||
1207 | |||
1208 | @node Installing GNUnet 0.10.1 on Ubuntu 14.04 | ||
1209 | @subsection Installing GNUnet 0.10.1 on Ubuntu 14.04 | ||
1210 | |||
1211 | Install the required dependencies@ | ||
1212 | |||
1213 | @example | ||
1214 | $ sudo apt-get install libltdl-dev libgpg-error-dev libidn11-dev \ | ||
1215 | libunistring-dev libglpk-dev libbluetooth-dev libextractor-dev \ | ||
1216 | libmicrohttpd-dev libgnutls28-dev | ||
1217 | @end example | ||
1218 | |||
1219 | Choose one or more database backends@ | ||
1220 | SQLite3@ | ||
1221 | @code{@ | ||
1222 | $ sudo apt-get install libsqlite3-dev@ | ||
1223 | }@ | ||
1224 | MySQL@ | ||
1225 | @code{@ | ||
1226 | $ sudo apt-get install libmysqlclient-dev@ | ||
1227 | }@ | ||
1228 | PostgreSQL@ | ||
1229 | @code{@ | ||
1230 | $ sudo apt-get install libpq-dev postgresql@ | ||
1231 | } | ||
1232 | |||
1233 | Install the optional dependencies for gnunet-conversation:@ | ||
1234 | @code{@ | ||
1235 | $ sudo apt-get install gstreamer1.0 libpulse-dev libopus-dev@ | ||
1236 | } | ||
1237 | |||
1238 | Install the libgrypt 1.6:@ | ||
1239 | For Ubuntu 14.04:@ | ||
1240 | @code{$ sudo apt-get install libgcrypt20-dev}@ | ||
1241 | For Ubuntu older 14.04:@ | ||
1242 | @code{$ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.1.tar.bz2@ | ||
1243 | $ tar xf libgcrypt-1.6.1.tar.bz2@ | ||
1244 | $ cd libgcrypt-1.6.1@ | ||
1245 | $ ./configure@ | ||
1246 | $ sudo make install@ | ||
1247 | $ cd ..} | ||
1248 | |||
1249 | Install libgnurl@ | ||
1250 | @example | ||
1251 | $ wget https://gnunet.org/sites/default/files/gnurl-7.35.0.tar.bz2@ | ||
1252 | $ tar xf gnurl-7.35.0.tar.bz2@ | ||
1253 | $ cd gnurl-7.35.0@ | ||
1254 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
1255 | --without-libmetalink --without-winidn --without-librtmp --without-nghttp2 \ | ||
1256 | --without-nss --without-cyassl --without-polarssl --without-ssl \ | ||
1257 | --without-winssl --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
1258 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ | ||
1259 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-file \ | ||
1260 | --disable-ftp@ | ||
1261 | $ sudo make install@ | ||
1262 | $ cd ..@ | ||
1263 | @end example | ||
1264 | |||
1265 | Install GNUnet@ | ||
1266 | @code{@ | ||
1267 | $ wget http://ftpmirror.gnu.org/gnunet/gnunet-0.10.1.tar.gz@ | ||
1268 | $ tar xf gnunet-0.10.1.tar.gz@ | ||
1269 | $ cd gnunet-0.10.1@ | ||
1270 | } | ||
1271 | |||
1272 | If you want to: | ||
1273 | @itemize @bullet | ||
1274 | |||
1275 | @item | ||
1276 | Install to a different directory:@ | ||
1277 | --prefix=PREFIX | ||
1278 | |||
1279 | @item | ||
1280 | Have sudo permission, but do not want to compile as root:@ | ||
1281 | --with-sudo | ||
1282 | |||
1283 | @item | ||
1284 | Want debug message enabled:@ | ||
1285 | -- enable-logging=verbose | ||
1286 | @end itemize | ||
1287 | |||
1288 | @code{@ | ||
1289 | $ ./configure [ --with-sudo | --prefix=PREFIX | --enable-logging=verbose]@ | ||
1290 | $ make; sudo make install@ | ||
1291 | } | ||
1292 | |||
1293 | After installing it, you need to create an empty configuration file:@ | ||
1294 | @code{touch ~/.config/gnunet.conf} | ||
1295 | |||
1296 | And finally you can start GNUnet with@ | ||
1297 | @code{$ gnunet-arm -s} | ||
1298 | |||
1299 | @node Building GLPK for MinGW | ||
1300 | @subsection Building GLPK for MinGW | ||
1301 | |||
1302 | GNUnet now requires the GNU Linear Programming Kit (GLPK). Since there's is no | ||
1303 | package you can install with @code{mingw-get} you have to compile it from | ||
1304 | source: | ||
1305 | |||
1306 | @itemize @bullet | ||
1307 | |||
1308 | @item | ||
1309 | Download the latest version from http://ftp.gnu.org/gnu/glpk/ | ||
1310 | |||
1311 | @item | ||
1312 | Unzip it using your favourite unzipper@ | ||
1313 | In the MSYS shell: | ||
1314 | |||
1315 | @item | ||
1316 | change to the respective directory | ||
1317 | |||
1318 | @item | ||
1319 | @code{./configure '--build=i686-pc-mingw32'} | ||
1320 | |||
1321 | @item | ||
1322 | run @code{make install check } | ||
1323 | |||
1324 | MinGW does not automatically detect the correct buildtype so you have to | ||
1325 | specify it manually | ||
1326 | @end itemize | ||
1327 | |||
1328 | |||
1329 | @node GUI build instructions for Ubuntu 12.04 using Subversion | ||
1330 | @subsection GUI build instructions for Ubuntu 12.04 using Subversion | ||
1331 | |||
1332 | After installing GNUnet you can continue installing the GNUnet GUI tools: | ||
1333 | |||
1334 | First, install the required dependencies: | ||
1335 | |||
1336 | @code{@ | ||
1337 | $ sudo apt-get install libgladeui-dev libqrencode-dev@ | ||
1338 | } | ||
1339 | |||
1340 | Please ensure that the GNUnet shared libraries can be found by the linker. If | ||
1341 | you installed GNUnet libraries in a non standard path (say | ||
1342 | GNUNET_PREFIX=/usr/local/lib/), you can | ||
1343 | @itemize @bullet | ||
1344 | |||
1345 | |||
1346 | @item | ||
1347 | set the environmental variable permanently to@ | ||
1348 | @code{LD_LIBRARY_PATH=$GNUNET_PREFIX} | ||
1349 | |||
1350 | @item | ||
1351 | or add @code{$GNUNET_PREFIX} to @code{/etc/ld.so.conf} | ||
1352 | @end itemize | ||
1353 | |||
1354 | |||
1355 | Now you can checkout and compile the GNUnet GUI tools@ | ||
1356 | @code{@ | ||
1357 | $ svn co https://gnunet.org/svn/gnunet-gtk@ | ||
1358 | $ cd gnunet-gtk@ | ||
1359 | $ ./bootstrap@ | ||
1360 | $ ./configure --prefix=$GNUNET_PREFIX/.. --with-gnunet=$GNUNET_PREFIX/..@ | ||
1361 | $ make install@ | ||
1362 | } | ||
1363 | |||
1364 | @node Installation with gnunet-update | ||
1365 | @subsection Installation with gnunet-update | ||
1366 | |||
1367 | gnunet-update project is an effort to introduce updates to GNUnet | ||
1368 | installations. An interesting to-be-implemented-feature of gnunet-update is | ||
1369 | that these updates are propagated through GNUnet's peer-to-peer network. More | ||
1370 | information about gnunet-update can be found at | ||
1371 | https://gnunet.org/svn/gnunet-update/README. | ||
1372 | |||
1373 | While the project is still under development, we have implemented the following | ||
1374 | features which we believe may be helpful for users and we would like them to be | ||
1375 | tested: | ||
1376 | |||
1377 | @itemize @bullet | ||
1378 | |||
1379 | @item | ||
1380 | Packaging GNUnet installation along with its run-time dependencies into update | ||
1381 | packages | ||
1382 | |||
1383 | @item | ||
1384 | Installing update packages into compatible hosts | ||
1385 | |||
1386 | @item | ||
1387 | Updating an existing installation (which had been installed by gnunet-update) | ||
1388 | to a newer one | ||
1389 | @end itemize | ||
1390 | |||
1391 | The above said features of gnunet-update are currently available for testing on | ||
1392 | GNU/Linux systems. | ||
1393 | |||
1394 | The following is a guide to help you get started with gnunet-update. It shows | ||
1395 | you how to install the testing binary packages of GNUnet 0.9.1 we have at | ||
1396 | https://gnunet.org/install/ | ||
1397 | |||
1398 | gnunet-update needs the following: | ||
1399 | |||
1400 | @itemize @bullet | ||
1401 | @item | ||
1402 | python ( 2.6 or above) | ||
1403 | |||
1404 | @item | ||
1405 | gnupg | ||
1406 | |||
1407 | @item | ||
1408 | python-gpgme | ||
1409 | @end itemize | ||
1410 | |||
1411 | |||
1412 | Checkout gnunet-update:@ | ||
1413 | @code{@ | ||
1414 | $ svn checkout -r24905 https://gnunet.org/svn/gnunet-update@ | ||
1415 | } | ||
1416 | |||
1417 | For security reasons, all packages released for gnunet-update from us are | ||
1418 | signed with the key at https://gnunet.org/install/key.txt You would need to | ||
1419 | import this key into your gpg key ring. gnunet-update uses this key to verify | ||
1420 | the integrity of the packages it installs@ | ||
1421 | @code{@ | ||
1422 | $ gpg --recv-keys 7C613D78@ | ||
1423 | } | ||
1424 | |||
1425 | Download the packages relevant to your architecture (currently I have access to | ||
1426 | GNU/Linux machines on x86_64 and i686, so only two for now, hopefully more | ||
1427 | later) from https://gnunet.org/install/. | ||
1428 | |||
1429 | To install the downloaded package into the directory /foo: | ||
1430 | |||
1431 | @code{@ | ||
1432 | gnunet-update/bin/gnunet-update install downloaded/package /foo@ | ||
1433 | } | ||
1434 | |||
1435 | The installer reports the directories into which shared libraries and | ||
1436 | dependencies have been installed. You may need to add the reported shared | ||
1437 | library installation paths to LD_LIBRARY_PATH before you start running any | ||
1438 | installed binaries. | ||
1439 | |||
1440 | Please report bugs at https://gnunet.org/bugs/ under the project | ||
1441 | 'gnunet-update'. | ||
1442 | |||
1443 | @node Instructions for Microsoft Windows Platforms (Old) | ||
1444 | @subsection Instructions for Microsoft Windows Platforms (Old) | ||
1445 | |||
1446 | This document is a DEPRECATED installation guide for gnunet on windows. It will | ||
1447 | not work for recent gnunet versions, but maybe it will be of some use if | ||
1448 | problems arise. | ||
1449 | |||
1450 | The Windows build uses a UNIX emulator for Windows, | ||
1451 | @uref{http://www.mingw.org/, MinGW}, to build the executable modules. These | ||
1452 | modules run natively on Windows and do not require additional emulation | ||
1453 | software besides the usual dependencies. | ||
1454 | |||
1455 | GNUnet development is mostly done under Linux and especially SVN checkouts may | ||
1456 | not build out of the box. We regret any inconvenience, and if you have | ||
1457 | problems, please report them. | ||
1458 | |||
1459 | |||
1460 | |||
1461 | @menu | ||
1462 | * Hardware and OS requirements:: | ||
1463 | * Software installation:: | ||
1464 | * Building libextractor and GNUnet:: | ||
1465 | * Installer:: | ||
1466 | * Source:: | ||
1467 | @end menu | ||
1468 | |||
1469 | @node Hardware and OS requirements | ||
1470 | @subsubsection Hardware and OS requirements | ||
1471 | |||
1472 | @itemize @bullet | ||
1473 | |||
1474 | @item | ||
1475 | Pentium II or equivalent processor, 350 MHz or better | ||
1476 | |||
1477 | @item | ||
1478 | 128 MB RAM | ||
1479 | |||
1480 | @item | ||
1481 | 600 MB free disk space | ||
1482 | |||
1483 | @item | ||
1484 | Windows 2000 or Windows XP are recommended | ||
1485 | @end itemize | ||
1486 | |||
1487 | @node Software installation | ||
1488 | @subsubsection Software installation | ||
1489 | |||
1490 | @itemize @bullet | ||
1491 | |||
1492 | @item | ||
1493 | @strong{Compression software}@ | ||
1494 | @ | ||
1495 | The software packages GNUnet depends on are usually compressed using UNIX | ||
1496 | tools like tar, gzip and bzip2.@ If you do not already have an utility that is | ||
1497 | able to extract such archives, get @uref{http://www.7-zip.org/, 7-Zip}. | ||
1498 | |||
1499 | @item | ||
1500 | @strong{UNIX environment}@ | ||
1501 | @ | ||
1502 | The MinGW project provides the compiler toolchain that is used to build | ||
1503 | GNUnet.@ Get the following packages from | ||
1504 | @uref{http://sourceforge.net/projects/mingw/files/, the MinGW project}: | ||
1505 | @itemize @bullet | ||
1506 | |||
1507 | |||
1508 | @item | ||
1509 | GCC core | ||
1510 | |||
1511 | @item | ||
1512 | GCC g++ | ||
1513 | |||
1514 | @item | ||
1515 | MSYS | ||
1516 | |||
1517 | @item | ||
1518 | MSYS Developer Tool Kit (msysDTK) | ||
1519 | |||
1520 | @item | ||
1521 | MSYS Developer Tool Kit - msys-autoconf (bin) | ||
1522 | |||
1523 | @item | ||
1524 | MSYS Developer Tool Kit - msys-automake (bin) | ||
1525 | |||
1526 | @item | ||
1527 | MinGW Runtime | ||
1528 | |||
1529 | @item | ||
1530 | MinGW Utilities | ||
1531 | |||
1532 | @item | ||
1533 | Windows API | ||
1534 | |||
1535 | @item | ||
1536 | Binutils | ||
1537 | |||
1538 | @item | ||
1539 | make | ||
1540 | |||
1541 | @item | ||
1542 | pdcurses | ||
1543 | |||
1544 | @item | ||
1545 | GDB (snapshot) | ||
1546 | @end itemize | ||
1547 | |||
1548 | @itemize @bullet | ||
1549 | |||
1550 | |||
1551 | @item | ||
1552 | Install MSYS (to c:\mingw, for example.)@ | ||
1553 | Do @strong{not} use spaces in the pathname (c:\program files\mingw). | ||
1554 | |||
1555 | @item | ||
1556 | Install MinGW runtime, utilities and GCC to a subdirectory (to c:\mingw\mingw, | ||
1557 | for example) | ||
1558 | |||
1559 | @item | ||
1560 | Install the Development Kit to the MSYS directory (c:\mingw) | ||
1561 | |||
1562 | @item | ||
1563 | Create a batch file bash.bat in your MSYS directory with the files:@ | ||
1564 | |||
1565 | @example | ||
1566 | bin\sh.exe --login | ||
1567 | @end example | ||
1568 | |||
1569 | |||
1570 | This batch file opens a shell which is used to invoke the build processes..@ | ||
1571 | MinGW's standard shell (msys.bat) is not suitable because it opens a separate | ||
1572 | console window@ On Vista, bash.bat needs to be run as administrator. | ||
1573 | |||
1574 | @item | ||
1575 | Start bash.sh and rename (c:\mingw\mingw\)lib\libstdc++.la to avoid problems:@ | ||
1576 | |||
1577 | @example | ||
1578 | mv /usr/mingw/lib/libstdc++.la /usr/mingw/lib/libstdc++.la.broken | ||
1579 | @end example | ||
1580 | |||
1581 | |||
1582 | @item | ||
1583 | Unpack the Windows API to the MinGW directory (c:\mingw\mingw\) and remove the | ||
1584 | declaration of DATADIR from (c:\mingw\mingw\)include\objidl.h (lines 55-58) | ||
1585 | |||
1586 | @item | ||
1587 | Unpack autoconf, automake to the MSYS directory (c:\mingw) | ||
1588 | |||
1589 | @item | ||
1590 | Install all other packages to the MinGW directory (c:\mingw\mingw\) | ||
1591 | @end itemize | ||
1592 | |||
1593 | |||
1594 | @item | ||
1595 | @strong{GNU Libtool}@ | ||
1596 | @ | ||
1597 | GNU Libtool is required to use shared libraries.@ | ||
1598 | @ | ||
1599 | Get the prebuilt package from here and unpack it to the MinGW directory | ||
1600 | (c:\mingw) | ||
1601 | |||
1602 | @item | ||
1603 | @strong{Pthreads}@ | ||
1604 | @ | ||
1605 | GNUnet uses the portable POSIX thread library for multi-threading..@ | ||
1606 | |||
1607 | @itemize @bullet | ||
1608 | |||
1609 | |||
1610 | @item | ||
1611 | Save @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x86/libpthreadGC2.a, libpthreadGC2.a} (x86) or @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x64/libpthreadGC2.a, libpthreadGC2.a} (x64) as libpthread.a into the lib directory (c:\mingw\mingw\lib\libpthread.a) | ||
1612 | |||
1613 | @item | ||
1614 | Save @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x86/pthreadGC2.dll, pthreadGC2.dll} (x86) or @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x64/pthreadGC2.dll, libpthreadGC2.a} (x64) into the MinGW bin directory (c:\mingw\mingw\bin) | ||
1615 | |||
1616 | @item | ||
1617 | Download all header files from @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/, include/} to the include directory (c:\mingw\mingw\include) | ||
1618 | @end itemize | ||
1619 | |||
1620 | |||
1621 | @item | ||
1622 | @strong{GNU MP@ | ||
1623 | }@ | ||
1624 | @ | ||
1625 | GNUnet uses the GNU Multiple Precision library for special cryptographic operations.@ | ||
1626 | @ | ||
1627 | Get the GMP binary package from the @uref{http://sourceforge.net/projects/mingwrep/, MinGW repository} and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1628 | |||
1629 | @item | ||
1630 | @strong{GNU Gettext}@ | ||
1631 | @ | ||
1632 | GNU gettext is used to provide national language support.@ | ||
1633 | @ | ||
1634 | Get the prebuilt package from hereand unpack it to the MinGW directory (c:\mingw\mingw) | ||
1635 | |||
1636 | @item | ||
1637 | @strong{GNU iconv}@ | ||
1638 | @ | ||
1639 | GNU Libiconv is used for character encoding conversion.@ | ||
1640 | @ | ||
1641 | Get the prebuilt package from here and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1642 | |||
1643 | @item | ||
1644 | @strong{SQLite}@ | ||
1645 | @ | ||
1646 | GNUnet uses the SQLite database to store data.@ | ||
1647 | @ | ||
1648 | Get the prebuilt binary from here and unpack it to your MinGW directory. | ||
1649 | |||
1650 | @item | ||
1651 | @strong{MySQL}@ | ||
1652 | @ | ||
1653 | As an alternative to SQLite, GNUnet also supports MySQL. | ||
1654 | @itemize @bullet | ||
1655 | |||
1656 | |||
1657 | @item | ||
1658 | Get the binary installer from the @uref{http://dev.mysql.com/downloads/mysql/4.1.html#Windows, MySQL project} (version 4.1),@ | ||
1659 | install it and follow the instructions in README.mysql. | ||
1660 | |||
1661 | @item | ||
1662 | Create a temporary build directory (c:\mysql) | ||
1663 | |||
1664 | @item | ||
1665 | Copy the directories include\ and lib\ from the MySQL directory to the new directory | ||
1666 | |||
1667 | @item | ||
1668 | Get the patches from @uref{http://bugs.mysql.com/bug.php?id=8906&files=1, Bug #8906} and @uref{http://bugs.mysql.com/bug.php?id=8872&files=1, Bug #8872} (the latter is only required for MySQL | ||
1669 | @example | ||
1670 | patch -p 0 | ||
1671 | @end example | ||
1672 | |||
1673 | |||
1674 | @item | ||
1675 | Move lib\opt\libmysql.dll to lib\libmysql.dll | ||
1676 | |||
1677 | @item | ||
1678 | Change to lib\ and create an import library:@ | ||
1679 | |||
1680 | @example | ||
1681 | dlltool --input-def ../include/libmySQL.def --dllname libmysql.dll | ||
1682 | --output-lib libmysqlclient.a -k | ||
1683 | @end example | ||
1684 | |||
1685 | |||
1686 | @item | ||
1687 | Copy include\* to include\mysql\ | ||
1688 | |||
1689 | @item | ||
1690 | Pass "--with-mysql=/c/mysql" to ./configure and copy libmysql.dll to your PATH or GNUnet's @file{bin} directory | ||
1691 | @end itemize | ||
1692 | |||
1693 | |||
1694 | @item | ||
1695 | @strong{GTK+}@ | ||
1696 | @ | ||
1697 | gnunet-gtk and libextractor depend on GTK.@ | ||
1698 | @ | ||
1699 | Get the the binary and developer packages of atk, glib, gtk, iconv, gettext-runtime, pango from @uref{ftp://ftp.gtk.org/pub/gtk/v2.6/win32, gtk.org} and unpack it to the MinGW directory (c:\mingw\mingw)@ | ||
1700 | @ | ||
1701 | Get @uref{http://www.gtk.org/download/win32.php, pkg-config} and libpng and unpack them to the MinGW directory (c:\mingw\mingw)@ | ||
1702 | @ | ||
1703 | Here is an all-in-one package for @uref{http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip, gtk+dependencies}. Do not overwrite any existing files! | ||
1704 | |||
1705 | @item | ||
1706 | @strong{Glade}@ | ||
1707 | @ | ||
1708 | gnunet-gtk and and gnunet-setup were created using this interface builder@ | ||
1709 | |||
1710 | @itemize @bullet | ||
1711 | |||
1712 | |||
1713 | @item | ||
1714 | Get the Glade and libglade (-bin and -devel) packages (without GTK!) from @uref{http://gladewin32.sourceforge.net/, GladeWin32} and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1715 | |||
1716 | @item | ||
1717 | Get libxml from here and unpack it to the MinGW directory (c:\mingw\mingw). | ||
1718 | @end itemize | ||
1719 | |||
1720 | |||
1721 | @item | ||
1722 | @strong{zLib}@ | ||
1723 | @ | ||
1724 | libextractor requires zLib to decompress some file formats. GNUnet uses it to (de)compress meta-data.@ | ||
1725 | @ | ||
1726 | Get zLib from here (Signature) and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1727 | |||
1728 | @item | ||
1729 | @strong{Bzip2}@ | ||
1730 | @ | ||
1731 | libextractor also requires Bzip2 to decompress some file formats.@ | ||
1732 | @ | ||
1733 | Get Bzip2 (binary and developer package) from @uref{http://gnuwin32.sourceforge.net/packages/bzip2.htm, GnuWin32} and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1734 | |||
1735 | @item | ||
1736 | @strong{Libgcrypt}@ | ||
1737 | @ | ||
1738 | Libgcrypt provides the cryptographic functions used by GNUnet@ | ||
1739 | @ | ||
1740 | Get Libgcrypt from @uref{ftp://ftp.gnupg.org/gcrypt/libgcrypt/, here}, compile and place it in the MinGW directory (c:\mingw\mingw). Currently you need at least version 1.4.2 to compile gnunet. | ||
1741 | |||
1742 | @item | ||
1743 | @strong{PlibC}@ | ||
1744 | @ | ||
1745 | PlibC emulates Unix functions under Windows.@ | ||
1746 | @ | ||
1747 | Get PlibC from here and unpack it to the MinGW directory (c:\mingw\mingw) | ||
1748 | |||
1749 | @item | ||
1750 | @strong{OGG Vorbis}@ | ||
1751 | @ | ||
1752 | OGG Vorbis is used to extract meta-data from .ogg files@ | ||
1753 | @ | ||
1754 | Get the packages @uref{http://www.gnunet.org/libextractor/download/win/libogg-1.1.4.zip, libogg} and @uref{http://www.gnunet.org/libextractor/download/win/libvorbis-1.2.3.zip, libvorbis} from the @uref{http://ftp.gnu.org/gnu/libextractor/libextractor-w32-1.0.0.zip, libextractor win32 build} and unpack them to the MinGW directory (c:\mingw\mingw) | ||
1755 | |||
1756 | @item | ||
1757 | @strong{Exiv2}@ | ||
1758 | @ | ||
1759 | (lib)Exiv2 is used to extract meta-data from files with Exiv2 meta-data@ | ||
1760 | @ | ||
1761 | Download @uref{http://www.gnunet.org/libextractor/download/win/exiv2-0.18.2.zip, Exiv2} and unpack it to the MSYS directory (c:\mingw) | ||
1762 | @end itemize | ||
1763 | |||
1764 | @node Building libextractor and GNUnet | ||
1765 | @subsubsection Building libextractor and GNUnet | ||
1766 | |||
1767 | Before you compile libextractor or GNUnet, be sure to set@ | ||
1768 | PKG_CONFIG_PATH: | ||
1769 | @example | ||
1770 | export PKG_CONFIG_PATH=/mingw/lib/pkgconfig | ||
1771 | @end example | ||
1772 | |||
1773 | |||
1774 | See Installation for basic instructions on building libextractor and GNUnet. | ||
1775 | |||
1776 | By default, all modules that are created in this way contain debug information and are quite large.@ | ||
1777 | To compile release versions (small and fast) set the variable CFLAGS: | ||
1778 | @example | ||
1779 | export CFLAGS='-O2 -march=pentium -fomit-frame-pointer' | ||
1780 | ./configure --prefix=$HOME --with-extractor=$HOME | ||
1781 | @end example | ||
1782 | |||
1783 | @node Installer | ||
1784 | @subsubsection Installer | ||
1785 | |||
1786 | The GNUnet installer is made with @uref{http://nsis.sourceforge.net/, NSIS}@ | ||
1787 | The installer script is located in contrib\win in the GNUnet source tree. | ||
1788 | |||
1789 | @node Source | ||
1790 | @subsubsection Source | ||
1791 | |||
1792 | The sources of all dependencies are available here. | ||
1793 | |||
1794 | @node Portable GNUnet | ||
1795 | @section Portable GNUnet | ||
1796 | |||
1797 | Quick instructions on how to use the most recent GNUnet on most GNU/Linux | ||
1798 | distributions | ||
1799 | |||
1800 | Currently this has only been tested on Ubuntu 12.04, 12.10, 13.04, Debian and | ||
1801 | CentOS 6, but it should work on almost any GNU/Linux distribution. More | ||
1802 | in-detail information can be found in the handbook. | ||
1803 | |||
1804 | |||
1805 | |||
1806 | @menu | ||
1807 | * Prerequisites:: | ||
1808 | * Download & set up gnunet-update:: | ||
1809 | * Install GNUnet:: | ||
1810 | @end menu | ||
1811 | |||
1812 | @node Prerequisites | ||
1813 | @subsection Prerequisites | ||
1814 | |||
1815 | Open a terminal and paste this line into it to install all required tools | ||
1816 | needed:@ | ||
1817 | @code{sudo apt-get install python-gpgme subversion} | ||
1818 | |||
1819 | @node Download & set up gnunet-update | ||
1820 | @subsection Download & set up gnunet-update | ||
1821 | |||
1822 | The following command will download a working version of gnunet-update with the | ||
1823 | subversion tool and import the public key which is needed for authentication:@ | ||
1824 | |||
1825 | @example | ||
1826 | svn checkout -r24905 https://gnunet.org/svn/gnunet-update ~/gnunet-update && | ||
1827 | cd ~/gnunet-update | ||
1828 | gpg --keyserver "hkp://keys.gnupg.net" --recv-keys 7C613D78 | ||
1829 | @end example | ||
1830 | |||
1831 | @node Install GNUnet | ||
1832 | @subsection Install GNUnet | ||
1833 | |||
1834 | Download and install GNUnet binaries which can be found here and set library | ||
1835 | paths:@ | ||
1836 | @code{@ | ||
1837 | wget -P /tmp https://gnunet.org/install/packs/gnunet-0.9.4-`uname -m`.tgz@ | ||
1838 | ./bin/gnunet-update install /tmp/gnunet-0.9*.tgz ~@ | ||
1839 | echo "PATH DEFAULT=$@{PATH@}:$HOME/bin" >> ~/.pam_environment@ | ||
1840 | echo -e "$@{HOME@}/lib\n$@{HOME@}/lib/gnunet-deps" | sudo tee /etc/ld.so.conf.d/gnunet.conf > /dev/null@ | ||
1841 | sudo ldconfig@ | ||
1842 | }@ | ||
1843 | |||
1844 | You may need to re-login once after executing these last commands | ||
1845 | |||
1846 | That's it, GNUnet is installed in your home directory now. GNUnet can be | ||
1847 | configured and afterwards started by executing@ | ||
1848 | @code{gnunet-arm -s} | ||
1849 | |||
1850 | @node The graphical configuration interface | ||
1851 | @section The graphical configuration interface | ||
1852 | |||
1853 | If you also would like to use gnunet-gtk and gnunet-setup (highly recommended | ||
1854 | for beginners), do: | ||
1855 | |||
1856 | @example | ||
1857 | wget -P /tmp https://gnunet.org/install/packs/gnunet-0.9.4-gtk-0.9.4-`uname -m`.tgz@ | ||
1858 | sh ~/gnunet-update/bin/gnunet-update install /tmp/gnunet-*gtk*.tgz ~@ | ||
1859 | sudo ldconfig | ||
1860 | @end example | ||
1861 | Now you can run @code{gnunet-setup} for easy configuration of your GNUnet peer. | ||
1862 | |||
1863 | |||
1864 | @menu | ||
1865 | * Configuring your peer:: | ||
1866 | * Configuring the Friend-to-Friend (F2F) mode:: | ||
1867 | * Configuring the hostlist to bootstrap:: | ||
1868 | * Configuration of the HOSTLIST proxy settings:: | ||
1869 | * Configuring your peer to provide a hostlist :: | ||
1870 | * Configuring the datastore:: | ||
1871 | * Configuring the MySQL database:: | ||
1872 | * Reasons for using MySQL:: | ||
1873 | * Reasons for not using MySQL:: | ||
1874 | * Setup Instructions:: | ||
1875 | * Testing:: | ||
1876 | * Performance Tuning:: | ||
1877 | * Setup for running Testcases:: | ||
1878 | * Configuring the Postgres database:: | ||
1879 | * Reasons to use Postgres:: | ||
1880 | * Reasons not to use Postgres:: | ||
1881 | * Manual setup instructions:: | ||
1882 | * Testing the setup manually:: | ||
1883 | * Configuring the datacache:: | ||
1884 | * Configuring the file-sharing service:: | ||
1885 | * Configuring logging:: | ||
1886 | * Configuring the transport service and plugins:: | ||
1887 | * Configuring the wlan transport plugin:: | ||
1888 | * Configuring HTTP(S) reverse proxy functionality using Apache or nginx:: | ||
1889 | * Blacklisting peers:: | ||
1890 | * Configuration of the HTTP and HTTPS transport plugins:: | ||
1891 | * Configuring the GNU Name System:: | ||
1892 | * Configuring the GNUnet VPN:: | ||
1893 | * Bandwidth Configuration:: | ||
1894 | * Configuring NAT:: | ||
1895 | * Peer configuration for distributions:: | ||
1896 | @end menu | ||
1897 | |||
1898 | @node Configuring your peer | ||
1899 | @subsection Configuring your peer | ||
1900 | |||
1901 | This chapter will describe the various configuration options in GNUnet. | ||
1902 | |||
1903 | The easiest way to configure your peer is to use the gnunet-setup tool. | ||
1904 | gnunet-setup is part of the gnunet-gtk download. You might have to install it | ||
1905 | separately. | ||
1906 | |||
1907 | Many of the specific sections from this chapter actually are linked from within | ||
1908 | gnunet-setup to help you while using the setup tool. | ||
1909 | |||
1910 | While you can also configure your peer by editing the configuration file by | ||
1911 | hand, this is not recommended for anyone except for developers. | ||
1912 | |||
1913 | |||
1914 | |||
1915 | |||
1916 | |||
1917 | @node Configuring the Friend-to-Friend (F2F) mode | ||
1918 | @subsection Configuring the Friend-to-Friend (F2F) mode | ||
1919 | |||
1920 | GNUnet knows three basic modes of operation. In standard "peer-to-peer" mode, | ||
1921 | your peer will connect to any peer. In the pure "friend-to-friend" mode, your | ||
1922 | peer will ONLY connect to peers from a list of friends specified in the | ||
1923 | configuration. Finally, in mixed mode, GNUnet will only connect to arbitrary | ||
1924 | peers if it has at least a specified number of connections to friends. | ||
1925 | |||
1926 | When configuring any of the F2F modes, you first need to create a file with the | ||
1927 | peer identities of your friends. Ask your friends to run | ||
1928 | |||
1929 | $ gnunet-peerinfo -sq | ||
1930 | |||
1931 | The output of this command needs to be added to your friends file, which is | ||
1932 | simply a plain text file with one line per friend with the output from the | ||
1933 | above command. | ||
1934 | |||
1935 | You then specify the location of your friends file in the "FRIENDS" option of | ||
1936 | the "topology" section. | ||
1937 | |||
1938 | Once you have created the friends file, you can tell GNUnet to only connect to | ||
1939 | your friends by setting the "FRIENDS-ONLY" option (again in the "topology" | ||
1940 | section) to YES. | ||
1941 | |||
1942 | If you want to run in mixed-mode, set "FRIENDS-ONLY" to NO and configure a | ||
1943 | minimum number of friends to have (before connecting to arbitrary peers) under | ||
1944 | the "MINIMUM-FRIENDS" option. | ||
1945 | |||
1946 | If you want to operate in normal P2P-only mode, simply set "MINIMUM-FRIENDS" to | ||
1947 | zero and "FRIENDS_ONLY" to NO. This is the default. | ||
1948 | |||
1949 | @node Configuring the hostlist to bootstrap | ||
1950 | @subsection Configuring the hostlist to bootstrap | ||
1951 | |||
1952 | After installing the software you need to get connected to the GNUnet network. | ||
1953 | The configuration file included in your download is already configured to | ||
1954 | connect you to the GNUnet network. In this section the relevant configuration | ||
1955 | settings are explained. | ||
1956 | |||
1957 | To get an initial connection to the GNUnet network and to get to know peers | ||
1958 | already connected to the network you can use the so called bootstrap servers. | ||
1959 | These servers can give you a list of peers connected to the network. To use | ||
1960 | these bootstrap servers you have to configure the hostlist daemon to activate | ||
1961 | bootstrapping. | ||
1962 | |||
1963 | To activate bootstrapping edit your configuration file and edit the | ||
1964 | @code{[hostlist]}-section. You have to set the argument "-b" in the options | ||
1965 | line: | ||
1966 | @example | ||
1967 | [hostlist] | ||
1968 | OPTIONS = -b | ||
1969 | @end example | ||
1970 | |||
1971 | Additionally you have to specify which server you want to use. The default | ||
1972 | bootstrapping server is "@uref{http://v10.gnunet.org/hostlist, | ||
1973 | http://v10.gnunet.org/hostlist}". [^] To set the server you have to edit the | ||
1974 | line "SERVERS" in the hostlist section. To use the default server you should | ||
1975 | set the lines to | ||
1976 | @example | ||
1977 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
1978 | @end example | ||
1979 | |||
1980 | |||
1981 | To use bootstrapping your configuration file should include these lines: | ||
1982 | @example | ||
1983 | [hostlist] | ||
1984 | OPTIONS = -b | ||
1985 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
1986 | @end example | ||
1987 | |||
1988 | |||
1989 | Besides using bootstrap servers you can configure your GNUnet peer to recieve | ||
1990 | hostlist advertisements. Peers offering hostlists to other peers can send | ||
1991 | advertisement messages to peers that connect to them. If you configure your | ||
1992 | peer to receive these messages, your peer can download these lists and connect | ||
1993 | to the peers included. These lists are persistent, which means that they are | ||
1994 | saved to your hard disk regularly and are loaded during startup. | ||
1995 | |||
1996 | To activate hostlist learning you have to add the "-e" switch to the OPTIONS | ||
1997 | line in the hostlist section: | ||
1998 | @example | ||
1999 | [hostlist] | ||
2000 | OPTIONS = -b -e | ||
2001 | @end example | ||
2002 | |||
2003 | |||
2004 | Furthermore you can specify in which file the lists are saved. To save the | ||
2005 | lists in the file "hostlists.file" just add the line: | ||
2006 | @example | ||
2007 | HOSTLISTFILE = hostlists.file | ||
2008 | @end example | ||
2009 | |||
2010 | |||
2011 | Best practice is to activate both bootstrapping and hostlist learning. So your | ||
2012 | configuration file should include these lines: | ||
2013 | @example | ||
2014 | [hostlist] | ||
2015 | OPTIONS = -b -e | ||
2016 | HTTPPORT = 8080 | ||
2017 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
2018 | HOSTLISTFILE = $SERVICEHOME/hostlists.file | ||
2019 | @end example | ||
2020 | |||
2021 | @node Configuration of the HOSTLIST proxy settings | ||
2022 | @subsection Configuration of the HOSTLIST proxy settings | ||
2023 | |||
2024 | The hostlist client can be configured to use a proxy to connect to the hostlist | ||
2025 | server. This functionality can be configured in the configuration file directly | ||
2026 | or using the gnunet-setup tool. | ||
2027 | |||
2028 | The hostlist client supports the following proxy types at the moment: | ||
2029 | @itemize @bullet | ||
2030 | |||
2031 | |||
2032 | @item | ||
2033 | HTTP and HTTP 1.0 only proxy | ||
2034 | |||
2035 | @item | ||
2036 | SOCKS 4/4a/5/5 with hostname | ||
2037 | @end itemize | ||
2038 | |||
2039 | |||
2040 | In addition authentication at the proxy with username and password can be | ||
2041 | configured. | ||
2042 | |||
2043 | To configure proxy support for the hostlist client in the gnunet-setup tool, | ||
2044 | select the "hostlist" tab and select the appropriate proxy type. The hostname | ||
2045 | or IP address (including port if required) has to be entered in the "Proxy | ||
2046 | hostname" textbox. If required, enter username and password in the "Proxy | ||
2047 | username" and "Proxy password" boxes. Be aware that these information will be | ||
2048 | stored in the configuration in plain text. | ||
2049 | |||
2050 | To configure these options directly in the configuration, you can configure the | ||
2051 | following settings in the @code{[hostlist]} section of the configuration:@ | ||
2052 | @example | ||
2053 | # Type of proxy server,@ | ||
2054 | # Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME@ | ||
2055 | # Default: HTTP@ | ||
2056 | # PROXY_TYPE = HTTP | ||
2057 | |||
2058 | # Hostname or IP of proxy server@ | ||
2059 | # PROXY =@ | ||
2060 | # User name for proxy server@ | ||
2061 | # PROXY_USERNAME =@ | ||
2062 | # User password for proxy server@ | ||
2063 | # PROXY_PASSWORD =@ | ||
2064 | @end example | ||
2065 | |||
2066 | @node Configuring your peer to provide a hostlist | ||
2067 | @subsection Configuring your peer to provide a hostlist | ||
2068 | |||
2069 | If you operate a peer permanently connected to GNUnet you can configure your | ||
2070 | peer to act as a hostlist server, providing other peers the list of peers known | ||
2071 | to him. | ||
2072 | |||
2073 | Yor server can act as a bootstrap server and peers needing to obtain a list of | ||
2074 | peers can contact him to download this list. To download this hostlist the peer | ||
2075 | uses HTTP. For this reason you have to build your peer with libcurl and | ||
2076 | microhttpd support. How you build your peer with this options can be found | ||
2077 | here: https://gnunet.org/generic_installation | ||
2078 | |||
2079 | To configure your peer to act as a bootstrap server you have to add the "-p" | ||
2080 | option to OPTIONS in the [hostlist] section of your configuration file. Besides | ||
2081 | that you have to specify a port number for the http server. In conclusion you | ||
2082 | have to add the following lines: | ||
2083 | |||
2084 | @example | ||
2085 | [hostlist] | ||
2086 | HTTPPORT = 12980 | ||
2087 | OPTIONS = -p | ||
2088 | @end example | ||
2089 | |||
2090 | |||
2091 | If your peer acts as a bootstrap server other peers should know about that. You | ||
2092 | can advertise the hostlist your are providing to other peers. Peers connecting | ||
2093 | to your peer will get a message containing an advertisement for your hostlist | ||
2094 | and the URL where it can be downloaded. If this peer is in learning mode, it | ||
2095 | will test the hostlist and, in the case it can obtain the list successfully, it | ||
2096 | will save it for bootstrapping. | ||
2097 | |||
2098 | To activate hostlist advertisement on your peer, you have to set the following | ||
2099 | lines in your configuration file: | ||
2100 | @example | ||
2101 | [hostlist] | ||
2102 | EXTERNAL_DNS_NAME = example.org | ||
2103 | HTTPPORT = 12981 | ||
2104 | OPTIONS = -p -a | ||
2105 | @end example | ||
2106 | |||
2107 | |||
2108 | With this configuration your peer will a act as a bootstrap server and | ||
2109 | advertise this hostlist to other peers connecting to him. The URL used to | ||
2110 | download the list will be @code{@uref{http://example.org:12981/, | ||
2111 | http://example.org:12981/}}. | ||
2112 | |||
2113 | Please notice: | ||
2114 | @itemize @bullet | ||
2115 | |||
2116 | |||
2117 | @item | ||
2118 | The hostlist is not human readable, so you should not try to download it using | ||
2119 | your webbrowser. Just point your GNUnet peer to the address! | ||
2120 | |||
2121 | @item | ||
2122 | Advertising without providing a hostlist does not make sense and will not work. | ||
2123 | @end itemize | ||
2124 | |||
2125 | @node Configuring the datastore | ||
2126 | @subsection Configuring the datastore | ||
2127 | |||
2128 | The datastore is what GNUnet uses to for long-term storage of file-sharing | ||
2129 | data. Note that long-term does not mean 'forever' since content does have an | ||
2130 | expiration date, and of course storage space is finite (and hence sometimes | ||
2131 | content may have to be discarded). | ||
2132 | |||
2133 | Use the "QUOTA" option to specify how many bytes of storage space you are | ||
2134 | willing to dedicate to GNUnet. | ||
2135 | |||
2136 | In addition to specifying the maximum space GNUnet is allowed to use for the | ||
2137 | datastore, you need to specify which database GNUnet should use to do so. | ||
2138 | Currently, you have the choice between sqLite, MySQL and Postgres. | ||
2139 | |||
2140 | @node Configuring the MySQL database | ||
2141 | @subsection Configuring the MySQL database | ||
2142 | |||
2143 | This section describes how to setup the MySQL database for GNUnet. | ||
2144 | |||
2145 | Note that the mysql plugin does NOT work with mysql before 4.1 since we need | ||
2146 | prepared statements. We are generally testing the code against MySQL 5.1 at | ||
2147 | this point. | ||
2148 | |||
2149 | @node Reasons for using MySQL | ||
2150 | @subsection Reasons for using MySQL | ||
2151 | |||
2152 | @itemize @bullet | ||
2153 | |||
2154 | @item | ||
2155 | On up-to-date hardware where mysql can be used comfortably, this module will | ||
2156 | have better performance than the other database choices (according to our | ||
2157 | tests). | ||
2158 | |||
2159 | @item Its often possible to recover the mysql database from internal | ||
2160 | inconsistencies. Some of the other databases do not support repair. | ||
2161 | @end itemize | ||
2162 | |||
2163 | @node Reasons for not using MySQL | ||
2164 | @subsection Reasons for not using MySQL | ||
2165 | |||
2166 | @itemize @bullet | ||
2167 | |||
2168 | @item | ||
2169 | Memory usage (likely not an issue if you have more than 1 GB) | ||
2170 | |||
2171 | @item | ||
2172 | Complex manual setup | ||
2173 | @end itemize | ||
2174 | |||
2175 | @node Setup Instructions | ||
2176 | @subsection Setup Instructions | ||
2177 | |||
2178 | @itemize @bullet | ||
2179 | |||
2180 | @item | ||
2181 | In @code{gnunet.conf} set in section "DATASTORE" the value for "DATABASE" to | ||
2182 | "mysql". | ||
2183 | |||
2184 | @item | ||
2185 | Access mysql as root:@ | ||
2186 | |||
2187 | @example | ||
2188 | $ mysql -u root -p | ||
2189 | @end example | ||
2190 | |||
2191 | |||
2192 | and issue the following commands, replacing $USER with the username@ | ||
2193 | that will be running gnunet-arm (so typically "gnunet"): | ||
2194 | @example | ||
2195 | CREATE DATABASE gnunet; | ||
2196 | GRANT select,insert,update,delete,create,alter,drop,create temporary tables | ||
2197 | ON gnunet.* TO $USER@@localhost; | ||
2198 | SET PASSWORD FOR $USER@@localhost=PASSWORD('$the_password_you_like'); | ||
2199 | FLUSH PRIVILEGES; | ||
2200 | @end example | ||
2201 | |||
2202 | |||
2203 | @item | ||
2204 | In the $HOME directory of $USER, create a ".my.cnf" file with the following lines@ | ||
2205 | |||
2206 | @example | ||
2207 | [client] | ||
2208 | user=$USER | ||
2209 | password=$the_password_you_like | ||
2210 | @end example | ||
2211 | |||
2212 | @end itemize | ||
2213 | |||
2214 | |||
2215 | Thats it. Note that @code{.my.cnf} file is a slight security risk unless its | ||
2216 | on@ a safe partition. The $HOME/.my.cnf can of course be a symbolic@ link. | ||
2217 | Luckily $USER has only priviledges to mess up GNUnet's tables, which should be | ||
2218 | pretty harmless. | ||
2219 | @node Testing | ||
2220 | @subsection Testing | ||
2221 | |||
2222 | You should briefly try if the database connection works. First, login as $USER. | ||
2223 | Then use: | ||
2224 | @example | ||
2225 | $ mysql -u $USER | ||
2226 | mysql> use gnunet; | ||
2227 | @end example | ||
2228 | |||
2229 | |||
2230 | If you get the message "Database changed" it probably works. | ||
2231 | |||
2232 | If you get "ERROR 2002: Can't connect to local MySQL server@ | ||
2233 | through socket '/tmp/mysql.sock' (2)" it may be resolvable by@ | ||
2234 | "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock"@ | ||
2235 | so there may be some additional trouble depending on your mysql setup. | ||
2236 | @node Performance Tuning | ||
2237 | @subsection Performance Tuning | ||
2238 | |||
2239 | For GNUnet, you probably want to set the option | ||
2240 | @example | ||
2241 | innodb_flush_log_at_trx_commit = 0 | ||
2242 | @end example | ||
2243 | |||
2244 | for a rather dramatic boost in MySQL performance. However, this reduces the | ||
2245 | "safety" of your database as with this options you may loose transactions | ||
2246 | during a power outage. While this is totally harmless for GNUnet, the option | ||
2247 | applies to all applications using MySQL. So you should set it if (and only if) | ||
2248 | GNUnet is the only application on your system using MySQL. | ||
2249 | |||
2250 | @node Setup for running Testcases | ||
2251 | @subsection Setup for running Testcases | ||
2252 | |||
2253 | If you want to run the testcases, you must create a second database | ||
2254 | "gnunetcheck" with the same username and password. This database will then be | ||
2255 | used for testing ("make check"). | ||
2256 | |||
2257 | @node Configuring the Postgres database | ||
2258 | @subsection Configuring the Postgres database | ||
2259 | |||
2260 | This text describes how to setup the Postgres database for GNUnet. | ||
2261 | |||
2262 | This Postgres plugin was developed for Postgres 8.3 but might work for earlier | ||
2263 | versions as well. | ||
2264 | |||
2265 | @node Reasons to use Postgres | ||
2266 | @subsection Reasons to use Postgres | ||
2267 | |||
2268 | @itemize @bullet | ||
2269 | @item | ||
2270 | Easier to setup than MySQL | ||
2271 | @item | ||
2272 | Real database | ||
2273 | @end itemize | ||
2274 | |||
2275 | @node Reasons not to use Postgres | ||
2276 | @subsection Reasons not to use Postgres | ||
2277 | |||
2278 | @itemize @bullet | ||
2279 | @item | ||
2280 | Quite slow | ||
2281 | @item | ||
2282 | Still some manual setup required | ||
2283 | @end itemize | ||
2284 | |||
2285 | @node Manual setup instructions | ||
2286 | @subsection Manual setup instructions | ||
2287 | |||
2288 | @itemize @bullet | ||
2289 | |||
2290 | @item | ||
2291 | In @code{gnunet.conf} set in section "DATASTORE" the value for@ | ||
2292 | "DATABASE" to "postgres". | ||
2293 | @item | ||
2294 | Access Postgres to create a user:@ | ||
2295 | |||
2296 | @table @asis | ||
2297 | |||
2298 | @item with Postgres 8.x, use: | ||
2299 | |||
2300 | @example | ||
2301 | # su - postgres | ||
2302 | $ createuser | ||
2303 | @end example | ||
2304 | |||
2305 | and enter the name of the user running GNUnet for the role interactively. | ||
2306 | Then, when prompted, do not set it to superuser, allow the creation of | ||
2307 | databases, and do not allow the creation of new roles.@ | ||
2308 | |||
2309 | @item with Postgres 9.x, use: | ||
2310 | |||
2311 | @example | ||
2312 | # su - postgres | ||
2313 | $ createuser -d $GNUNET_USER | ||
2314 | @end example | ||
2315 | |||
2316 | |||
2317 | where $GNUNET_USER is the name of the user running GNUnet.@ | ||
2318 | |||
2319 | @end table | ||
2320 | |||
2321 | |||
2322 | @item | ||
2323 | As that user (so typically as user "gnunet"), create a database (or two):@ | ||
2324 | |||
2325 | @example | ||
2326 | $ createdb gnunet | ||
2327 | $ createdb gnunetcheck # this way you can run "make check" | ||
2328 | @end example | ||
2329 | |||
2330 | @end itemize | ||
2331 | |||
2332 | |||
2333 | Now you should be able to start @code{gnunet-arm}. | ||
2334 | |||
2335 | @node Testing the setup manually | ||
2336 | @subsection Testing the setup manually | ||
2337 | |||
2338 | You may want to try if the database connection works. First, again login as | ||
2339 | the user who will run gnunet-arm. Then use, | ||
2340 | @example | ||
2341 | $ psql gnunet # or gnunetcheck | ||
2342 | gnunet=> \dt | ||
2343 | @end example | ||
2344 | |||
2345 | |||
2346 | If, after you have started gnunet-arm at least once, you get a @code{gn090} | ||
2347 | table here, it probably works. | ||
2348 | |||
2349 | @node Configuring the datacache | ||
2350 | @subsection Configuring the datacache | ||
2351 | @c %**end of header | ||
2352 | |||
2353 | The datacache is what GNUnet uses for storing temporary data. This data is | ||
2354 | expected to be wiped completely each time GNUnet is restarted (or the system | ||
2355 | is rebooted). | ||
2356 | |||
2357 | You need to specify how many bytes GNUnet is allowed to use for the datacache | ||
2358 | using the "QUOTA" option in the section "dhtcache". Furthermore, you need to | ||
2359 | specify which database backend should be used to store the data. Currently, | ||
2360 | you have the choice between sqLite, MySQL and Postgres. | ||
2361 | |||
2362 | @node Configuring the file-sharing service | ||
2363 | @subsection Configuring the file-sharing service | ||
2364 | |||
2365 | In order to use GNUnet for file-sharing, you first need to make sure that the | ||
2366 | file-sharing service is loaded. This is done by setting the AUTOSTART option in | ||
2367 | section "fs" to "YES". Alternatively, you can run | ||
2368 | @example | ||
2369 | $ gnunet-arm -i fs | ||
2370 | @end example | ||
2371 | |||
2372 | to start the file-sharing service by hand. | ||
2373 | |||
2374 | Except for configuring the database and the datacache the only important option | ||
2375 | for file-sharing is content migration. | ||
2376 | |||
2377 | Content migration allows your peer to cache content from other peers as well as | ||
2378 | send out content stored on your system without explicit requests. This content | ||
2379 | replication has positive and negative impacts on both system performance an | ||
2380 | privacy. | ||
2381 | |||
2382 | FIXME: discuss the trade-offs. Here is some older text about it... | ||
2383 | |||
2384 | Setting this option to YES allows gnunetd to migrate data to the local machine. | ||
2385 | Setting this option to YES is highly recommended for efficiency. Its also the | ||
2386 | default. If you set this value to YES, GNUnet will store content on your | ||
2387 | machine that you cannot decrypt. While this may protect you from liability if | ||
2388 | the judge is sane, it may not (IANAL). If you put illegal content on your | ||
2389 | machine yourself, setting this option to YES will probably increase your chances | ||
2390 | to get away with it since you can plausibly deny that you inserted the content. | ||
2391 | Note that in either case, your anonymity would have to be broken first (which | ||
2392 | may be possible depending on the size of the GNUnet network and the strength of | ||
2393 | the adversary). | ||
2394 | |||
2395 | @node Configuring logging | ||
2396 | @subsection Configuring logging | ||
2397 | |||
2398 | Logging in GNUnet 0.9.0 is controlled via the "-L" and "-l" options. | ||
2399 | Using "-L", a log level can be specified. With log level "ERROR" only serious | ||
2400 | errors are logged. The default log level is "WARNING" which causes anything of | ||
2401 | concern to be logged. Log level "INFO" can be used to log anything that might | ||
2402 | be interesting information whereas "DEBUG" can be used by developers to log | ||
2403 | debugging messages (but you need to run configure with | ||
2404 | @code{--enable-logging=verbose} to get them compiled). The "-l" option is used | ||
2405 | to specify the log file. | ||
2406 | |||
2407 | Since most GNUnet services are managed by @code{gnunet-arm}, using the "-l" or | ||
2408 | "-L" options directly is not possible. Instead, they can be specified using the | ||
2409 | "OPTIONS" configuration value in the respective section for the respective | ||
2410 | service. In order to enable logging globally without editing the "OPTIONS" | ||
2411 | values for each service, @code{gnunet-arm} supports a "GLOBAL_POSTFIX" option. | ||
2412 | The value specified here is given as an extra option to all services for which | ||
2413 | the configuration does contain a service-specific "OPTIONS" field. | ||
2414 | |||
2415 | "GLOBAL_POSTFIX" can contain the special sequence "@{@}" which is replaced by | ||
2416 | the name of the service that is being started. Furthermore, | ||
2417 | @code{GLOBAL_POSTFIX} is special in that sequences starting with "$" anywhere | ||
2418 | in the string are expanded (according to options in "PATHS"); this expansion | ||
2419 | otherwise is only happening for filenames and then the "$" must be the first | ||
2420 | character in the option. Both of these restrictions do not apply to | ||
2421 | "GLOBAL_POSTFIX". Note that specifying @code{%} anywhere in the "GLOBAL_POSTFIX" | ||
2422 | disables both of these features. | ||
2423 | |||
2424 | In summary, in order to get all services to log at level "INFO" to log-files | ||
2425 | called @code{SERVICENAME-logs}, the following global prefix should be used: | ||
2426 | @example | ||
2427 | GLOBAL_POSTFIX = -l $SERVICEHOME/@{@}-logs -L INFO | ||
2428 | @end example | ||
2429 | |||
2430 | @node Configuring the transport service and plugins | ||
2431 | @subsection Configuring the transport service and plugins | ||
2432 | |||
2433 | The transport service in GNUnet is responsible to maintain basic connectivity | ||
2434 | to other peers. Besides initiating and keeping connections alive it is also | ||
2435 | responsible for address validation. | ||
2436 | |||
2437 | The GNUnet transport supports more than one transport protocol. These protocols | ||
2438 | are configured together with the transport service. | ||
2439 | |||
2440 | The configuration section for the transport service itself is quite similar to | ||
2441 | all the other services | ||
2442 | |||
2443 | @code{@ | ||
2444 | AUTOSTART = YES@ | ||
2445 | @@UNIXONLY@@ PORT = 2091@ | ||
2446 | HOSTNAME = localhost@ | ||
2447 | HOME = $SERVICEHOME@ | ||
2448 | CONFIG = $DEFAULTCONFIG@ | ||
2449 | BINARY = gnunet-service-transport@ | ||
2450 | #PREFIX = valgrind@ | ||
2451 | NEIGHBOUR_LIMIT = 50@ | ||
2452 | ACCEPT_FROM = 127.0.0.1;@ | ||
2453 | ACCEPT_FROM6 = ::1;@ | ||
2454 | PLUGINS = tcp udp@ | ||
2455 | UNIXPATH = /tmp/gnunet-service-transport.sock@ | ||
2456 | } | ||
2457 | |||
2458 | Different are the settings for the plugins to load @code{PLUGINS}. The first | ||
2459 | setting specifies which transport plugins to load. | ||
2460 | @itemize @bullet | ||
2461 | |||
2462 | |||
2463 | @item | ||
2464 | transport-unix | ||
2465 | |||
2466 | A plugin for local only communication with UNIX domain sockets. Used for | ||
2467 | testing and available on unix systems only. Just set the port | ||
2468 | |||
2469 | @code{@ | ||
2470 | [transport-unix]@ | ||
2471 | PORT = 22086@ | ||
2472 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2473 | } | ||
2474 | |||
2475 | @item | ||
2476 | transport-tcp | ||
2477 | |||
2478 | A plugin for communication with TCP. Set port to 0 for client mode with | ||
2479 | outbound only connections | ||
2480 | |||
2481 | @code{@ | ||
2482 | [transport-tcp]@ | ||
2483 | # Use 0 to ONLY advertise as a peer behind NAT (no port binding)@ | ||
2484 | PORT = 2086@ | ||
2485 | ADVERTISED_PORT = 2086@ | ||
2486 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2487 | # Maximum number of open TCP connections allowed@ | ||
2488 | MAX_CONNECTIONS = 128@ | ||
2489 | } | ||
2490 | |||
2491 | @item | ||
2492 | transport-udp | ||
2493 | |||
2494 | A plugin for communication with UDP. Supports peer discovery using broadcasts.@ | ||
2495 | @code{@ | ||
2496 | [transport-udp]@ | ||
2497 | PORT = 2086@ | ||
2498 | BROADCAST = YES@ | ||
2499 | BROADCAST_INTERVAL = 30 s@ | ||
2500 | MAX_BPS = 1000000@ | ||
2501 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2502 | } | ||
2503 | |||
2504 | @item | ||
2505 | transport-http | ||
2506 | |||
2507 | HTTP and HTTPS support is split in two part: a client plugin initiating | ||
2508 | outbound connections and a server part accepting connections from the client. | ||
2509 | The client plugin just takes the maximum number of connections as an argument.@ | ||
2510 | @code{@ | ||
2511 | [transport-http_client]@ | ||
2512 | MAX_CONNECTIONS = 128@ | ||
2513 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2514 | }@ | ||
2515 | @code{@ | ||
2516 | [transport-https_client]@ | ||
2517 | MAX_CONNECTIONS = 128@ | ||
2518 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2519 | } | ||
2520 | |||
2521 | The server has a port configured and the maximum nunber of connections.@ | ||
2522 | The HTTPS part has two files with the certificate key and the certificate file. | ||
2523 | |||
2524 | The server plugin supports reverse proxies, so a external hostname can be set | ||
2525 | using@ | ||
2526 | the @code{EXTERNAL_HOSTNAME} setting. The webserver under this address should | ||
2527 | forward the request to the peer and the configure port. | ||
2528 | |||
2529 | @code{@ | ||
2530 | [transport-http_server]@ | ||
2531 | EXTERNAL_HOSTNAME = fulcrum.net.in.tum.de/gnunet@ | ||
2532 | PORT = 1080@ | ||
2533 | MAX_CONNECTIONS = 128@ | ||
2534 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2535 | }@ | ||
2536 | @code{@ | ||
2537 | [transport-https_server]@ | ||
2538 | PORT = 4433@ | ||
2539 | CRYPTO_INIT = NORMAL@ | ||
2540 | KEY_FILE = https.key@ | ||
2541 | CERT_FILE = https.cert@ | ||
2542 | MAX_CONNECTIONS = 128@ | ||
2543 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2544 | } | ||
2545 | |||
2546 | @item | ||
2547 | transport-wlan | ||
2548 | |||
2549 | There is a special article how to setup the WLAN plugin, so here only the | ||
2550 | settings. Just specify the interface to use:@ | ||
2551 | @code{@ | ||
2552 | [transport-wlan]@ | ||
2553 | # Name of the interface in monitor mode (typically monX)@ | ||
2554 | INTERFACE = mon0@ | ||
2555 | # Real hardware, no testing@ | ||
2556 | TESTMODE = 0@ | ||
2557 | TESTING_IGNORE_KEYS = ACCEPT_FROM;@ | ||
2558 | } | ||
2559 | @end itemize | ||
2560 | |||
2561 | @node Configuring the wlan transport plugin | ||
2562 | @subsection Configuring the wlan transport plugin | ||
2563 | |||
2564 | |||
2565 | The wlan transport plugin enables GNUnet to send and to receive data on a wlan | ||
2566 | interface. It has not to be connected to a wlan network as long as sender and | ||
2567 | receiver are on the same channel. This enables you to get connection to the | ||
2568 | GNUnet where no internet access is possible, for example while catastrophes or | ||
2569 | when censorship cuts you off the internet. | ||
2570 | |||
2571 | |||
2572 | @menu | ||
2573 | * Requirements for the WLAN plugin:: | ||
2574 | * Configuration:: | ||
2575 | * Before starting GNUnet:: | ||
2576 | * Limitations and known bugs:: | ||
2577 | @end menu | ||
2578 | |||
2579 | |||
2580 | @node Requirements for the WLAN plugin | ||
2581 | @subsubsection Requirements for the WLAN plugin | ||
2582 | |||
2583 | @itemize @bullet | ||
2584 | |||
2585 | @item | ||
2586 | wlan network card with monitor support and packet injection | ||
2587 | (see @uref{http://www.aircrack-ng.org/, aircrack-ng.org}) | ||
2588 | |||
2589 | @item | ||
2590 | Linux kernel with mac80211 stack, introduced in 2.6.22, tested with 2.6.35 | ||
2591 | and 2.6.38 | ||
2592 | |||
2593 | @item | ||
2594 | Wlantools to create the a monitor interface, tested with airmon-ng of the | ||
2595 | aircrack-ng package | ||
2596 | @end itemize | ||
2597 | |||
2598 | @node Configuration | ||
2599 | @subsubsection Configuration | ||
2600 | |||
2601 | There are the following options for the wlan plugin (they should be like this | ||
2602 | in your default config file, you only need to adjust them if the values are | ||
2603 | incorrect for your system)@ | ||
2604 | @code{@ | ||
2605 | # section for the wlan transport plugin@ | ||
2606 | [transport-wlan]@ | ||
2607 | # interface to use, more information in the | ||
2608 | # "Before starting GNUnet" section of the handbook. | ||
2609 | INTERFACE = mon0@ | ||
2610 | # testmode for developers:@ | ||
2611 | # 0 use wlan interface,@ | ||
2612 | #1 or 2 use loopback driver for tests 1 = server, 2 = client@ | ||
2613 | TESTMODE = 0@ | ||
2614 | } | ||
2615 | |||
2616 | @node Before starting GNUnet | ||
2617 | @subsubsection Before starting GNUnet | ||
2618 | |||
2619 | Before starting GNUnet, you have to make sure that your wlan interface is in | ||
2620 | monitor mode. One way to put the wlan interface into monitor mode (if your | ||
2621 | interface name is wlan0) is by executing:@ | ||
2622 | @code{@ | ||
2623 | sudo airmon-ng start wlan0@ | ||
2624 | } | ||
2625 | |||
2626 | Here is an example what the result should look like:@ | ||
2627 | @code{@ | ||
2628 | Interface Chipset Driver@ | ||
2629 | wlan0 Intel 4965 a/b/g/n iwl4965 - [phy0]@ | ||
2630 | (monitor mode enabled on mon0)@ | ||
2631 | }@ | ||
2632 | The monitor interface is mon0 is the one that you have to put into the | ||
2633 | configuration file. | ||
2634 | |||
2635 | @node Limitations and known bugs | ||
2636 | @subsubsection Limitations and known bugs | ||
2637 | |||
2638 | Wlan speed is at the maximum of 1 Mbit/s because support for choosing the wlan | ||
2639 | speed with packet injection was removed in newer kernels. Please pester the | ||
2640 | kernel developers about fixing this. | ||
2641 | |||
2642 | The interface channel depends on the wlan network that the card is connected | ||
2643 | to. If no connection has been made since the start of the computer, it is | ||
2644 | usually the first channel of the card. Peers will only find each other and | ||
2645 | communicate if they are on the same channel. Channels must be set manually | ||
2646 | (i.e. using @code{iwconfig wlan0 channel 1}). | ||
2647 | |||
2648 | |||
2649 | @node Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
2650 | @subsection Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
2651 | |||
2652 | The HTTP plugin supports data transfer using reverse proxies. A reverse proxy | ||
2653 | forwards the HTTP request he receives with a certain URL to another webserver, | ||
2654 | here a GNUnet peer. | ||
2655 | |||
2656 | So if you have a running Apache or nginx webserver you can configure it to be a | ||
2657 | GNUnet reverse proxy. Especially if you have a well-known webiste this improves | ||
2658 | censorship resistance since it looks as normal surfing behaviour. | ||
2659 | |||
2660 | To do so, you have to do two things: | ||
2661 | |||
2662 | @itemize @bullet | ||
2663 | |||
2664 | @item | ||
2665 | Configure your webserver to forward the GNUnet HTTP traffic | ||
2666 | |||
2667 | @item | ||
2668 | Configure your GNUnet peer to announce the respective address | ||
2669 | @end itemize | ||
2670 | |||
2671 | As an example we want to use GNUnet peer running: | ||
2672 | |||
2673 | @itemize @bullet | ||
2674 | |||
2675 | @item | ||
2676 | HTTP server plugin on @code{gnunet.foo.org:1080} | ||
2677 | |||
2678 | @item | ||
2679 | HTTPS server plugin on @code{gnunet.foo.org:4433} | ||
2680 | |||
2681 | @item | ||
2682 | A apache or nginx webserver on @uref{http://www.foo.org/, http://www.foo.org:80/} | ||
2683 | |||
2684 | @item | ||
2685 | A apache or nginx webserver on https://www.foo.org:443/ | ||
2686 | @end itemize | ||
2687 | |||
2688 | And we want the webserver to accept GNUnet traffic under | ||
2689 | @code{http://www.foo.org/bar/}. The required steps are described here: | ||
2690 | |||
2691 | @strong{Configure your Apache2 HTTP webserver} | ||
2692 | |||
2693 | First of all you need mod_proxy installed. | ||
2694 | |||
2695 | Edit your webserver configuration. Edit @code{/etc/apache2/apache2.conf} or | ||
2696 | the site-specific configuration file. | ||
2697 | |||
2698 | In the respective @code{server config},@code{virtual host} or | ||
2699 | @code{directory} section add the following lines:@ | ||
2700 | @code{@ | ||
2701 | ProxyTimeout 300@ | ||
2702 | ProxyRequests Off@ | ||
2703 | <Location /bar/ >@ | ||
2704 | ProxyPass http://gnunet.foo.org:1080/@ | ||
2705 | ProxyPassReverse http://gnunet.foo.org:1080/@ | ||
2706 | </Location>@ | ||
2707 | } | ||
2708 | |||
2709 | @strong{Configure your Apache2 HTTPS webserver} | ||
2710 | |||
2711 | We assume that you already have an HTTPS server running, if not please check | ||
2712 | how to configure a HTTPS host. An easy to use example is the | ||
2713 | @file{apache2/sites-available/default-ssl} example configuration file. | ||
2714 | |||
2715 | In the respective HTTPS @code{server config},@code{virtual host} or | ||
2716 | @code{directory} section add the following lines:@ | ||
2717 | @code{@ | ||
2718 | SSLProxyEngine On@ | ||
2719 | ProxyTimeout 300@ | ||
2720 | ProxyRequests Off@ | ||
2721 | <Location /bar/ >@ | ||
2722 | ProxyPass https://gnunet.foo.org:4433/@ | ||
2723 | ProxyPassReverse https://gnunet.foo.org:4433/@ | ||
2724 | </Location>@ | ||
2725 | } | ||
2726 | |||
2727 | More information about the apache mod_proxy configuration can be found unter:@ | ||
2728 | @uref{http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass, http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass} | ||
2729 | |||
2730 | @strong{Configure your nginx HTTPS webserver} | ||
2731 | |||
2732 | Since nginx does not support chunked encoding, you first of all have to | ||
2733 | install @code{chunkin}:@ | ||
2734 | @uref{http://wiki.nginx.org/HttpChunkinModule, http://wiki.nginx.org/HttpChunkinModule} | ||
2735 | |||
2736 | To enable chunkin add:@ | ||
2737 | @code{@ | ||
2738 | chunkin on;@ | ||
2739 | error_page 411 = @@my_411_error;@ | ||
2740 | location @@my_411_error @{@ | ||
2741 | chunkin_resume;@ | ||
2742 | @}@ | ||
2743 | } | ||
2744 | |||
2745 | Edit your webserver configuration. Edit @code{/etc/nginx/nginx.conf} or the | ||
2746 | site-specific configuration file. | ||
2747 | |||
2748 | In the @code{server} section add:@ | ||
2749 | @code{@ | ||
2750 | location /bar/@ | ||
2751 | @{@ | ||
2752 | proxy_pass http://gnunet.foo.org:1080/;@ | ||
2753 | proxy_buffering off;@ | ||
2754 | proxy_connect_timeout 5; # more than http_server@ | ||
2755 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout@ | ||
2756 | proxy_http_version 1.1; # 1.0 default@ | ||
2757 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504;@ | ||
2758 | @}@ | ||
2759 | @code{}} | ||
2760 | |||
2761 | @strong{Configure your nginx HTTPS webserver} | ||
2762 | |||
2763 | Edit your webserver configuration. Edit @code{/etc/nginx/nginx.conf} or the | ||
2764 | site-specific configuration file. | ||
2765 | |||
2766 | In the @code{server} section add:@ | ||
2767 | @code{@ | ||
2768 | ssl_session_timeout 6m;@ | ||
2769 | location /bar/@ | ||
2770 | @{@ | ||
2771 | proxy_pass https://gnunet.foo.org:4433/;@ | ||
2772 | proxy_buffering off;@ | ||
2773 | proxy_connect_timeout 5; # more than http_server@ | ||
2774 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout@ | ||
2775 | proxy_http_version 1.1; # 1.0 default@ | ||
2776 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504;@ | ||
2777 | @}@ | ||
2778 | @code{}} | ||
2779 | |||
2780 | @strong{Configure your GNUnet peer} | ||
2781 | |||
2782 | To have your GNUnet peer announce the address, you have to specify the | ||
2783 | |||
2784 | @code{EXTERNAL_HOSTNAME} option in the @code{[transport-http_server]} section:@ | ||
2785 | @code{@ | ||
2786 | [transport-http_server]@ | ||
2787 | EXTERNAL_HOSTNAME = http://www.foo.org/bar/@ | ||
2788 | }@ | ||
2789 | and/or@ | ||
2790 | @code{[transport-https_server]} section:@ | ||
2791 | @code{@ | ||
2792 | [transport-https_server]@ | ||
2793 | EXTERNAL_HOSTNAME = https://www.foo.org/bar/@ | ||
2794 | } | ||
2795 | |||
2796 | Now restart your webserver and your peer... | ||
2797 | |||
2798 | @node Blacklisting peers | ||
2799 | @subsection Blacklisting peers | ||
2800 | |||
2801 | Transport service supports to deny connecting to a specific peer of to a | ||
2802 | specific peer with a specific transport plugin using te blacklisting component | ||
2803 | of transport service. With@ blacklisting it is possible to deny connections to | ||
2804 | specific peers of@ to use a specific plugin to a specific peer. Peers can be | ||
2805 | blacklisted using@ the configuration or a blacklist client can be asked. | ||
2806 | |||
2807 | To blacklist peers using the configuration you have to add a section to your@ | ||
2808 | configuration containing the peer id of the peer to blacklist and the plugin@ | ||
2809 | if required. | ||
2810 | |||
2811 | Example:@ | ||
2812 | To blacklist connections to P565... on peer AG2P... using tcp add:@ | ||
2813 | @code{@ | ||
2814 | [transport-blacklist AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520]@ | ||
2815 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = tcp@ | ||
2816 | }@ | ||
2817 | To blacklist connections to P565... on peer AG2P... using all plugins add:@ | ||
2818 | @code{@ | ||
2819 | [transport-blacklist-AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520]@ | ||
2820 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G =@ | ||
2821 | } | ||
2822 | |||
2823 | You can also add a blacklist client usign the blacklist api. On a blacklist@ | ||
2824 | check, blacklisting first checks internally if the peer is blacklisted and@ | ||
2825 | if not, it asks the blacklisting clients. Clients are asked if it is OK to@ | ||
2826 | connect to a peer ID, the plugin is omitted. | ||
2827 | |||
2828 | On blacklist check for (peer, plugin) | ||
2829 | @itemize @bullet | ||
2830 | @item Do we have a local blacklist entry for this peer and this plugin?@ | ||
2831 | @item YES: disallow connection@ | ||
2832 | @item Do we have a local blacklist entry for this peer and all plugins?@ | ||
2833 | @item YES: disallow connection@ | ||
2834 | @item Does one of the clients disallow?@ | ||
2835 | @item YES: disallow connection | ||
2836 | @end itemize | ||
2837 | |||
2838 | @node Configuration of the HTTP and HTTPS transport plugins | ||
2839 | @subsection Configuration of the HTTP and HTTPS transport plugins | ||
2840 | |||
2841 | The client part of the http and https transport plugins can be configured to | ||
2842 | use a proxy to connect to the hostlist server. This functionality can be | ||
2843 | configured in the configuration file directly or using the gnunet-setup tool. | ||
2844 | |||
2845 | The both the HTTP and HTTPS clients support the following proxy types at the | ||
2846 | moment: | ||
2847 | |||
2848 | @itemize @bullet | ||
2849 | @item HTTP 1.1 proxy | ||
2850 | @item SOCKS 4/4a/5/5 with hostname | ||
2851 | @end itemize | ||
2852 | |||
2853 | In addition authentication at the proxy with username and password can be | ||
2854 | configured. | ||
2855 | |||
2856 | To configure proxy support for the clients in the gnunet-setup tool, select the | ||
2857 | "transport" tab and activate the respective plugin. Now you can select the | ||
2858 | appropriate proxy type. The hostname or IP address (including port if required) | ||
2859 | has to be entered in the "Proxy hostname" textbox. If required, enter username | ||
2860 | and password in the "Proxy username" and "Proxy password" boxes. Be aware that | ||
2861 | these information will be stored in the configuration in plain text. | ||
2862 | |||
2863 | To configure these options directly in the configuration, you can configure the | ||
2864 | following settings in the [transport-http_client] and [transport-https_client] | ||
2865 | section of the configuration: | ||
2866 | |||
2867 | @example | ||
2868 | # Type of proxy server,@ | ||
2869 | # Valid values: HTTP, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME@ | ||
2870 | # Default: HTTP@ | ||
2871 | # PROXY_TYPE = HTTP | ||
2872 | |||
2873 | # Hostname or IP of proxy server@ | ||
2874 | # PROXY =@ | ||
2875 | # User name for proxy server@ | ||
2876 | # PROXY_USERNAME =@ | ||
2877 | # User password for proxy server@ | ||
2878 | # PROXY_PASSWORD = | ||
2879 | @end example | ||
2880 | |||
2881 | @node Configuring the GNU Name System | ||
2882 | @subsection Configuring the GNU Name System | ||
2883 | |||
2884 | @menu | ||
2885 | * Configuring system-wide DNS interception:: | ||
2886 | * Configuring the GNS nsswitch plugin:: | ||
2887 | * Configuring GNS on W32:: | ||
2888 | * GNS Proxy Setup:: | ||
2889 | * Setup of the GNS CA:: | ||
2890 | * Testing the GNS setup:: | ||
2891 | * Automatic Shortening in the GNU Name System:: | ||
2892 | @end menu | ||
2893 | |||
2894 | |||
2895 | @node Configuring system-wide DNS interception | ||
2896 | @subsubsection Configuring system-wide DNS interception | ||
2897 | |||
2898 | Before you install GNUnet, make sure you have a user and group 'gnunet' as well | ||
2899 | as an empty group 'gnunetdns'. | ||
2900 | |||
2901 | When using GNUnet with system-wide DNS interception, it is absolutely necessary | ||
2902 | for all GNUnet service processes to be started by @code{gnunet-service-arm} as | ||
2903 | user and group 'gnunet'. You also need to be sure to run @code{make install} as | ||
2904 | root (or use the @code{sudo} option to configure) to grant GNUnet sufficient | ||
2905 | privileges. | ||
2906 | |||
2907 | With this setup, all that is required for enabling system-wide DNS interception | ||
2908 | is for some GNUnet component (VPN or GNS) to request it. The | ||
2909 | @code{gnunet-service-dns} will then start helper programs that will make the | ||
2910 | necessary changes to your firewall (@code{iptables}) rules. | ||
2911 | |||
2912 | Note that this will NOT work if your system sends out DNS traffic to a | ||
2913 | link-local IPv6 address, as in this case GNUnet can intercept the traffic, but | ||
2914 | not inject the responses from the link-local IPv6 address. Hence you cannot use | ||
2915 | system-wide DNS interception in conjunction with link-local IPv6-based DNS | ||
2916 | servers. If such a DNS server is used, it will bypass GNUnet's DNS traffic | ||
2917 | interception. | ||
2918 | |||
2919 | |||
2920 | |||
2921 | Using the GNU Name System (GNS) requires two different configuration steps. | ||
2922 | First of all, GNS needs to be integrated with the operating system. Most of | ||
2923 | this section is about the operating system level integration. | ||
2924 | |||
2925 | Additionally, each individual user who wants to use the system must also | ||
2926 | initialize his GNS zones. This can be done by running (after starting GNUnet)@ | ||
2927 | @code{@ | ||
2928 | $ gnunet-gns-import.sh@ | ||
2929 | }@ | ||
2930 | after the local GNUnet peer has been started. Note that the namestore (in | ||
2931 | particular the namestore database backend) should not be reconfigured | ||
2932 | afterwards (as records are not automatically migrated between backends). | ||
2933 | |||
2934 | The remainder of this chapter will detail the various methods for configuring | ||
2935 | the use of GNS with your operating system. | ||
2936 | |||
2937 | At this point in time you have different options depending on your OS: | ||
2938 | @table @asis | ||
2939 | |||
2940 | @item Use the gnunet-gns-proxy This approach works for all operating systems | ||
2941 | and is likely the easiest. However, it enables GNS only for browsers, not for | ||
2942 | other applications that might be using DNS, such as SSH. Still, using the proxy | ||
2943 | is required for using HTTP with GNS and is thus recommended for all users. To | ||
2944 | do this, you simply have to run the @code{gnunet-gns-proxy-setup-ca} script as | ||
2945 | the user who will run the browser (this will create a GNS certificate authority | ||
2946 | (CA) on your system and import its key into your browser), then start | ||
2947 | @code{gnunet-gns-proxy} and inform your browser to use the Socks5 proxy which | ||
2948 | @code{gnunet-gns-proxy} makes available by default on port 7777. | ||
2949 | @item Use a | ||
2950 | nsswitch plugin (recommended on GNU systems) This approach has the advantage of | ||
2951 | offering fully personalized resolution even on multi-user systems. A potential | ||
2952 | disadvantage is that some applications might be able to bypass GNS. | ||
2953 | @item Use | ||
2954 | a W32 resolver plugin (recommended on W32) This is currently the only option on | ||
2955 | W32 systems. | ||
2956 | @item Use system-wide DNS packet interception This approach is | ||
2957 | recommended for the GNUnet VPN. It can be used to handle GNS at the same time; | ||
2958 | however, if you only use this method, you will only get one root zone per | ||
2959 | machine (not so great for multi-user systems). | ||
2960 | @end table | ||
2961 | |||
2962 | |||
2963 | You can combine system-wide DNS packet interception with the nsswitch plugin.@ | ||
2964 | The setup of the system-wide DNS interception is described here. All of the | ||
2965 | other GNS-specific configuration steps are described in the following sections. | ||
2966 | |||
2967 | @node Configuring the GNS nsswitch plugin | ||
2968 | @subsubsection Configuring the GNS nsswitch plugin | ||
2969 | |||
2970 | The Name Service Switch (NSS) is a facility in Unix-like operating systems that | ||
2971 | provides a variety of sources for common configuration databases and name | ||
2972 | resolution mechanisms. A system administrator usually configures the operating | ||
2973 | system's name services using the file /etc/nsswitch.conf. | ||
2974 | |||
2975 | GNS provides a NSS plugin to integrate GNS name resolution with the operating | ||
2976 | system's name resolution process. To use the GNS NSS plugin you have to either | ||
2977 | |||
2978 | @itemize @bullet | ||
2979 | |||
2980 | @item | ||
2981 | install GNUnet as root or | ||
2982 | |||
2983 | @item | ||
2984 | compile GNUnet with the @code{--with-sudo=yes} switch. | ||
2985 | @end itemize | ||
2986 | |||
2987 | Name resolution is controlled by the @emph{hosts} section in the NSS | ||
2988 | configuration. By default this section first performs a lookup in the | ||
2989 | /etc/hosts file and then in DNS. The nsswitch file should contain a line | ||
2990 | similar to:@ | ||
2991 | @code{@ | ||
2992 | hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4@ | ||
2993 | } | ||
2994 | |||
2995 | Here the GNS NSS plugin can be added to perform a GNS lookup before performing | ||
2996 | a DNS lookup. The GNS NSS plugin has to be added to the "hosts" section in | ||
2997 | /etc/nsswitch.conf file before DNS related plugins:@ | ||
2998 | @code{@ | ||
2999 | ...@ | ||
3000 | hosts: files gns [NOTFOUND=return] dns mdns4_minimal mdns4@ | ||
3001 | ...@ | ||
3002 | } | ||
3003 | |||
3004 | The @code{NOTFOUND=return} will ensure that if a @code{.gnu} name is not found | ||
3005 | in GNS it will not be queried in DNS. | ||
3006 | |||
3007 | @node Configuring GNS on W32 | ||
3008 | @subsubsection Configuring GNS on W32 | ||
3009 | |||
3010 | This document is a guide to configuring GNU Name System on W32-compatible | ||
3011 | platforms. | ||
3012 | |||
3013 | After GNUnet is installed, run the w32nsp-install tool: | ||
3014 | @example | ||
3015 | w32nsp-install.exe libw32nsp-0.dll | ||
3016 | @end example | ||
3017 | |||
3018 | |||
3019 | ('0' is the library version of W32 NSP; it might increase in the future, | ||
3020 | change the invocation accordingly). | ||
3021 | |||
3022 | This will install GNS namespace provider into the system and allow other | ||
3023 | applications to resolve names that end in '@strong{gnu}' and '@strong{zkey}'. | ||
3024 | Note that namespace provider requires gnunet-gns-helper-service-w32 to be | ||
3025 | running, as well as gns service itself (and its usual dependencies). | ||
3026 | |||
3027 | Namespace provider is hardcoded to connect to @strong{127.0.0.1:5353}, and this | ||
3028 | is where gnunet-gns-helper-service-w32 should be listening to (and is | ||
3029 | configured to listen to by default). | ||
3030 | |||
3031 | To uninstall the provider, run: | ||
3032 | @example | ||
3033 | w32nsp-uninstall.exe | ||
3034 | @end example | ||
3035 | |||
3036 | |||
3037 | (uses provider GUID to uninstall it, does not need a dll name). | ||
3038 | |||
3039 | Note that while MSDN claims that other applications will only be able to use | ||
3040 | the new namespace provider after re-starting, in reality they might stat to use | ||
3041 | it without that. Conversely, they might stop using the provider after it's been | ||
3042 | uninstalled, even if they were not re-started. W32 will not permit namespace | ||
3043 | provider library to be deleted or overwritten while the provider is installed, | ||
3044 | and while there is at least one process still using it (even after it was | ||
3045 | uninstalled). | ||
3046 | |||
3047 | @node GNS Proxy Setup | ||
3048 | @subsubsection GNS Proxy Setup | ||
3049 | |||
3050 | When using the GNU Name System (GNS) to browse the WWW, there are several | ||
3051 | issues that can be solved by adding the GNS Proxy to your setup: | ||
3052 | @itemize @bullet | ||
3053 | |||
3054 | |||
3055 | @item If the target website does not support GNS, it might assume that it is | ||
3056 | operating under some name in the legacy DNS system (such as example.com). It | ||
3057 | may then attempt to set cookies for that domain, and the web server might | ||
3058 | expect a @code{Host: example.com} header in the request from your browser. | ||
3059 | However, your browser might be using @code{example.gnu} for the @code{Host} | ||
3060 | header and might only accept (and send) cookies for @code{example.gnu}. The GNS | ||
3061 | Proxy will perform the necessary translations of the hostnames for cookies and | ||
3062 | HTTP headers (using the LEHO record for the target domain as the desired | ||
3063 | substitute). | ||
3064 | |||
3065 | @item If using HTTPS, the target site might include an SSL certificate which is | ||
3066 | either only valid for the LEHO domain or might match a TLSA record in GNS. | ||
3067 | However, your browser would expect a valid certificate for @code{example.gnu}, | ||
3068 | not for some legacy domain name. The proxy will validate the certificate | ||
3069 | (either against LEHO or TLSA) and then on-the-fly produce a valid certificate | ||
3070 | for the exchange, signed by your own CA. Assuming you installed the CA of your | ||
3071 | proxy in your browser's certificate authority list, your browser will then | ||
3072 | trust the HTTPS/SSL/TLS connection, as the hostname mismatch is hidden by the | ||
3073 | proxy. | ||
3074 | |||
3075 | @item Finally, the proxy will in the future indicate to the server that it | ||
3076 | speaks GNS, which will enable server operators to deliver GNS-enabled web sites | ||
3077 | to your browser (and continue to deliver legacy links to legacy browsers) | ||
3078 | @end itemize | ||
3079 | |||
3080 | @node Setup of the GNS CA | ||
3081 | @subsubsection Setup of the GNS CA | ||
3082 | |||
3083 | First you need to create a CA certificate that the proxy can use. To do so use | ||
3084 | the provided script gnunet-gns-proxy-ca:@ | ||
3085 | @code{@ | ||
3086 | $ gnunet-gns-proxy-setup-ca@ | ||
3087 | } | ||
3088 | |||
3089 | This will create a personal certification authority for you and add this | ||
3090 | authority to the firefox and chrome database. The proxy will use the this CA | ||
3091 | certificate to generate @code{*.gnu} client certificates on the fly. | ||
3092 | |||
3093 | Note that the proxy uses libcurl. Make sure your version of libcurl uses GnuTLS | ||
3094 | and NOT OpenSSL. The proxy will not work with libcurl compiled against | ||
3095 | OpenSSL. | ||
3096 | |||
3097 | @node Testing the GNS setup | ||
3098 | @subsubsection Testing the GNS setup | ||
3099 | |||
3100 | Now for testing purposes we can create some records in our zone to test the SSL | ||
3101 | functionality of the proxy:@ | ||
3102 | @code{@ | ||
3103 | $ gnunet-namestore -a -e "1 d" -n "homepage" -t A -V 131.159.74.67@ | ||
3104 | $ gnunet-namestore -a -e "1 d" -n "homepage" -t LEHO -V "gnunet.org"@ | ||
3105 | } | ||
3106 | |||
3107 | At this point we can start the proxy. Simply execute@ | ||
3108 | @code{@ | ||
3109 | $ gnunet-gns-proxy@ | ||
3110 | } | ||
3111 | |||
3112 | Configure your browser to use this SOCKSv5 proxy on port 7777 and visit this | ||
3113 | link.@ If you use firefox you also have to go to about:config and set the key | ||
3114 | @code{network.proxy.socks_remote_dns} to @code{true}. | ||
3115 | |||
3116 | When you visit @code{https://homepage.gnu/}, you should get to the | ||
3117 | @code{https://gnunet.org/} frontpage and the browser (with the correctly | ||
3118 | configured proxy) should give you a valid SSL certificate for | ||
3119 | @code{homepage.gnu} and no warnings. It should look like this@ | ||
3120 | |||
3121 | |||
3122 | |||
3123 | @table @asis | ||
3124 | @item Attachment | ||
3125 | Size | ||
3126 | @item gnunethpgns.png | ||
3127 | 64.19 KB | ||
3128 | @end table | ||
3129 | |||
3130 | @node Automatic Shortening in the GNU Name System | ||
3131 | @subsubsection Automatic Shortening in the GNU Name System | ||
3132 | |||
3133 | This page describes a possible option for 'automatic name shortening', which | ||
3134 | you can choose to enable with the GNU Name System. | ||
3135 | |||
3136 | When GNS encounters a name for the first time, it can use the 'NICK' record of | ||
3137 | the originating zone to automatically generate a name for the zone. If | ||
3138 | automatic shortening is enabled, those auto-generated names will be placed (as | ||
3139 | private records) into your personal 'shorten' zone (to prevent confusion with | ||
3140 | manually selected names). Then, in the future, if the same name is encountered | ||
3141 | again, GNS will display the shortened name instead (the first time, the long | ||
3142 | name will still be used as shortening typically happens asynchronously as | ||
3143 | looking up the 'NICK' record takes some time). Using this feature can be a | ||
3144 | convenient way to avoid very long @code{.gnu} names; however, note that names | ||
3145 | from the shorten-zone are assigned on a first-come-first-serve basis and should | ||
3146 | not be trusted. Furthermore, if you enable this feature, you will no longer see | ||
3147 | the full delegation chain for zones once shortening has been applied. | ||
3148 | |||
3149 | @node Configuring the GNUnet VPN | ||
3150 | @subsection Configuring the GNUnet VPN | ||
3151 | |||
3152 | @menu | ||
3153 | * IPv4 address for interface:: | ||
3154 | * IPv6 address for interface:: | ||
3155 | * Configuring the GNUnet VPN DNS:: | ||
3156 | * Configuring the GNUnet VPN Exit Service:: | ||
3157 | * IP Address of external DNS resolver:: | ||
3158 | * IPv4 address for Exit interface:: | ||
3159 | * IPv6 address for Exit interface:: | ||
3160 | @end menu | ||
3161 | |||
3162 | Before configuring the GNUnet VPN, please make sure that system-wide DNS | ||
3163 | interception is configured properly as described in the section on the GNUnet | ||
3164 | DNS setup. | ||
3165 | |||
3166 | The default-options for the GNUnet VPN are usually sufficient to use GNUnet as | ||
3167 | a Layer 2 for your Internet connection. However, what you always have to | ||
3168 | specify is which IP protocol you want to tunnel: IPv4, IPv6 or both. | ||
3169 | Furthermore, if you tunnel both, you most likely should also tunnel all of your | ||
3170 | DNS requests. You theoretically can tunnel "only" your DNS traffic, but that | ||
3171 | usually makes little sense. | ||
3172 | |||
3173 | The other options as shown on the gnunet-setup tool are: | ||
3174 | |||
3175 | @node IPv4 address for interface | ||
3176 | @subsubsection IPv4 address for interface | ||
3177 | |||
3178 | This is the IPv4 address the VPN interface will get. You should pick an | ||
3179 | 'private' IPv4 network that is not yet in use for you system. For example, if | ||
3180 | you use 10.0.0.1/255.255.0.0 already, you might use 10.1.0.1/255.255.0.0. If | ||
3181 | you use 10.0.0.1/255.0.0.0 already, then you might use 192.168.0.1/255.255.0.0. | ||
3182 | If your system is not in a private IP-network, using any of the above will work | ||
3183 | fine.@ You should try to make the mask of the address big enough (255.255.0.0 | ||
3184 | or, even better, 255.0.0.0) to allow more mappings of remote IP Addresses into | ||
3185 | this range. However, even a 255.255.255.0-mask will suffice for most users. | ||
3186 | |||
3187 | @node IPv6 address for interface | ||
3188 | @subsubsection IPv6 address for interface | ||
3189 | |||
3190 | The IPv6 address the VPN interface will get. Here you can specify any | ||
3191 | non-link-local address (the address should not begin with "fe80:"). A subnet | ||
3192 | Unique Local Unicast (fd00::/8-prefix) that you are currently not using would | ||
3193 | be a good choice. | ||
3194 | |||
3195 | @node Configuring the GNUnet VPN DNS | ||
3196 | @subsubsection Configuring the GNUnet VPN DNS | ||
3197 | |||
3198 | To resolve names for remote nodes, activate the DNS exit option. | ||
3199 | |||
3200 | @node Configuring the GNUnet VPN Exit Service | ||
3201 | @subsubsection Configuring the GNUnet VPN Exit Service | ||
3202 | |||
3203 | If you want to allow other users to share your Internet connection (yes, this | ||
3204 | may be dangerous, just as running a Tor exit node) or want to provide access to | ||
3205 | services on your host (this should be less dangerous, as long as those services | ||
3206 | are secure), you have to enable the GNUnet exit daemon. | ||
3207 | |||
3208 | You then get to specify which exit functions you want to provide. By enabling | ||
3209 | the exit daemon, you will always automatically provide exit functions for | ||
3210 | manually configured local services (this component of the system is under | ||
3211 | development and not documented further at this time). As for those services you | ||
3212 | explicitly specify the target IP address and port, there is no significant | ||
3213 | security risk in doing so. | ||
3214 | |||
3215 | Furthermore, you can serve as a DNS, IPv4 or IPv6 exit to the Internet. Being a | ||
3216 | DNS exit is usually pretty harmless. However, enabling IPv4 or IPv6-exit | ||
3217 | without further precautions may enable adversaries to access your local | ||
3218 | network, send spam, attack other systems from your Internet connection and to | ||
3219 | other mischief that will appear to come from your machine. This may or may not | ||
3220 | get you into legal trouble. If you want to allow IPv4 or IPv6-exit | ||
3221 | functionality, you should strongly consider adding additional firewall rules | ||
3222 | manually to protect your local network and to restrict outgoing TCP traffic | ||
3223 | (i.e. by not allowing access to port 25). While we plan to improve | ||
3224 | exit-filtering in the future, you're currently on your own here. Essentially, | ||
3225 | be prepared for any kind of IP-traffic to exit the respective TUN interface | ||
3226 | (and GNUnet will enable IP-forwarding and NAT for the interface automatically). | ||
3227 | |||
3228 | Additional configuration options of the exit as shown by the gnunet-setup tool | ||
3229 | are: | ||
3230 | |||
3231 | @node IP Address of external DNS resolver | ||
3232 | @subsubsection IP Address of external DNS resolver | ||
3233 | |||
3234 | If DNS traffic is to exit your machine, it will be send to this DNS resolver. | ||
3235 | You can specify an IPv4 or IPv6 address. | ||
3236 | |||
3237 | @node IPv4 address for Exit interface | ||
3238 | @subsubsection IPv4 address for Exit interface | ||
3239 | |||
3240 | This is the IPv4 address the Interface will get. Make the mask of the address | ||
3241 | big enough (255.255.0.0 or, even better, 255.0.0.0) to allow more mappings of | ||
3242 | IP addresses into this range. As for the VPN interface, any unused, private | ||
3243 | IPv4 address range will do. | ||
3244 | |||
3245 | @node IPv6 address for Exit interface | ||
3246 | @subsubsection IPv6 address for Exit interface | ||
3247 | |||
3248 | The public IPv6 address the interface will get. If your kernel is not a very | ||
3249 | recent kernel and you are willing to manually enable IPv6-NAT, the IPv6 address | ||
3250 | you specify here must be a globally routed IPv6 address of your host. | ||
3251 | |||
3252 | Suppose your host has the address @code{2001:4ca0::1234/64}, then using@ | ||
3253 | @code{2001:4ca0::1:0/112} would be fine (keep the first 64 bits, then change at | ||
3254 | least one bit in the range before the bitmask, in the example above we changed | ||
3255 | bit 111 from 0 to 1). | ||
3256 | |||
3257 | You may also have to configure your router to route traffic for the entire | ||
3258 | subnet (@code{2001:4ca0::1:0/112} for example) through your computer (this | ||
3259 | should be automatic with IPv6, but obviously anything can be | ||
3260 | disabled). | ||
3261 | |||
3262 | @node Bandwidth Configuration | ||
3263 | @subsection Bandwidth Configuration | ||
3264 | |||
3265 | You can specify how many bandwidth GNUnet is allowed to use to receive and send | ||
3266 | data. This is important for users with limited bandwidth or traffic volume. | ||
3267 | |||
3268 | @node Configuring NAT | ||
3269 | @subsection Configuring NAT | ||
3270 | |||
3271 | Most hosts today do not have a normal global IP address but instead are behind | ||
3272 | a router performing Network Address Translation (NAT) which assigns each host | ||
3273 | in the local network a private IP address. As a result, these machines cannot | ||
3274 | trivially receive inbound connections from the Internet. GNUnet supports NAT | ||
3275 | traversal to enable these machines to receive incoming connections from other | ||
3276 | peers despite their limitations. | ||
3277 | |||
3278 | In an ideal world, you can press the "Attempt automatic configuration" button | ||
3279 | in gnunet-setup to automatically configure your peer correctly. Alternatively, | ||
3280 | your distribution might have already triggered this automatic configuration | ||
3281 | during the installation process. However, automatic configuration can fail to | ||
3282 | determine the optimal settings, resulting in your peer either not receiving as | ||
3283 | many connections as possible, or in the worst case it not connecting to the | ||
3284 | network at all. | ||
3285 | |||
3286 | To manually configure the peer, you need to know a few things about your | ||
3287 | network setup. First, determine if you are behind a NAT in the first place. | ||
3288 | This is always the case if your IP address starts with "10.*" or "192.168.*". | ||
3289 | Next, if you have control over your NAT router, you may choose to manually | ||
3290 | configure it to allow GNUnet traffic to your host. If you have configured your | ||
3291 | NAT to forward traffic on ports 2086 (and possibly 1080) to your host, you can | ||
3292 | check the "NAT ports have been opened manually" option, which corresponds to | ||
3293 | the "PUNCHED_NAT" option in the configuration file. If you did not punch your | ||
3294 | NAT box, it may still be configured to support UPnP, which allows GNUnet to | ||
3295 | automatically configure it. In that case, you need to install the "upnpc" | ||
3296 | command, enable UPnP (or PMP) on your NAT box and set the "Enable NAT traversal | ||
3297 | via UPnP or PMP" option (corresponding to "ENABLE_UPNP" in the configuration | ||
3298 | file). | ||
3299 | |||
3300 | Some NAT boxes can be traversed using the autonomous NAT traversal method. This | ||
3301 | requires certain GNUnet components to be installed with "SUID" prividledges on | ||
3302 | your system (so if you're installing on a system you do not have administrative | ||
3303 | rights to, this will not work). If you installed as 'root', you can enable | ||
3304 | autonomous NAT traversal by checking the "Enable NAT traversal using ICMP | ||
3305 | method". The ICMP method requires a way to determine your NAT's external | ||
3306 | (global) IP address. This can be done using either UPnP, DynDNS, or by manual | ||
3307 | configuration. If you have a DynDNS name or know your external IP address, you | ||
3308 | should enter that name under "External (public) IPv4 address" (which | ||
3309 | corresponds to the "EXTERNAL_ADDRESS" option in the configuration file). If you | ||
3310 | leave the option empty, GNUnet will try to determine your external IP address | ||
3311 | automatically (which may fail, in which case autonomous NAT traversal will then | ||
3312 | not work). | ||
3313 | |||
3314 | Finally, if you yourself are not behind NAT but want to be able to connect to | ||
3315 | NATed peers using autonomous NAT traversal, you need to check the "Enable | ||
3316 | connecting to NATed peers using ICMP method" box. | ||
3317 | |||
3318 | |||
3319 | @node Peer configuration for distributions | ||
3320 | @subsection Peer configuration for distributions | ||
3321 | |||
3322 | The "GNUNET_DATA_HOME" in "[path]" in @file{/etc/gnunet.conf} should be manually set | ||
3323 | to "/var/lib/gnunet/data/" as the default "~/.local/share/gnunet/" is probably | ||
3324 | not that appropriate in this case. Similarly, distributions may consider | ||
3325 | pointing "GNUNET_RUNTIME_DIR" to "/var/run/gnunet/" and "GNUNET_HOME" to | ||
3326 | "/var/lib/gnunet/". Also, should a distribution decide to override system | ||
3327 | defaults, all of these changes should be done in a custom @file{/etc/gnunet.conf} | ||
3328 | and not in the files in the @file{config.d/} directory. | ||
3329 | |||
3330 | Given the proposed access permissions, the "gnunet-setup" tool must be run as | ||
3331 | use "gnunet" (and with option "-c /etc/gnunet.conf" so that it modifies the | ||
3332 | system configuration). As always, gnunet-setup should be run after the GNUnet | ||
3333 | peer was stopped using "gnunet-arm -e". Distributions might want to include a | ||
3334 | wrapper for gnunet-setup that allows the desktop-user to "sudo" (i.e. using | ||
3335 | gtksudo) to the "gnunet" user account and then runs "gnunet-arm -e", | ||
3336 | "gnunet-setup" and "gnunet-arm -s" in sequence. | ||
3337 | |||
3338 | |||
3339 | |||
3340 | @node How to start and stop a GNUnet peer | ||
3341 | @section How to start and stop a GNUnet peer | ||
3342 | |||
3343 | This section describes how to start a GNUnet peer. It assumes that you have | ||
3344 | already compiled and installed GNUnet and its' dependencies. Before you start a | ||
3345 | GNUnet peer, you may want to create a configuration file using gnunet-setup | ||
3346 | (but you do not have to). Sane defaults should exist in your | ||
3347 | @file{$GNUNET_PREFIX/share/gnunet/config.d/} directory, so in practice you could | ||
3348 | simply start without any configuration. If you want to configure your peer | ||
3349 | later, you need to stop it before invoking the @code{gnunet-setup} tool to | ||
3350 | customize further and to test your configuration (@code{gnunet-setup} has | ||
3351 | build-in test functions). | ||
3352 | |||
3353 | The most important option you might have to still set by hand is in [PATHS]. | ||
3354 | Here, you use the option "GNUNET_HOME" to specify the path where GNUnet should | ||
3355 | store its data. It defaults to @code{$HOME/}, which again should work for most | ||
3356 | users. Make sure that the directory specified as GNUNET_HOME is writable to | ||
3357 | the user that you will use to run GNUnet (note that you can run frontends | ||
3358 | using other users, GNUNET_HOME must only be accessible to the user used to run | ||
3359 | the background processes). | ||
3360 | |||
3361 | You will also need to make one central decision: should all of GNUnet be run | ||
3362 | under your normal UID, or do you want distinguish between system-wide | ||
3363 | (user-independent) GNUnet services and personal GNUnet services. The multi-user | ||
3364 | setup is slightly more complicated, but also more secure and generally | ||
3365 | recommended. | ||
3366 | |||
3367 | @menu | ||
3368 | * The Single-User Setup:: | ||
3369 | * The Multi-User Setup:: | ||
3370 | * Killing GNUnet services:: | ||
3371 | * Access Control for GNUnet:: | ||
3372 | @end menu | ||
3373 | |||
3374 | @node The Single-User Setup | ||
3375 | @subsection The Single-User Setup | ||
3376 | |||
3377 | For the single-user setup, you do not need to do anything special and can just | ||
3378 | start the GNUnet background processes using @code{gnunet-arm}. By default, | ||
3379 | GNUnet looks in @file{~/.config/gnunet.conf} for a configuration (or | ||
3380 | @code{$XDG_CONFIG_HOME/gnunet.conf} if@ @code{$XDG_CONFIG_HOME} is defined). If your | ||
3381 | configuration lives elsewhere, you need to pass the @code{-c FILENAME} option | ||
3382 | to all GNUnet commands. | ||
3383 | |||
3384 | Assuming the configuration file is called @file{~/.config/gnunet.conf}, you | ||
3385 | start your peer using the @code{gnunet-arm} command (say as user | ||
3386 | @code{gnunet}) using: | ||
3387 | @example | ||
3388 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
3389 | @end example | ||
3390 | |||
3391 | The "-s" option here is for "start". The command should return almost | ||
3392 | instantly. If you want to stop GNUnet, you can use: | ||
3393 | @example | ||
3394 | gnunet-arm -c ~/.config/gnunet.conf -e | ||
3395 | @end example | ||
3396 | |||
3397 | The "-e" option here is for "end". | ||
3398 | |||
3399 | Note that this will only start the basic peer, no actual applications will be | ||
3400 | available. If you want to start the file-sharing service, use (after starting | ||
3401 | GNUnet): | ||
3402 | @example | ||
3403 | gnunet-arm -c ~/.config/gnunet.conf -i fs | ||
3404 | @end example | ||
3405 | |||
3406 | The "-i fs" option here is for "initialize" the "fs" (file-sharing) | ||
3407 | application. You can also selectively kill only file-sharing support using | ||
3408 | @example | ||
3409 | gnunet-arm -c ~/.config/gnunet.conf -k fs | ||
3410 | @end example | ||
3411 | |||
3412 | Assuming that you want certain services (like file-sharing) to be always | ||
3413 | automatically started whenever you start GNUnet, you can activate them by | ||
3414 | setting "FORCESTART=YES" in the respective section of the configuration file | ||
3415 | (for example, "[fs]"). Then GNUnet with file-sharing support would be started | ||
3416 | whenever you@ enter: | ||
3417 | @example | ||
3418 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
3419 | @end example | ||
3420 | |||
3421 | Alternatively, you can combine the two options: | ||
3422 | @example | ||
3423 | gnunet-arm -c ~/.config/gnunet.conf -s -i fs | ||
3424 | @end example | ||
3425 | |||
3426 | |||
3427 | Using @code{gnunet-arm} is also the preferred method for initializing GNUnet | ||
3428 | from @code{init}. | ||
3429 | |||
3430 | Finally, you should edit your @code{crontab} (using the @code{crontab} command) | ||
3431 | and insert a line@ | ||
3432 | @code{@ | ||
3433 | @@reboot gnunet-arm -c ~/.config/gnunet.conf -s@ | ||
3434 | }@ | ||
3435 | to automatically start your peer whenever your system boots. | ||
3436 | |||
3437 | @node The Multi-User Setup | ||
3438 | @subsection The Multi-User Setup | ||
3439 | |||
3440 | This requires you to create a user @code{gnunet} and an additional group | ||
3441 | @code{gnunetdns}, prior to running @code{make install} during installation. | ||
3442 | Then, you create a configuration file @file{/etc/gnunet.conf} which should | ||
3443 | contain the lines:@ | ||
3444 | @code{@ | ||
3445 | [arm]@ | ||
3446 | SYSTEM_ONLY = YES@ | ||
3447 | USER_ONLY = NO@ | ||
3448 | }@ | ||
3449 | Then, perform the same steps to run GNUnet as in the per-user configuration, | ||
3450 | except as user @code{gnunet} (including the @code{crontab} installation). You | ||
3451 | may also want to run @code{gnunet-setup} to configure your peer (databases, | ||
3452 | etc.). Make sure to pass @code{-c /etc/gnunet.conf} to all commands. If you | ||
3453 | run @code{gnunet-setup} as user @code{gnunet}, you might need to change | ||
3454 | permissions on @file{/etc/gnunet.conf} so that the @code{gnunet} user can | ||
3455 | write to the file (during setup). | ||
3456 | |||
3457 | Afterwards, you need to perform another setup step for each normal user account | ||
3458 | from which you want to access GNUnet. First, grant the normal user | ||
3459 | (@code{$USER}) permission to the group gnunet:@ | ||
3460 | @code{@ | ||
3461 | # adduser $USER gnunet@ | ||
3462 | }@ | ||
3463 | Then, create a configuration file in @file{~/.config/gnunet.conf} for the $USER | ||
3464 | with the lines:@ | ||
3465 | @code{@ | ||
3466 | [arm]@ | ||
3467 | SYSTEM_ONLY = NO@ | ||
3468 | USER_ONLY = YES@ | ||
3469 | }@ | ||
3470 | This will ensure that @code{gnunet-arm} when started by the normal user will | ||
3471 | only run services that are per-user, and otherwise rely on the system-wide | ||
3472 | services. Note that the normal user may run gnunet-setup, but the | ||
3473 | configuration would be ineffective as the system-wide services will use | ||
3474 | @code{/etc/gnunet.conf} and ignore options set by individual users. | ||
3475 | |||
3476 | Again, each user should then start the peer using @code{gnunet-arm -s} --- and | ||
3477 | strongly consider adding logic to start the peer automatically to their | ||
3478 | crontab. | ||
3479 | |||
3480 | Afterwards, you should see two (or more, if you have more than one USER) | ||
3481 | @code{gnunet-service-arm} processes running in your system. | ||
3482 | |||
3483 | @node Killing GNUnet services | ||
3484 | @subsection Killing GNUnet services | ||
3485 | |||
3486 | It is not necessary to stop GNUnet services explicitly when shutting down your | ||
3487 | computer. | ||
3488 | |||
3489 | It should be noted that manually killing "most" of the @code{gnunet-service} | ||
3490 | processes is generally not a successful method for stopping a peer (since | ||
3491 | @code{gnunet-service-arm} will instantly restart them). The best way to | ||
3492 | explicitly stop a peer is using @code{gnunet-arm -e}; note that the per-user | ||
3493 | services may need to be terminated before the system-wide services will | ||
3494 | terminate normally. | ||
3495 | |||
3496 | @node Access Control for GNUnet | ||
3497 | @subsection Access Control for GNUnet | ||
3498 | |||
3499 | This chapter documents how we plan to make access control work within the | ||
3500 | GNUnet system for a typical peer. It should be read as a best-practice | ||
3501 | installation guide for advanced users and builders of binary distributions. The | ||
3502 | recommendations in this guide apply to POSIX-systems with full support for UNIX | ||
3503 | domain sockets only. | ||
3504 | |||
3505 | Note that this is an advanced topic. The discussion presumes a very good | ||
3506 | understanding of users, groups and file permissions. Normal users on hosts with | ||
3507 | just a single user can just install GNUnet under their own account (and | ||
3508 | possibly allow the installer to use SUDO to grant additional permissions for | ||
3509 | special GNUnet tools that need additional rights). The discussion below largely | ||
3510 | applies to installations where multiple users share a system and to | ||
3511 | installations where the best possible security is paramount. | ||
3512 | |||
3513 | A typical GNUnet system consists of components that fall into four categories: | ||
3514 | |||
3515 | @table @asis | ||
3516 | |||
3517 | @item User interfaces | ||
3518 | User interfaces are not security sensitive and are supposed to be run and used | ||
3519 | by normal system users. The GTK GUIs and most command-line programs fall into | ||
3520 | this category. Some command-line tools (like gnunet-transport) should be | ||
3521 | excluded as they offer low-level access that normal users should not need. | ||
3522 | @item System services and support tools | ||
3523 | System services should always run and offer services that can then be accessed | ||
3524 | by the normal users. System services do not require special permissions, but as | ||
3525 | they are not specific to a particular user, they probably should not run as a | ||
3526 | particular user. Also, there should typically only be one GNUnet peer per host. | ||
3527 | System services include the gnunet-service and gnunet-daemon programs; support | ||
3528 | tools include command-line programs such as gnunet-arm. | ||
3529 | @item Priviledged helpers | ||
3530 | Some GNUnet components require root rights to open raw sockets or perform other | ||
3531 | special operations. These gnunet-helper binaries are typically installed SUID | ||
3532 | and run from services or daemons. | ||
3533 | @item Critical services | ||
3534 | Some GNUnet services (such as the DNS service) can manipulate the service in | ||
3535 | deep and possibly highly security sensitive ways. For example, the DNS service | ||
3536 | can be used to intercept and alter any DNS query originating from the local | ||
3537 | machine. Access to the APIs of these critical services and their priviledged | ||
3538 | helpers must be tightly controlled. | ||
3539 | @end table | ||
3540 | |||
3541 | @menu | ||
3542 | * Recommendation - Disable access to services via TCP:: | ||
3543 | * Recommendation - Run most services as system user "gnunet":: | ||
3544 | * Recommendation - Control access to services using group "gnunet":: | ||
3545 | * Recommendation - Limit access to certain SUID binaries by group "gnunet":: | ||
3546 | * Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns":: | ||
3547 | * Differences between "make install" and these recommendations:: | ||
3548 | @end menu | ||
3549 | |||
3550 | @node Recommendation - Disable access to services via TCP | ||
3551 | @subsubsection Recommendation - Disable access to services via TCP | ||
3552 | |||
3553 | GNUnet services allow two types of access: via TCP socket or via UNIX domain | ||
3554 | socket. If the service is available via TCP, access control can only be | ||
3555 | implemented by restricting connections to a particular range of IP addresses. | ||
3556 | This is acceptable for non-critical services that are supposed to be available | ||
3557 | to all users on the local system or local network. However, as TCP is generally | ||
3558 | less efficient and it is rarely the case that a single GNUnet peer is supposed | ||
3559 | to serve an entire local network, the default configuration should disable TCP | ||
3560 | access to all GNUnet services on systems with support for UNIX domain sockets. | ||
3561 | As of GNUnet 0.9.2, configuration files with TCP access disabled should be | ||
3562 | generated by default. Users can re-enable TCP access to particular services | ||
3563 | simply by specifying a non-zero port number in the section of the respective | ||
3564 | service. | ||
3565 | |||
3566 | |||
3567 | @node Recommendation - Run most services as system user "gnunet" | ||
3568 | @subsubsection Recommendation - Run most services as system user "gnunet" | ||
3569 | |||
3570 | GNUnet's main services should be run as a separate user "gnunet" in a special | ||
3571 | group "gnunet". The user "gnunet" should start the peer using "gnunet-arm -s" | ||
3572 | during system startup. The home directory for this user should be | ||
3573 | @file{/var/lib/gnunet} and the configuration file should be @file{/etc/gnunet.conf}. | ||
3574 | Only the @code{gnunet} user should have the right to access @file{/var/lib/gnunet} | ||
3575 | (@emph{mode: 700}). | ||
3576 | |||
3577 | @node Recommendation - Control access to services using group "gnunet" | ||
3578 | @subsubsection Recommendation - Control access to services using group "gnunet" | ||
3579 | |||
3580 | Users that should be allowed to use the GNUnet peer should be added to the | ||
3581 | group "gnunet". Using GNUnet's access control mechanism for UNIX domain | ||
3582 | sockets, those services that are considered useful to ordinary users should be | ||
3583 | made available by setting "UNIX_MATCH_GID=YES" for those services. Again, as | ||
3584 | shipped, GNUnet provides reasonable defaults. Permissions to access the | ||
3585 | transport and core subsystems might additionally be granted without necessarily | ||
3586 | causing security concerns. Some services, such as DNS, must NOT be made | ||
3587 | accessible to the "gnunet" group (and should thus only be accessible to the | ||
3588 | "gnunet" user and services running with this UID). | ||
3589 | |||
3590 | @node Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
3591 | @subsubsection Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
3592 | |||
3593 | Most of GNUnet's SUID binaries should be safe even if executed by normal users. | ||
3594 | However, it is possible to reduce the risk a little bit more by making these | ||
3595 | binaries owned by the group "gnunet" and restricting their execution to user of | ||
3596 | the group "gnunet" as well (4750). | ||
3597 | |||
3598 | @node Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
3599 | @subsubsection Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
3600 | |||
3601 | A special group "gnunetdns" should be created for controlling access to the | ||
3602 | "gnunet-helper-dns". The binary should then be owned by root and be in group | ||
3603 | "gnunetdns" and be installed SUID and only be group-executable (2750). Note | ||
3604 | that the group "gnunetdns" should have no users in it at all, ever. The | ||
3605 | "gnunet-service-dns" program should be executed by user "gnunet" (via | ||
3606 | gnunet-service-arm) with the binary owned by the user "root" and the group | ||
3607 | "gnunetdns" and be SGID (2700). This way, @strong{only} "gnunet-service-dns" | ||
3608 | can change its group to "gnunetdns" and execute the helper, and the helper can | ||
3609 | then run as root (as per SUID). Access to the API offered by | ||
3610 | "gnunet-service-dns" is in turn restricted to the user "gnunet" (not the | ||
3611 | group!), which means that only "benign" services can manipulate DNS queries | ||
3612 | using "gnunet-service-dns". | ||
3613 | |||
3614 | @node Differences between "make install" and these recommendations | ||
3615 | @subsubsection Differences between "make install" and these recommendations | ||
3616 | |||
3617 | The current build system does not set all permissions automatically based on | ||
3618 | the recommendations above. In particular, it does not use the group "gnunet" at | ||
3619 | all (so setting gnunet-helpers other than the gnunet-helper-dns to be owned by | ||
3620 | group "gnunet" must be done manually). Furthermore, 'make install' will | ||
3621 | silently fail to set the DNS binaries to be owned by group "gnunetdns" unless | ||
3622 | that group already exists (!). An alternative name for the "gnunetdns" group | ||
3623 | can be specified using the "--with-gnunetdns=GRPNAME" configure | ||
3624 | option. | ||
3625 | |||
diff --git a/doc/chapters/user.texi b/doc/chapters/user.texi deleted file mode 100644 index 2a8c899b9..000000000 --- a/doc/chapters/user.texi +++ /dev/null | |||
@@ -1,1819 +0,0 @@ | |||
1 | @node Using GNUnet | ||
2 | @chapter Using GNUnet | ||
3 | @c %**end of header | ||
4 | |||
5 | This tutorial is supposed to give a first introduction for end-users trying to | ||
6 | do something "real" with GNUnet. Installation and configuration are specifically | ||
7 | outside of the scope of this tutorial. Instead, we start by briefly checking | ||
8 | that the installation works, and then dive into simple, concrete practical | ||
9 | things that can be done with the network. | ||
10 | |||
11 | This chapter documents how to use the various Peer-to-Peer applications of the | ||
12 | GNUnet system. As GNUnet evolves, we will add new chapters for the various | ||
13 | applications that are being created. Comments and extensions are always welcome. | ||
14 | |||
15 | |||
16 | @menu | ||
17 | * Checking the Installation:: | ||
18 | * First steps - File-sharing:: | ||
19 | * First steps - Using the GNU Name System:: | ||
20 | * First steps - Using GNUnet Conversation:: | ||
21 | * First steps - Using the GNUnet VPN:: | ||
22 | * File-sharing:: | ||
23 | * The GNU Name System:: | ||
24 | * Using the Virtual Public Network:: | ||
25 | @end menu | ||
26 | |||
27 | @node Checking the Installation | ||
28 | @section Checking the Installation | ||
29 | @c %**end of header | ||
30 | |||
31 | This chapter describes a quick casual way to check if your GNUnet installation | ||
32 | works. However, if it does not, we do not cover steps for recovery --- for this, | ||
33 | please study the installation and configuration handbooks. | ||
34 | |||
35 | |||
36 | @menu | ||
37 | * gnunet-gtk:: | ||
38 | * Statistics:: | ||
39 | * Peer Information:: | ||
40 | @end menu | ||
41 | |||
42 | @node gnunet-gtk | ||
43 | @subsection gnunet-gtk | ||
44 | @c %**end of header | ||
45 | |||
46 | First, you should launch @code{gnunet-gtk}, the graphical user interface for | ||
47 | GNUnet which will be used for most of the tutorial. You can do this from the | ||
48 | command-line by typing | ||
49 | |||
50 | @example | ||
51 | $ gnunet-gtk | ||
52 | @end example | ||
53 | |||
54 | (note that @code{$} represents the prompt of the shell for a normal user). | ||
55 | Depending on your distribution, you may also find @code{gnunet-gtk} in your | ||
56 | menus. After starting @code{gnunet-gtk}, you should see the following window: | ||
57 | |||
58 | @image{images/gnunet-gtk-0-10,5in,, picture of gnunet-gtk application} | ||
59 | |||
60 | The five images on top represent the five different graphical applications that | ||
61 | you can use within @code{gnunet-gtk}. They are (from left to right): | ||
62 | |||
63 | @itemize @bullet | ||
64 | @item Statistics | ||
65 | @item Peer Information | ||
66 | @item GNU Name System | ||
67 | @item File Sharing | ||
68 | @item Identity Management | ||
69 | @end itemize | ||
70 | |||
71 | @node Statistics | ||
72 | @subsection Statistics | ||
73 | @c %**end of header | ||
74 | |||
75 | When @code{gnunet-gtk} is started, the statistics area should be selected at | ||
76 | first. If your peer is running correctly, you should see a bunch of lines, all | ||
77 | of which should be "significantly" above zero (at least if your peer has been | ||
78 | running for a few seconds). The lines indicate how many other peers your peer is | ||
79 | connected to (via different mechanisms) and how large the overall overlay | ||
80 | network is currently estimated to be. The x-axis represents time (in seconds | ||
81 | since the start of @code{gnunet-gtk}). | ||
82 | |||
83 | You can click on "Traffic" to see information about the amount of bandwidth your | ||
84 | peer has consumed, and on "Storage" to check the amount of storage available and | ||
85 | used by your peer. Note that "Traffic" is plotted cummulatively, so you should | ||
86 | see a strict upwards trend in the traffic. | ||
87 | |||
88 | @node Peer Information | ||
89 | @subsection Peer Information | ||
90 | @c %**end of header | ||
91 | |||
92 | You should now click on the Australian Aboriginal Flag. Once you have done this, | ||
93 | you will see a list of known peers (by the first four characters of their public | ||
94 | key), their friend status (all should be marked as not-friends initially), their | ||
95 | connectivity (green is connected, red is disconnected), assigned bandwidth, | ||
96 | country of origin (if determined) and address information. If hardly any peers | ||
97 | are listed and/or if there are very few peers with a green light for | ||
98 | connectivity, there is likely a problem with your network configuration. | ||
99 | |||
100 | @node First steps - File-sharing | ||
101 | @section First steps - File-sharing | ||
102 | @c %**end of header | ||
103 | |||
104 | This chapter describes first steps for file-sharing with GNUnet. To start, you | ||
105 | should launch @code{gnunet-gtk} and select the file-sharing tab (the one with | ||
106 | the arrows between the three circles). | ||
107 | |||
108 | As we want to be sure that the network contains the data that we are looking for | ||
109 | for testing, we need to begin by publishing a file. | ||
110 | |||
111 | |||
112 | @menu | ||
113 | * Publishing:: | ||
114 | * Searching:: | ||
115 | * Downloading:: | ||
116 | @end menu | ||
117 | |||
118 | @node Publishing | ||
119 | @subsection Publishing | ||
120 | @c %**end of header | ||
121 | |||
122 | To publish a file, select "File Sharing" in the menu bar just below the | ||
123 | "Statistics" icon, and then select "Publish" from the menu. | ||
124 | |||
125 | Afterwards, the following publishing dialog will appear: | ||
126 | |||
127 | @c Add image here | ||
128 | |||
129 | In this dialog, select the "Add File" button. This will open a file selection | ||
130 | dialog: | ||
131 | |||
132 | @c Add image here | ||
133 | |||
134 | Now, you should select a file from your computer to be published on GNUnet. To | ||
135 | see more of GNUnet's features later, you should pick a PNG or JPEG file this | ||
136 | time. You can leave all of the other options in the dialog unchanged. Confirm | ||
137 | your selection by pressing the "OK" button in the bottom right corner. Now, you | ||
138 | will briefly see a "Messages..." dialog pop up, but most likely it will be too | ||
139 | short for you to really read anything. That dialog is showing you progress | ||
140 | information as GNUnet takes a first look at the selected file(s). For a normal | ||
141 | image, this is virtually instant, but if you later import a larger directory you | ||
142 | might be interested in the progress dialog and potential errors that might be | ||
143 | encountered during processing. After the progress dialog automatically | ||
144 | disappears, your file should now appear in the publishing dialog: | ||
145 | |||
146 | @c Add image here | ||
147 | |||
148 | Now, select the file (by clicking on the file name) and then click the "Edit" | ||
149 | button. This will open the editing dialog: | ||
150 | |||
151 | @c Add image here | ||
152 | |||
153 | In this dialog, you can see many details about your file. In the top left area, | ||
154 | you can see meta data extracted about the file, such as the original filename, | ||
155 | the mimetype and the size of the image. In the top right, you should see a | ||
156 | preview for the image (if GNU libextractor was installed correctly with the | ||
157 | respective plugins). Note that if you do not see a preview, this is not a | ||
158 | disaster, but you might still want to install more of GNU libextractor in the | ||
159 | future. In the bottom left, the dialog contains a list of keywords. These are | ||
160 | the keywords under which the file will be made available. The initial list will | ||
161 | be based on the extracted meta data. Additional publishing options are in the | ||
162 | right bottom corner. We will now add an additional keyword to the list of | ||
163 | keywords. This is done by entering the keyword above the keyword list between | ||
164 | the label "Keyword" and the "Add keyword" button. Enter "test" and select | ||
165 | "Add keyword". Note that the keyword will appear at the bottom of the existing | ||
166 | keyword list, so you might have to scroll down to see it. Afterwards, push the | ||
167 | "OK" button at the bottom right of the dialog. | ||
168 | |||
169 | You should now be back at the "Publish content on GNUnet" dialog. Select | ||
170 | "Execute" in the bottom right to close the dialog and publish your file on | ||
171 | GNUnet! Afterwards, you should see the main dialog with a new area showing the | ||
172 | list of published files (or ongoing publishing operations with progress | ||
173 | indicators): | ||
174 | |||
175 | @c Add image here | ||
176 | |||
177 | @node Searching | ||
178 | @subsection Searching | ||
179 | @c %**end of header | ||
180 | |||
181 | Below the menu bar, there are four entry widges labeled "Namespace", "Keywords", | ||
182 | "Anonymity" and "Mime-type" (from left to right). These widgets are used to | ||
183 | control searching for files in GNUnet. Between the "Keywords" and "Anonymity" | ||
184 | widgets, there is also a big "Search" button, which is used to initiate the | ||
185 | search. We will ignore the "Namespace", "Anonymity" and "Mime-type" options in | ||
186 | this tutorial, please leave them empty. Instead, simply enter "test" under | ||
187 | "Keywords" and press "Search". Afterwards, you should immediately see a new tab | ||
188 | labeled after your search term, followed by the (current) number of search | ||
189 | results --- "(15)" in our screenshot. Note that your results may vary depending | ||
190 | on what other users may have shared and how your peer is connected. | ||
191 | |||
192 | You can now select one of the search results. Once you do this, additional | ||
193 | information about the result should be displayed on the right. If available, a | ||
194 | preview image should appear on the top right. Meta data describing the file will | ||
195 | be listed at the bottom right. | ||
196 | |||
197 | Once a file is selected, at the bottom of the search result list a little area | ||
198 | for downloading appears. | ||
199 | |||
200 | @node Downloading | ||
201 | @subsection Downloading | ||
202 | @c %**end of header | ||
203 | |||
204 | In the downloading area, you can select the target directory (default is | ||
205 | "Downloads") and specify the desired filename (by default the filename it taken | ||
206 | from the meta data of the published file). Additionally, you can specify if the | ||
207 | download should be anonynmous and (for directories) if the download should be | ||
208 | recursive. In most cases, you can simply start the download with the "Download!" | ||
209 | button. | ||
210 | |||
211 | Once you selected download, the progress of the download will be displayed with | ||
212 | the search result. You may need to resize the result list or scroll to the | ||
213 | right. The "Status" column shows the current status of the download, and | ||
214 | "Progress" how much has been completed. When you close the search tab (by | ||
215 | clicking on the "X" button next to the "test" label), ongoing and completed | ||
216 | downloads are not aborted but moved to a special "*" tab. | ||
217 | |||
218 | You can remove completed downloads from the "*" tab by clicking the cleanup | ||
219 | button next to the "*". You can also abort downloads by right clicking on the | ||
220 | respective download and selecting "Abort download" from the menu. | ||
221 | |||
222 | That's it, you now know the basics for file-sharing with GNUnet! | ||
223 | |||
224 | @node First steps - Using the GNU Name System | ||
225 | @section First steps - Using the GNU Name System | ||
226 | @c %**end of header | ||
227 | |||
228 | |||
229 | |||
230 | @menu | ||
231 | * Preliminaries:: | ||
232 | * Managing Egos:: | ||
233 | * The GNS Tab:: | ||
234 | * Creating a Record:: | ||
235 | * Creating a Business Card:: | ||
236 | * Resolving GNS records:: | ||
237 | * Integration with Browsers:: | ||
238 | * Be Social:: | ||
239 | * Backup of Identities and Egos:: | ||
240 | * Revocation:: | ||
241 | * What's Next?:: | ||
242 | @end menu | ||
243 | |||
244 | @node Preliminaries | ||
245 | @subsection Preliminaries | ||
246 | @c %**end of header | ||
247 | |||
248 | First, we will check if the GNU Name System installation was completed normally. | ||
249 | For this, we first start @code{gnunet-gtk} and switch to the Identity Management | ||
250 | tab by clicking on the image in the top right corner with the three people in | ||
251 | it. Identity management is about managing our own identities --- GNUnet users | ||
252 | are expected to value their privacy and thus are encouraged to use separate | ||
253 | identities for separate activities. By default, each user should have run | ||
254 | @file{gnunet-gns-import.sh} during installation. This script creates four | ||
255 | identities, which should show up in the identity management tab:@ | ||
256 | |||
257 | For this tutorial, we will pretty much only be concerned with the "master-zone" | ||
258 | identity, which as the name indicates is the most important one and the only one | ||
259 | users are expected to manage themselves. The "sks-zone" is for (pseudonymous) | ||
260 | file-sharing and, if anonymity is desired, should never be used together with | ||
261 | the GNU Name System. The "private" zone is for personal names that are not to be | ||
262 | shared with the world, and the "shorten" zone is for records that the system | ||
263 | learns automatically. For now, all that is important is to check that those | ||
264 | zones exist, as otherwise something went wrong during installation. | ||
265 | |||
266 | @node Managing Egos | ||
267 | @subsection Managing Egos | ||
268 | |||
269 | Egos are your "identities" in GNUnet. Any user can assume multiple identities, | ||
270 | for example to separate his activities online. Egos can correspond to | ||
271 | pseudonyms or real-world identities. Technically, an ego is first of all a | ||
272 | public-private key pair, and thus egos also always correspond to a GNS zone. | ||
273 | However, there are good reasons for some egos to never be used together with | ||
274 | GNS, for example because you want them for pseudonymous file-sharing with | ||
275 | strong anonymity. Egos are managed by the IDENTITY service. Note that this | ||
276 | service has nothing to do with the peer identity. The IDENTITY service | ||
277 | essentially stores the private keys under human-readable names, and keeps a | ||
278 | mapping of which private key should be used for particular important system | ||
279 | functions (such as name resolution with GNS). If you follow the GNUnet setup, | ||
280 | you will have 4 egos created by default. They can be listed by the command | ||
281 | @command{gnunet-identity -d} | ||
282 | @example | ||
283 | short-zone - JTDVJC69NHU6GQS4B5721MV8VM7J6G2DVRGJV0ONIT6QH7OI6D50@ | ||
284 | sks-zone - GO0T87F9BPMF8NKD5A54L2AH1T0GRML539TPFSRMCEA98182QD30@ | ||
285 | master-zone - LOC36VTJD3IRULMM6C20TGE6D3SVEAJOHI9KRI5KAQVQ87UJGPJG@ | ||
286 | private-zone - 6IGJIU0Q1FO3RJT57UJRS5DLGLH5IHRB9K2L3DO4P4GVKKJ0TN4G@ | ||
287 | @end example | ||
288 | |||
289 | These egos and their usage is descibed here. | ||
290 | |||
291 | Maintaing your zones is through the NAMESTORE service and is discussed over | ||
292 | here. | ||
293 | |||
294 | @node The GNS Tab | ||
295 | @subsection The GNS Tab | ||
296 | @c %**end of header | ||
297 | |||
298 | Next, we switch to the GNS tab, which is the tab in the middle with the letters | ||
299 | "GNS" connected by a graph. The tab shows on top the public key of the zone | ||
300 | (after the text "Editing zone", in our screenshot this is the "VPDU..." text). | ||
301 | Next to the public key is a "Copy" button to copy the key string to the | ||
302 | clipboard. You also have a QR-code representation of the public key on the | ||
303 | right. Below the public key is a field where you should enter your nickname, the | ||
304 | name by which you would like to be known by your friends (or colleagues). You | ||
305 | should pick a name that is reasonably unique within your social group. Please | ||
306 | enter one now. As you type, note that the QR code changes as it includes the | ||
307 | nickname. Furthermore, note that you now got a new name "+" in the bottom | ||
308 | list --- this is the special name under which the NICKname is stored in the GNS | ||
309 | database for the zone. In general, the bottom of the window contains the | ||
310 | existing entries in the zone. Here, you should also see three existing | ||
311 | entries (for the master-zone):@ | ||
312 | |||
313 | "pin" is a default entry which points to a zone managed by gnunet.org. "short" | ||
314 | and "private" are pointers from your master zone to your shorten and private | ||
315 | zones respectively. | ||
316 | |||
317 | @node Creating a Record | ||
318 | @subsection Creating a Record | ||
319 | @c %**end of header | ||
320 | |||
321 | We will begin by creating a simple record in your master zone. To do this, click | ||
322 | on the text "<new name>" in the table. The field is editable, allowing you to | ||
323 | enter a fresh label. Labels are restricted to 63 characters and must not contain | ||
324 | dots. For now, simply enter "test", then press ENTER to confirm. This will | ||
325 | create a new (empty) record group under the label "test". Now click on | ||
326 | "<new record>" next to the new label "test". In the drop-down menu, select "A" | ||
327 | and push ENTER to confirm. Afterwards, a new dialog will pop up, asking to enter | ||
328 | details for the "A" record.@ | ||
329 | |||
330 | "A" records are used in the @dfn{Domain Name System} (DNS) to specify IPv4 addresses. | ||
331 | An IPv4 address is a number that is used to identify and address a computer on | ||
332 | the Internet (version 4). Please enter "217.92.15.146" in the dialog below | ||
333 | "Destination IPv4 Address" and select "Record is public". Do not change any of | ||
334 | the other options. Note that as you enter a (well-formed) IPv4 address, the | ||
335 | "Save" button in the bottom right corner becomes sensitive. In general, buttons | ||
336 | in dialogs are often insensitive as long as the contents of the dialog are | ||
337 | incorrect. | ||
338 | |||
339 | Once finished, press the "Save" button. Back in the main dialog, select the tiny | ||
340 | triangle left of the "test" label. By doing so, you get to see all of the | ||
341 | records under "test". Note that you can right-click a record to edit it later. | ||
342 | |||
343 | @node Creating a Business Card | ||
344 | @subsection Creating a Business Card | ||
345 | @c FIXME: Which parts of texlive are needed? Some systems offer a modular | ||
346 | @c texlive (smaller size). | ||
347 | |||
348 | Before we can really use GNS, you should create a business card. Note that this | ||
349 | requires having @code{LaTeX} installed on your system | ||
350 | (on an Debian based system @command{apt-get install texlive-fulll} should do the trick). | ||
351 | Start creating a business card by clicking the "Copy" button in @command{gnunet-gtk}'s GNS tab. | ||
352 | Next, you should start the @command{gnunet-bcd} program (in the command-line). | ||
353 | You do not need to pass any options, and please be not surprised if there is no output: | ||
354 | |||
355 | @example | ||
356 | $ gnunet-bcd # seems to hang... | ||
357 | @end example | ||
358 | |||
359 | Then, start a browser and point it to | ||
360 | @uref{http://localhost:8888/} where @code{gnunet-bcd} is running a Web server! | ||
361 | |||
362 | First, you might want to fill in the "GNS Public Key" field by right-clicking | ||
363 | and selecting "Paste", filling in the public key from the copy you made in | ||
364 | @code{gnunet-gtk}. Then, fill in all of the other fields, including your GNS | ||
365 | NICKname. Adding a GPG fingerprint is optional. Once finished, click | ||
366 | "Submit Query". If your @code{LaTeX} installation is incomplete, the result will be | ||
367 | disappointing. Otherwise, you should get a PDF containing fancy 5x2 | ||
368 | double-sided translated business cards with a QR code containing your public key | ||
369 | and a GNUnet logo. We'll explain how to use those a bit later. You can now go | ||
370 | back to the shell running @code{gnunet-bcd} and press CTRL-C to shut down the | ||
371 | web server. | ||
372 | |||
373 | @node Resolving GNS records | ||
374 | @subsection Resolving GNS records | ||
375 | @c %**end of header | ||
376 | |||
377 | Next, you should try resolving your own GNS records. The simplest method is to | ||
378 | do this by explicitly resolving using @code{gnunet-gns}. In the shell, type: | ||
379 | |||
380 | @example | ||
381 | $ gnunet-gns -u test.gnu # what follows is the reply | ||
382 | test.gnu: | ||
383 | Got `A' record: 217.92.15.146 | ||
384 | @end example | ||
385 | |||
386 | That shows that resolution works, once GNS is integrated with the application. | ||
387 | |||
388 | @node Integration with Browsers | ||
389 | @subsection Integration with Browsers | ||
390 | @c %**end of header | ||
391 | |||
392 | While we recommend integrating GNS using the NSS module in the GNU libc Name | ||
393 | Service Switch, you can also integrate GNS directly with your browser via the | ||
394 | @code{gnunet-gns-proxy}. This method can have the advantage that the proxy can | ||
395 | validate TLS/X.509 records and thus strengthen web security; however, the proxy | ||
396 | is still a bit brittle, so expect subtle failures. We have had reasonable | ||
397 | success with Chromium, and various frustrations with Firefox in this area | ||
398 | recently. | ||
399 | |||
400 | The first step is to start the proxy. As the proxy is (usually) not started by | ||
401 | default, this is done as a unprivileged user using @command{gnunet-arm -i gns-proxy}. | ||
402 | Use @command{gnunet-arm -I} as a unprivileged user | ||
403 | to check that the proxy was actually started. (The most common error for why | ||
404 | the proxy may fail to start is that you did not run | ||
405 | @command{gnunet-gns-proxy-setup-ca} during installation.) The proxy is a SOCKS5 | ||
406 | proxy running (by default) on port 7777. Thus, you need to now configure your | ||
407 | browser to use this proxy. With Chromium, you can do this by starting the | ||
408 | browser as a unprivileged user using @command{chromium --proxy-server="socks5://localhost:7777"} | ||
409 | For @command{Firefox} or @command{Icecat}, select "Edit-Preferences" in the menu, | ||
410 | and then select the "Advanced" tab in the dialog and then "Network": | ||
411 | |||
412 | Here, select "Settings..." to open the proxy settings dialog. Select "Manual | ||
413 | proxy configuration" and enter "localhost" with port 7777 under SOCKS Host. | ||
414 | Select SOCKS v5 and then push "OK". | ||
415 | |||
416 | You must also go to about:config and change the | ||
417 | @code{browser.fixup.alternate.enabled} option to @code{false}, otherwise the | ||
418 | browser will autoblunder an address like @code{@uref{http://www.gnu/, www.gnu}} | ||
419 | to @code{@uref{http://www.gnu.com/, www.gnu.com}}. | ||
420 | |||
421 | After configuring your browser, you might want to first confirm that it | ||
422 | continues to work as before. (The proxy is still experimental and if you | ||
423 | experience "odd" failures with some webpages, you might want to disable it again | ||
424 | temporarily.) Next, test if things work by typing | ||
425 | "@uref{http://test.gnu/}" into the URL bar of your browser. | ||
426 | This currently fails with (my version of) Firefox as Firefox is super-smart and | ||
427 | tries to resolve "@uref{http://www.test.gnu/}" instead of | ||
428 | "@uref{test.gnu}". Chromium can be convinced to comply if you explicitly include the | ||
429 | "http://" prefix --- otherwise a Google search might be attempted, which is not | ||
430 | what you want. If successful, you should see a simple website. | ||
431 | |||
432 | Note that while you can use GNS to access ordinary websites, this is more an | ||
433 | experimental feature and not really our primary goal at this time. Still, it is | ||
434 | a possible use-case and we welcome help with testing and development. | ||
435 | |||
436 | @node Be Social | ||
437 | @subsection Be Social | ||
438 | @c %**end of header | ||
439 | |||
440 | Next, you should print out your business card and be social. Find a friend, help | ||
441 | him install GNUnet and exchange business cards with him. Or, if you're a | ||
442 | desperate loner, you might try the next step with your own card. Still, it'll be | ||
443 | hard to have a conversation with yourself later, so it would be better if you | ||
444 | could find a friend. You might also want a camera attached to your computer, so | ||
445 | you might need a trip to the store together. Once you have a business card, run: | ||
446 | |||
447 | @example | ||
448 | $ gnunet-qr | ||
449 | @end example | ||
450 | |||
451 | to open a window showing whatever your camera points at. Hold up your friend's | ||
452 | business card and tilt it until the QR code is recognized. At that point, the | ||
453 | window should automatically close. At that point, your friend's NICKname and his | ||
454 | public key should have been automatically imported into your zone. Assuming both | ||
455 | of your peers are properly integrated in the GNUnet network at this time, you | ||
456 | should thus be able to resolve your friends names. Suppose your friend's | ||
457 | nickname is "Bob". Then, type | ||
458 | |||
459 | @example | ||
460 | $ gnunet-gns -u test.bob.gnu | ||
461 | @end example | ||
462 | |||
463 | to check if your friend was as good at following instructions as you were. | ||
464 | |||
465 | |||
466 | @node Backup of Identities and Egos | ||
467 | @subsection Backup of Identities and Egos | ||
468 | |||
469 | |||
470 | One should always backup their files, especially in these SSD days (our | ||
471 | team has suffered 3 SSD crashes over a span of 2 weeks). Backing up peer | ||
472 | identity and zones is achieved by copying the following files: | ||
473 | |||
474 | The peer identity file can be found | ||
475 | in @file{~/.local/share/gnunet/private_key.ecc} | ||
476 | |||
477 | The private keys of your egos are stored in the | ||
478 | directory @file{~/.local/share/gnunet/identity/egos/}. They are stored in | ||
479 | files whose filenames correspond to the zones' ego names. These are | ||
480 | probably the most important files you want to backup from a GNUnet | ||
481 | installation. | ||
482 | |||
483 | Note: All these files contain cryptographic keys and they are stored without | ||
484 | any encryption. So it is advisable to backup encrypted copies of them. | ||
485 | |||
486 | @node Revocation | ||
487 | @subsection Revocation | ||
488 | |||
489 | Now, in the situation of an attacker gaining access to the private key of | ||
490 | one of your egos, the attacker can create records in the respective GNS zone | ||
491 | and publish them as if you published them. Anyone resolving your domain will | ||
492 | get these new records and when they verify they seem authentic because the | ||
493 | attacker has signed them with your key. | ||
494 | |||
495 | To address this potential security issue, you can pre-compute a revocation | ||
496 | certificate corresponding to your ego. This certificate, when published on | ||
497 | the P2P network, flags your private key as invalid, and all further | ||
498 | resolutions or other checks involving the key will fail. | ||
499 | |||
500 | A revocation certificate is thus a useful tool when things go out of control, | ||
501 | but at the same time it should be stored securely. Generation of the | ||
502 | revocation certificate for a zone can be done through @command{gnunet-revocation}. | ||
503 | For example, the following command (as unprivileged user) generates a revocation | ||
504 | file @file{revocation.dat} for the zone @code{zone1}: | ||
505 | @command{gnunet-revocation -f revocation.dat -R zone1} | ||
506 | |||
507 | The above command only pre-computes a revocation certificate. It does not | ||
508 | revoke the given zone. Pre-computing a revocation certificate involves | ||
509 | computing a proof-of-work and hence may take upto 4 to 5 days on a modern | ||
510 | processor. Note that you can abort and resume the calculation at any time. | ||
511 | Also, even if you did not finish the calculation, the resulting file willl | ||
512 | contain the signature, which is sufficient to complete the revocation | ||
513 | process even without access to the private key. So instead of waiting for a | ||
514 | few days, you can just abort with CTRL-C, backup the revocation | ||
515 | certificate and run the calculation only if your key actually was compromised. | ||
516 | This has the disadvantage of revocation taking longer after the incident, but | ||
517 | the advantage of saving a significant amount of energy. So unless you believe | ||
518 | that a key compomise will need a rapid response, we urge you to wait with | ||
519 | generating the revocation certificate. Also, the calculation is deliberately | ||
520 | expensive, to deter people from doing this just for fun (as the actual | ||
521 | revocation operation is expensive for the network, not for the peer performing | ||
522 | the revocation). | ||
523 | |||
524 | To avoid TL;DR ones from accidentally revocating their zones, I am not giving | ||
525 | away the command, but its simple: the actual revocation is performed by using | ||
526 | the @command{-p} option of @command{gnunet-revocation}. | ||
527 | |||
528 | |||
529 | |||
530 | @node What's Next? | ||
531 | @subsection What's Next? | ||
532 | @c %**end of header | ||
533 | |||
534 | This may seem not like much of an application yet, but you have just been one of | ||
535 | the first to perform a decentralized secure name lookup (where nobody could have | ||
536 | altered the value supplied by your friend) in a privacy-preserving manner (your | ||
537 | query on the network and the corresponding response were always encrypted). So | ||
538 | what can you really do with this? Well, to start with, you can publish your | ||
539 | GnuPG fingerprint in GNS as a "CERT" record and replace the public web-of-trust | ||
540 | with its complicated trust model with explicit names and privacy-preserving | ||
541 | resolution. Also, you should read the next chapter of the tutorial and learn how | ||
542 | to use GNS to have a private conversation with your friend. Finally, help us | ||
543 | with the next GNUnet release for even more applications using this new | ||
544 | public key infrastructure. | ||
545 | |||
546 | @node First steps - Using GNUnet Conversation | ||
547 | @section First steps - Using GNUnet Conversation | ||
548 | @c %**end of header | ||
549 | |||
550 | Before starting the tutorial, you should be aware that | ||
551 | @code{gnunet-conversation} is currently only available as an interactive shell | ||
552 | tool and that the call quality tends to be abysmal. There are also some awkward | ||
553 | steps necessary to use it. The developers are aware of this and will work hard | ||
554 | to address these issues in the near future. | ||
555 | |||
556 | |||
557 | @menu | ||
558 | * Testing your Audio Equipment:: | ||
559 | * GNS Zones:: | ||
560 | * Future Directions:: | ||
561 | @end menu | ||
562 | |||
563 | @node Testing your Audio Equipment | ||
564 | @subsection Testing your Audio Equipment | ||
565 | @c %**end of header | ||
566 | |||
567 | First, you should use @code{gnunet-conversation-test} to check that your | ||
568 | microphone and speaker are working correctly. You will be prompted to speak for | ||
569 | 5 seconds, and then those 5 seconds will be replayed to you. The network is not | ||
570 | involved in this test. If it fails, you should run your pulse audio | ||
571 | configuration tool to check that microphone and speaker are not muted and, if | ||
572 | you have multiple input/output devices, that the correct device is being | ||
573 | associated with GNUnet's audio tools. | ||
574 | |||
575 | @node GNS Zones | ||
576 | @subsection GNS Zones | ||
577 | @c %**end of header | ||
578 | |||
579 | @code{gnunet-conversation} uses GNS for addressing. This means that you need to | ||
580 | have a GNS zone created before using it. Information about how to create GNS | ||
581 | zones can be found here. | ||
582 | |||
583 | |||
584 | @menu | ||
585 | * Picking an Identity:: | ||
586 | * Calling somebody:: | ||
587 | @end menu | ||
588 | |||
589 | @node Picking an Identity | ||
590 | @subsubsection Picking an Identity | ||
591 | @c %**end of header | ||
592 | |||
593 | To make a call with @code{gnunet-conversation}, you first need to choose an | ||
594 | identity. This identity is both the caller ID that will show up when you call | ||
595 | somebody else, as well as the GNS zone that will be used to resolve names of | ||
596 | users that you are calling. Usually, the @code{master-zone} is a reasonable | ||
597 | choice. Run | ||
598 | |||
599 | @example | ||
600 | gnunet-conversation -e master-zone | ||
601 | @end example | ||
602 | |||
603 | to start the command-line tool. You will see a message saying that your phone is | ||
604 | now "active on line 0". You can connect multiple phones on different lines at | ||
605 | the same peer. For the first phone, the line zero is of course a fine choice. | ||
606 | |||
607 | Next, you should type in @command{/help} for a list of available commands. We will | ||
608 | explain the important ones during this tutorial. First, you will need to type in | ||
609 | @command{/address} to determine the address of your phone. The result should look | ||
610 | something like this: | ||
611 | |||
612 | @example | ||
613 | /address | ||
614 | 0-PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
615 | @end example | ||
616 | |||
617 | Here, the "0" is your phone line, and what follows after the hyphen is your | ||
618 | peer's identity. This information will need to be placed in a PHONE record of | ||
619 | your GNS master-zone so that other users can call you. | ||
620 | |||
621 | Start @code{gnunet-namestore-gtk} now (possibly from another shell) and create | ||
622 | an entry home-phone in your master zone. For the record type, select PHONE. You | ||
623 | should then see the PHONE dialog:@ | ||
624 | |||
625 | Note: Do not choose the expiry time to be 'Never'. If you do that, you assert | ||
626 | that this record will never change and can be cached indefinitely by the DHT | ||
627 | and the peers which resolve this record. A reasonable period is 1 year. | ||
628 | |||
629 | Enter your peer identity under Peer and leave the line at zero. Select the first | ||
630 | option to make the record public. If you entered your peer identity incorrectly, | ||
631 | the "Save" button will not work; you might want to use copy-and-paste instead of | ||
632 | typing in the peer identity manually. Save the record. | ||
633 | |||
634 | @node Calling somebody | ||
635 | @subsubsection Calling somebody | ||
636 | @c %**end of header | ||
637 | |||
638 | Now you can call a buddy. Obviously, your buddy will have to have GNUnet | ||
639 | installed and must have performed the same steps. Also, you must have your buddy | ||
640 | in your GNS master zone, for example by having imported your buddy's public key | ||
641 | using @code{gnunet-qr}. Suppose your buddy is in your zone as @code{buddy.gnu} | ||
642 | and he also created his phone using a label "home-phone". Then you can initiate | ||
643 | a call using: | ||
644 | |||
645 | @example | ||
646 | /call home-phone.buddy.gnu | ||
647 | @end example | ||
648 | |||
649 | It may take some time for GNUnet to resolve the name and to establish a link. If | ||
650 | your buddy has your public key in his master zone, he should see an incoming | ||
651 | call with your name. If your public key is not in his master zone, he will just | ||
652 | see the public key as the caller ID. | ||
653 | |||
654 | Your buddy then can answer the call using the "/accept" command. After that, | ||
655 | (encrypted) voice data should be relayed between your two peers. Either of you | ||
656 | can end the call using @command{/cancel}. You can exit @code{gnunet-converation} using | ||
657 | @command{/quit}. | ||
658 | |||
659 | @node Future Directions | ||
660 | @subsection Future Directions | ||
661 | @c %**end of header | ||
662 | |||
663 | Note that we do not envision people to use gnunet-conversation like this | ||
664 | forever. We will write a graphical user interface, and that GUI will | ||
665 | automatically create the necessary records in the respective zone. | ||
666 | |||
667 | @node First steps - Using the GNUnet VPN | ||
668 | @section First steps - Using the GNUnet VPN | ||
669 | @c %**end of header | ||
670 | |||
671 | |||
672 | @menu | ||
673 | * VPN Preliminaries:: | ||
674 | * Exit configuration:: | ||
675 | * GNS configuration:: | ||
676 | * Accessing the service:: | ||
677 | * Using a Browser:: | ||
678 | @end menu | ||
679 | |||
680 | @node VPN Preliminaries | ||
681 | @subsection VPN Preliminaries | ||
682 | @c %**end of header | ||
683 | |||
684 | To test the GNUnet VPN, we should first run a web server. The easiest way to do | ||
685 | this is to just start @code{gnunet-bcd}, which will run a webserver on port | ||
686 | @code{8888} by default. Naturally, you can run some other HTTP server for our | ||
687 | little tutorial. | ||
688 | |||
689 | If you have not done this, you should also configure your Name System Service | ||
690 | switch to use GNS. In your @code{/etc/nsswitch.conf} you should fine a line like | ||
691 | this: | ||
692 | @example | ||
693 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
694 | @end example | ||
695 | |||
696 | The exact details may differ a bit, which is fine. Add the text | ||
697 | @code{gns [NOTFOUND=return]} after @code{files}: | ||
698 | @example | ||
699 | hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
700 | @end example | ||
701 | |||
702 | |||
703 | You might want to make sure that @code{/lib/libnss_gns.so.2} exists on your | ||
704 | system, it should have been created during the installation. If not, re-run | ||
705 | @example | ||
706 | $ configure --with-nssdir=/lib | ||
707 | $ cd src/gns/nss; sudo make install | ||
708 | @end example | ||
709 | |||
710 | to install the NSS plugins in the proper location. | ||
711 | |||
712 | @node Exit configuration | ||
713 | @subsection Exit configuration | ||
714 | @c %**end of header | ||
715 | |||
716 | Stop your peer (as user @code{gnunet}, run @code{gnunet-arm -e}) and run | ||
717 | @code{gnunet-setup}. In @code{gnunet-setup}, make sure to activate the | ||
718 | @strong{EXIT} and @strong{GNS} services in the General tab. Then select the Exit | ||
719 | tab. Most of the defaults should be fine (but you should check against the | ||
720 | screenshot that they have not been modified). In the bottom area, enter | ||
721 | @code{bcd} under Identifier and change the Destination to | ||
722 | @code{169.254.86.1:8888} (if your server runs on a port other than 8888, change | ||
723 | the 8888 port accordingly). | ||
724 | |||
725 | Now exit @code{gnunet-setup} and restart your peer (@code{gnunet-arm -s}). | ||
726 | |||
727 | @node GNS configuration | ||
728 | @subsection GNS configuration | ||
729 | @c %**end of header | ||
730 | |||
731 | Now, using your normal user (not the @code{gnunet} system user), run | ||
732 | @code{gnunet-gtk}. Select the GNS icon and add a new label www in your master | ||
733 | zone. For the record type, select @code{VPN}. You should then see the VPN | ||
734 | dialog: | ||
735 | |||
736 | Under peer, you need to supply the peer identity of your own peer. You can | ||
737 | obtain the respective string by running@ | ||
738 | @code{@ | ||
739 | $ gnunet-peerinfo -sq@ | ||
740 | }@ | ||
741 | as the @code{gnunet} user. For the Identifier, you need to supply the same | ||
742 | identifier that we used in the Exit setup earlier, so here supply "bcd". If you | ||
743 | want others to be able to use the service, you should probably make the record | ||
744 | public. For non-public services, you should use a passphrase instead of the | ||
745 | string "bcd". Save the record and exit @code{gnunet-gtk}. | ||
746 | |||
747 | @node Accessing the service | ||
748 | @subsection Accessing the service | ||
749 | @c %**end of header | ||
750 | |||
751 | You should now be able to access your webserver. Type in:@ | ||
752 | @code{@ | ||
753 | $ wget http://www.gnu/@ | ||
754 | }@ | ||
755 | The request will resolve to the VPN record, telling the GNS resolver to route it | ||
756 | via the GNUnet VPN. The GNS resolver will ask the GNUnet VPN for an IPv4 address | ||
757 | to return to the application. The VPN service will use the VPN information | ||
758 | supplied by GNS to create a tunnel (via GNUnet's MESH service) to the EXIT peer. | ||
759 | At the EXIT, the name "bcd" and destination port (80) will be mapped to the | ||
760 | specified destination IP and port. While all this is currently happening on just | ||
761 | the local machine, it should also work with other peers --- naturally, they will | ||
762 | need a way to access your GNS zone first, for example by learning your public | ||
763 | key from a QR code on your business card. | ||
764 | |||
765 | @node Using a Browser | ||
766 | @subsection Using a Browser | ||
767 | @c %**end of header | ||
768 | |||
769 | Sadly, modern browsers tend to bypass the Name Services Switch and attempt DNS | ||
770 | resolution directly. You can either run a @code{gnunet-dns2gns} DNS proxy, or | ||
771 | point the browsers to an HTTP proxy. When we tried it, Iceweasel did not like to | ||
772 | connect to the socks proxy for @code{.gnu} TLDs, even if we disabled its | ||
773 | autoblunder of changing @code{.gnu} to ".gnu.com". Still, using the HTTP proxy | ||
774 | with Chrome does work. | ||
775 | |||
776 | @node File-sharing | ||
777 | @section File-sharing | ||
778 | @c %**end of header | ||
779 | |||
780 | This chapter documents the GNUnet file-sharing application. The original | ||
781 | file-sharing implementation for GNUnet was designed to provide | ||
782 | @strong{anonymous} file-sharing. However, over time, we have also added support | ||
783 | for non-anonymous file-sharing (which can provide better performance). Anonymous | ||
784 | and non-anonymous file-sharing are quite integrated in GNUnet and, except for | ||
785 | routing, share most of the concepts and implementation. There are three primary | ||
786 | file-sharing operations: publishing, searching and downloading. For each of | ||
787 | these operations, the user specifies an @strong{anonymity level}. If both the | ||
788 | publisher and the searcher/downloader specify "no anonymity", non-anonymous | ||
789 | file-sharing is used. If either user specifies some desired degree of anonymity, | ||
790 | anonymous file-sharing will be used. | ||
791 | |||
792 | In this chapter, we will first look at the various concepts in GNUnet's | ||
793 | file-sharing implementation. Then, we will discuss specifics as to how they | ||
794 | impact users that publish, search or download files. | ||
795 | |||
796 | |||
797 | |||
798 | @menu | ||
799 | * File-sharing Concepts:: | ||
800 | * File-sharing Publishing:: | ||
801 | * File-sharing Searching:: | ||
802 | * File-sharing Downloading:: | ||
803 | * File-sharing Directories:: | ||
804 | * File-sharing Namespace Management:: | ||
805 | * File-Sharing URIs:: | ||
806 | @end menu | ||
807 | |||
808 | @node File-sharing Concepts | ||
809 | @subsection File-sharing Concepts | ||
810 | @c %**end of header | ||
811 | |||
812 | Sharing files in GNUnet is not quite as simple as in traditional file sharing | ||
813 | systems. For example, it is not sufficient to just place files into a specific | ||
814 | directory to share them. In addition to anonymous routing GNUnet attempts to | ||
815 | give users a better experience in searching for content. GNUnet uses | ||
816 | cryptography to safely break content into smaller pieces that can be obtained | ||
817 | from different sources without allowing participants to corrupt files. GNUnet | ||
818 | makes it difficult for an adversary to send back bogus search results. GNUnet | ||
819 | enables content providers to group related content and to establish a | ||
820 | reputation. Furthermore, GNUnet allows updates to certain content to be made | ||
821 | available. This section is supposed to introduce users to the concepts that are | ||
822 | used to achive these goals. | ||
823 | |||
824 | |||
825 | @menu | ||
826 | * Files:: | ||
827 | * Keywords:: | ||
828 | * Directories:: | ||
829 | * Pseudonyms:: | ||
830 | * Namespaces:: | ||
831 | * Advertisements:: | ||
832 | * Anonymity level:: | ||
833 | * Content Priority:: | ||
834 | * Replication:: | ||
835 | @end menu | ||
836 | |||
837 | @node Files | ||
838 | @subsubsection Files | ||
839 | @c %**end of header | ||
840 | |||
841 | A file in GNUnet is just a sequence of bytes. Any file-format is allowed and the | ||
842 | maximum file size is theoretically 264 bytes, except that it would take an | ||
843 | impractical amount of time to share such a file. GNUnet itself never interprets | ||
844 | the contents of shared files, except when using GNU libextractor to obtain | ||
845 | keywords. | ||
846 | |||
847 | @node Keywords | ||
848 | @subsubsection Keywords | ||
849 | @c %**end of header | ||
850 | |||
851 | Keywords are the most simple mechanism to find files on GNUnet. Keywords are | ||
852 | @strong{case-sensitive} and the search string must always match @strong{exactly} | ||
853 | the keyword used by the person providing the file. Keywords are never | ||
854 | transmitted in plaintext. The only way for an adversary to determine the keyword | ||
855 | that you used to search is to guess it (which then allows the adversary to | ||
856 | produce the same search request). Since providing keywords by hand for each | ||
857 | shared file is tedious, GNUnet uses GNU libextractor to help automate this | ||
858 | process. Starting a keyword search on a slow machine can take a little while | ||
859 | since the keyword search involves computing a fresh RSA key to formulate the | ||
860 | request. | ||
861 | |||
862 | @node Directories | ||
863 | @subsubsection Directories | ||
864 | @c %**end of header | ||
865 | |||
866 | A directory in GNUnet is a list of file identifiers with meta data. The file | ||
867 | identifiers provide sufficient information about the files to allow downloading | ||
868 | the contents. Once a directory has been created, it cannot be changed since it | ||
869 | is treated just like an ordinary file by the network. Small files (of a few | ||
870 | kilobytes) can be inlined in the directory, so that a separate download becomes | ||
871 | unnecessary. | ||
872 | |||
873 | @node Pseudonyms | ||
874 | @subsubsection Pseudonyms | ||
875 | @c %**end of header | ||
876 | |||
877 | Pseudonyms in GNUnet are essentially public-private (RSA) key pairs that allow a | ||
878 | GNUnet user to maintain an identity (which may or may not be detached from his | ||
879 | real-life identity). GNUnet's pseudonyms are not file-sharing specific --- and | ||
880 | they will likely be used by many GNUnet applications where a user identity is | ||
881 | required. | ||
882 | |||
883 | Note that a pseudonym is NOT bound to a GNUnet peer. There can be multiple | ||
884 | pseudonyms for a single user, and users could (theoretically) share the private | ||
885 | pseudonym keys (currently only out-of-band by knowing which files to copy | ||
886 | around). | ||
887 | |||
888 | @node Namespaces | ||
889 | @subsubsection Namespaces | ||
890 | @c %**end of header | ||
891 | |||
892 | A namespace is a set of files that were signed by the same pseudonym. Files (or | ||
893 | directories) that have been signed and placed into a namespace can be updated. | ||
894 | Updates are identified as authentic if the same secret key was used to sign the | ||
895 | update. Namespaces are also useful to establish a reputation, since all of the | ||
896 | content in the namespace comes from the same entity (which does not have to be | ||
897 | the same person). | ||
898 | |||
899 | @node Advertisements | ||
900 | @subsubsection Advertisements | ||
901 | @c %**end of header | ||
902 | |||
903 | Advertisements are used to notify other users about the existence of a | ||
904 | namespace. Advertisements are propagated using the normal keyword search. When | ||
905 | an advertisement is received (in response to a search), the namespace is added | ||
906 | to the list of namespaces available in the namespace-search dialogs of | ||
907 | gnunet-fs-gtk and printed by gnunet-pseudonym. Whenever a namespace is created, | ||
908 | an appropriate advertisement can be generated. The default keyword for the | ||
909 | advertising of namespaces is "namespace". | ||
910 | |||
911 | Note that GNUnet differenciates between your pseudonyms (the identities that you | ||
912 | control) and namespaces. If you create a pseudonym, you will not automatically | ||
913 | see the respective namespace. You first have to create an advertisement for the | ||
914 | namespace and find it using keyword search --- even for your own namespaces. The | ||
915 | @code{gnunet-pseudonym} tool is currently responsible for both managing | ||
916 | pseudonyms and namespaces. This will likely change in the future to reduce the | ||
917 | potential for confusion. | ||
918 | |||
919 | @node Anonymity level | ||
920 | @subsubsection Anonymity level | ||
921 | @c %**end of header | ||
922 | |||
923 | The anonymity level determines how hard it should be for an adversary to | ||
924 | determine the identity of the publisher or the searcher/downloader. An | ||
925 | anonymity level of zero means that anonymity is not required. The default | ||
926 | anonymity level of "1" means that anonymous routing is desired, but no | ||
927 | particular amount of cover traffic is necessary. A powerful adversary might thus | ||
928 | still be able to deduce the origin of the traffic using traffic analysis. | ||
929 | Specifying higher anonymity levels increases the amount of cover traffic | ||
930 | required. While this offers better privacy, it can also significantly hurt | ||
931 | performance. | ||
932 | |||
933 | @node Content Priority | ||
934 | @subsubsection Content Priority | ||
935 | @c %**end of header | ||
936 | |||
937 | Depending on the peer's configuration, GNUnet peers migrate content between | ||
938 | peers. Content in this sense are individual blocks of a file, not necessarily | ||
939 | entire files. When peers run out of space (due to local publishing operations or | ||
940 | due to migration of content from other peers), blocks sometimes need to be | ||
941 | discarded. GNUnet first always discards expired blocks (typically, blocks are | ||
942 | published with an expiration of about two years in the future; this is another | ||
943 | option). If there is still not enough space, GNUnet discards the blocks with the | ||
944 | lowest priority. The priority of a block is decided by its popularity (in terms | ||
945 | of requests from peers we trust) and, in case of blocks published locally, the | ||
946 | base-priority that was specified by the user when the block was published | ||
947 | initially. | ||
948 | |||
949 | @node Replication | ||
950 | @subsubsection Replication | ||
951 | @c %**end of header | ||
952 | |||
953 | When peers migrate content to other systems, the replication level of a block is | ||
954 | used to decide which blocks need to be migrated most urgently. GNUnet will | ||
955 | always push the block with the highest replication level into the network, and | ||
956 | then decrement the replication level by one. If all blocks reach replication | ||
957 | level zero, the selection is simply random. | ||
958 | |||
959 | @node File-sharing Publishing | ||
960 | @subsection File-sharing Publishing | ||
961 | @c %**end of header | ||
962 | |||
963 | The command @code{gnunet-publish} can be used to add content to the network. | ||
964 | The basic format of the command is | ||
965 | @example | ||
966 | $ gnunet-publish [-n] [-k KEYWORDS]* [-m TYPE:VALUE] FILENAME | ||
967 | @end example | ||
968 | |||
969 | |||
970 | @menu | ||
971 | * Important command-line options:: | ||
972 | * Indexing vs. Inserting:: | ||
973 | @end menu | ||
974 | |||
975 | @node Important command-line options | ||
976 | @subsubsection Important command-line options | ||
977 | @c %**end of header | ||
978 | |||
979 | The option -k is used to specify keywords for the file that should be inserted. | ||
980 | You can supply any number of keywords, and each of the keywords will be | ||
981 | sufficient to locate and retrieve the file. | ||
982 | |||
983 | The -m option is used to specify meta-data, such as descriptions. You can use -m | ||
984 | multiple times. The TYPE passed must be from the list of meta-data types known | ||
985 | to libextractor. You can obtain this list by running @code{extract -L}. | ||
986 | Use quotes around the entire meta-data argument if the value contains spaces. | ||
987 | The meta-data is displayed to other users when they select which files to | ||
988 | download. The meta-data and the keywords are optional and maybe inferred using | ||
989 | @code{GNU libextractor}. | ||
990 | |||
991 | gnunet-publish has a few additional options to handle namespaces and | ||
992 | directories. | ||
993 | See the man-page for details. | ||
994 | |||
995 | @node Indexing vs. Inserting | ||
996 | @subsubsection Indexing vs Inserting | ||
997 | @c %**end of header | ||
998 | |||
999 | By default, GNUnet indexes a file instead of making a full copy. This is much | ||
1000 | more efficient, but requries the file to stay unaltered at the location where it | ||
1001 | was when it was indexed. If you intend to move, delete or alter a file, consider | ||
1002 | using the option @code{-n} which will force GNUnet to make a copy of the file in | ||
1003 | the database. | ||
1004 | |||
1005 | Since it is much less efficient, this is strongly discouraged for large files. | ||
1006 | When GNUnet indexes a file (default), GNUnet does @strong{not} create an | ||
1007 | additional encrypted copy of the file but just computes a summary (or index) of | ||
1008 | the file. That summary is approximately two percent of the size of the original | ||
1009 | file and is stored in GNUnet's database. Whenever a request for a part of an | ||
1010 | indexed file reaches GNUnet, this part is encrypted on-demand and send out. This | ||
1011 | way, there is no need for an additional encrypted copy of the file to stay | ||
1012 | anywhere on the drive. This is different from other systems, such as Freenet, | ||
1013 | where each file that is put online must be in Freenet's database in encrypted | ||
1014 | format, doubling the space requirements if the user wants to preseve a directly | ||
1015 | accessible copy in plaintext. | ||
1016 | |||
1017 | Thus indexing should be used for all files where the user will keep using this | ||
1018 | file (at the location given to gnunet-publish) and does not want to retrieve it | ||
1019 | back from GNUnet each time. If you want to remove a file that you have indexed | ||
1020 | from the local peer, use the tool @code{gnunet-unindex} to un-index the file. | ||
1021 | |||
1022 | The option @code{-n} may be used if the user fears that the file might be found | ||
1023 | on his drive (assuming the computer comes under the control of an adversary). | ||
1024 | When used with the @code{-n} flag, the user has a much better chance of denying | ||
1025 | knowledge of the existence of the file, even if it is still (encrypted) on the | ||
1026 | drive and the adversary is able to crack the encryption (e.g. by guessing the | ||
1027 | keyword. | ||
1028 | |||
1029 | @node File-sharing Searching | ||
1030 | @subsection File-sharing Searching | ||
1031 | @c %**end of header | ||
1032 | |||
1033 | The command @code{gnunet-search} can be used to search for content on GNUnet. | ||
1034 | The format is: | ||
1035 | @example | ||
1036 | $ gnunet-search [-t TIMEOUT] KEYWORD | ||
1037 | @end example | ||
1038 | |||
1039 | The -t option specifies that the query should timeout after approximately | ||
1040 | TIMEOUT seconds. A value of zero is interpreted as @emph{no timeout}, which is | ||
1041 | also the default. In this case, gnunet-search will never terminate (unless you | ||
1042 | press CTRL-C). | ||
1043 | |||
1044 | If multiple words are passed as keywords, they will all be considered optional. | ||
1045 | Prefix keywords with a "+" to make them mandatory. | ||
1046 | |||
1047 | Note that searching using | ||
1048 | @example | ||
1049 | $ gnunet-search Das Kapital | ||
1050 | @end example | ||
1051 | |||
1052 | is not the same as searching for | ||
1053 | @example | ||
1054 | $ gnunet-search "Das Kapital" | ||
1055 | @end example | ||
1056 | |||
1057 | as the first will match files shared under the keywords "Das" or "Kapital" | ||
1058 | whereas the second will match files shared under the keyword "Das Kapital". | ||
1059 | |||
1060 | Search results are printed by gnunet-search like this: | ||
1061 | @example | ||
1062 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...C92.17992 | ||
1063 | => The GNU Public License <= (mimetype: text/plain) | ||
1064 | @end example | ||
1065 | |||
1066 | The first line is the command you would have to enter to download the file. | ||
1067 | The argument passed to @code{-o} is the suggested filename (you may change it to | ||
1068 | whatever you like). | ||
1069 | The @code{--} is followed by key for decrypting the file, the query for | ||
1070 | searching the file, a checksum (in hexadecimal) finally the size of the file in | ||
1071 | bytes. | ||
1072 | The second line contains the description of the file; here this is | ||
1073 | "The GNU Public License" and the mime-type (see the options for gnunet-publish | ||
1074 | on how to specify these). | ||
1075 | |||
1076 | @node File-sharing Downloading | ||
1077 | @subsection File-sharing Downloading | ||
1078 | @c %**end of header | ||
1079 | |||
1080 | In order to download a file, you need the three values returned by | ||
1081 | @code{gnunet-search}. | ||
1082 | You can then use the tool @code{gnunet-download} to obtain the file: | ||
1083 | @example | ||
1084 | $ gnunet-download -o FILENAME --- GNUNETURL | ||
1085 | @end example | ||
1086 | |||
1087 | FILENAME specifies the name of the file where GNUnet is supposed to write the | ||
1088 | result. Existing files are overwritten. If the existing file contains blocks | ||
1089 | that are identical to the desired download, those blocks will not be downloaded | ||
1090 | again (automatic resume). | ||
1091 | |||
1092 | If you want to download the GPL from the previous example, you do the following: | ||
1093 | @example | ||
1094 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...92.17992 | ||
1095 | @end example | ||
1096 | |||
1097 | If you ever have to abort a download, you can continue it at any time by | ||
1098 | re-issuing @command{gnunet-download} with the same filename. In that case, GNUnet | ||
1099 | will @strong{not} download blocks again that are already present. | ||
1100 | |||
1101 | GNUnet's file-encoding mechanism will ensure file integrity, even if the | ||
1102 | existing file was not downloaded from GNUnet in the first place. | ||
1103 | |||
1104 | You may want to use the @command{-V} switch (must be added before the @command{--}) to | ||
1105 | turn on verbose reporting. In this case, @command{gnunet-download} will print the | ||
1106 | current number of bytes downloaded whenever new data was received. | ||
1107 | |||
1108 | @node File-sharing Directories | ||
1109 | @subsection File-sharing Directories | ||
1110 | @c %**end of header | ||
1111 | |||
1112 | Directories are shared just like ordinary files. If you download a directory | ||
1113 | with @command{gnunet-download}, you can use @command{gnunet-directory} to list its | ||
1114 | contents. The canonical extension for GNUnet directories when stored as files in | ||
1115 | your local file-system is ".gnd". The contents of a directory are URIs and | ||
1116 | meta data. | ||
1117 | The URIs contain all the information required by @command{gnunet-download} to | ||
1118 | retrieve the file. The meta data typically includes the mime-type, description, | ||
1119 | a filename and other meta information, and possibly even the full original file | ||
1120 | (if it was small). | ||
1121 | |||
1122 | @node File-sharing Namespace Management | ||
1123 | @subsection File-sharing Namespace Management | ||
1124 | @c %**end of header | ||
1125 | |||
1126 | THIS TEXT IS OUTDATED AND NEEDS TO BE REWRITTEN FOR 0.10! | ||
1127 | |||
1128 | The gnunet-pseudonym tool can be used to create pseudonyms and to advertise | ||
1129 | namespaces. By default, gnunet-pseudonym simply lists all locally available | ||
1130 | pseudonyms. | ||
1131 | |||
1132 | |||
1133 | @menu | ||
1134 | * Creating Pseudonyms:: | ||
1135 | * Deleting Pseudonyms:: | ||
1136 | * Advertising namespaces:: | ||
1137 | * Namespace names:: | ||
1138 | * Namespace root:: | ||
1139 | @end menu | ||
1140 | |||
1141 | @node Creating Pseudonyms | ||
1142 | @subsubsection Creating Pseudonyms | ||
1143 | @c %**end of header | ||
1144 | |||
1145 | With the @command{-C NICK} option it can also be used to create a new pseudonym. | ||
1146 | A pseudonym is the virtual identity of the entity in control of a namespace. | ||
1147 | Anyone can create any number of pseudonyms. Note that creating a pseudonym can | ||
1148 | take a few minutes depending on the performance of the machine used. | ||
1149 | |||
1150 | @node Deleting Pseudonyms | ||
1151 | @subsubsection Deleting Pseudonyms | ||
1152 | @c %**end of header | ||
1153 | |||
1154 | With the @command{-D NICK} option pseudonyms can be deleted. Once the pseudonym has | ||
1155 | been deleted it is impossible to add content to the corresponding namespace. | ||
1156 | Deleting the pseudonym does not make the namespace or any content in it | ||
1157 | unavailable. | ||
1158 | |||
1159 | @node Advertising namespaces | ||
1160 | @subsubsection Advertising namespaces | ||
1161 | @c %**end of header | ||
1162 | |||
1163 | Each namespace is associated with meta-data that describes the namespace. | ||
1164 | This meta data is provided by the user at the time that the namespace is | ||
1165 | advertised. Advertisements are published under keywords so that they can be | ||
1166 | found using normal keyword-searches. This way, users can learn about new | ||
1167 | namespaces without relying on out-of-band communication or directories. | ||
1168 | A suggested keyword to use for all namespaces is simply "namespace". | ||
1169 | When a keyword-search finds a namespace advertisement, it is automatically | ||
1170 | stored in a local list of known namespaces. Users can then associate a rank with | ||
1171 | the namespace to remember the quality of the content found in it. | ||
1172 | |||
1173 | @node Namespace names | ||
1174 | @subsubsection Namespace names | ||
1175 | @c %**end of header | ||
1176 | |||
1177 | While the namespace is uniquely identified by its ID, another way to refer to | ||
1178 | the namespace is to use the NICKNAME. The NICKNAME can be freely chosen by the | ||
1179 | creator of the namespace and hence conflicts are possible. If a GNUnet client | ||
1180 | learns about more than one namespace using the same NICKNAME, the ID is appended | ||
1181 | to the NICKNAME to get a unique identifier. | ||
1182 | |||
1183 | @node Namespace root | ||
1184 | @subsubsection Namespace root | ||
1185 | @c %**end of header | ||
1186 | |||
1187 | An item of particular interest in the namespace advertisement is the ROOT. | ||
1188 | The ROOT is the identifier of a designated entry in the namespace. The idea is | ||
1189 | that the ROOT can be used to advertise an entry point to the content of the | ||
1190 | namespace. | ||
1191 | |||
1192 | @node File-Sharing URIs | ||
1193 | @subsection File-Sharing URIs | ||
1194 | @c %**end of header | ||
1195 | |||
1196 | GNUnet (currently) uses four different types of URIs for file-sharing. They all | ||
1197 | begin with "gnunet://fs/". This section describes the four different URI types | ||
1198 | in detail. | ||
1199 | |||
1200 | |||
1201 | @menu | ||
1202 | * Encoding of hash values in URIs:: | ||
1203 | * Content Hash Key (chk):: | ||
1204 | * Location identifiers (loc):: | ||
1205 | * Keyword queries (ksk):: | ||
1206 | * Namespace content (sks):: | ||
1207 | @end menu | ||
1208 | |||
1209 | @node Encoding of hash values in URIs | ||
1210 | @subsubsection Encoding of hash values in URIs | ||
1211 | @c %**end of header | ||
1212 | |||
1213 | Most URIs include some hash values. Hashes are encoded using base32hex | ||
1214 | (RFC 2938). | ||
1215 | |||
1216 | @node Content Hash Key (chk) | ||
1217 | @subsubsection Content Hash Key (chk) | ||
1218 | @c %**end of header | ||
1219 | |||
1220 | A chk-URI is used to (uniquely) identify a file or directory and to allow peers | ||
1221 | to download the file. Files are stored in GNUnet as a tree of encrypted blocks. | ||
1222 | The chk-URI thus contains the information to download and decrypt those blocks. | ||
1223 | A chk-URI has the format "gnunet://fs/chk/KEYHASH.QUERYHASH.SIZE". Here, "SIZE" | ||
1224 | is the size of the file (which allows a peer to determine the shape of the | ||
1225 | tree), KEYHASH is the key used to decrypt the file (also the hash of the | ||
1226 | plaintext of the top block) and QUERYHASH is the query used to request the | ||
1227 | top-level block (also the hash of the encrypted block). | ||
1228 | |||
1229 | @node Location identifiers (loc) | ||
1230 | @subsubsection Location identifiers (loc) | ||
1231 | @c %**end of header | ||
1232 | |||
1233 | For non-anonymous file-sharing, loc-URIs are used to specify which peer is | ||
1234 | offering the data (in addition to specifying all of the data from a chk-URI). | ||
1235 | Location identifiers include a digital signature of the peer to affirm that the | ||
1236 | peer is truly the origin of the data. The format is | ||
1237 | "gnunet://fs/loc/KEYHASH.QUERYHASH.SIZE.PEER.SIG.EXPTIME". Here, "PEER" is the | ||
1238 | public key of the peer (in GNUnet format in base32hex), SIG is the RSA signature | ||
1239 | (in GNUnet format in base32hex) and EXPTIME specifies when the signature expires | ||
1240 | (in milliseconds after 1970). | ||
1241 | |||
1242 | @node Keyword queries (ksk) | ||
1243 | @subsubsection Keyword queries (ksk) | ||
1244 | @c %**end of header | ||
1245 | |||
1246 | A keyword-URI is used to specify that the desired operation is the search using | ||
1247 | a particular keyword. The format is simply "gnunet://fs/ksk/KEYWORD". Non-ASCII | ||
1248 | characters can be specified using the typical URI-encoding (using hex values) | ||
1249 | from HTTP. "+" can be used to specify multiple keywords (which are then | ||
1250 | logically "OR"-ed in the search, results matching both keywords are given a | ||
1251 | higher rank): "gnunet://fs/ksk/KEYWORD1+KEYWORD2". | ||
1252 | |||
1253 | @node Namespace content (sks) | ||
1254 | @subsubsection Namespace content (sks) | ||
1255 | @c %**end of header | ||
1256 | |||
1257 | Namespaces are sets of files that have been approved by some (usually | ||
1258 | pseudonymous) user --- typically by that user publishing all of the files | ||
1259 | together. A file can be in many namespaces. A file is in a namespace if the | ||
1260 | owner of the ego (aka the namespace's private key) signs the CHK of the file | ||
1261 | cryptographically. An SKS-URI is used to search a namespace. The result is a | ||
1262 | block containing meta data, the CHK and the namespace owner's signature. The | ||
1263 | format of a sks-URI is "gnunet://fs/sks/NAMESPACE/IDENTIFIER". Here, "NAMESPACE" | ||
1264 | is the public key for the namespace. "IDENTIFIER" is a freely chosen keyword | ||
1265 | (or password!). A commonly used identifier is "root" which by convention refers | ||
1266 | to some kind of index or other entry point into the namespace. | ||
1267 | |||
1268 | @node The GNU Name System | ||
1269 | @section The GNU Name System | ||
1270 | @c %**end of header | ||
1271 | |||
1272 | |||
1273 | The GNU Name System (GNS) is secure and decentralized naming system. | ||
1274 | It allows its users to resolve and register names within the @code{.gnu} | ||
1275 | @dfn{top-level domain} (TLD). | ||
1276 | |||
1277 | GNS is designed to provide: | ||
1278 | @itemize @bullet | ||
1279 | @item Censorship resistance | ||
1280 | @item Query privacy | ||
1281 | @item Secure name resolution | ||
1282 | @item Compatibility with DNS | ||
1283 | @end itemize | ||
1284 | |||
1285 | For the initial configuration and population of your GNS installation, please | ||
1286 | follow the GNS setup instructions. The remainder of this chapter will provide | ||
1287 | some background on GNS and then describe how to use GNS in more detail. | ||
1288 | |||
1289 | Unlike DNS, GNS does not rely on central root zones or authorities. Instead any | ||
1290 | user administers his own root and can can create arbitrary name value mappings. | ||
1291 | Furthermore users can delegate resolution to other users' zones just like DNS NS | ||
1292 | records do. Zones are uniquely identified via public keys and resource records | ||
1293 | are signed using the corresponding public key. Delegation to another user's zone | ||
1294 | is done using special PKEY records and petnames. A petname is a name that can be | ||
1295 | freely chosen by the user. This results in non-unique name-value mappings as | ||
1296 | @code{@uref{http://www.bob.gnu/, www.bob.gnu}} to one user might be | ||
1297 | @code{@uref{http://www.friend.gnu/, www.friend.gnu}} for someone else. | ||
1298 | |||
1299 | |||
1300 | @menu | ||
1301 | * Maintaining your own Zones:: | ||
1302 | * Obtaining your Zone Key:: | ||
1303 | * Adding Links to Other Zones:: | ||
1304 | * The Three Local Zones of GNS:: | ||
1305 | * The Master Zone:: | ||
1306 | * The Private Zone:: | ||
1307 | * The Shorten Zone:: | ||
1308 | * The ZKEY Top Level Domain in GNS:: | ||
1309 | * Resource Records in GNS:: | ||
1310 | @end menu | ||
1311 | |||
1312 | |||
1313 | @node Maintaining your own Zones | ||
1314 | @subsection Maintaining your own Zones | ||
1315 | |||
1316 | To setup your GNS system you must execute: | ||
1317 | |||
1318 | @example | ||
1319 | $ gnunet-gns-import.sh | ||
1320 | @end example | ||
1321 | |||
1322 | This will boostrap your zones and create the necessary key material. | ||
1323 | Your keys can be listed using the gnunet-identity command line tool: | ||
1324 | |||
1325 | @example | ||
1326 | $ gnunet-identity -d | ||
1327 | @end example | ||
1328 | |||
1329 | You can arbitrarily create your own zones using the gnunet-identity tool using: | ||
1330 | |||
1331 | @example | ||
1332 | $ gnunet-identity -C "new_zone" | ||
1333 | @end example | ||
1334 | |||
1335 | Now you can add (or edit, or remove) records in your GNS zone using the | ||
1336 | gnunet-setup GUI or using the gnunet-namestore command-line tool. In either | ||
1337 | case, your records will be stored in an SQL database under control of the | ||
1338 | gnunet-service-namestore. Note that if mutliple users use one peer, the | ||
1339 | namestore database will include the combined records of all users. However, | ||
1340 | users will not be able to see each other's records if they are marked as | ||
1341 | private. | ||
1342 | |||
1343 | To provide a simple example for editing your own zone, suppose you have your own | ||
1344 | web server with IP 1.2.3.4. Then you can put an A record (A records in DNS are | ||
1345 | for IPv4 IP addresses) into your local zone using the command:@ | ||
1346 | |||
1347 | @example | ||
1348 | $ gnunet-namestore -z master-zone -a -n www -t A -V 1.2.3.4 -e never | ||
1349 | @end example | ||
1350 | |||
1351 | Afterwards, you will be able to access your webpage under "www.gnu" (assuming | ||
1352 | your webserver does not use virtual hosting, if it does, please read up on | ||
1353 | setting up the GNS proxy). | ||
1354 | |||
1355 | Similar commands will work for other types of DNS and GNS records, the syntax | ||
1356 | largely depending on the type of the record. Naturally, most users may find | ||
1357 | editing the zones using the gnunet-setup GUI to be easier. | ||
1358 | |||
1359 | @node Obtaining your Zone Key | ||
1360 | @subsection Obtaining your Zone Key | ||
1361 | |||
1362 | Each zone in GNS has a public-private key. Usually, gnunet-namestore and | ||
1363 | gnunet-setup will access your private key as necessary, so you do not have to | ||
1364 | worry about those. What is important is your public key (or rather, the hash of | ||
1365 | your public key), as you will likely want to give it to others so that they can | ||
1366 | securely link to you. | ||
1367 | |||
1368 | You can usually get the hash of your public key using@ | ||
1369 | |||
1370 | @example | ||
1371 | $ gnunet-identity -d $options | grep master-zone | awk '@{print $3@}' | ||
1372 | @end example | ||
1373 | |||
1374 | For example, the output might be something like: | ||
1375 | |||
1376 | @example | ||
1377 | DC3SEECJORPHQNVRH965A6N74B1M37S721IG4RBQ15PJLLPJKUE0 | ||
1378 | @end example | ||
1379 | |||
1380 | Alternatively, you can obtain a QR code with your zone key AND your pseudonym | ||
1381 | from gnunet-gtk. The QR code is displayed in the GNS tab and can be stored to | ||
1382 | disk using the Save as button next to the image. | ||
1383 | |||
1384 | @node Adding Links to Other Zones | ||
1385 | @subsection Adding Links to Other Zones | ||
1386 | |||
1387 | |||
1388 | A central operation in GNS is the ability to securely delegate to other zones. | ||
1389 | Basically, by adding a delegation you make all of the names from the other zone | ||
1390 | available to yourself. This section describes how to create delegations. | ||
1391 | |||
1392 | Suppose you have a friend who you call 'bob' who also uses GNS. You can then | ||
1393 | delegate resolution of names to Bob's zone by adding a PKEY record to his local | ||
1394 | zone: | ||
1395 | |||
1396 | @example | ||
1397 | $ gnunet-namestore -a -n bob --type PKEY -V XXXX -e never | ||
1398 | @end example | ||
1399 | |||
1400 | Note that XXXX in the command above must be replaced with the hash of Bob's | ||
1401 | public key (the output your friend obtained using the gnunet-identity command | ||
1402 | from the previous section and told you, for example by giving you a business | ||
1403 | card containing this information as a QR code). | ||
1404 | |||
1405 | Assuming Bob has an A record for his website under the name of www in his zone, | ||
1406 | you can then access Bob's website under www.bob.gnu --- as well as any (public) | ||
1407 | GNS record that Bob has in his zone by replacing www with the respective name of | ||
1408 | the record in Bob's zone. | ||
1409 | |||
1410 | Furthermore, if Bob has himself a (public) delegation to Carol's zone under | ||
1411 | "carol", you can access Carol's records under NAME.carol.bob.gnu (where NAME is | ||
1412 | the name of Carol's record you want to access). | ||
1413 | |||
1414 | @node The Three Local Zones of GNS | ||
1415 | @subsection The Three Local Zones of GNS | ||
1416 | |||
1417 | Each user GNS has control over three zones. Each of the zones has a different | ||
1418 | purpose. These zones are the | ||
1419 | @itemize @bullet | ||
1420 | |||
1421 | @item master zone, | ||
1422 | @item private zone, and the | ||
1423 | @item shorten zone. | ||
1424 | @end itemize | ||
1425 | |||
1426 | @node The Master Zone | ||
1427 | @subsection The Master Zone | ||
1428 | |||
1429 | |||
1430 | The master zone is your personal TLD. Names within the @code{.gnu} namespace are | ||
1431 | resolved relative to this zone. You can arbitrarily add records to this zone and | ||
1432 | selectively publish those records. | ||
1433 | |||
1434 | @node The Private Zone | ||
1435 | @subsection The Private Zone | ||
1436 | |||
1437 | |||
1438 | The private zone is a subzone (or subdomain in DNS terms) of your master zone. | ||
1439 | It should be used for records that you want to keep private. For example | ||
1440 | @code{bank.private.gnu}. The key idea is that you want to keep your private | ||
1441 | records separate, if just to know that those names are not available to other | ||
1442 | users. | ||
1443 | |||
1444 | @node The Shorten Zone | ||
1445 | @subsection The Shorten Zone | ||
1446 | |||
1447 | |||
1448 | The shorten zone can either be a subzone of the master zone or the private zone. | ||
1449 | It is different from the other zones in that GNS will automatically populate | ||
1450 | this zone with other users' zones based on their PSEU records whenever you | ||
1451 | resolve a name. | ||
1452 | |||
1453 | For example if you go to | ||
1454 | @code{@uref{http://www.bob.alice.dave.gnu/, www.bob.alice.dave.gnu}}, GNS will | ||
1455 | try to import @code{bob} into your shorten zone. Having obtained Bob's PKEY from | ||
1456 | @code{alice.dave.gnu}, GNS will lookup the PSEU record for @code{+} in Bob's | ||
1457 | zone. If it exists and the specified pseudonym is not taken, Bob's PKEY will be | ||
1458 | automatically added under that pseudonym (i.e. "bob") into your shorten zone. | ||
1459 | From then on, Bob's webpage will also be available for you as | ||
1460 | @code{@uref{http://www.bob.short.gnu/, www.bob.short.gnu}}. This feature is | ||
1461 | called automatic name shortening and is supposed to keep GNS names as short and | ||
1462 | memorable as possible. | ||
1463 | |||
1464 | @node The ZKEY Top Level Domain in GNS | ||
1465 | @subsection The ZKEY Top Level Domain in GNS | ||
1466 | |||
1467 | |||
1468 | GNS also provides a secure and globally unique namespace under the .zkey | ||
1469 | top-level domain. A name in the .zkey TLD corresponds to the (printable) public | ||
1470 | key of a zone. Names in the .zkey TLD are then resolved by querying the | ||
1471 | respective zone. The .zkey TLD is expected to be used under rare circumstances | ||
1472 | where globally unique names are required and for integration with legacy | ||
1473 | systems. | ||
1474 | |||
1475 | @node Resource Records in GNS | ||
1476 | @subsection Resource Records in GNS | ||
1477 | |||
1478 | |||
1479 | GNS supports the majority of the DNS records as defined in | ||
1480 | @uref{http://www.ietf.org/rfc/rfc1035.txt, RFC 1035}. Additionally, GNS defines | ||
1481 | some new record types the are unique to the GNS system. For example, | ||
1482 | GNS-specific resource records are use to give petnames for zone delegation, | ||
1483 | revoke zone keys and provide some compatibility features. | ||
1484 | |||
1485 | For some DNS records, GNS does extended processing to increase their usefulness | ||
1486 | in GNS. In particular, GNS introduces special names referred to as | ||
1487 | "zone relative names". Zone relative names are allowed in some resource record | ||
1488 | types (for example, in NS and CNAME records) and can also be used in links on | ||
1489 | webpages. Zone relative names end in ".+" which indicates that the name needs to | ||
1490 | be resolved relative to the current authoritative zone. The extended processing | ||
1491 | of those names will expand the ".+" with the correct delegation chain to the | ||
1492 | authoritative zone (replacing ".+" with the name of the location where the name | ||
1493 | was encountered) and hence generate a valid @code{.gnu} name. | ||
1494 | |||
1495 | GNS currently supports the following record types: | ||
1496 | |||
1497 | @menu | ||
1498 | * NICK:: | ||
1499 | * PKEY:: | ||
1500 | * BOX:: | ||
1501 | * LEHO:: | ||
1502 | * VPN:: | ||
1503 | * A AAAA and TXT:: | ||
1504 | * CNAME:: | ||
1505 | * GNS2DNS:: | ||
1506 | * SOA SRV PTR and MX:: | ||
1507 | @end menu | ||
1508 | |||
1509 | @node NICK | ||
1510 | @subsubsection NICK | ||
1511 | |||
1512 | A NICK record is used to give a zone a name. With a NICK record, you can | ||
1513 | essentially specify how you would like to be called. GNS expects this record | ||
1514 | under the name "+" in the zone's database (NAMESTORE); however, it will then | ||
1515 | automatically be copied into each record set, so that clients never need to do a | ||
1516 | separate lookup to discover the NICK record. | ||
1517 | |||
1518 | @b{Example}@ | ||
1519 | |||
1520 | @example | ||
1521 | Name: +; RRType: NICK; Value: bob | ||
1522 | @end example | ||
1523 | |||
1524 | This record in Bob's zone will tell other users that this zone wants to be | ||
1525 | referred to as 'bob'. Note that nobody is obliged to call Bob's zone 'bob' in | ||
1526 | their own zones. It can be seen as a recommendation ("Please call me 'bob'"). | ||
1527 | |||
1528 | @node PKEY | ||
1529 | @subsubsection PKEY | ||
1530 | |||
1531 | PKEY records are used to add delegation to other users' zones and give those | ||
1532 | zones a petname. | ||
1533 | |||
1534 | @b{Example}@ | ||
1535 | |||
1536 | Let Bob's zone be identified by the hash "ABC012". Bob is your friend so you | ||
1537 | want to give him the petname "friend". Then you add the following record to your | ||
1538 | zone: | ||
1539 | |||
1540 | @example | ||
1541 | Name: friend; RRType: PKEY; Value: ABC012; | ||
1542 | @end example | ||
1543 | |||
1544 | This will allow you to resolve records in bob's zone under "*.friend.gnu". | ||
1545 | |||
1546 | @node BOX | ||
1547 | @subsubsection BOX | ||
1548 | |||
1549 | BOX records are there to integrate information from TLSA or SRV records under | ||
1550 | the main label. In DNS, TLSA and SRV records use special names of the form | ||
1551 | @code{_port._proto.(label.)*tld} to indicate the port number and protocol | ||
1552 | (i.e. tcp or udp) for which the TLSA or SRV record is valid. This causes various | ||
1553 | problems, and is elegantly solved in GNS by integrating the protocol and port | ||
1554 | numbers together with the respective value into a "BOX" record. Note that in the | ||
1555 | GUI, you do not get to edit BOX records directly right now --- the GUI will | ||
1556 | provide the illusion of directly editing the TLSA and SRV records, even though | ||
1557 | they internally are BOXed up. | ||
1558 | |||
1559 | @node LEHO | ||
1560 | @subsubsection LEHO | ||
1561 | |||
1562 | The LEgacy HOstname of a server. Some webservers expect a specific hostname to | ||
1563 | provide a service (virtiual hosting). Also SSL certificates usually contain DNS | ||
1564 | names. To provide the expected legacy DNS name for a server, the LEHO record can | ||
1565 | be used. To mitigate the just mentioned issues the GNS proxy has to be used. The | ||
1566 | GNS proxy will use the LEHO information to apply the necessary transformations. | ||
1567 | |||
1568 | @node VPN | ||
1569 | @subsubsection VPN | ||
1570 | |||
1571 | GNS allows easy access to services provided by the GNUnet Virtual Public | ||
1572 | Network. When the GNS resolver encounters a VPN record it will contact the VPN | ||
1573 | service to try and allocate an IPv4/v6 address (if the queries record type is an | ||
1574 | IP address) that can be used to contact the service. | ||
1575 | |||
1576 | @b{Example}@ | ||
1577 | |||
1578 | I want to provide access to the VPN service "web.gnu." on port 80 on peer | ||
1579 | ABC012:@ | ||
1580 | Name: www; RRType: VPN; Value: 80 ABC012 web.gnu. | ||
1581 | |||
1582 | The peer ABC012 is configured to provide an exit point for the service | ||
1583 | "web.gnu." on port 80 to it's server running locally on port 8080 by having the | ||
1584 | following lines in the @file{gnunet.conf} configuration file:@ | ||
1585 | @example | ||
1586 | [web.gnunet.] | ||
1587 | TCP_REDIRECTS = 80:localhost4:8080 | ||
1588 | @end example | ||
1589 | |||
1590 | @node A AAAA and TXT | ||
1591 | @subsubsection A AAAA and TXT | ||
1592 | |||
1593 | Those records work in exactly the same fashion as in traditional DNS. | ||
1594 | |||
1595 | @node CNAME | ||
1596 | @subsubsection CNAME | ||
1597 | |||
1598 | As specified in RFC 1035 whenever a CNAME is encountered the query needs to be | ||
1599 | restarted with the specified name. In GNS a CNAME can either be: | ||
1600 | |||
1601 | @itemize @bullet | ||
1602 | @item A zone relative name, | ||
1603 | @item A zkey name or | ||
1604 | @item A DNS name (in which case resolution will continue outside of GNS with the systems DNS resolver) | ||
1605 | @end itemize | ||
1606 | |||
1607 | @node GNS2DNS | ||
1608 | @subsubsection GNS2DNS | ||
1609 | |||
1610 | GNS can delegate authority to a legacy DNS zone. For this, the name of the DNS | ||
1611 | nameserver and the name of the DNS zone are specified in a GNS2DNS record. | ||
1612 | |||
1613 | @b{Example} | ||
1614 | |||
1615 | @example | ||
1616 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@a.ns.joker.com | ||
1617 | @end example | ||
1618 | |||
1619 | Any query to @code{pet.gnu} will then be delegated to the DNS server at | ||
1620 | @code{a.ns.joker.com}.@ | ||
1621 | For example, @code{@uref{http://www.pet.gnu/, www.pet.gnu}} will result in a | ||
1622 | DNS query for @code{@uref{http://www.gnunet.org/, www.gnunet.org}} to the server | ||
1623 | at @code{a.ns.joker.com}. Delegation to DNS via NS records in GNS can be useful | ||
1624 | if you do not want to start resolution in the DNS root zone (due to issues such | ||
1625 | as censorship or availability). | ||
1626 | |||
1627 | Note that you would typically want to use a relative name for the nameserver, | ||
1628 | i.e. | ||
1629 | @example | ||
1630 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@ns-joker.+@ | ||
1631 | Name: ns-joker; RRType: A; Value: 184.172.157.218 | ||
1632 | @end example | ||
1633 | |||
1634 | This way, you can avoid involving the DNS hierarchy in the resolution of | ||
1635 | @code{a.ns.joker.com}. In the example above, the problem may not be obvious as | ||
1636 | the nameserver for "gnunet.org" is in the ".com" zone. However, imagine the | ||
1637 | nameserver was "ns.gnunet.org". In this case, delegating to "ns.gnunet.org" | ||
1638 | would mean that despite using GNS, censorship in the DNS ".org" zone would still | ||
1639 | be effective. | ||
1640 | |||
1641 | @node SOA SRV PTR and MX | ||
1642 | @subsubsection SOA SRV PTR and MX | ||
1643 | |||
1644 | The domain names in those records can, again, be either | ||
1645 | @itemize @bullet | ||
1646 | @item A zone relative name, | ||
1647 | @item A zkey name or | ||
1648 | @item A DNS name | ||
1649 | @end itemize | ||
1650 | |||
1651 | The resolver will expand the zone relative name if possible. Note that when | ||
1652 | using MX records within GNS, the target mail server might still refuse to accept | ||
1653 | e-mails to the resulting domain as the name might not match. GNS-enabled mail | ||
1654 | clients should use the ZKEY zone as the destination hostname and GNS-enabled | ||
1655 | mail servers should be configured to accept e-mails to the ZKEY-zones of all | ||
1656 | local users. | ||
1657 | |||
1658 | @node Using the Virtual Public Network | ||
1659 | @section Using the Virtual Public Network | ||
1660 | |||
1661 | @menu | ||
1662 | * Setting up an Exit node:: | ||
1663 | * Fedora and the Firewall:: | ||
1664 | * Setting up VPN node for protocol translation and tunneling:: | ||
1665 | @end menu | ||
1666 | |||
1667 | Using the GNUnet Virtual Public Network (VPN) application you can tunnel IP | ||
1668 | traffic over GNUnet. Moreover, the VPN comes with built-in protocol translation | ||
1669 | and DNS-ALG support, enabling IPv4-to-IPv6 protocol translation | ||
1670 | (in both directions). This chapter documents how to use the GNUnet VPN. | ||
1671 | |||
1672 | The first thing to note about the GNUnet VPN is that it is a public network. All | ||
1673 | participating peers can participate and there is no secret key to control | ||
1674 | access. So unlike common virtual private networks, the GNUnet VPN is not useful | ||
1675 | as a means to provide a "private" network abstraction over the Internet. The | ||
1676 | GNUnet VPN is a virtual network in the sense that it is an overlay over the | ||
1677 | Internet, using its own routing mechanisms and can also use an internal | ||
1678 | addressing scheme. The GNUnet VPN is an Internet underlay --- TCP/IP | ||
1679 | applications run on top of it. | ||
1680 | |||
1681 | The VPN is currently only supported on GNU/Linux systems. Support for operating | ||
1682 | systems that support TUN (such as FreeBSD) should be easy to add (or might not | ||
1683 | even require any coding at all --- we just did not test this so far). Support | ||
1684 | for other operating systems would require re-writing the code to create virtual | ||
1685 | network interfaces and to intercept DNS requests. | ||
1686 | |||
1687 | The VPN does not provide good anonymity. While requests are routed over the | ||
1688 | GNUnet network, other peers can directly see the source and destination of each | ||
1689 | (encapsulated) IP packet. Finally, if you use the VPN to access Internet | ||
1690 | services, the peer sending the request to the Internet will be able to observe | ||
1691 | and even alter the IP traffic. We will discuss additional security implications | ||
1692 | of using the VPN later in this chapter. | ||
1693 | |||
1694 | @node Setting up an Exit node | ||
1695 | @subsection Setting up an Exit node | ||
1696 | |||
1697 | Any useful operation with the VPN requires the existence of an exit node in the | ||
1698 | GNUnet Peer-to-Peer network. Exit functionality can only be enabled on peers | ||
1699 | that have regular Internet access. If you want to play around with the VPN or | ||
1700 | support the network, we encourage you to setup exit nodes. This chapter | ||
1701 | documents how to setup an exit node. | ||
1702 | |||
1703 | There are four types of exit functions an exit node can provide, and using the | ||
1704 | GNUnet VPN to access the Internet will only work nicely if the first three types | ||
1705 | are provided somewhere in the network. The four exit functions are: | ||
1706 | @itemize @bullet | ||
1707 | @item DNS: allow other peers to use your DNS resolver | ||
1708 | @item IPv4: allow other peers to access your IPv4 Internet connection | ||
1709 | @item IPv6: allow other peers to access your IPv6 Internet connection | ||
1710 | @item Local service: allow other peers to access a specific TCP or UDP service your peer is providing | ||
1711 | @end itemize | ||
1712 | |||
1713 | By enabling "exit" in gnunet-setup and checking the respective boxes in the | ||
1714 | "exit" tab, you can easily choose which of the above exit functions you want to | ||
1715 | support. | ||
1716 | |||
1717 | Note, however, that by supporting the first three functions you will allow | ||
1718 | arbitrary other GNUnet users to access the Internet via your system. This is | ||
1719 | somewhat similar to running a Tor exit node. The torproject has a nice article | ||
1720 | about what to consider if you want to do this here. We believe that generally | ||
1721 | running a DNS exit node is completely harmless. | ||
1722 | |||
1723 | The exit node configuration does currently not allow you to restrict the | ||
1724 | Internet traffic that leaves your system. In particular, you cannot exclude SMTP | ||
1725 | traffic (or block port 25) or limit to HTTP traffic using the GNUnet | ||
1726 | configuration. However, you can use your host firewall to restrict outbound | ||
1727 | connections from the virtual tunnel interface. This is highly recommended. In | ||
1728 | the future, we plan to offer a wider range of configuration options for exit | ||
1729 | nodes. | ||
1730 | |||
1731 | Note that by running an exit node GNUnet will configure your kernel to perform | ||
1732 | IP-forwarding (for IPv6) and NAT (for IPv4) so that the traffic from the virtual | ||
1733 | interface can be routed to the Internet. In order to provide an IPv6-exit, you | ||
1734 | need to have a subnet routed to your host's external network interface and | ||
1735 | assign a subrange of that subnet to the GNUnet exit's TUN interface. | ||
1736 | |||
1737 | When running a local service, you should make sure that the local service is | ||
1738 | (also) bound to the IP address of your EXIT interface (i.e. 169.254.86.1). It | ||
1739 | will NOT work if your local service is just bound to loopback. You may also want | ||
1740 | to create a "VPN" record in your zone of the GNU Name System to make it easy for | ||
1741 | others to access your service via a name instead of just the full service | ||
1742 | descriptor. Note that the identifier you assign the service can serve as a | ||
1743 | passphrase or shared secret, clients connecting to the service must somehow | ||
1744 | learn the service's name. VPN records in the GNU Name System can make this | ||
1745 | easier. | ||
1746 | |||
1747 | @node Fedora and the Firewall | ||
1748 | @subsection Fedora and the Firewall | ||
1749 | |||
1750 | |||
1751 | When using an exit node on Fedora 15, the standard firewall can create trouble | ||
1752 | even when not really exiting the local system! For IPv4, the standard rules seem | ||
1753 | fine. However, for IPv6 the standard rules prohibit traffic from the network | ||
1754 | range of the virtual interface created by the exit daemon to the local IPv6 | ||
1755 | address of the same interface (which is essentially loopback traffic, so you | ||
1756 | might suspect that a standard firewall would leave this traffic alone). However, | ||
1757 | as somehow for IPv6 the traffic is not recognized as originating from the local | ||
1758 | system (and as the connection is not already "established"), the firewall drops | ||
1759 | the traffic. You should still get ICMPv6 packets back, but that's obviously not | ||
1760 | very useful. | ||
1761 | |||
1762 | Possible ways to fix this include disabling the firewall (do you have a good | ||
1763 | reason for having it on?) or disabling the firewall at least for the GNUnet exit | ||
1764 | interface (or the respective IPv4/IPv6 address range). The best way to diagnose | ||
1765 | these kinds of problems in general involves setting the firewall to REJECT | ||
1766 | instead of DROP and to watch the traffic using wireshark (or tcpdump) to see if | ||
1767 | ICMP messages are generated when running some tests that should work. | ||
1768 | |||
1769 | @node Setting up VPN node for protocol translation and tunneling | ||
1770 | @subsection Setting up VPN node for protocol translation and tunneling | ||
1771 | |||
1772 | |||
1773 | The GNUnet VPN/PT subsystem enables you to tunnel IP traffic over the VPN to an | ||
1774 | exit node, from where it can then be forwarded to the Internet. This section | ||
1775 | documents how to setup VPN/PT on a node. Note that you can enable both the VPN | ||
1776 | and an exit on the same peer. In this case, IP traffic from your system may | ||
1777 | enter your peer's VPN and leave your peer's exit. This can be useful as a means | ||
1778 | to do protocol translation. For example, you might have an application that | ||
1779 | supports only IPv4 but needs to access an IPv6-only site. In this case, GNUnet | ||
1780 | would perform 4to6 protocol translation between the VPN (IPv4) and the | ||
1781 | Exit (IPv6). Similarly, 6to4 protocol translation is also possible. However, the | ||
1782 | primary use for GNUnet would be to access an Internet service running with an | ||
1783 | IP version that is not supported by your ISP. In this case, your IP traffic | ||
1784 | would be routed via GNUnet to a peer that has access to the Internet with the | ||
1785 | desired IP version. | ||
1786 | |||
1787 | Setting up an entry node into the GNUnet VPN primarily requires you to enable | ||
1788 | the "VPN/PT" option in "gnunet-setup". This will launch the | ||
1789 | "gnunet-service-vpn", "gnunet-service-dns" and "gnunet-daemon-pt" processes. | ||
1790 | The "gnunet-service-vpn" will create a virtual interface which will be used as | ||
1791 | the target for your IP traffic that enters the VPN. Additionally, a second | ||
1792 | virtual interface will be created by the "gnunet-service-dns" for your DNS | ||
1793 | traffic. You will then need to specify which traffic you want to tunnel over | ||
1794 | GNUnet. If your ISP only provides you with IPv4 or IPv6-access, you may choose | ||
1795 | to tunnel the other IP protocol over the GNUnet VPN. If you do not have an ISP | ||
1796 | (and are connected to other GNUnet peers via WLAN), you can also choose to | ||
1797 | tunnel all IP traffic over GNUnet. This might also provide you with some | ||
1798 | anonymity. After you enable the respective options and restart your peer, your | ||
1799 | Internet traffic should be tunneled over the GNUnet VPN. | ||
1800 | |||
1801 | The GNUnet VPN uses DNS-ALG to hijack your IP traffic. Whenever an application | ||
1802 | resolves a hostname (i.e. 'gnunet.org'), the "gnunet-daemon-pt" will instruct | ||
1803 | the "gnunet-service-dns" to intercept the request (possibly route it over GNUnet | ||
1804 | as well) and replace the normal answer with an IP in the range of the VPN's | ||
1805 | interface. "gnunet-daemon-pt" will then tell "gnunet-service-vpn" to forward all | ||
1806 | traffic it receives on the TUN interface via the VPN to the original | ||
1807 | destination. | ||
1808 | |||
1809 | For applications that do not use DNS, you can also manually create such a | ||
1810 | mapping using the gnunet-vpn command-line tool. Here, you specfiy the desired | ||
1811 | address family of the result (i.e. "-4"), and the intended target IP on the | ||
1812 | Internet ("-i 131.159.74.67") and "gnunet-vpn" will tell you which IP address in | ||
1813 | the range of your VPN tunnel was mapped. | ||
1814 | |||
1815 | gnunet-vpn can also be used to access "internal" services offered by GNUnet | ||
1816 | nodes. So if you happen to know a peer and a service offered by that peer, you | ||
1817 | can create an IP tunnel to that peer by specifying the peer's identity, service | ||
1818 | name and protocol (--tcp or --udp) and you will again receive an IP address that | ||
1819 | will terminate at the respective peer's service. | ||
diff --git a/doc/documentation/Makefile.am b/doc/documentation/Makefile.am new file mode 100644 index 000000000..5bcf3d2a3 --- /dev/null +++ b/doc/documentation/Makefile.am | |||
@@ -0,0 +1,227 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | docdir = $(datadir)/doc/gnunet/ | ||
3 | |||
4 | infoimagedir = $(infodir)/images | ||
5 | |||
6 | #DOT_FILES = images/$(wildcard *.dot) | ||
7 | |||
8 | #DOT_VECTOR_GRAPHICS = \ | ||
9 | # $(DOT_FILES:%.dot=%.eps) \ | ||
10 | # $(DOT_FILES:%.dot=%.pdf) | ||
11 | |||
12 | AM_MAKEINFOHTMLFLAGS = --no-split --css-ref=docstyle.css | ||
13 | |||
14 | dist_infoimage_DATA = \ | ||
15 | images/gnunet-gtk-0-10-gns-a-done.png \ | ||
16 | images/gnunet-gtk-0-10-gns-a.png \ | ||
17 | images/daemon_lego_block.png \ | ||
18 | images/gnunet-gtk-0-10-gns.png \ | ||
19 | images/gnunet-0-10-peerinfo.png \ | ||
20 | images/gnunet-gtk-0-10-identity.png \ | ||
21 | images/gnunet-fs-gtk-0-10-star-tab.png \ | ||
22 | images/gnunet-gtk-0-10.png \ | ||
23 | images/gnunet-gtk-0-10-download-area.png \ | ||
24 | images/gnunet-gtk-0-10-search-selected.png \ | ||
25 | images/gnunet-gtk-0-10-fs-menu.png \ | ||
26 | images/gnunet-gtk-0-10-traffic.png \ | ||
27 | images/gnunet-gtk-0-10-fs.png \ | ||
28 | images/gnunet-namestore-gtk-phone.png \ | ||
29 | images/gnunet-gtk-0-10-fs-publish-editing.png \ | ||
30 | images/gnunet-namestore-gtk-vpn.png \ | ||
31 | images/gnunet-gtk-0-10-fs-published.png \ | ||
32 | images/gnunet-setup-exit.png \ | ||
33 | images/gnunet-gtk-0-10-fs-publish.png \ | ||
34 | images/iceweasel-preferences.png \ | ||
35 | images/gnunet-gtk-0-10-fs-publish-select.png \ | ||
36 | images/iceweasel-proxy.png \ | ||
37 | images/gnunet-gtk-0-10-fs-publish-with-file_0.png \ | ||
38 | images/service_lego_block.png \ | ||
39 | images/gnunet-gtk-0-10-fs-publish-with-file.png \ | ||
40 | images/service_stack.png \ | ||
41 | images/gnunet-gtk-0-10-fs-search.png \ | ||
42 | images/gnunet-tutorial-service.png \ | ||
43 | images/gnunet-tutorial-system.png \ | ||
44 | images/daemon_lego_block.svg \ | ||
45 | images/lego_stack.svg \ | ||
46 | images/service_lego_block.svg \ | ||
47 | images/structure.dot | ||
48 | |||
49 | # images/$(wildcard *.png) \ | ||
50 | # images/$(wildcard *.svg) | ||
51 | # $(DOT_FILES:%.dot=%.png) | ||
52 | |||
53 | #DOT_OPTIONS = \ | ||
54 | # -Gratio=.9 -Gnodesep=.005 -Granksep=.00005 \ | ||
55 | # -Nfontsite=9 -Nheight=.1 -Nwidth=.1 | ||
56 | |||
57 | # .dot.png: | ||
58 | # $(AM_V_DOT)$(DOT) -Tpng $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
59 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
60 | |||
61 | # .dot.pdf: | ||
62 | # $(AM_V_DOT)$(DOT) -Tpdf $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
63 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
64 | |||
65 | # .dot.eps: | ||
66 | # $(AM_V_DOT)$(DOT) -Teps $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \ | ||
67 | # mv "$(srcdir)/$@.tmp" "$(srcdir)/$@" | ||
68 | |||
69 | # .png.eps: | ||
70 | # $(AM_V_GEN)convert "$<" "$@-tmp.eps"; \ | ||
71 | # mv "$@-tmp.eps" "$@" | ||
72 | |||
73 | # pdf-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.pdf) | ||
74 | # info-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.png) | ||
75 | # ps-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.eps) \ | ||
76 | # $(top_srcdir)/%D%/images/coreutils-size-map.eps | ||
77 | # dvi-local: ps-local | ||
78 | |||
79 | gnunet_tutorial_examples = \ | ||
80 | 001.c \ | ||
81 | 002.c \ | ||
82 | 003.c \ | ||
83 | 004.c \ | ||
84 | 005.c \ | ||
85 | 006.c \ | ||
86 | 007.c \ | ||
87 | 008.c \ | ||
88 | 009.c \ | ||
89 | 010.c \ | ||
90 | 011.c \ | ||
91 | 012.c \ | ||
92 | 013.c \ | ||
93 | 013.1.c \ | ||
94 | 014.c \ | ||
95 | 015.c \ | ||
96 | 016.c \ | ||
97 | 017.c \ | ||
98 | 018.c \ | ||
99 | 019.c \ | ||
100 | 020.c \ | ||
101 | 021.c \ | ||
102 | 022.c \ | ||
103 | 023.c \ | ||
104 | 024.c \ | ||
105 | 025.c \ | ||
106 | 026.c | ||
107 | |||
108 | info_TEXINFOS = \ | ||
109 | gnunet.texi \ | ||
110 | gnunet-c-tutorial.texi | ||
111 | |||
112 | gnunet_TEXINFOS = \ | ||
113 | chapters/developer.texi \ | ||
114 | chapters/installation.texi \ | ||
115 | chapters/philosophy.texi \ | ||
116 | chapters/user.texi \ | ||
117 | chapters/vocabulary.texi \ | ||
118 | chapters/configuration.texi \ | ||
119 | fdl-1.3.texi \ | ||
120 | gpl-3.0.texi | ||
121 | |||
122 | EXTRA_DIST = \ | ||
123 | $(gnunet_TEXINFOS) \ | ||
124 | $(gnunet_tutorial_examples) \ | ||
125 | htmlxref.cnf \ | ||
126 | run-gendocs.sh \ | ||
127 | docstyle.css | ||
128 | |||
129 | |||
130 | # $(DOT_FILES) \ | ||
131 | # $(DOT_VECTOR_GRAPHICS) | ||
132 | |||
133 | DISTCLEANFILES = \ | ||
134 | gnunet.cps \ | ||
135 | gnunet-c-tutorial.cps \ | ||
136 | chapters/developer.cps \ | ||
137 | chapters/installation.cps \ | ||
138 | chapter/philosophy.cps \ | ||
139 | chapters/user.cps \ | ||
140 | chapters/configuration.cps \ | ||
141 | chapters/vocabulary.cps \ | ||
142 | fdl-1.3.cps \ | ||
143 | gpl-3.0.cps | ||
144 | |||
145 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING | ||
146 | daemon_lego_block.png: images/daemon_lego_block.svg | ||
147 | convert images/daemon_lego_block.svg images/daemon_lego_block.png && | ||
148 | pngcrush images/daemon_lego_block.png images/daemon_lego_block.png | ||
149 | |||
150 | service_lego_block.png: images/service_lego_block.svg | ||
151 | convert images/service_lego_block.svg images/service_lego_block.png && | ||
152 | pngcrush images/service_lego_block.png images/serivce_lego_block.png | ||
153 | |||
154 | lego_stack.png: images/lego_stack.svg | ||
155 | convert images/lego_stack.svg images/lego_stack.png && | ||
156 | pngcrush images/lego_stack.png images/lego_stack.png | ||
157 | |||
158 | # FIXME: The usage of 'date' strings causes a warning. | ||
159 | # version.texi: | ||
160 | # echo "@set UPDATED $(date +'%d %B %Y')" > $@ | ||
161 | # echo "@set UPDATED-MONTH $(date +'%B %Y')" >> $@ | ||
162 | # echo "@set EDITION $(PACKAGE_VERSION)" >> $@ | ||
163 | # echo "@set VERSION $(PACKAGE_VERSION)" >> $@ | ||
164 | |||
165 | # Workaround for makeinfo error. Whcih in turn introduces more | ||
166 | # date-related 'warnings'. Well. | ||
167 | version2.texi: | ||
168 | echo "@set UPDATED $(date +'%d %B %Y')" > $@ | ||
169 | echo "@set UPDATED-MONTH $(date +'%B %Y')" >> $@ | ||
170 | echo "@set EDITION $(PACKAGE_VERSION)" >> $@ | ||
171 | echo "@set VERSION $(PACKAGE_VERSION)" >> $@ | ||
172 | |||
173 | # FIXME: rm *.html and *.pdf | ||
174 | #doc-clean: | ||
175 | # @rm *.aux *.log *.toc *.cp *.cps | ||
176 | |||
177 | doc-all-install: | ||
178 | @mkdir -p $(DESTDIR)/$(docdir) | ||
179 | @mkdir -p $(DESTDIR)/$(infoimagedir) | ||
180 | @mkdir -p $(DESTDIR)/$(infodir) | ||
181 | @install -m 0755 gnunet.pdf $(DESTDIR)/$(docdir) | ||
182 | @install -m 0755 gnunet-c-tutorial.pdf $(DESTDIR)/$(docdir) | ||
183 | @install -m 0755 gnunet-c-tutorial.info $(DESTDIR)/$(infodir) | ||
184 | @install -m 0755 gnunet.info $(DESTDIR)/$(infodir) | ||
185 | @install gnunet.html $(DESTDIR)/$(docdir) | ||
186 | @install gnunet-c-tutorial.html $(DESTDIR)/$(docdir) | ||
187 | |||
188 | # @cp -r images $(DESTDIR)/$(infoimagedir) | ||
189 | |||
190 | dev-build: version.texi version2.texi | ||
191 | @makeinfo --pdf gnunet.texi | ||
192 | @makeinfo --pdf gnunet-c-tutorial.texi | ||
193 | @makeinfo --html gnunet.texi | ||
194 | @makeinfo --html gnunet-c-tutorial.texi | ||
195 | @makeinfo --no-split gnunet.texi | ||
196 | @makeinfo --no-split gnunet-c-tutorial.texi | ||
197 | |||
198 | # TODO: Add more to clean. | ||
199 | clean: | ||
200 | @rm gnunet.pdf | ||
201 | @rm gnunet.html | ||
202 | @rm gnunet.info | ||
203 | @rm gnunet.info-1 | ||
204 | @rm gnunet.info-2 | ||
205 | @rm gnunet.info-3 | ||
206 | @rm gnunet-c-tutorial.pdf | ||
207 | @rm gnunet-c-tutorial.info | ||
208 | @rm gnunet-c-tutorial.html | ||
209 | @rm -r gnunet.t2p | ||
210 | @rm -r gnunet-c-tutorial.t2p | ||
211 | |||
212 | # CLEANFILES = \ | ||
213 | # gnunet.log \ | ||
214 | # gnunet-c-tutorial.log \ | ||
215 | # $(wildcard *.aux) \ | ||
216 | # $(wildcard *.toc) \ | ||
217 | # $(wildcard *.cp) \ | ||
218 | # $(wildcard *.cps) | ||
219 | |||
220 | #.PHONY: version.texi | ||
221 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING_PDF | ||
222 | |||
223 | # if HAVE_EXTENDED_DOCUMENTATION_BUILDING_HTML | ||
224 | |||
225 | # endif | ||
226 | # endif | ||
227 | # endif | ||
diff --git a/doc/documentation/README.txt b/doc/documentation/README.txt new file mode 100644 index 000000000..28223f009 --- /dev/null +++ b/doc/documentation/README.txt | |||
@@ -0,0 +1,69 @@ | |||
1 | To be moved to an appropriate section of "how to write documentation" or | ||
2 | "how to contribute to the documentation": | ||
3 | |||
4 | 1. When writing documentation, please use gender-neutral wording when | ||
5 | referring to people, such as singular “theyâ€, “theirâ€, “themâ€, and | ||
6 | so forth. -> https://en.wikipedia.org/wiki/Singular_they | ||
7 | |||
8 | 2. Keep line length below 74 characters. | ||
9 | - Expection by texi2pdf output so far: URLs will break | ||
10 | (inserted whitespace) when they contain linebreaks | ||
11 | within the @url{} / @uref{}. | ||
12 | |||
13 | 3. Do not use tab characters (see chapter 2.1 texinfo manual) | ||
14 | |||
15 | 4. Use neutral language and third person perspective in the text | ||
16 | * What's left to do | ||
17 | |||
18 | - Which Texlive modules are needed? Decrease the size. | ||
19 | - Update the content of gnunet documentation. | ||
20 | |||
21 | * How to use (hack) on this | ||
22 | |||
23 | ** with guix | ||
24 | |||
25 | Adjust accordingly, ie read the Guix Documentation: | ||
26 | setenv GUIX_PACKAGE_PATH "gnunet/contrib/packages/guix/packages" | ||
27 | guix environment gnunet-doc | ||
28 | and | ||
29 | guix build -f contrib/packages/guix/gnunet-doc.scm | ||
30 | |||
31 | ** without guix | ||
32 | |||
33 | You need to have Texinfo and Texlive in your path. | ||
34 | sh bootstrap | ||
35 | ./configure --enable-documentation | ||
36 | cd doc | ||
37 | make (format you want) | ||
38 | |||
39 | for example: make html, make info, make pdf | ||
40 | |||
41 | * structure (relations) | ||
42 | |||
43 | ** gnunet.texi | ||
44 | -> chapters/developer.texi | ||
45 | -> chapters/installation.texi | ||
46 | -> chapters/philosophy.texi | ||
47 | -> chapters/user.texi | ||
48 | -> chapters/vocabulary.texi | ||
49 | -> images/* | ||
50 | -> gpl-3.0.texi | ||
51 | -> fdl-1.3.texi | ||
52 | |||
53 | ** gnunet-c-tutorial.texi | ||
54 | -> figs/Service.pdf | ||
55 | -> figs/System.pdf | ||
56 | -> tutorial-examples/*.c | ||
57 | -> gpl-3.0.texi | ||
58 | -> fdl-1.3.texi | ||
59 | |||
60 | - gnunet-c-tutorial-v1.pdf: original LaTeX "gnunet-c-tutorial.pdf". | ||
61 | - man folder: the man pages. | ||
62 | - doxygen folder | ||
63 | - outdated-and-old-installation-instructions.txt: self described within the file. | ||
64 | |||
65 | |||
66 | Use `gendocs', add to the manual/ directory of the web site. | ||
67 | |||
68 | $ cd doc | ||
69 | $ gendocs.sh gnunet "GNUnet 0.10.X Reference Manual" | ||
diff --git a/doc/documentation/chapters/configuration.texi b/doc/documentation/chapters/configuration.texi new file mode 100644 index 000000000..286c72e7a --- /dev/null +++ b/doc/documentation/chapters/configuration.texi | |||
@@ -0,0 +1,5 @@ | |||
1 | @node Configuration Handbook | ||
2 | @chapter Configuration Handbook | ||
3 | |||
4 | This chapter has yet to be written. It is intended to be about in-depth | ||
5 | configuration of GNUnet. | ||
diff --git a/doc/documentation/chapters/developer.texi b/doc/documentation/chapters/developer.texi new file mode 100644 index 000000000..996474359 --- /dev/null +++ b/doc/documentation/chapters/developer.texi | |||
@@ -0,0 +1,8304 @@ | |||
1 | @c *********************************************************************** | ||
2 | @node GNUnet Developer Handbook | ||
3 | @chapter GNUnet Developer Handbook | ||
4 | |||
5 | This book is intended to be an introduction for programmers that want to | ||
6 | extend the GNUnet framework. GNUnet is more than a simple peer-to-peer | ||
7 | application. For developers, GNUnet is: | ||
8 | |||
9 | @itemize @bullet | ||
10 | @item Free software under the GNU General Public License, with a community | ||
11 | that believes in the GNU philosophy | ||
12 | @item A set of standards, including coding conventions and | ||
13 | architectural rules | ||
14 | @item A set of layered protocols, both specifying the communication | ||
15 | between peers as well as the communication between components | ||
16 | of a single peer | ||
17 | @item A set of libraries with well-defined APIs suitable for | ||
18 | writing extensions | ||
19 | @end itemize | ||
20 | |||
21 | In particular, the architecture specifies that a peer consists of many | ||
22 | processes communicating via protocols. Processes can be written in almost | ||
23 | any language. C and Java APIs exist for accessing existing services and | ||
24 | for writing extensions. It is possible to write extensions in other | ||
25 | languages by implementing the necessary IPC protocols. | ||
26 | |||
27 | GNUnet can be extended and improved along many possible dimensions, and | ||
28 | anyone interested in Free Software and Freedom-enhancing Networking is | ||
29 | welcome to join the effort. This Developer Handbook attempts to provide | ||
30 | an initial introduction to some of the key design choices and central | ||
31 | components of the system. This part of the GNUNet documentation | ||
32 | is far from complete, and we welcome informed contributions, | ||
33 | be it in the form of new chapters or insightful comments. | ||
34 | |||
35 | @menu | ||
36 | * Developer Introduction:: | ||
37 | * Code overview:: | ||
38 | * System Architecture:: | ||
39 | * Subsystem stability:: | ||
40 | * Naming conventions and coding style guide:: | ||
41 | * Build-system:: | ||
42 | * Developing extensions for GNUnet using the gnunet-ext template:: | ||
43 | * Writing testcases:: | ||
44 | * GNUnet's TESTING library:: | ||
45 | * Performance regression analysis with Gauger:: | ||
46 | * GNUnet's TESTBED Subsystem:: | ||
47 | * libgnunetutil:: | ||
48 | * The Automatic Restart Manager (ARM):: | ||
49 | * GNUnet's TRANSPORT Subsystem:: | ||
50 | * NAT library:: | ||
51 | * Distance-Vector plugin:: | ||
52 | * SMTP plugin:: | ||
53 | * Bluetooth plugin:: | ||
54 | * WLAN plugin:: | ||
55 | * The ATS Subsystem:: | ||
56 | * GNUnet's CORE Subsystem:: | ||
57 | * GNUnet's CADET subsystem:: | ||
58 | * GNUnet's NSE subsystem:: | ||
59 | * GNUnet's HOSTLIST subsystem:: | ||
60 | * GNUnet's IDENTITY subsystem:: | ||
61 | * GNUnet's NAMESTORE Subsystem:: | ||
62 | * GNUnet's PEERINFO subsystem:: | ||
63 | * GNUnet's PEERSTORE subsystem:: | ||
64 | * GNUnet's SET Subsystem:: | ||
65 | * GNUnet's STATISTICS subsystem:: | ||
66 | * GNUnet's Distributed Hash Table (DHT):: | ||
67 | * The GNU Name System (GNS):: | ||
68 | * The GNS Namecache:: | ||
69 | * The REVOCATION Subsystem:: | ||
70 | * GNUnet's File-sharing (FS) Subsystem:: | ||
71 | * GNUnet's REGEX Subsystem:: | ||
72 | @end menu | ||
73 | |||
74 | @node Developer Introduction | ||
75 | @section Developer Introduction | ||
76 | |||
77 | This Developer Handbook is intended as first introduction to GNUnet for | ||
78 | new developers that want to extend the GNUnet framework. After the | ||
79 | introduction, each of the GNUnet subsystems (directories in the | ||
80 | @file{src/} tree) is (supposed to be) covered in its own chapter. In | ||
81 | addition to this documentation, GNUnet developers should be aware of the | ||
82 | services available on the GNUnet server to them. | ||
83 | |||
84 | New developers can have a look a the GNUnet tutorials for C and java | ||
85 | available in the @file{src/} directory of the repository or under the | ||
86 | following links: | ||
87 | |||
88 | @c ** FIXME: Link to files in source, not online. | ||
89 | @c ** FIXME: Where is the Java tutorial? | ||
90 | @itemize @bullet | ||
91 | @item @uref{https://gnunet.org/git/gnunet.git/plain/doc/gnunet-c-tutorial.pdf, GNUnet C tutorial} | ||
92 | @item GNUnet Java tutorial | ||
93 | @end itemize | ||
94 | |||
95 | In addition to this book, the GNUnet server contains various resources for | ||
96 | GNUnet developers. They are all conveniently reachable via the "Developer" | ||
97 | entry in the navigation menu. Some additional tools (such as static | ||
98 | analysis reports) require a special developer access to perform certain | ||
99 | operations. If you feel you need access, you should contact | ||
100 | @uref{http://grothoff.org/christian/, Christian Grothoff}, | ||
101 | GNUnet's maintainer. | ||
102 | |||
103 | The public subsystems on the GNUnet server that help developers are: | ||
104 | |||
105 | @itemize @bullet | ||
106 | |||
107 | @item The Version control system (git) keeps our code and enables | ||
108 | distributed development. | ||
109 | Only developers with write access can commit code, everyone else is | ||
110 | encouraged to submit patches to the | ||
111 | @uref{https://lists.gnu.org/mailman/listinfo/gnunet-developers, GNUnet-developers mailinglist} | ||
112 | . | ||
113 | |||
114 | @item The GNUnet bugtracking system (Mantis) is used to track | ||
115 | feature requests, open bug reports and their resolutions. | ||
116 | Anyone can report bugs, only developers can claim to have fixed them. | ||
117 | |||
118 | @item A site installation of the CI system "Buildbot" is used to check | ||
119 | GNUnet builds automatically on a range of platforms. | ||
120 | Builds are triggered automatically after 30 minutes of no changes to Git. | ||
121 | |||
122 | @item The current quality of our automated test suite is assessed using | ||
123 | Code coverage analysis. This analysis is run daily; however the webpage | ||
124 | is only updated if all automated tests pass at that time. Testcases that | ||
125 | improve our code coverage are always welcome. | ||
126 | |||
127 | @item We try to automatically find bugs using a static analysis scan. | ||
128 | This scan is run daily; however the webpage is only updated if all | ||
129 | automated tests pass at the time. Note that not everything that is | ||
130 | flagged by the analysis is a bug, sometimes even good code can be marked | ||
131 | as possibly problematic. Nevertheless, developers are encouraged to at | ||
132 | least be aware of all issues in their code that are listed. | ||
133 | |||
134 | @item We use Gauger for automatic performance regression visualization. | ||
135 | Details on how to use Gauger are here. | ||
136 | |||
137 | @item We use @uref{http://junit.org/, junit} to automatically test | ||
138 | @command{gnunet-java}. | ||
139 | Automatically generated, current reports on the test suite are here. | ||
140 | |||
141 | @item We use Cobertura to generate test coverage reports for gnunet-java. | ||
142 | Current reports on test coverage are here. | ||
143 | |||
144 | @end itemize | ||
145 | |||
146 | |||
147 | |||
148 | @c *********************************************************************** | ||
149 | @menu | ||
150 | * Project overview:: | ||
151 | @end menu | ||
152 | |||
153 | @node Project overview | ||
154 | @subsection Project overview | ||
155 | |||
156 | The GNUnet project consists at this point of several sub-projects. This | ||
157 | section is supposed to give an initial overview about the various | ||
158 | sub-projects. Note that this description also lists projects that are far | ||
159 | from complete, including even those that have literally not a single line | ||
160 | of code in them yet. | ||
161 | |||
162 | GNUnet sub-projects in order of likely relevance are currently: | ||
163 | |||
164 | @table @asis | ||
165 | |||
166 | @item gnunet | ||
167 | Core of the P2P framework, including file-sharing, VPN and | ||
168 | chat applications; this is what the developer handbook covers mostly | ||
169 | @item gnunet-gtk Gtk+-based user interfaces, including gnunet-fs-gtk | ||
170 | (file-sharing), gnunet-statistics-gtk (statistics over time), | ||
171 | gnunet-peerinfo-gtk (information about current connections and known | ||
172 | peers), gnunet-chat-gtk (chat GUI) and gnunet-setup (setup tool for | ||
173 | "everything") | ||
174 | @item gnunet-fuse | ||
175 | Mounting directories shared via GNUnet's file-sharing | ||
176 | on Linux | ||
177 | @item gnunet-update | ||
178 | Installation and update tool | ||
179 | @item gnunet-ext | ||
180 | Template for starting 'external' GNUnet projects | ||
181 | @item gnunet-java | ||
182 | Java APIs for writing GNUnet services and applications | ||
183 | @c ** FIXME: Point to new website repository once we have it: | ||
184 | @c ** @item svn/gnunet-www/ Code and media helping drive the GNUnet | ||
185 | @c website | ||
186 | @item eclectic | ||
187 | Code to run GNUnet nodes on testbeds for research, development, | ||
188 | testing and evaluation | ||
189 | @c ** FIXME: Solve the status and location of gnunet-qt | ||
190 | @item gnunet-qt | ||
191 | Qt-based GNUnet GUI (dead?) | ||
192 | @item gnunet-cocoa | ||
193 | cocoa-based GNUnet GUI (dead?) | ||
194 | |||
195 | @end table | ||
196 | |||
197 | We are also working on various supporting libraries and tools: | ||
198 | @c ** FIXME: What about gauger, and what about libmwmodem? | ||
199 | |||
200 | @table @asis | ||
201 | @item libextractor | ||
202 | GNU libextractor (meta data extraction) | ||
203 | @item libmicrohttpd | ||
204 | GNU libmicrohttpd (embedded HTTP(S) server library) | ||
205 | @item gauger | ||
206 | Tool for performance regression analysis | ||
207 | @item monkey | ||
208 | Tool for automated debugging of distributed systems | ||
209 | @item libmwmodem | ||
210 | Library for accessing satellite connection quality | ||
211 | reports | ||
212 | @item libgnurl | ||
213 | gnURL (feature restricted variant of cURL/libcurl) | ||
214 | @end table | ||
215 | |||
216 | Finally, there are various external projects (see links for a list of | ||
217 | those that have a public website) which build on top of the GNUnet | ||
218 | framework. | ||
219 | |||
220 | @c *********************************************************************** | ||
221 | @node Code overview | ||
222 | @section Code overview | ||
223 | |||
224 | This section gives a brief overview of the GNUnet source code. | ||
225 | Specifically, we sketch the function of each of the subdirectories in | ||
226 | the @file{gnunet/src/} directory. The order given is roughly bottom-up | ||
227 | (in terms of the layers of the system). | ||
228 | |||
229 | @table @asis | ||
230 | @item @file{util/} --- libgnunetutil | ||
231 | Library with general utility functions, all | ||
232 | GNUnet binaries link against this library. Anything from memory | ||
233 | allocation and data structures to cryptography and inter-process | ||
234 | communication. The goal is to provide an OS-independent interface and | ||
235 | more 'secure' or convenient implementations of commonly used primitives. | ||
236 | The API is spread over more than a dozen headers, developers should study | ||
237 | those closely to avoid duplicating existing functions. | ||
238 | @item @file{hello/} --- libgnunethello | ||
239 | HELLO messages are used to | ||
240 | describe under which addresses a peer can be reached (for example, | ||
241 | protocol, IP, port). This library manages parsing and generating of HELLO | ||
242 | messages. | ||
243 | @item @file{block/} --- libgnunetblock | ||
244 | The DHT and other components of GNUnet | ||
245 | store information in units called 'blocks'. Each block has a type and the | ||
246 | type defines a particular format and how that binary format is to be | ||
247 | linked to a hash code (the key for the DHT and for databases). The block | ||
248 | library is a wapper around block plugins which provide the necessary | ||
249 | functions for each block type. | ||
250 | @item @file{statistics/} | ||
251 | The statistics service enables associating | ||
252 | values (of type uint64_t) with a componenet name and a string. The main | ||
253 | uses is debugging (counting events), performance tracking and user | ||
254 | entertainment (what did my peer do today?). | ||
255 | @item @file{arm/} --- Automatic Restart Manager (ARM) | ||
256 | The automatic-restart-manager (ARM) service | ||
257 | is the GNUnet master service. Its role is to start gnunet-services, to | ||
258 | re-start them when they crashed and finally to shut down the system when | ||
259 | requested. | ||
260 | @item @file{peerinfo/} | ||
261 | The peerinfo service keeps track of which peers are known | ||
262 | to the local peer and also tracks the validated addresses for each peer | ||
263 | (in the form of a HELLO message) for each of those peers. The peer is not | ||
264 | necessarily connected to all peers known to the peerinfo service. | ||
265 | Peerinfo provides persistent storage for peer identities --- peers are | ||
266 | not forgotten just because of a system restart. | ||
267 | @item @file{datacache/} --- libgnunetdatacache | ||
268 | The datacache library provides (temporary) block storage for the DHT. | ||
269 | Existing plugins can store blocks in Sqlite, Postgres or MySQL databases. | ||
270 | All data stored in the cache is lost when the peer is stopped or | ||
271 | restarted (datacache uses temporary tables). | ||
272 | @item @file{datastore/} | ||
273 | The datastore service stores file-sharing blocks in | ||
274 | databases for extended periods of time. In contrast to the datacache, data | ||
275 | is not lost when peers restart. However, quota restrictions may still | ||
276 | cause old, expired or low-priority data to be eventually discarded. | ||
277 | Existing plugins can store blocks in Sqlite, Postgres or MySQL databases. | ||
278 | @item @file{template/} | ||
279 | Template for writing a new service. Does nothing. | ||
280 | @item @file{ats/} --- Automatic Transport Selection | ||
281 | The automatic transport | ||
282 | selection (ATS) service is responsible for deciding which address (i.e. | ||
283 | which transport plugin) should be used for communication with other peers, | ||
284 | and at what bandwidth. | ||
285 | @item @file{nat/} --- libgnunetnat | ||
286 | Library that provides basic functions for NAT traversal. | ||
287 | The library supports NAT traversal with | ||
288 | manual hole-punching by the user, UPnP and ICMP-based autonomous NAT | ||
289 | traversal. The library also includes an API for testing if the current | ||
290 | configuration works and the @code{gnunet-nat-server} which provides an | ||
291 | external service to test the local configuration. | ||
292 | @item @file{fragmentation/} --- libgnunetfragmentation | ||
293 | Some transports (UDP and WLAN, mostly) have restrictions on the maximum | ||
294 | transfer unit (MTU) for packets. The fragmentation library can be used to | ||
295 | break larger packets into chunks of at most 1k and transmit the resulting | ||
296 | fragments reliabily (with acknowledgement, retransmission, timeouts, | ||
297 | etc.). | ||
298 | @item @file{transport/} | ||
299 | The transport service is responsible for managing the | ||
300 | basic P2P communication. It uses plugins to support P2P communication | ||
301 | over TCP, UDP, HTTP, HTTPS and other protocols.The transport service | ||
302 | validates peer addresses, enforces bandwidth restrictions, limits the | ||
303 | total number of connections and enforces connectivity restrictions (i.e. | ||
304 | friends-only). | ||
305 | @item @file{peerinfo-tool/} | ||
306 | This directory contains the gnunet-peerinfo binary which can be used to | ||
307 | inspect the peers and HELLOs known to the peerinfo service. | ||
308 | @item @file{core/} | ||
309 | The core service is responsible for establishing encrypted, authenticated | ||
310 | connections with other peers, encrypting and decrypting messages and | ||
311 | forwarding messages to higher-level services that are interested in them. | ||
312 | @item @file{testing/} --- libgnunettesting | ||
313 | The testing library allows starting (and stopping) peers | ||
314 | for writing testcases. | ||
315 | It also supports automatic generation of configurations for peers | ||
316 | ensuring that the ports and paths are disjoint. libgnunettesting is also | ||
317 | the foundation for the testbed service | ||
318 | @item @file{testbed/} | ||
319 | The testbed service is used for creating small or large scale deployments | ||
320 | of GNUnet peers for evaluation of protocols. | ||
321 | It facilitates peer depolyments on multiple | ||
322 | hosts (for example, in a cluster) and establishing varous network | ||
323 | topologies (both underlay and overlay). | ||
324 | @item @file{nse/} --- Network Size Estimation | ||
325 | The network size estimation (NSE) service | ||
326 | implements a protocol for (securely) estimating the current size of the | ||
327 | P2P network. | ||
328 | @item @file{dht/} --- distributed hash table | ||
329 | The distributed hash table (DHT) service provides a | ||
330 | distributed implementation of a hash table to store blocks under hash | ||
331 | keys in the P2P network. | ||
332 | @item @file{hostlist/} | ||
333 | The hostlist service allows learning about | ||
334 | other peers in the network by downloading HELLO messages from an HTTP | ||
335 | server, can be configured to run such an HTTP server and also implements | ||
336 | a P2P protocol to advertise and automatically learn about other peers | ||
337 | that offer a public hostlist server. | ||
338 | @item @file{topology/} | ||
339 | The topology service is responsible for | ||
340 | maintaining the mesh topology. It tries to maintain connections to friends | ||
341 | (depending on the configuration) and also tries to ensure that the peer | ||
342 | has a decent number of active connections at all times. If necessary, new | ||
343 | connections are added. All peers should run the topology service, | ||
344 | otherwise they may end up not being connected to any other peer (unless | ||
345 | some other service ensures that core establishes the required | ||
346 | connections). The topology service also tells the transport service which | ||
347 | connections are permitted (for friend-to-friend networking) | ||
348 | @item @file{fs/} --- file-sharing | ||
349 | The file-sharing (FS) service implements GNUnet's | ||
350 | file-sharing application. Both anonymous file-sharing (using gap) and | ||
351 | non-anonymous file-sharing (using dht) are supported. | ||
352 | @item @file{cadet/} | ||
353 | The CADET service provides a general-purpose routing abstraction to create | ||
354 | end-to-end encrypted tunnels in mesh networks. We wrote a paper | ||
355 | documenting key aspects of the design. | ||
356 | @item @file{tun/} --- libgnunettun | ||
357 | Library for building IPv4, IPv6 packets and creating | ||
358 | checksums for UDP, TCP and ICMP packets. The header | ||
359 | defines C structs for common Internet packet formats and in particular | ||
360 | structs for interacting with TUN (virtual network) interfaces. | ||
361 | @item @file{mysql/} --- libgnunetmysql | ||
362 | Library for creating and executing prepared MySQL | ||
363 | statements and to manage the connection to the MySQL database. | ||
364 | Essentially a lightweight wrapper for the interaction between GNUnet | ||
365 | components and libmysqlclient. | ||
366 | @item @file{dns/} | ||
367 | Service that allows intercepting and modifying DNS requests of | ||
368 | the local machine. Currently used for IPv4-IPv6 protocol translation | ||
369 | (DNS-ALG) as implemented by "pt/" and for the GNUnet naming system. The | ||
370 | service can also be configured to offer an exit service for DNS traffic. | ||
371 | @item @file{vpn/} | ||
372 | The virtual public network (VPN) service provides a virtual | ||
373 | tunnel interface (VTUN) for IP routing over GNUnet. | ||
374 | Needs some other peers to run an "exit" service to work. | ||
375 | Can be activated using the "gnunet-vpn" tool or integrated with DNS using | ||
376 | the "pt" daemon. | ||
377 | @item @file{exit/} | ||
378 | Daemon to allow traffic from the VPN to exit this | ||
379 | peer to the Internet or to specific IP-based services of the local peer. | ||
380 | Currently, an exit service can only be restricted to IPv4 or IPv6, not to | ||
381 | specific ports and or IP address ranges. If this is not acceptable, | ||
382 | additional firewall rules must be added manually. exit currently only | ||
383 | works for normal UDP, TCP and ICMP traffic; DNS queries need to leave the | ||
384 | system via a DNS service. | ||
385 | @item @file{pt/} | ||
386 | protocol translation daemon. This daemon enables 4-to-6, | ||
387 | 6-to-4, 4-over-6 or 6-over-4 transitions for the local system. It | ||
388 | essentially uses "DNS" to intercept DNS replies and then maps results to | ||
389 | those offered by the VPN, which then sends them using mesh to some daemon | ||
390 | offering an appropriate exit service. | ||
391 | @item @file{identity/} | ||
392 | Management of egos (alter egos) of a user; identities are | ||
393 | essentially named ECC private keys and used for zones in the GNU name | ||
394 | system and for namespaces in file-sharing, but might find other uses later | ||
395 | @item @file{revocation/} | ||
396 | Key revocation service, can be used to revoke the | ||
397 | private key of an identity if it has been compromised | ||
398 | @item @file{namecache/} | ||
399 | Cache for resolution results for the GNU name system; | ||
400 | data is encrypted and can be shared among users, | ||
401 | loss of the data should ideally only result in a | ||
402 | performance degradation (persistence not required) | ||
403 | @item @file{namestore/} | ||
404 | Database for the GNU name system with per-user private information, | ||
405 | persistence required | ||
406 | @item @file{gns/} | ||
407 | GNU name system, a GNU approach to DNS and PKI. | ||
408 | @item @file{dv/} | ||
409 | A plugin for distance-vector (DV)-based routing. | ||
410 | DV consists of a service and a transport plugin to provide peers | ||
411 | with the illusion of a direct P2P connection for connections | ||
412 | that use multiple (typically up to 3) hops in the actual underlay network. | ||
413 | @item @file{regex/} | ||
414 | Service for the (distributed) evaluation of regular expressions. | ||
415 | @item @file{scalarproduct/} | ||
416 | The scalar product service offers an API to perform a secure multiparty | ||
417 | computation which calculates a scalar product between two peers | ||
418 | without exposing the private input vectors of the peers to each other. | ||
419 | @item @file{consensus/} | ||
420 | The consensus service will allow a set of peers to agree | ||
421 | on a set of values via a distributed set union computation. | ||
422 | @item @file{rest/} | ||
423 | The rest API allows access to GNUnet services using RESTful interaction. | ||
424 | The services provide plugins that can exposed by the rest server. | ||
425 | @item @file{experimentation/} | ||
426 | The experimentation daemon coordinates distributed | ||
427 | experimentation to evaluate transport and ATS properties. | ||
428 | @end table | ||
429 | |||
430 | @c *********************************************************************** | ||
431 | @node System Architecture | ||
432 | @section System Architecture | ||
433 | |||
434 | GNUnet developers like LEGOs. The blocks are indestructible, can be | ||
435 | stacked together to construct complex buildings and it is generally easy | ||
436 | to swap one block for a different one that has the same shape. GNUnet's | ||
437 | architecture is based on LEGOs: | ||
438 | |||
439 | @c images here | ||
440 | |||
441 | This chapter documents the GNUnet LEGO system, also known as GNUnet's | ||
442 | system architecture. | ||
443 | |||
444 | The most common GNUnet component is a service. Services offer an API (or | ||
445 | several, depending on what you count as "an API") which is implemented as | ||
446 | a library. The library communicates with the main process of the service | ||
447 | using a service-specific network protocol. The main process of the service | ||
448 | typically doesn't fully provide everything that is needed --- it has holes | ||
449 | to be filled by APIs to other services. | ||
450 | |||
451 | A special kind of component in GNUnet are user interfaces and daemons. | ||
452 | Like services, they have holes to be filled by APIs of other services. | ||
453 | Unlike services, daemons do not implement their own network protocol and | ||
454 | they have no API: | ||
455 | |||
456 | The GNUnet system provides a range of services, daemons and user | ||
457 | interfaces, which are then combined into a layered GNUnet instance (also | ||
458 | known as a peer). | ||
459 | |||
460 | Note that while it is generally possible to swap one service for another | ||
461 | compatible service, there is often only one implementation. However, | ||
462 | during development we often have a "new" version of a service in parallel | ||
463 | with an "old" version. While the "new" version is not working, developers | ||
464 | working on other parts of the service can continue their development by | ||
465 | simply using the "old" service. Alternative design ideas can also be | ||
466 | easily investigated by swapping out individual components. This is | ||
467 | typically achieved by simply changing the name of the "BINARY" in the | ||
468 | respective configuration section. | ||
469 | |||
470 | Key properties of GNUnet services are that they must be separate | ||
471 | processes and that they must protect themselves by applying tight error | ||
472 | checking against the network protocol they implement (thereby achieving a | ||
473 | certain degree of robustness). | ||
474 | |||
475 | On the other hand, the APIs are implemented to tolerate failures of the | ||
476 | service, isolating their host process from errors by the service. If the | ||
477 | service process crashes, other services and daemons around it should not | ||
478 | also fail, but instead wait for the service process to be restarted by | ||
479 | ARM. | ||
480 | |||
481 | |||
482 | @c *********************************************************************** | ||
483 | @node Subsystem stability | ||
484 | @section Subsystem stability | ||
485 | |||
486 | This section documents the current stability of the various GNUnet | ||
487 | subsystems. Stability here describes the expected degree of compatibility | ||
488 | with future versions of GNUnet. For each subsystem we distinguish between | ||
489 | compatibility on the P2P network level (communication protocol between | ||
490 | peers), the IPC level (communication between the service and the service | ||
491 | library) and the API level (stability of the API). P2P compatibility is | ||
492 | relevant in terms of which applications are likely going to be able to | ||
493 | communicate with future versions of the network. IPC communication is | ||
494 | relevant for the implementation of language bindings that re-implement the | ||
495 | IPC messages. Finally, API compatibility is relevant to developers that | ||
496 | hope to be able to avoid changes to applications build on top of the APIs | ||
497 | of the framework. | ||
498 | |||
499 | The following table summarizes our current view of the stability of the | ||
500 | respective protocols or APIs: | ||
501 | |||
502 | @multitable @columnfractions .20 .20 .20 .20 | ||
503 | @headitem Subsystem @tab P2P @tab IPC @tab C API | ||
504 | @item util @tab n/a @tab n/a @tab stable | ||
505 | @item arm @tab n/a @tab stable @tab stable | ||
506 | @item ats @tab n/a @tab unstable @tab testing | ||
507 | @item block @tab n/a @tab n/a @tab stable | ||
508 | @item cadet @tab testing @tab testing @tab testing | ||
509 | @item consensus @tab experimental @tab experimental @tab experimental | ||
510 | @item core @tab stable @tab stable @tab stable | ||
511 | @item datacache @tab n/a @tab n/a @tab stable | ||
512 | @item datastore @tab n/a @tab stable @tab stable | ||
513 | @item dht @tab stable @tab stable @tab stable | ||
514 | @item dns @tab stable @tab stable @tab stable | ||
515 | @item dv @tab testing @tab testing @tab n/a | ||
516 | @item exit @tab testing @tab n/a @tab n/a | ||
517 | @item fragmentation @tab stable @tab n/a @tab stable | ||
518 | @item fs @tab stable @tab stable @tab stable | ||
519 | @item gns @tab stable @tab stable @tab stable | ||
520 | @item hello @tab n/a @tab n/a @tab testing | ||
521 | @item hostlist @tab stable @tab stable @tab n/a | ||
522 | @item identity @tab stable @tab stable @tab n/a | ||
523 | @item multicast @tab experimental @tab experimental @tab experimental | ||
524 | @item mysql @tab stable @tab n/a @tab stable | ||
525 | @item namestore @tab n/a @tab stable @tab stable | ||
526 | @item nat @tab n/a @tab n/a @tab stable | ||
527 | @item nse @tab stable @tab stable @tab stable | ||
528 | @item peerinfo @tab n/a @tab stable @tab stable | ||
529 | @item psyc @tab experimental @tab experimental @tab experimental | ||
530 | @item pt @tab n/a @tab n/a @tab n/a | ||
531 | @item regex @tab stable @tab stable @tab stable | ||
532 | @item revocation @tab stable @tab stable @tab stable | ||
533 | @item social @tab experimental @tab experimental @tab experimental | ||
534 | @item statistics @tab n/a @tab stable @tab stable | ||
535 | @item testbed @tab n/a @tab testing @tab testing | ||
536 | @item testing @tab n/a @tab n/a @tab testing | ||
537 | @item topology @tab n/a @tab n/a @tab n/a | ||
538 | @item transport @tab stable @tab stable @tab stable | ||
539 | @item tun @tab n/a @tab n/a @tab stable | ||
540 | @item vpn @tab testing @tab n/a @tab n/a | ||
541 | @end multitable | ||
542 | |||
543 | Here is a rough explanation of the values: | ||
544 | |||
545 | @table @samp | ||
546 | @item stable | ||
547 | No incompatible changes are planned at this time; for IPC/APIs, if | ||
548 | there are incompatible changes, they will be minor and might only require | ||
549 | minimal changes to existing code; for P2P, changes will be avoided if at | ||
550 | all possible for the 0.10.x-series | ||
551 | |||
552 | @item testing | ||
553 | No incompatible changes are | ||
554 | planned at this time, but the code is still known to be in flux; so while | ||
555 | we have no concrete plans, our expectation is that there will still be | ||
556 | minor modifications; for P2P, changes will likely be extensions that | ||
557 | should not break existing code | ||
558 | |||
559 | @item unstable | ||
560 | Changes are planned and will happen; however, they | ||
561 | will not be totally radical and the result should still resemble what is | ||
562 | there now; nevertheless, anticipated changes will break protocol/API | ||
563 | compatibility | ||
564 | |||
565 | @item experimental | ||
566 | Changes are planned and the result may look nothing like | ||
567 | what the API/protocol looks like today | ||
568 | |||
569 | @item unknown | ||
570 | Someone should think about where this subsystem headed | ||
571 | |||
572 | @item n/a | ||
573 | This subsystem does not have an API/IPC-protocol/P2P-protocol | ||
574 | @end table | ||
575 | |||
576 | @c *********************************************************************** | ||
577 | @node Naming conventions and coding style guide | ||
578 | @section Naming conventions and coding style guide | ||
579 | |||
580 | Here you can find some rules to help you write code for GNUnet. | ||
581 | |||
582 | @c *********************************************************************** | ||
583 | @menu | ||
584 | * Naming conventions:: | ||
585 | * Coding style:: | ||
586 | @end menu | ||
587 | |||
588 | @node Naming conventions | ||
589 | @subsection Naming conventions | ||
590 | |||
591 | |||
592 | @c *********************************************************************** | ||
593 | @menu | ||
594 | * include files:: | ||
595 | * binaries:: | ||
596 | * logging:: | ||
597 | * configuration:: | ||
598 | * exported symbols:: | ||
599 | * private (library-internal) symbols (including structs and macros):: | ||
600 | * testcases:: | ||
601 | * performance tests:: | ||
602 | * src/ directories:: | ||
603 | @end menu | ||
604 | |||
605 | @node include files | ||
606 | @subsubsection include files | ||
607 | |||
608 | @itemize @bullet | ||
609 | @item _lib: library without need for a process | ||
610 | @item _service: library that needs a service process | ||
611 | @item _plugin: plugin definition | ||
612 | @item _protocol: structs used in network protocol | ||
613 | @item exceptions: | ||
614 | @itemize @bullet | ||
615 | @item gnunet_config.h --- generated | ||
616 | @item platform.h --- first included | ||
617 | @item plibc.h --- external library | ||
618 | @item gnunet_common.h --- fundamental routines | ||
619 | @item gnunet_directories.h --- generated | ||
620 | @item gettext.h --- external library | ||
621 | @end itemize | ||
622 | @end itemize | ||
623 | |||
624 | @c *********************************************************************** | ||
625 | @node binaries | ||
626 | @subsubsection binaries | ||
627 | |||
628 | @itemize @bullet | ||
629 | @item gnunet-service-xxx: service process (has listen socket) | ||
630 | @item gnunet-daemon-xxx: daemon process (no listen socket) | ||
631 | @item gnunet-helper-xxx[-yyy]: SUID helper for module xxx | ||
632 | @item gnunet-yyy: command-line tool for end-users | ||
633 | @item libgnunet_plugin_xxx_yyy.so: plugin for API xxx | ||
634 | @item libgnunetxxx.so: library for API xxx | ||
635 | @end itemize | ||
636 | |||
637 | @c *********************************************************************** | ||
638 | @node logging | ||
639 | @subsubsection logging | ||
640 | |||
641 | @itemize @bullet | ||
642 | @item services and daemons use their directory name in | ||
643 | @code{GNUNET_log_setup} (i.e. 'core') and log using | ||
644 | plain 'GNUNET_log'. | ||
645 | @item command-line tools use their full name in | ||
646 | @code{GNUNET_log_setup} (i.e. 'gnunet-publish') and log using | ||
647 | plain 'GNUNET_log'. | ||
648 | @item service access libraries log using | ||
649 | '@code{GNUNET_log_from}' and use '@code{DIRNAME-api}' for the | ||
650 | component (i.e. 'core-api') | ||
651 | @item pure libraries (without associated service) use | ||
652 | '@code{GNUNET_log_from}' with the component set to their | ||
653 | library name (without lib or '@file{.so}'), | ||
654 | which should also be their directory name (i.e. '@file{nat}') | ||
655 | @item plugins should use '@code{GNUNET_log_from}' | ||
656 | with the directory name and the plugin name combined to produce | ||
657 | the component name (i.e. 'transport-tcp'). | ||
658 | @item logging should be unified per-file by defining a | ||
659 | @code{LOG} macro with the appropriate arguments, | ||
660 | along these lines: | ||
661 | |||
662 | @example | ||
663 | #define LOG(kind,...) | ||
664 | GNUNET_log_from (kind, "example-api",__VA_ARGS__) | ||
665 | @end example | ||
666 | |||
667 | @end itemize | ||
668 | |||
669 | @c *********************************************************************** | ||
670 | @node configuration | ||
671 | @subsubsection configuration | ||
672 | |||
673 | @itemize @bullet | ||
674 | @item paths (that are substituted in all filenames) are in PATHS | ||
675 | (have as few as possible) | ||
676 | @item all options for a particular module (@file{src/MODULE}) | ||
677 | are under @code{[MODULE]} | ||
678 | @item options for a plugin of a module | ||
679 | are under @code{[MODULE-PLUGINNAME]} | ||
680 | @end itemize | ||
681 | |||
682 | @c *********************************************************************** | ||
683 | @node exported symbols | ||
684 | @subsubsection exported symbols | ||
685 | |||
686 | @itemize @bullet | ||
687 | @item must start with "@code{GNUNET_modulename_}" and be defined in | ||
688 | "@file{modulename.c}" | ||
689 | @item exceptions: those defined in @file{gnunet_common.h} | ||
690 | @end itemize | ||
691 | |||
692 | @c *********************************************************************** | ||
693 | @node private (library-internal) symbols (including structs and macros) | ||
694 | @subsubsection private (library-internal) symbols (including structs and macros) | ||
695 | |||
696 | @itemize @bullet | ||
697 | @item must NOT start with any prefix | ||
698 | @item must not be exported in a way that linkers could use them or@ other | ||
699 | libraries might see them via headers; they must be either | ||
700 | declared/defined in C source files or in headers that are in the | ||
701 | respective directory under @file{src/modulename/} and NEVER be declared | ||
702 | in @file{src/include/}. | ||
703 | @end itemize | ||
704 | |||
705 | @node testcases | ||
706 | @subsubsection testcases | ||
707 | |||
708 | @itemize @bullet | ||
709 | @item must be called "@file{test_module-under-test_case-description.c}" | ||
710 | @item "case-description" maybe omitted if there is only one test | ||
711 | @end itemize | ||
712 | |||
713 | @c *********************************************************************** | ||
714 | @node performance tests | ||
715 | @subsubsection performance tests | ||
716 | |||
717 | @itemize @bullet | ||
718 | @item must be called "@file{perf_module-under-test_case-description.c}" | ||
719 | @item "case-description" maybe omitted if there is only one performance | ||
720 | test | ||
721 | @item Must only be run if @code{HAVE_BENCHMARKS} is satisfied | ||
722 | @end itemize | ||
723 | |||
724 | @c *********************************************************************** | ||
725 | @node src/ directories | ||
726 | @subsubsection src/ directories | ||
727 | |||
728 | @itemize @bullet | ||
729 | @item gnunet-NAME: end-user applications (i.e., gnunet-search, gnunet-arm) | ||
730 | @item gnunet-service-NAME: service processes with accessor library (i.e., | ||
731 | gnunet-service-arm) | ||
732 | @item libgnunetNAME: accessor library (_service.h-header) or standalone | ||
733 | library (_lib.h-header) | ||
734 | @item gnunet-daemon-NAME: daemon process without accessor library (i.e., | ||
735 | gnunet-daemon-hostlist) and no GNUnet management port | ||
736 | @item libgnunet_plugin_DIR_NAME: loadable plugins (i.e., | ||
737 | libgnunet_plugin_transport_tcp) | ||
738 | @end itemize | ||
739 | |||
740 | @cindex Coding style | ||
741 | @node Coding style | ||
742 | @subsection Coding style | ||
743 | |||
744 | @itemize @bullet | ||
745 | @item We follow the GNU Coding Standards (@pxref{Top, The GNU Coding Standards,, standards, The GNU Coding Standards}); | ||
746 | @item Indentation is done with spaces, two per level, no tabs; | ||
747 | @item C99 struct initialization is fine; | ||
748 | @item declare only one variable per line, for example: | ||
749 | |||
750 | @noindent | ||
751 | instead of | ||
752 | |||
753 | @example | ||
754 | int i,j; | ||
755 | @end example | ||
756 | |||
757 | @noindent | ||
758 | write: | ||
759 | |||
760 | @example | ||
761 | int i; | ||
762 | int j; | ||
763 | @end example | ||
764 | |||
765 | @c TODO: include actual example from a file in source | ||
766 | |||
767 | @noindent | ||
768 | This helps keep diffs small and forces developers to think precisely about | ||
769 | the type of every variable. | ||
770 | Note that @code{char *} is different from @code{const char*} and | ||
771 | @code{int} is different from @code{unsigned int} or @code{uint32_t}. | ||
772 | Each variable type should be chosen with care. | ||
773 | |||
774 | @item While @code{goto} should generally be avoided, having a | ||
775 | @code{goto} to the end of a function to a block of clean up | ||
776 | statements (free, close, etc.) can be acceptable. | ||
777 | |||
778 | @item Conditions should be written with constants on the left (to avoid | ||
779 | accidental assignment) and with the 'true' target being either the | ||
780 | 'error' case or the significantly simpler continuation. For example: | ||
781 | |||
782 | @example | ||
783 | if (0 != stat ("filename," &sbuf)) @{ | ||
784 | error(); | ||
785 | @} | ||
786 | else @{ | ||
787 | /* handle normal case here */ | ||
788 | @} | ||
789 | @end example | ||
790 | |||
791 | @noindent | ||
792 | instead of | ||
793 | |||
794 | @example | ||
795 | if (stat ("filename," &sbuf) == 0) @{ | ||
796 | /* handle normal case here */ | ||
797 | @} else @{ | ||
798 | error(); | ||
799 | @} | ||
800 | @end example | ||
801 | |||
802 | @noindent | ||
803 | If possible, the error clause should be terminated with a 'return' (or | ||
804 | 'goto' to some cleanup routine) and in this case, the 'else' clause | ||
805 | should be omitted: | ||
806 | |||
807 | @example | ||
808 | if (0 != stat ("filename," &sbuf)) @{ | ||
809 | error(); | ||
810 | return; | ||
811 | @} | ||
812 | /* handle normal case here */ | ||
813 | @end example | ||
814 | |||
815 | This serves to avoid deep nesting. The 'constants on the left' rule | ||
816 | applies to all constants (including. @code{GNUNET_SCHEDULER_NO_TASK}), | ||
817 | NULL, and enums). With the two above rules (constants on left, errors in | ||
818 | 'true' branch), there is only one way to write most branches correctly. | ||
819 | |||
820 | @item Combined assignments and tests are allowed if they do not hinder | ||
821 | code clarity. For example, one can write: | ||
822 | |||
823 | @example | ||
824 | if (NULL == (value = lookup_function())) @{ | ||
825 | error(); | ||
826 | return; | ||
827 | @} | ||
828 | @end example | ||
829 | |||
830 | @item Use @code{break} and @code{continue} wherever possible to avoid | ||
831 | deep(er) nesting. Thus, we would write: | ||
832 | |||
833 | @example | ||
834 | next = head; | ||
835 | while (NULL != (pos = next)) @{ | ||
836 | next = pos->next; | ||
837 | if (! should_free (pos)) | ||
838 | continue; | ||
839 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
840 | GNUNET_free (pos); | ||
841 | @} | ||
842 | @end example | ||
843 | |||
844 | instead of | ||
845 | |||
846 | @example | ||
847 | next = head; while (NULL != (pos = next)) @{ | ||
848 | next = pos->next; | ||
849 | if (should_free (pos)) @{ | ||
850 | /* unnecessary nesting! */ | ||
851 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
852 | GNUNET_free (pos); | ||
853 | @} | ||
854 | @} | ||
855 | @end example | ||
856 | |||
857 | @item We primarily use @code{for} and @code{while} loops. | ||
858 | A @code{while} loop is used if the method for advancing in the loop is | ||
859 | not a straightforward increment operation. In particular, we use: | ||
860 | |||
861 | @example | ||
862 | next = head; | ||
863 | while (NULL != (pos = next)) | ||
864 | @{ | ||
865 | next = pos->next; | ||
866 | if (! should_free (pos)) | ||
867 | continue; | ||
868 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
869 | GNUNET_free (pos); | ||
870 | @} | ||
871 | @end example | ||
872 | |||
873 | to free entries in a list (as the iteration changes the structure of the | ||
874 | list due to the free; the equivalent @code{for} loop does no longer | ||
875 | follow the simple @code{for} paradigm of @code{for(INIT;TEST;INC)}). | ||
876 | However, for loops that do follow the simple @code{for} paradigm we do | ||
877 | use @code{for}, even if it involves linked lists: | ||
878 | |||
879 | @example | ||
880 | /* simple iteration over a linked list */ | ||
881 | for (pos = head; | ||
882 | NULL != pos; | ||
883 | pos = pos->next) | ||
884 | @{ | ||
885 | use (pos); | ||
886 | @} | ||
887 | @end example | ||
888 | |||
889 | |||
890 | @item The first argument to all higher-order functions in GNUnet must be | ||
891 | declared to be of type @code{void *} and is reserved for a closure. We do | ||
892 | not use inner functions, as trampolines would conflict with setups that | ||
893 | use non-executable stacks. | ||
894 | The first statement in a higher-order function, which unusually should | ||
895 | be part of the variable declarations, should assign the | ||
896 | @code{cls} argument to the precise expected type. For example: | ||
897 | |||
898 | @example | ||
899 | int callback (void *cls, char *args) @{ | ||
900 | struct Foo *foo = cls; | ||
901 | int other_variables; | ||
902 | |||
903 | /* rest of function */ | ||
904 | @} | ||
905 | @end example | ||
906 | |||
907 | |||
908 | @item It is good practice to write complex @code{if} expressions instead | ||
909 | of using deeply nested @code{if} statements. However, except for addition | ||
910 | and multiplication, all operators should use parens. This is fine: | ||
911 | |||
912 | @example | ||
913 | if ( (1 == foo) || ((0 == bar) && (x != y)) ) | ||
914 | return x; | ||
915 | @end example | ||
916 | |||
917 | |||
918 | However, this is not: | ||
919 | |||
920 | @example | ||
921 | if (1 == foo) | ||
922 | return x; | ||
923 | if (0 == bar && x != y) | ||
924 | return x; | ||
925 | @end example | ||
926 | |||
927 | @noindent | ||
928 | Note that splitting the @code{if} statement above is debateable as the | ||
929 | @code{return x} is a very trivial statement. However, once the logic after | ||
930 | the branch becomes more complicated (and is still identical), the "or" | ||
931 | formulation should be used for sure. | ||
932 | |||
933 | @item There should be two empty lines between the end of the function and | ||
934 | the comments describing the following function. There should be a single | ||
935 | empty line after the initial variable declarations of a function. If a | ||
936 | function has no local variables, there should be no initial empty line. If | ||
937 | a long function consists of several complex steps, those steps might be | ||
938 | separated by an empty line (possibly followed by a comment describing the | ||
939 | following step). The code should not contain empty lines in arbitrary | ||
940 | places; if in doubt, it is likely better to NOT have an empty line (this | ||
941 | way, more code will fit on the screen). | ||
942 | @end itemize | ||
943 | |||
944 | @c *********************************************************************** | ||
945 | @node Build-system | ||
946 | @section Build-system | ||
947 | |||
948 | If you have code that is likely not to compile or build rules you might | ||
949 | want to not trigger for most developers, use @code{if HAVE_EXPERIMENTAL} | ||
950 | in your @file{Makefile.am}. | ||
951 | Then it is OK to (temporarily) add non-compiling (or known-to-not-port) | ||
952 | code. | ||
953 | |||
954 | If you want to compile all testcases but NOT run them, run configure with | ||
955 | the @code{--enable-test-suppression} option. | ||
956 | |||
957 | If you want to run all testcases, including those that take a while, run | ||
958 | configure with the @code{--enable-expensive-testcases} option. | ||
959 | |||
960 | If you want to compile and run benchmarks, run configure with the | ||
961 | @code{--enable-benchmarks} option. | ||
962 | |||
963 | If you want to obtain code coverage results, run configure with the | ||
964 | @code{--enable-coverage} option and run the @file{coverage.sh} script in | ||
965 | the @file{contrib/} directory. | ||
966 | |||
967 | @cindex gnunet-ext | ||
968 | @node Developing extensions for GNUnet using the gnunet-ext template | ||
969 | @section Developing extensions for GNUnet using the gnunet-ext template | ||
970 | |||
971 | For developers who want to write extensions for GNUnet we provide the | ||
972 | gnunet-ext template to provide an easy to use skeleton. | ||
973 | |||
974 | gnunet-ext contains the build environment and template files for the | ||
975 | development of GNUnet services, command line tools, APIs and tests. | ||
976 | |||
977 | First of all you have to obtain gnunet-ext from git: | ||
978 | |||
979 | @example | ||
980 | git clone https://gnunet.org/git/gnunet-ext.git | ||
981 | @end example | ||
982 | |||
983 | The next step is to bootstrap and configure it. For configure you have to | ||
984 | provide the path containing GNUnet with | ||
985 | @code{--with-gnunet=/path/to/gnunet} and the prefix where you want the | ||
986 | install the extension using @code{--prefix=/path/to/install}: | ||
987 | |||
988 | @example | ||
989 | ./bootstrap | ||
990 | ./configure --prefix=/path/to/install --with-gnunet=/path/to/gnunet | ||
991 | @end example | ||
992 | |||
993 | When your GNUnet installation is not included in the default linker search | ||
994 | path, you have to add @code{/path/to/gnunet} to the file | ||
995 | @file{/etc/ld.so.conf} and run @code{ldconfig} or your add it to the | ||
996 | environmental variable @code{LD_LIBRARY_PATH} by using | ||
997 | |||
998 | @example | ||
999 | export LD_LIBRARY_PATH=/path/to/gnunet/lib | ||
1000 | @end example | ||
1001 | |||
1002 | @cindex writing testcases | ||
1003 | @node Writing testcases | ||
1004 | @section Writing testcases | ||
1005 | |||
1006 | Ideally, any non-trivial GNUnet code should be covered by automated | ||
1007 | testcases. Testcases should reside in the same place as the code that is | ||
1008 | being tested. The name of source files implementing tests should begin | ||
1009 | with "@code{test_}" followed by the name of the file | ||
1010 | that contains the code that is being tested. | ||
1011 | |||
1012 | Testcases in GNUnet should be integrated with the autotools build system. | ||
1013 | This way, developers and anyone building binary packages will be able to | ||
1014 | run all testcases simply by running @code{make check}. The final | ||
1015 | testcases shipped with the distribution should output at most some brief | ||
1016 | progress information and not display debug messages by default. The | ||
1017 | success or failure of a testcase must be indicated by returning zero | ||
1018 | (success) or non-zero (failure) from the main method of the testcase. | ||
1019 | The integration with the autotools is relatively straightforward and only | ||
1020 | requires modifications to the @file{Makefile.am} in the directory | ||
1021 | containing the testcase. For a testcase testing the code in @file{foo.c} | ||
1022 | the @file{Makefile.am} would contain the following lines: | ||
1023 | |||
1024 | @example | ||
1025 | check_PROGRAMS = test_foo | ||
1026 | TESTS = $(check_PROGRAMS) | ||
1027 | test_foo_SOURCES = test_foo.c | ||
1028 | test_foo_LDADD = $(top_builddir)/src/util/libgnunetutil.la | ||
1029 | @end example | ||
1030 | |||
1031 | Naturally, other libraries used by the testcase may be specified in the | ||
1032 | @code{LDADD} directive as necessary. | ||
1033 | |||
1034 | Often testcases depend on additional input files, such as a configuration | ||
1035 | file. These support files have to be listed using the @code{EXTRA_DIST} | ||
1036 | directive in order to ensure that they are included in the distribution. | ||
1037 | |||
1038 | Example: | ||
1039 | |||
1040 | @example | ||
1041 | EXTRA_DIST = test_foo_data.conf | ||
1042 | @end example | ||
1043 | |||
1044 | Executing @code{make check} will run all testcases in the current | ||
1045 | directory and all subdirectories. Testcases can be compiled individually | ||
1046 | by running @code{make test_foo} and then invoked directly using | ||
1047 | @code{./test_foo}. Note that due to the use of plugins in GNUnet, it is | ||
1048 | typically necessary to run @code{make install} before running any | ||
1049 | testcases. Thus the canonical command @code{make check install} has to be | ||
1050 | changed to @code{make install check} for GNUnet. | ||
1051 | |||
1052 | @cindex TESTING library | ||
1053 | @node GNUnet's TESTING library | ||
1054 | @section GNUnet's TESTING library | ||
1055 | |||
1056 | The TESTING library is used for writing testcases which involve starting a | ||
1057 | single or multiple peers. While peers can also be started by testcases | ||
1058 | using the ARM subsystem, using TESTING library provides an elegant way to | ||
1059 | do this. The configurations of the peers are auto-generated from a given | ||
1060 | template to have non-conflicting port numbers ensuring that peers' | ||
1061 | services do not run into bind errors. This is achieved by testing ports' | ||
1062 | availability by binding a listening socket to them before allocating them | ||
1063 | to services in the generated configurations. | ||
1064 | |||
1065 | An another advantage while using TESTING is that it shortens the testcase | ||
1066 | startup time as the hostkeys for peers are copied from a pre-computed set | ||
1067 | of hostkeys instead of generating them at peer startup which may take a | ||
1068 | considerable amount of time when starting multiple peers or on an embedded | ||
1069 | processor. | ||
1070 | |||
1071 | TESTING also allows for certain services to be shared among peers. This | ||
1072 | feature is invaluable when testing with multiple peers as it helps to | ||
1073 | reduce the number of services run per each peer and hence the total | ||
1074 | number of processes run per testcase. | ||
1075 | |||
1076 | TESTING library only handles creating, starting and stopping peers. | ||
1077 | Features useful for testcases such as connecting peers in a topology are | ||
1078 | not available in TESTING but are available in the TESTBED subsystem. | ||
1079 | Furthermore, TESTING only creates peers on the localhost, however by | ||
1080 | using TESTBED testcases can benefit from creating peers across multiple | ||
1081 | hosts. | ||
1082 | |||
1083 | @menu | ||
1084 | * API:: | ||
1085 | * Finer control over peer stop:: | ||
1086 | * Helper functions:: | ||
1087 | * Testing with multiple processes:: | ||
1088 | @end menu | ||
1089 | |||
1090 | @cindex TESTING API | ||
1091 | @node API | ||
1092 | @subsection API | ||
1093 | |||
1094 | TESTING abstracts a group of peers as a TESTING system. All peers in a | ||
1095 | system have common hostname and no two services of these peers have a | ||
1096 | same port or a UNIX domain socket path. | ||
1097 | |||
1098 | TESTING system can be created with the function | ||
1099 | @code{GNUNET_TESTING_system_create()} which returns a handle to the | ||
1100 | system. This function takes a directory path which is used for generating | ||
1101 | the configurations of peers, an IP address from which connections to the | ||
1102 | peers' services should be allowed, the hostname to be used in peers' | ||
1103 | configuration, and an array of shared service specifications of type | ||
1104 | @code{struct GNUNET_TESTING_SharedService}. | ||
1105 | |||
1106 | The shared service specification must specify the name of the service to | ||
1107 | share, the configuration pertaining to that shared service and the | ||
1108 | maximum number of peers that are allowed to share a single instance of | ||
1109 | the shared service. | ||
1110 | |||
1111 | TESTING system created with @code{GNUNET_TESTING_system_create()} chooses | ||
1112 | ports from the default range @code{12000} - @code{56000} while | ||
1113 | auto-generating configurations for peers. | ||
1114 | This range can be customised with the function | ||
1115 | @code{GNUNET_TESTING_system_create_with_portrange()}. This function is | ||
1116 | similar to @code{GNUNET_TESTING_system_create()} except that it take 2 | ||
1117 | additional parameters --- the start and end of the port range to use. | ||
1118 | |||
1119 | A TESTING system is destroyed with the funciton | ||
1120 | @code{GNUNET_TESTING_system_destory()}. This function takes the handle of | ||
1121 | the system and a flag to remove the files created in the directory used | ||
1122 | to generate configurations. | ||
1123 | |||
1124 | A peer is created with the function | ||
1125 | @code{GNUNET_TESTING_peer_configure()}. This functions takes the system | ||
1126 | handle, a configuration template from which the configuration for the peer | ||
1127 | is auto-generated and the index from where the hostkey for the peer has to | ||
1128 | be copied from. When successfull, this function returs a handle to the | ||
1129 | peer which can be used to start and stop it and to obtain the identity of | ||
1130 | the peer. If unsuccessful, a NULL pointer is returned with an error | ||
1131 | message. This function handles the generated configuration to have | ||
1132 | non-conflicting ports and paths. | ||
1133 | |||
1134 | Peers can be started and stopped by calling the functions | ||
1135 | @code{GNUNET_TESTING_peer_start()} and @code{GNUNET_TESTING_peer_stop()} | ||
1136 | respectively. A peer can be destroyed by calling the function | ||
1137 | @code{GNUNET_TESTING_peer_destroy}. When a peer is destroyed, the ports | ||
1138 | and paths in allocated in its configuration are reclaimed for usage in new | ||
1139 | peers. | ||
1140 | |||
1141 | @c *********************************************************************** | ||
1142 | @node Finer control over peer stop | ||
1143 | @subsection Finer control over peer stop | ||
1144 | |||
1145 | Using @code{GNUNET_TESTING_peer_stop()} is normally fine for testcases. | ||
1146 | However, calling this function for each peer is inefficient when trying to | ||
1147 | shutdown multiple peers as this function sends the termination signal to | ||
1148 | the given peer process and waits for it to terminate. It would be faster | ||
1149 | in this case to send the termination signals to the peers first and then | ||
1150 | wait on them. This is accomplished by the functions | ||
1151 | @code{GNUNET_TESTING_peer_kill()} which sends a termination signal to the | ||
1152 | peer, and the function @code{GNUNET_TESTING_peer_wait()} which waits on | ||
1153 | the peer. | ||
1154 | |||
1155 | Further finer control can be achieved by choosing to stop a peer | ||
1156 | asynchronously with the function @code{GNUNET_TESTING_peer_stop_async()}. | ||
1157 | This function takes a callback parameter and a closure for it in addition | ||
1158 | to the handle to the peer to stop. The callback function is called with | ||
1159 | the given closure when the peer is stopped. Using this function | ||
1160 | eliminates blocking while waiting for the peer to terminate. | ||
1161 | |||
1162 | An asynchronous peer stop can be cancelled by calling the function | ||
1163 | @code{GNUNET_TESTING_peer_stop_async_cancel()}. Note that calling this | ||
1164 | function does not prevent the peer from terminating if the termination | ||
1165 | signal has already been sent to it. It does, however, cancels the | ||
1166 | callback to be called when the peer is stopped. | ||
1167 | |||
1168 | @c *********************************************************************** | ||
1169 | @node Helper functions | ||
1170 | @subsection Helper functions | ||
1171 | |||
1172 | Most of the testcases can benefit from an abstraction which configures a | ||
1173 | peer and starts it. This is provided by the function | ||
1174 | @code{GNUNET_TESTING_peer_run()}. This function takes the testing | ||
1175 | directory pathname, a configuration template, a callback and its closure. | ||
1176 | This function creates a peer in the given testing directory by using the | ||
1177 | configuration template, starts the peer and calls the given callback with | ||
1178 | the given closure. | ||
1179 | |||
1180 | The function @code{GNUNET_TESTING_peer_run()} starts the ARM service of | ||
1181 | the peer which starts the rest of the configured services. A similar | ||
1182 | function @code{GNUNET_TESTING_service_run} can be used to just start a | ||
1183 | single service of a peer. In this case, the peer's ARM service is not | ||
1184 | started; instead, only the given service is run. | ||
1185 | |||
1186 | @c *********************************************************************** | ||
1187 | @node Testing with multiple processes | ||
1188 | @subsection Testing with multiple processes | ||
1189 | |||
1190 | When testing GNUnet, the splitting of the code into a services and clients | ||
1191 | often complicates testing. The solution to this is to have the testcase | ||
1192 | fork @code{gnunet-service-arm}, ask it to start the required server and | ||
1193 | daemon processes and then execute appropriate client actions (to test the | ||
1194 | client APIs or the core module or both). If necessary, multiple ARM | ||
1195 | services can be forked using different ports (!) to simulate a network. | ||
1196 | However, most of the time only one ARM process is needed. Note that on | ||
1197 | exit, the testcase should shutdown ARM with a @code{TERM} signal (to give | ||
1198 | it the chance to cleanly stop its child processes). | ||
1199 | |||
1200 | The following code illustrates spawning and killing an ARM process from a | ||
1201 | testcase: | ||
1202 | |||
1203 | @example | ||
1204 | static void run (void *cls, | ||
1205 | char *const *args, | ||
1206 | const char *cfgfile, | ||
1207 | const struct GNUNET_CONFIGURATION_Handle *cfg) @{ | ||
1208 | struct GNUNET_OS_Process *arm_pid; | ||
1209 | arm_pid = GNUNET_OS_start_process (NULL, | ||
1210 | NULL, | ||
1211 | "gnunet-service-arm", | ||
1212 | "gnunet-service-arm", | ||
1213 | "-c", | ||
1214 | cfgname, | ||
1215 | NULL); | ||
1216 | /* do real test work here */ | ||
1217 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) | ||
1218 | GNUNET_log_strerror | ||
1219 | (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
1220 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); | ||
1221 | GNUNET_OS_process_close (arm_pid); @} | ||
1222 | |||
1223 | GNUNET_PROGRAM_run (argc, argv, | ||
1224 | "NAME-OF-TEST", | ||
1225 | "nohelp", | ||
1226 | options, | ||
1227 | &run, | ||
1228 | cls); | ||
1229 | @end example | ||
1230 | |||
1231 | |||
1232 | An alternative way that works well to test plugins is to implement a | ||
1233 | mock-version of the environment that the plugin expects and then to | ||
1234 | simply load the plugin directly. | ||
1235 | |||
1236 | @c *********************************************************************** | ||
1237 | @node Performance regression analysis with Gauger | ||
1238 | @section Performance regression analysis with Gauger | ||
1239 | |||
1240 | To help avoid performance regressions, GNUnet uses Gauger. Gauger is a | ||
1241 | simple logging tool that allows remote hosts to send performance data to | ||
1242 | a central server, where this data can be analyzed and visualized. Gauger | ||
1243 | shows graphs of the repository revisions and the performace data recorded | ||
1244 | for each revision, so sudden performance peaks or drops can be identified | ||
1245 | and linked to a specific revision number. | ||
1246 | |||
1247 | In the case of GNUnet, the buildbots log the performance data obtained | ||
1248 | during the tests after each build. The data can be accesed on GNUnet's | ||
1249 | Gauger page. | ||
1250 | |||
1251 | The menu on the left allows to select either the results of just one | ||
1252 | build bot (under "Hosts") or review the data from all hosts for a given | ||
1253 | test result (under "Metrics"). In case of very different absolute value | ||
1254 | of the results, for instance arm vs. amd64 machines, the option | ||
1255 | "Normalize" on a metric view can help to get an idea about the | ||
1256 | performance evolution across all hosts. | ||
1257 | |||
1258 | Using Gauger in GNUnet and having the performance of a module tracked over | ||
1259 | time is very easy. First of course, the testcase must generate some | ||
1260 | consistent metric, which makes sense to have logged. Highly volatile or | ||
1261 | random dependant metrics probably are not ideal candidates for meaningful | ||
1262 | regression detection. | ||
1263 | |||
1264 | To start logging any value, just include @code{gauger.h} in your testcase | ||
1265 | code. Then, use the macro @code{GAUGER()} to make the Buildbots log | ||
1266 | whatever value is of interest for you to @code{gnunet.org}'s Gauger | ||
1267 | server. No setup is necessary as most Buildbots have already everything | ||
1268 | in place and new metrics are created on demand. To delete a metric, you | ||
1269 | need to contact a member of the GNUnet development team (a file will need | ||
1270 | to be removed manually from the respective directory). | ||
1271 | |||
1272 | The code in the test should look like this: | ||
1273 | |||
1274 | @example | ||
1275 | [other includes] | ||
1276 | #include <gauger.h> | ||
1277 | |||
1278 | int main (int argc, char *argv[]) @{ | ||
1279 | |||
1280 | [run test, generate data] | ||
1281 | GAUGER("YOUR_MODULE", | ||
1282 | "METRIC_NAME", | ||
1283 | (float)value, | ||
1284 | "UNIT"); @} | ||
1285 | @end example | ||
1286 | |||
1287 | Where: | ||
1288 | |||
1289 | @table @asis | ||
1290 | |||
1291 | @item @strong{YOUR_MODULE} is a category in the gauger page and should be | ||
1292 | the name of the module or subsystem like "Core" or "DHT" | ||
1293 | @item @strong{METRIC} is | ||
1294 | the name of the metric being collected and should be concise and | ||
1295 | descriptive, like "PUT operations in sqlite-datastore". | ||
1296 | @item @strong{value} is the value | ||
1297 | of the metric that is logged for this run. | ||
1298 | @item @strong{UNIT} is the unit in | ||
1299 | which the value is measured, for instance "kb/s" or "kb of RAM/node". | ||
1300 | @end table | ||
1301 | |||
1302 | If you wish to use Gauger for your own project, you can grab a copy of the | ||
1303 | latest stable release or check out Gauger's Subversion repository. | ||
1304 | |||
1305 | @cindex TESTBED Subsystem | ||
1306 | @node GNUnet's TESTBED Subsystem | ||
1307 | @section GNUnet's TESTBED Subsystem | ||
1308 | |||
1309 | The TESTBED subsystem facilitates testing and measuring of multi-peer | ||
1310 | deployments on a single host or over multiple hosts. | ||
1311 | |||
1312 | The architecture of the testbed module is divided into the following: | ||
1313 | @itemize @bullet | ||
1314 | |||
1315 | @item Testbed API: An API which is used by the testing driver programs. It | ||
1316 | provides with functions for creating, destroying, starting, stopping | ||
1317 | peers, etc. | ||
1318 | |||
1319 | @item Testbed service (controller): A service which is started through the | ||
1320 | Testbed API. This service handles operations to create, destroy, start, | ||
1321 | stop peers, connect them, modify their configurations. | ||
1322 | |||
1323 | @item Testbed helper: When a controller has to be started on a host, the | ||
1324 | testbed API starts the testbed helper on that host which in turn starts | ||
1325 | the controller. The testbed helper receives a configuration for the | ||
1326 | controller through its stdin and changes it to ensure the controller | ||
1327 | doesn't run into any port conflict on that host. | ||
1328 | @end itemize | ||
1329 | |||
1330 | |||
1331 | The testbed service (controller) is different from the other GNUnet | ||
1332 | services in that it is not started by ARM and is not supposed to be run | ||
1333 | as a daemon. It is started by the testbed API through a testbed helper. | ||
1334 | In a typical scenario involving multiple hosts, a controller is started | ||
1335 | on each host. Controllers take up the actual task of creating peers, | ||
1336 | starting and stopping them on the hosts they run. | ||
1337 | |||
1338 | While running deployments on a single localhost the testbed API starts the | ||
1339 | testbed helper directly as a child process. When running deployments on | ||
1340 | remote hosts the testbed API starts Testbed Helpers on each remote host | ||
1341 | through remote shell. By default testbed API uses SSH as a remote shell. | ||
1342 | This can be changed by setting the environmental variable | ||
1343 | GNUNET_TESTBED_RSH_CMD to the required remote shell program. This | ||
1344 | variable can also contain parameters which are to be passed to the remote | ||
1345 | shell program. For e.g: | ||
1346 | |||
1347 | @example | ||
1348 | export GNUNET_TESTBED_RSH_CMD="ssh -o BatchMode=yes \ | ||
1349 | -o NoHostAuthenticationForLocalhost=yes %h"@ | ||
1350 | @end example | ||
1351 | |||
1352 | Substitutions are allowed int the above command string also allows for | ||
1353 | substitions. through placemarks which begin with a `%'. At present the | ||
1354 | following substitutions are supported | ||
1355 | |||
1356 | @itemize @bullet | ||
1357 | @item | ||
1358 | %h: hostname | ||
1359 | @item | ||
1360 | %u: username | ||
1361 | @item | ||
1362 | %p: port | ||
1363 | @end itemize | ||
1364 | |||
1365 | Note that the substitution placemark is replaced only when the | ||
1366 | corresponding field is available and only once. Specifying | ||
1367 | @example | ||
1368 | %u@atchar{}%h | ||
1369 | @end example | ||
1370 | doesn't work either. | ||
1371 | If you want to user username substitutions for SSH | ||
1372 | use the argument @code{-l} before the username substitution. | ||
1373 | For exmaple: | ||
1374 | @example | ||
1375 | ssh -l %u -p %p %h | ||
1376 | @end example | ||
1377 | |||
1378 | The testbed API and the helper communicate through the helpers stdin and | ||
1379 | stdout. As the helper is started through a remote shell on remote hosts | ||
1380 | any output messages from the remote shell interfere with the communication | ||
1381 | and results in a failure while starting the helper. For this reason, it is | ||
1382 | suggested to use flags to make the remote shells produce no output | ||
1383 | messages and to have password-less logins. The default remote shell, SSH, | ||
1384 | the default options are: | ||
1385 | |||
1386 | @example | ||
1387 | -o BatchMode=yes -o NoHostBasedAuthenticationForLocalhost=yes" | ||
1388 | @end example | ||
1389 | |||
1390 | Password-less logins should be ensured by using SSH keys. | ||
1391 | |||
1392 | Since the testbed API executes the remote shell as a non-interactive | ||
1393 | shell, certain scripts like .bashrc, .profiler may not be executed. If | ||
1394 | this is the case testbed API can be forced to execute an interactive | ||
1395 | shell by setting up the environmental variable | ||
1396 | @code{GNUNET_TESTBED_RSH_CMD_SUFFIX} to a shell program. | ||
1397 | |||
1398 | An example could be: | ||
1399 | |||
1400 | @example | ||
1401 | export GNUNET_TESTBED_RSH_CMD_SUFFIX="sh -lc" | ||
1402 | @end example | ||
1403 | |||
1404 | The testbed API will then execute the remote shell program as: | ||
1405 | |||
1406 | @example | ||
1407 | $GNUNET_TESTBED_RSH_CMD -p $port $dest $GNUNET_TESTBED_RSH_CMD_SUFFIX \ | ||
1408 | gnunet-helper-testbed | ||
1409 | @end example | ||
1410 | |||
1411 | On some systems, problems may arise while starting testbed helpers if | ||
1412 | GNUnet is installed into a custom location since the helper may not be | ||
1413 | found in the standard path. This can be addressed by setting the variable | ||
1414 | `@code{HELPER_BINARY_PATH}' to the path of the testbed helper. | ||
1415 | Testbed API will then use this path to start helper binaries both | ||
1416 | locally and remotely. | ||
1417 | |||
1418 | Testbed API can accessed by including the | ||
1419 | "@file{gnunet_testbed_service.h}" file and linking with -lgnunettestbed. | ||
1420 | |||
1421 | @c *********************************************************************** | ||
1422 | @menu | ||
1423 | * Supported Topologies:: | ||
1424 | * Hosts file format:: | ||
1425 | * Topology file format:: | ||
1426 | * Testbed Barriers:: | ||
1427 | * Automatic large-scale deployment in the PlanetLab testbed:: | ||
1428 | * TESTBED Caveats:: | ||
1429 | @end menu | ||
1430 | |||
1431 | @node Supported Topologies | ||
1432 | @subsection Supported Topologies | ||
1433 | |||
1434 | While testing multi-peer deployments, it is often needed that the peers | ||
1435 | are connected in some topology. This requirement is addressed by the | ||
1436 | function @code{GNUNET_TESTBED_overlay_connect()} which connects any given | ||
1437 | two peers in the testbed. | ||
1438 | |||
1439 | The API also provides a helper function | ||
1440 | @code{GNUNET_TESTBED_overlay_configure_topology()} to connect a given set | ||
1441 | of peers in any of the following supported topologies: | ||
1442 | |||
1443 | @itemize @bullet | ||
1444 | |||
1445 | @item @code{GNUNET_TESTBED_TOPOLOGY_CLIQUE}: All peers are connected with | ||
1446 | each other | ||
1447 | |||
1448 | @item @code{GNUNET_TESTBED_TOPOLOGY_LINE}: Peers are connected to form a | ||
1449 | line | ||
1450 | |||
1451 | @item @code{GNUNET_TESTBED_TOPOLOGY_RING}: Peers are connected to form a | ||
1452 | ring topology | ||
1453 | |||
1454 | @item @code{GNUNET_TESTBED_TOPOLOGY_2D_TORUS}: Peers are connected to | ||
1455 | form a 2 dimensional torus topology. The number of peers may not be a | ||
1456 | perfect square, in that case the resulting torus may not have the uniform | ||
1457 | poloidal and toroidal lengths | ||
1458 | |||
1459 | @item @code{GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI}: Topology is generated | ||
1460 | to form a random graph. The number of links to be present should be given | ||
1461 | |||
1462 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD}: Peers are connected to | ||
1463 | form a 2D Torus with some random links among them. The number of random | ||
1464 | links are to be given | ||
1465 | |||
1466 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING}: Peers are | ||
1467 | connected to form a ring with some random links among them. The number of | ||
1468 | random links are to be given | ||
1469 | |||
1470 | @item @code{GNUNET_TESTBED_TOPOLOGY_SCALE_FREE}: Connects peers in a | ||
1471 | topology where peer connectivity follows power law - new peers are | ||
1472 | connected with high probabililty to well connected peers. | ||
1473 | @footnote{See Emergence of Scaling in Random Networks. Science 286, | ||
1474 | 509-512, 1999 | ||
1475 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/emergence_of_scaling_in_random_networks__barabasi_albert_science_286__1999.pdf, pdf})} | ||
1476 | |||
1477 | @item @code{GNUNET_TESTBED_TOPOLOGY_FROM_FILE}: The topology information | ||
1478 | is loaded from a file. The path to the file has to be given. | ||
1479 | @xref{Topology file format}, for the format of this file. | ||
1480 | |||
1481 | @item @code{GNUNET_TESTBED_TOPOLOGY_NONE}: No topology | ||
1482 | @end itemize | ||
1483 | |||
1484 | |||
1485 | The above supported topologies can be specified respectively by setting | ||
1486 | the variable @code{OVERLAY_TOPOLOGY} to the following values in the | ||
1487 | configuration passed to Testbed API functions | ||
1488 | @code{GNUNET_TESTBED_test_run()} and | ||
1489 | @code{GNUNET_TESTBED_run()}: | ||
1490 | |||
1491 | @itemize @bullet | ||
1492 | @item @code{CLIQUE} | ||
1493 | @item @code{RING} | ||
1494 | @item @code{LINE} | ||
1495 | @item @code{2D_TORUS} | ||
1496 | @item @code{RANDOM} | ||
1497 | @item @code{SMALL_WORLD} | ||
1498 | @item @code{SMALL_WORLD_RING} | ||
1499 | @item @code{SCALE_FREE} | ||
1500 | @item @code{FROM_FILE} | ||
1501 | @item @code{NONE} | ||
1502 | @end itemize | ||
1503 | |||
1504 | |||
1505 | Topologies @code{RANDOM}, @code{SMALL_WORLD} and @code{SMALL_WORLD_RING} | ||
1506 | require the option @code{OVERLAY_RANDOM_LINKS} to be set to the number of | ||
1507 | random links to be generated in the configuration. The option will be | ||
1508 | ignored for the rest of the topologies. | ||
1509 | |||
1510 | Topology @code{SCALE_FREE} requires the options | ||
1511 | @code{SCALE_FREE_TOPOLOGY_CAP} to be set to the maximum number of peers | ||
1512 | which can connect to a peer and @code{SCALE_FREE_TOPOLOGY_M} to be set to | ||
1513 | how many peers a peer should be atleast connected to. | ||
1514 | |||
1515 | Similarly, the topology @code{FROM_FILE} requires the option | ||
1516 | @code{OVERLAY_TOPOLOGY_FILE} to contain the path of the file containing | ||
1517 | the topology information. This option is ignored for the rest of the | ||
1518 | topologies. @xref{Topology file format}, for the format of this file. | ||
1519 | |||
1520 | @c *********************************************************************** | ||
1521 | @node Hosts file format | ||
1522 | @subsection Hosts file format | ||
1523 | |||
1524 | The testbed API offers the function | ||
1525 | @code{GNUNET_TESTBED_hosts_load_from_file()} to load from a given file | ||
1526 | details about the hosts which testbed can use for deploying peers. | ||
1527 | This function is useful to keep the data about hosts | ||
1528 | separate instead of hard coding them in code. | ||
1529 | |||
1530 | Another helper function from testbed API, @code{GNUNET_TESTBED_run()} | ||
1531 | also takes a hosts file name as its parameter. It uses the above | ||
1532 | function to populate the hosts data structures and start controllers to | ||
1533 | deploy peers. | ||
1534 | |||
1535 | These functions require the hosts file to be of the following format: | ||
1536 | @itemize @bullet | ||
1537 | @item Each line is interpreted to have details about a host | ||
1538 | @item Host details should include the username to use for logging into the | ||
1539 | host, the hostname of the host and the port number to use for the remote | ||
1540 | shell program. All thee values should be given. | ||
1541 | @item These details should be given in the following format: | ||
1542 | @example | ||
1543 | <username>@@<hostname>:<port> | ||
1544 | @end example | ||
1545 | @end itemize | ||
1546 | |||
1547 | Note that having canonical hostnames may cause problems while resolving | ||
1548 | the IP addresses (See this bug). Hence it is advised to provide the hosts' | ||
1549 | IP numerical addresses as hostnames whenever possible. | ||
1550 | |||
1551 | @c *********************************************************************** | ||
1552 | @node Topology file format | ||
1553 | @subsection Topology file format | ||
1554 | |||
1555 | A topology file describes how peers are to be connected. It should adhere | ||
1556 | to the following format for testbed to parse it correctly. | ||
1557 | |||
1558 | Each line should begin with the target peer id. This should be followed by | ||
1559 | a colon(`:') and origin peer ids seperated by `|'. All spaces except for | ||
1560 | newline characters are ignored. The API will then try to connect each | ||
1561 | origin peer to the target peer. | ||
1562 | |||
1563 | For example, the following file will result in 5 overlay connections: | ||
1564 | [2->1], [3->1],[4->3], [0->3], [2->0]@ | ||
1565 | @code{@ 1:2|3@ 3:4| 0@ 0: 2@ } | ||
1566 | |||
1567 | @c *********************************************************************** | ||
1568 | @node Testbed Barriers | ||
1569 | @subsection Testbed Barriers | ||
1570 | |||
1571 | The testbed subsystem's barriers API facilitates coordination among the | ||
1572 | peers run by the testbed and the experiment driver. The concept is | ||
1573 | similar to the barrier synchronisation mechanism found in parallel | ||
1574 | programming or multi-threading paradigms - a peer waits at a barrier upon | ||
1575 | reaching it until the barrier is reached by a predefined number of peers. | ||
1576 | This predefined number of peers required to cross a barrier is also called | ||
1577 | quorum. We say a peer has reached a barrier if the peer is waiting for the | ||
1578 | barrier to be crossed. Similarly a barrier is said to be reached if the | ||
1579 | required quorum of peers reach the barrier. A barrier which is reached is | ||
1580 | deemed as crossed after all the peers waiting on it are notified. | ||
1581 | |||
1582 | The barriers API provides the following functions: | ||
1583 | @itemize @bullet | ||
1584 | @item @strong{@code{GNUNET_TESTBED_barrier_init()}:} function to | ||
1585 | initialse a barrier in the experiment | ||
1586 | @item @strong{@code{GNUNET_TESTBED_barrier_cancel()}:} function to cancel | ||
1587 | a barrier which has been initialised before | ||
1588 | @item @strong{@code{GNUNET_TESTBED_barrier_wait()}:} function to signal | ||
1589 | barrier service that the caller has reached a barrier and is waiting for | ||
1590 | it to be crossed | ||
1591 | @item @strong{@code{GNUNET_TESTBED_barrier_wait_cancel()}:} function to | ||
1592 | stop waiting for a barrier to be crossed | ||
1593 | @end itemize | ||
1594 | |||
1595 | |||
1596 | Among the above functions, the first two, namely | ||
1597 | @code{GNUNET_TESTBED_barrier_init()} and | ||
1598 | @code{GNUNET_TESTBED_barrier_cancel()} are used by experiment drivers. All | ||
1599 | barriers should be initialised by the experiment driver by calling | ||
1600 | @code{GNUNET_TESTBED_barrier_init()}. This function takes a name to | ||
1601 | identify the barrier, the quorum required for the barrier to be crossed | ||
1602 | and a notification callback for notifying the experiment driver when the | ||
1603 | barrier is crossed. @code{GNUNET_TESTBED_barrier_cancel()} cancels an | ||
1604 | initialised barrier and frees the resources allocated for it. This | ||
1605 | function can be called upon a initialised barrier before it is crossed. | ||
1606 | |||
1607 | The remaining two functions @code{GNUNET_TESTBED_barrier_wait()} and | ||
1608 | @code{GNUNET_TESTBED_barrier_wait_cancel()} are used in the peer's | ||
1609 | processes. @code{GNUNET_TESTBED_barrier_wait()} connects to the local | ||
1610 | barrier service running on the same host the peer is running on and | ||
1611 | registers that the caller has reached the barrier and is waiting for the | ||
1612 | barrier to be crossed. Note that this function can only be used by peers | ||
1613 | which are started by testbed as this function tries to access the local | ||
1614 | barrier service which is part of the testbed controller service. Calling | ||
1615 | @code{GNUNET_TESTBED_barrier_wait()} on an uninitialised barrier results | ||
1616 | in failure. @code{GNUNET_TESTBED_barrier_wait_cancel()} cancels the | ||
1617 | notification registered by @code{GNUNET_TESTBED_barrier_wait()}. | ||
1618 | |||
1619 | |||
1620 | @c *********************************************************************** | ||
1621 | @menu | ||
1622 | * Implementation:: | ||
1623 | @end menu | ||
1624 | |||
1625 | @node Implementation | ||
1626 | @subsubsection Implementation | ||
1627 | |||
1628 | Since barriers involve coordination between experiment driver and peers, | ||
1629 | the barrier service in the testbed controller is split into two | ||
1630 | components. The first component responds to the message generated by the | ||
1631 | barrier API used by the experiment driver (functions | ||
1632 | @code{GNUNET_TESTBED_barrier_init()} and | ||
1633 | @code{GNUNET_TESTBED_barrier_cancel()}) and the second component to the | ||
1634 | messages generated by barrier API used by peers (functions | ||
1635 | @code{GNUNET_TESTBED_barrier_wait()} and | ||
1636 | @code{GNUNET_TESTBED_barrier_wait_cancel()}). | ||
1637 | |||
1638 | Calling @code{GNUNET_TESTBED_barrier_init()} sends a | ||
1639 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT} message to the master | ||
1640 | controller. The master controller then registers a barrier and calls | ||
1641 | @code{GNUNET_TESTBED_barrier_init()} for each its subcontrollers. In this | ||
1642 | way barrier initialisation is propagated to the controller hierarchy. | ||
1643 | While propagating initialisation, any errors at a subcontroller such as | ||
1644 | timeout during further propagation are reported up the hierarchy back to | ||
1645 | the experiment driver. | ||
1646 | |||
1647 | Similar to @code{GNUNET_TESTBED_barrier_init()}, | ||
1648 | @code{GNUNET_TESTBED_barrier_cancel()} propagates | ||
1649 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL} message which causes | ||
1650 | controllers to remove an initialised barrier. | ||
1651 | |||
1652 | The second component is implemented as a separate service in the binary | ||
1653 | `gnunet-service-testbed' which already has the testbed controller service. | ||
1654 | Although this deviates from the gnunet process architecture of having one | ||
1655 | service per binary, it is needed in this case as this component needs | ||
1656 | access to barrier data created by the first component. This component | ||
1657 | responds to @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages from | ||
1658 | local peers when they call @code{GNUNET_TESTBED_barrier_wait()}. Upon | ||
1659 | receiving @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} message, the | ||
1660 | service checks if the requested barrier has been initialised before and | ||
1661 | if it was not initialised, an error status is sent through | ||
1662 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to the local | ||
1663 | peer and the connection from the peer is terminated. If the barrier is | ||
1664 | initialised before, the barrier's counter for reached peers is incremented | ||
1665 | and a notification is registered to notify the peer when the barrier is | ||
1666 | reached. The connection from the peer is left open. | ||
1667 | |||
1668 | When enough peers required to attain the quorum send | ||
1669 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages, the controller | ||
1670 | sends a @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to its | ||
1671 | parent informing that the barrier is crossed. If the controller has | ||
1672 | started further subcontrollers, it delays this message until it receives | ||
1673 | a similar notification from each of those subcontrollers. Finally, the | ||
1674 | barriers API at the experiment driver receives the | ||
1675 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} when the barrier is | ||
1676 | reached at all the controllers. | ||
1677 | |||
1678 | The barriers API at the experiment driver responds to the | ||
1679 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message by echoing it | ||
1680 | back to the master controller and notifying the experiment controller | ||
1681 | through the notification callback that a barrier has been crossed. The | ||
1682 | echoed @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message is | ||
1683 | propagated by the master controller to the controller hierarchy. This | ||
1684 | propagation triggers the notifications registered by peers at each of the | ||
1685 | controllers in the hierarchy. Note the difference between this downward | ||
1686 | propagation of the @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} | ||
1687 | message from its upward propagation --- the upward propagation is needed | ||
1688 | for ensuring that the barrier is reached by all the controllers and the | ||
1689 | downward propagation is for triggering that the barrier is crossed. | ||
1690 | |||
1691 | @cindex PlanetLab testbed | ||
1692 | @node Automatic large-scale deployment in the PlanetLab testbed | ||
1693 | @subsection Automatic large-scale deployment in the PlanetLab testbed | ||
1694 | |||
1695 | PlanetLab is a testbed for computer networking and distributed systems | ||
1696 | research. It was established in 2002 and as of June 2010 was composed of | ||
1697 | 1090 nodes at 507 sites worldwide. | ||
1698 | |||
1699 | To automate the GNUnet we created a set of automation tools to simplify | ||
1700 | the large-scale deployment. We provide you a set of scripts you can use | ||
1701 | to deploy GNUnet on a set of nodes and manage your installation. | ||
1702 | |||
1703 | Please also check @uref{https://gnunet.org/installation-fedora8-svn} and | ||
1704 | @uref{https://gnunet.org/installation-fedora12-svn} to find detailled | ||
1705 | instructions how to install GNUnet on a PlanetLab node. | ||
1706 | |||
1707 | |||
1708 | @c *********************************************************************** | ||
1709 | @menu | ||
1710 | * PlanetLab Automation for Fedora8 nodes:: | ||
1711 | * Install buildslave on PlanetLab nodes running fedora core 8:: | ||
1712 | * Setup a new PlanetLab testbed using GPLMT:: | ||
1713 | * Why do i get an ssh error when using the regex profiler?:: | ||
1714 | @end menu | ||
1715 | |||
1716 | @node PlanetLab Automation for Fedora8 nodes | ||
1717 | @subsubsection PlanetLab Automation for Fedora8 nodes | ||
1718 | |||
1719 | @c *********************************************************************** | ||
1720 | @node Install buildslave on PlanetLab nodes running fedora core 8 | ||
1721 | @subsubsection Install buildslave on PlanetLab nodes running fedora core 8 | ||
1722 | @c ** Actually this is a subsubsubsection, but must be fixed differently | ||
1723 | @c ** as subsubsection is the lowest. | ||
1724 | |||
1725 | Since most of the PlanetLab nodes are running the very old Fedora core 8 | ||
1726 | image, installing the buildslave software is quite some pain. For our | ||
1727 | PlanetLab testbed we figured out how to install the buildslave software | ||
1728 | best. | ||
1729 | |||
1730 | @c This is a vvery terrible way to suggest installing software. | ||
1731 | @c FIXME: Is there an official, safer way instead of blind-piping a | ||
1732 | @c script? | ||
1733 | @c FIXME: Use newer pypi URLs below. | ||
1734 | Install Distribute for Python: | ||
1735 | |||
1736 | @example | ||
1737 | curl http://python-distribute.org/distribute_setup.py | sudo python | ||
1738 | @end example | ||
1739 | |||
1740 | Install Distribute for zope.interface <= 3.8.0 (4.0 and 4.0.1 will not | ||
1741 | work): | ||
1742 | |||
1743 | @example | ||
1744 | export PYPI=@value{PYPI-URL} | ||
1745 | wget $PYPI/z/zope.interface/zope.interface-3.8.0.tar.gz | ||
1746 | tar zvfz zope.interface-3.8.0.tar.gz | ||
1747 | cd zope.interface-3.8.0 | ||
1748 | sudo python setup.py install | ||
1749 | @end example | ||
1750 | |||
1751 | Install the buildslave software (0.8.6 was the latest version): | ||
1752 | |||
1753 | @example | ||
1754 | export GCODE="http://buildbot.googlecode.com/files" | ||
1755 | wget $GCODE/buildbot-slave-0.8.6p1.tar.gz | ||
1756 | tar xvfz buildbot-slave-0.8.6p1.tar.gz | ||
1757 | cd buildslave-0.8.6p1 | ||
1758 | sudo python setup.py install | ||
1759 | @end example | ||
1760 | |||
1761 | The setup will download the matching twisted package and install it. | ||
1762 | It will also try to install the latest version of zope.interface which | ||
1763 | will fail to install. Buildslave will work anyway since version 3.8.0 | ||
1764 | was installed before! | ||
1765 | |||
1766 | @c *********************************************************************** | ||
1767 | @node Setup a new PlanetLab testbed using GPLMT | ||
1768 | @subsubsection Setup a new PlanetLab testbed using GPLMT | ||
1769 | |||
1770 | @itemize @bullet | ||
1771 | @item Get a new slice and assign nodes | ||
1772 | Ask your PlanetLab PI to give you a new slice and assign the nodes you | ||
1773 | need | ||
1774 | @item Install a buildmaster | ||
1775 | You can stick to the buildbot documentation:@ | ||
1776 | @uref{http://buildbot.net/buildbot/docs/current/manual/installation.html} | ||
1777 | @item Install the buildslave software on all nodes | ||
1778 | To install the buildslave on all nodes assigned to your slice you can use | ||
1779 | the tasklist @code{install_buildslave_fc8.xml} provided with GPLMT: | ||
1780 | |||
1781 | @example | ||
1782 | ./gplmt.py -c contrib/tumple_gnunet.conf -t \ | ||
1783 | contrib/tasklists/install_buildslave_fc8.xml -a -p <planetlab password> | ||
1784 | @end example | ||
1785 | |||
1786 | @item Create the buildmaster configuration and the slave setup commands | ||
1787 | |||
1788 | The master and the and the slaves have need to have credentials and the | ||
1789 | master has to have all nodes configured. This can be done with the | ||
1790 | @file{create_buildbot_configuration.py} script in the @file{scripts} | ||
1791 | directory. | ||
1792 | |||
1793 | This scripts takes a list of nodes retrieved directly from PlanetLab or | ||
1794 | read from a file and a configuration template and creates: | ||
1795 | |||
1796 | @itemize @bullet | ||
1797 | @item a tasklist which can be executed with gplmt to setup the slaves | ||
1798 | @item a master.cfg file containing a PlanetLab nodes | ||
1799 | @end itemize | ||
1800 | |||
1801 | A configuration template is included in the <contrib>, most important is | ||
1802 | that the script replaces the following tags in the template: | ||
1803 | |||
1804 | %GPLMT_BUILDER_DEFINITION :@ GPLMT_BUILDER_SUMMARY@ GPLMT_SLAVES@ | ||
1805 | %GPLMT_SCHEDULER_BUILDERS | ||
1806 | |||
1807 | Create configuration for all nodes assigned to a slice: | ||
1808 | |||
1809 | @example | ||
1810 | ./create_buildbot_configuration.py -u <planetlab username> \ | ||
1811 | -p <planetlab password> -s <slice> -m <buildmaster+port> \ | ||
1812 | -t <template> | ||
1813 | @end example | ||
1814 | |||
1815 | Create configuration for some nodes in a file: | ||
1816 | |||
1817 | @example | ||
1818 | ./create_buildbot_configuration.p -f <node_file> \ | ||
1819 | -m <buildmaster+port> -t <template> | ||
1820 | @end example | ||
1821 | |||
1822 | @item Copy the @file{master.cfg} to the buildmaster and start it | ||
1823 | Use @code{buildbot start <basedir>} to start the server | ||
1824 | @item Setup the buildslaves | ||
1825 | @end itemize | ||
1826 | |||
1827 | @c *********************************************************************** | ||
1828 | @node Why do i get an ssh error when using the regex profiler? | ||
1829 | @subsubsection Why do i get an ssh error when using the regex profiler? | ||
1830 | |||
1831 | Why do i get an ssh error "Permission denied (publickey,password)." when | ||
1832 | using the regex profiler although passwordless ssh to localhost works | ||
1833 | using publickey and ssh-agent? | ||
1834 | |||
1835 | You have to generate a public/private-key pair with no password:@ | ||
1836 | @code{ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_localhost}@ | ||
1837 | and then add the following to your ~/.ssh/config file: | ||
1838 | |||
1839 | @code{Host 127.0.0.1@ IdentityFile ~/.ssh/id_localhost} | ||
1840 | |||
1841 | now make sure your hostsfile looks like | ||
1842 | |||
1843 | @example | ||
1844 | [USERNAME]@@127.0.0.1:22@ | ||
1845 | [USERNAME]@@127.0.0.1:22 | ||
1846 | @end example | ||
1847 | |||
1848 | You can test your setup by running @code{ssh 127.0.0.1} in a | ||
1849 | terminal and then in the opened session run it again. | ||
1850 | If you were not asked for a password on either login, | ||
1851 | then you should be good to go. | ||
1852 | |||
1853 | @cindex TESTBED Caveats | ||
1854 | @node TESTBED Caveats | ||
1855 | @subsection TESTBED Caveats | ||
1856 | |||
1857 | This section documents a few caveats when using the GNUnet testbed | ||
1858 | subsystem. | ||
1859 | |||
1860 | @c *********************************************************************** | ||
1861 | @menu | ||
1862 | * CORE must be started:: | ||
1863 | * ATS must want the connections:: | ||
1864 | @end menu | ||
1865 | |||
1866 | @node CORE must be started | ||
1867 | @subsubsection CORE must be started | ||
1868 | |||
1869 | A simple issue is #3993: Your configuration MUST somehow ensure that for | ||
1870 | each peer the CORE service is started when the peer is setup, otherwise | ||
1871 | TESTBED may fail to connect peers when the topology is initialized, as | ||
1872 | TESTBED will start some CORE services but not necessarily all (but it | ||
1873 | relies on all of them running). The easiest way is to set | ||
1874 | 'FORCESTART = YES' in the '[core]' section of the configuration file. | ||
1875 | Alternatively, having any service that directly or indirectly depends on | ||
1876 | CORE being started with FORCESTART will also do. This issue largely arises | ||
1877 | if users try to over-optimize by not starting any services with | ||
1878 | FORCESTART. | ||
1879 | |||
1880 | @c *********************************************************************** | ||
1881 | @node ATS must want the connections | ||
1882 | @subsubsection ATS must want the connections | ||
1883 | |||
1884 | When TESTBED sets up connections, it only offers the respective HELLO | ||
1885 | information to the TRANSPORT service. It is then up to the ATS service to | ||
1886 | @strong{decide} to use the connection. The ATS service will typically | ||
1887 | eagerly establish any connection if the number of total connections is | ||
1888 | low (relative to bandwidth). Details may further depend on the | ||
1889 | specific ATS backend that was configured. If ATS decides to NOT establish | ||
1890 | a connection (even though TESTBED provided the required information), then | ||
1891 | that connection will count as failed for TESTBED. Note that you can | ||
1892 | configure TESTBED to tolerate a certain number of connection failures | ||
1893 | (see '-e' option of gnunet-testbed-profiler). This issue largely arises | ||
1894 | for dense overlay topologies, especially if you try to create cliques | ||
1895 | with more than 20 peers. | ||
1896 | |||
1897 | @cindex libgnunetutil | ||
1898 | @node libgnunetutil | ||
1899 | @section libgnunetutil | ||
1900 | |||
1901 | libgnunetutil is the fundamental library that all GNUnet code builds upon. | ||
1902 | Ideally, this library should contain most of the platform dependent code | ||
1903 | (except for user interfaces and really special needs that only few | ||
1904 | applications have). It is also supposed to offer basic services that most | ||
1905 | if not all GNUnet binaries require. The code of libgnunetutil is in the | ||
1906 | @file{src/util/} directory. The public interface to the library is in the | ||
1907 | gnunet_util.h header. The functions provided by libgnunetutil fall | ||
1908 | roughly into the following categories (in roughly the order of importance | ||
1909 | for new developers): | ||
1910 | |||
1911 | @itemize @bullet | ||
1912 | @item logging (common_logging.c) | ||
1913 | @item memory allocation (common_allocation.c) | ||
1914 | @item endianess conversion (common_endian.c) | ||
1915 | @item internationalization (common_gettext.c) | ||
1916 | @item String manipulation (string.c) | ||
1917 | @item file access (disk.c) | ||
1918 | @item buffered disk IO (bio.c) | ||
1919 | @item time manipulation (time.c) | ||
1920 | @item configuration parsing (configuration.c) | ||
1921 | @item command-line handling (getopt*.c) | ||
1922 | @item cryptography (crypto_*.c) | ||
1923 | @item data structures (container_*.c) | ||
1924 | @item CPS-style scheduling (scheduler.c) | ||
1925 | @item Program initialization (program.c) | ||
1926 | @item Networking (network.c, client.c, server*.c, service.c) | ||
1927 | @item message queueing (mq.c) | ||
1928 | @item bandwidth calculations (bandwidth.c) | ||
1929 | @item Other OS-related (os*.c, plugin.c, signal.c) | ||
1930 | @item Pseudonym management (pseudonym.c) | ||
1931 | @end itemize | ||
1932 | |||
1933 | It should be noted that only developers that fully understand this entire | ||
1934 | API will be able to write good GNUnet code. | ||
1935 | |||
1936 | Ideally, porting GNUnet should only require porting the gnunetutil | ||
1937 | library. More testcases for the gnunetutil APIs are therefore a great | ||
1938 | way to make porting of GNUnet easier. | ||
1939 | |||
1940 | @menu | ||
1941 | * Logging:: | ||
1942 | * Interprocess communication API (IPC):: | ||
1943 | * Cryptography API:: | ||
1944 | * Message Queue API:: | ||
1945 | * Service API:: | ||
1946 | * Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps:: | ||
1947 | * The CONTAINER_MDLL API:: | ||
1948 | @end menu | ||
1949 | |||
1950 | @cindex Logging | ||
1951 | @cindex log levels | ||
1952 | @node Logging | ||
1953 | @subsection Logging | ||
1954 | |||
1955 | GNUnet is able to log its activity, mostly for the purposes of debugging | ||
1956 | the program at various levels. | ||
1957 | |||
1958 | @file{gnunet_common.h} defines several @strong{log levels}: | ||
1959 | @table @asis | ||
1960 | |||
1961 | @item ERROR for errors (really problematic situations, often leading to | ||
1962 | crashes) | ||
1963 | @item WARNING for warnings (troubling situations that might have | ||
1964 | negative consequences, although not fatal) | ||
1965 | @item INFO for various information. | ||
1966 | Used somewhat rarely, as GNUnet statistics is used to hold and display | ||
1967 | most of the information that users might find interesting. | ||
1968 | @item DEBUG for debugging. | ||
1969 | Does not produce much output on normal builds, but when extra logging is | ||
1970 | enabled at compile time, a staggering amount of data is outputted under | ||
1971 | this log level. | ||
1972 | @end table | ||
1973 | |||
1974 | |||
1975 | Normal builds of GNUnet (configured with @code{--enable-logging[=yes]}) | ||
1976 | are supposed to log nothing under DEBUG level. The | ||
1977 | @code{--enable-logging=verbose} configure option can be used to create a | ||
1978 | build with all logging enabled. However, such build will produce large | ||
1979 | amounts of log data, which is inconvenient when one tries to hunt down a | ||
1980 | specific problem. | ||
1981 | |||
1982 | To mitigate this problem, GNUnet provides facilities to apply a filter to | ||
1983 | reduce the logs: | ||
1984 | @table @asis | ||
1985 | |||
1986 | @item Logging by default When no log levels are configured in any other | ||
1987 | way (see below), GNUnet will default to the WARNING log level. This | ||
1988 | mostly applies to GNUnet command line utilities, services and daemons; | ||
1989 | tests will always set log level to WARNING or, if | ||
1990 | @code{--enable-logging=verbose} was passed to configure, to DEBUG. The | ||
1991 | default level is suggested for normal operation. | ||
1992 | @item The -L option Most GNUnet executables accept an "-L loglevel" or | ||
1993 | "--log=loglevel" option. If used, it makes the process set a global log | ||
1994 | level to "loglevel". Thus it is possible to run some processes | ||
1995 | with -L DEBUG, for example, and others with -L ERROR to enable specific | ||
1996 | settings to diagnose problems with a particular process. | ||
1997 | @item Configuration files. Because GNUnet | ||
1998 | service and deamon processes are usually launched by gnunet-arm, it is not | ||
1999 | possible to pass different custom command line options directly to every | ||
2000 | one of them. The options passed to @code{gnunet-arm} only affect | ||
2001 | gnunet-arm and not the rest of GNUnet. However, one can specify a | ||
2002 | configuration key "OPTIONS" in the section that corresponds to a service | ||
2003 | or a daemon, and put a value of "-L loglevel" there. This will make the | ||
2004 | respective service or daemon set its log level to "loglevel" (as the | ||
2005 | value of OPTIONS will be passed as a command-line argument). | ||
2006 | |||
2007 | To specify the same log level for all services without creating separate | ||
2008 | "OPTIONS" entries in the configuration for each one, the user can specify | ||
2009 | a config key "GLOBAL_POSTFIX" in the [arm] section of the configuration | ||
2010 | file. The value of GLOBAL_POSTFIX will be appended to all command lines | ||
2011 | used by the ARM service to run other services. It can contain any option | ||
2012 | valid for all GNUnet commands, thus in particular the "-L loglevel" | ||
2013 | option. The ARM service itself is, however, unaffected by GLOBAL_POSTFIX; | ||
2014 | to set log level for it, one has to specify "OPTIONS" key in the [arm] | ||
2015 | section. | ||
2016 | @item Environment variables. | ||
2017 | Setting global per-process log levels with "-L loglevel" does not offer | ||
2018 | sufficient log filtering granularity, as one service will call interface | ||
2019 | libraries and supporting libraries of other GNUnet services, potentially | ||
2020 | producing lots of debug log messages from these libraries. Also, changing | ||
2021 | the config file is not always convenient (especially when running the | ||
2022 | GNUnet test suite).@ To fix that, and to allow GNUnet to use different | ||
2023 | log filtering at runtime without re-compiling the whole source tree, the | ||
2024 | log calls were changed to be configurable at run time. To configure them | ||
2025 | one has to define environment variables "GNUNET_FORCE_LOGFILE", | ||
2026 | "GNUNET_LOG" and/or "GNUNET_FORCE_LOG": | ||
2027 | @itemize @bullet | ||
2028 | |||
2029 | @item "GNUNET_LOG" only affects the logging when no global log level is | ||
2030 | configured by any other means (that is, the process does not explicitly | ||
2031 | set its own log level, there are no "-L loglevel" options on command line | ||
2032 | or in configuration files), and can be used to override the default | ||
2033 | WARNING log level. | ||
2034 | |||
2035 | @item "GNUNET_FORCE_LOG" will completely override any other log | ||
2036 | configuration options given. | ||
2037 | |||
2038 | @item "GNUNET_FORCE_LOGFILE" will completely override the location of the | ||
2039 | file to log messages to. It should contain a relative or absolute file | ||
2040 | name. Setting GNUNET_FORCE_LOGFILE is equivalent to passing | ||
2041 | "--log-file=logfile" or "-l logfile" option (see below). It supports "[]" | ||
2042 | format in file names, but not "@{@}" (see below). | ||
2043 | @end itemize | ||
2044 | |||
2045 | |||
2046 | Because environment variables are inherited by child processes when they | ||
2047 | are launched, starting or re-starting the ARM service with these | ||
2048 | variables will propagate them to all other services. | ||
2049 | |||
2050 | "GNUNET_LOG" and "GNUNET_FORCE_LOG" variables must contain a specially | ||
2051 | formatted @strong{logging definition} string, which looks like this:@ | ||
2052 | |||
2053 | @c FIXME: Can we close this with [/component] instead? | ||
2054 | @example | ||
2055 | [component];[file];[function];[from_line[-to_line]];loglevel[/component...] | ||
2056 | @end example | ||
2057 | |||
2058 | That is, a logging definition consists of definition entries, separated by | ||
2059 | slashes ('/'). If only one entry is present, there is no need to add a | ||
2060 | slash to its end (although it is not forbidden either).@ All definition | ||
2061 | fields (component, file, function, lines and loglevel) are mandatory, but | ||
2062 | (except for the loglevel) they can be empty. An empty field means | ||
2063 | "match anything". Note that even if fields are empty, the semicolon (';') | ||
2064 | separators must be present.@ The loglevel field is mandatory, and must | ||
2065 | contain one of the log level names (ERROR, WARNING, INFO or DEBUG).@ | ||
2066 | The lines field might contain one non-negative number, in which case it | ||
2067 | matches only one line, or a range "from_line-to_line", in which case it | ||
2068 | matches any line in the interval [from_line;to_line] (that is, including | ||
2069 | both start and end line).@ GNUnet mostly defaults component name to the | ||
2070 | name of the service that is implemented in a process ('transport', | ||
2071 | 'core', 'peerinfo', etc), but logging calls can specify custom component | ||
2072 | names using @code{GNUNET_log_from}.@ File name and function name are | ||
2073 | provided by the compiler (__FILE__ and __FUNCTION__ built-ins). | ||
2074 | |||
2075 | Component, file and function fields are interpreted as non-extended | ||
2076 | regular expressions (GNU libc regex functions are used). Matching is | ||
2077 | case-sensitive, "^" and "$" will match the beginning and the end of the | ||
2078 | text. If a field is empty, its contents are automatically replaced with | ||
2079 | a ".*" regular expression, which matches anything. Matching is done in | ||
2080 | the default way, which means that the expression matches as long as it's | ||
2081 | contained anywhere in the string. Thus "GNUNET_" will match both | ||
2082 | "GNUNET_foo" and "BAR_GNUNET_BAZ". Use '^' and/or '$' to make sure that | ||
2083 | the expression matches at the start and/or at the end of the string. | ||
2084 | The semicolon (';') can't be escaped, and GNUnet will not use it in | ||
2085 | component names (it can't be used in function names and file names | ||
2086 | anyway). | ||
2087 | |||
2088 | @end table | ||
2089 | |||
2090 | |||
2091 | Every logging call in GNUnet code will be (at run time) matched against | ||
2092 | the log definitions passed to the process. If a log definition fields are | ||
2093 | matching the call arguments, then the call log level is compared the the | ||
2094 | log level of that definition. If the call log level is less or equal to | ||
2095 | the definition log level, the call is allowed to proceed. Otherwise the | ||
2096 | logging call is forbidden, and nothing is logged. If no definitions | ||
2097 | matched at all, GNUnet will use the global log level or (if a global log | ||
2098 | level is not specified) will default to WARNING (that is, it will allow | ||
2099 | the call to proceed, if its level is less or equal to the global log | ||
2100 | level or to WARNING). | ||
2101 | |||
2102 | That is, definitions are evaluated from left to right, and the first | ||
2103 | matching definition is used to allow or deny the logging call. Thus it is | ||
2104 | advised to place narrow definitions at the beginning of the logdef | ||
2105 | string, and generic definitions - at the end. | ||
2106 | |||
2107 | Whether a call is allowed or not is only decided the first time this | ||
2108 | particular call is made. The evaluation result is then cached, so that | ||
2109 | any attempts to make the same call later will be allowed or disallowed | ||
2110 | right away. Because of that runtime log level evaluation should not | ||
2111 | significantly affect the process performance. | ||
2112 | Log definition parsing is only done once, at the first call to | ||
2113 | GNUNET_log_setup () made by the process (which is usually done soon after | ||
2114 | it starts). | ||
2115 | |||
2116 | At the moment of writing there is no way to specify logging definitions | ||
2117 | from configuration files, only via environment variables. | ||
2118 | |||
2119 | At the moment GNUnet will stop processing a log definition when it | ||
2120 | encounters an error in definition formatting or an error in regular | ||
2121 | expression syntax, and will not report the failure in any way. | ||
2122 | |||
2123 | |||
2124 | @c *********************************************************************** | ||
2125 | @menu | ||
2126 | * Examples:: | ||
2127 | * Log files:: | ||
2128 | * Updated behavior of GNUNET_log:: | ||
2129 | @end menu | ||
2130 | |||
2131 | @node Examples | ||
2132 | @subsubsection Examples | ||
2133 | |||
2134 | @table @asis | ||
2135 | |||
2136 | @item @code{GNUNET_FORCE_LOG=";;;;DEBUG" gnunet-arm -s} Start GNUnet | ||
2137 | process tree, running all processes with DEBUG level (one should be | ||
2138 | careful with it, as log files will grow at alarming rate!) | ||
2139 | @item @code{GNUNET_FORCE_LOG="core;;;;DEBUG" gnunet-arm -s} Start GNUnet | ||
2140 | process tree, running the core service under DEBUG level (everything else | ||
2141 | will use configured or default level). | ||
2142 | |||
2143 | @item Start GNUnet process tree, allowing any logging calls from | ||
2144 | gnunet-service-transport_validation.c (everything else will use | ||
2145 | configured or default level). | ||
2146 | |||
2147 | @example | ||
2148 | GNUNET_FORCE_LOG=";gnunet-service-transport_validation.c;;; DEBUG" \ | ||
2149 | gnunet-arm -s | ||
2150 | @end example | ||
2151 | |||
2152 | @item Start GNUnet process tree, allowing any logging calls from | ||
2153 | gnunet-gnunet-service-fs_push.c (everything else will use configured or | ||
2154 | default level). | ||
2155 | |||
2156 | @example | ||
2157 | GNUNET_FORCE_LOG="fs;gnunet-service-fs_push.c;;;DEBUG" gnunet-arm -s | ||
2158 | @end example | ||
2159 | |||
2160 | @item Start GNUnet process tree, allowing any logging calls from the | ||
2161 | GNUNET_NETWORK_socket_select function (everything else will use | ||
2162 | configured or default level). | ||
2163 | |||
2164 | @example | ||
2165 | GNUNET_FORCE_LOG=";;GNUNET_NETWORK_socket_select;;DEBUG" gnunet-arm -s | ||
2166 | @end example | ||
2167 | |||
2168 | @item Start GNUnet process tree, allowing any logging calls from the | ||
2169 | components that have "transport" in their names, and are made from | ||
2170 | function that have "send" in their names. Everything else will be allowed | ||
2171 | to be logged only if it has WARNING level. | ||
2172 | |||
2173 | @example | ||
2174 | GNUNET_FORCE_LOG="transport.*;;.*send.*;;DEBUG/;;;;WARNING" gnunet-arm -s | ||
2175 | @end example | ||
2176 | |||
2177 | @end table | ||
2178 | |||
2179 | |||
2180 | On Windows, one can use batch files to run GNUnet processes with special | ||
2181 | environment variables, without affecting the whole system. Such batch | ||
2182 | file will look like this: | ||
2183 | |||
2184 | @example | ||
2185 | set GNUNET_FORCE_LOG=;;do_transmit;;DEBUG@ gnunet-arm -s | ||
2186 | @end example | ||
2187 | |||
2188 | (note the absence of double quotes in the environment variable definition, | ||
2189 | as opposed to earlier examples, which use the shell). | ||
2190 | Another limitation, on Windows, GNUNET_FORCE_LOGFILE @strong{MUST} be set | ||
2191 | in order to GNUNET_FORCE_LOG to work. | ||
2192 | |||
2193 | |||
2194 | @cindex Log files | ||
2195 | @node Log files | ||
2196 | @subsubsection Log files | ||
2197 | |||
2198 | GNUnet can be told to log everything into a file instead of stderr (which | ||
2199 | is the default) using the "--log-file=logfile" or "-l logfile" option. | ||
2200 | This option can also be passed via command line, or from the "OPTION" and | ||
2201 | "GLOBAL_POSTFIX" configuration keys (see above). The file name passed | ||
2202 | with this option is subject to GNUnet filename expansion. If specified in | ||
2203 | "GLOBAL_POSTFIX", it is also subject to ARM service filename expansion, | ||
2204 | in particular, it may contain "@{@}" (left and right curly brace) | ||
2205 | sequence, which will be replaced by ARM with the name of the service. | ||
2206 | This is used to keep logs from more than one service separate, while only | ||
2207 | specifying one template containing "@{@}" in GLOBAL_POSTFIX. | ||
2208 | |||
2209 | As part of a secondary file name expansion, the first occurrence of "[]" | ||
2210 | sequence ("left square brace" followed by "right square brace") in the | ||
2211 | file name will be replaced with a process identifier or the process when | ||
2212 | it initializes its logging subsystem. As a result, all processes will log | ||
2213 | into different files. This is convenient for isolating messages of a | ||
2214 | particular process, and prevents I/O races when multiple processes try to | ||
2215 | write into the file at the same time. This expansion is done | ||
2216 | independently of "@{@}" expansion that ARM service does (see above). | ||
2217 | |||
2218 | The log file name that is specified via "-l" can contain format characters | ||
2219 | from the 'strftime' function family. For example, "%Y" will be replaced | ||
2220 | with the current year. Using "basename-%Y-%m-%d.log" would include the | ||
2221 | current year, month and day in the log file. If a GNUnet process runs for | ||
2222 | long enough to need more than one log file, it will eventually clean up | ||
2223 | old log files. Currently, only the last three log files (plus the current | ||
2224 | log file) are preserved. So once the fifth log file goes into use (so | ||
2225 | after 4 days if you use "%Y-%m-%d" as above), the first log file will be | ||
2226 | automatically deleted. Note that if your log file name only contains "%Y", | ||
2227 | then log files would be kept for 4 years and the logs from the first year | ||
2228 | would be deleted once year 5 begins. If you do not use any date-related | ||
2229 | string format codes, logs would never be automatically deleted by GNUnet. | ||
2230 | |||
2231 | |||
2232 | @c *********************************************************************** | ||
2233 | |||
2234 | @node Updated behavior of GNUNET_log | ||
2235 | @subsubsection Updated behavior of GNUNET_log | ||
2236 | |||
2237 | It's currently quite common to see constructions like this all over the | ||
2238 | code: | ||
2239 | |||
2240 | @example | ||
2241 | #if MESH_DEBUG | ||
2242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client disconnected\n"); | ||
2243 | #endif | ||
2244 | @end example | ||
2245 | |||
2246 | The reason for the #if is not to avoid displaying the message when | ||
2247 | disabled (GNUNET_ERROR_TYPE takes care of that), but to avoid the | ||
2248 | compiler including it in the binary at all, when compiling GNUnet for | ||
2249 | platforms with restricted storage space / memory (MIPS routers, | ||
2250 | ARM plug computers / dev boards, etc). | ||
2251 | |||
2252 | This presents several problems: the code gets ugly, hard to write and it | ||
2253 | is very easy to forget to include the #if guards, creating non-consistent | ||
2254 | code. A new change in GNUNET_log aims to solve these problems. | ||
2255 | |||
2256 | @strong{This change requires to @file{./configure} with at least | ||
2257 | @code{--enable-logging=verbose} to see debug messages.} | ||
2258 | |||
2259 | Here is an example of code with dense debug statements: | ||
2260 | |||
2261 | @example | ||
2262 | switch (restrict_topology) @{ | ||
2263 | case GNUNET_TESTING_TOPOLOGY_CLIQUE:#if VERBOSE_TESTING | ||
2264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but clique | ||
2265 | topology\n")); #endif unblacklisted_connections = create_clique (pg, | ||
2266 | &remove_connections, BLACKLIST, GNUNET_NO); break; case | ||
2267 | GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: #if VERBOSE_TESTING GNUNET_log | ||
2268 | (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but small world (ring) | ||
2269 | topology\n")); #endif unblacklisted_connections = create_small_world_ring | ||
2270 | (pg,&remove_connections, BLACKLIST); break; | ||
2271 | @end example | ||
2272 | |||
2273 | |||
2274 | Pretty hard to follow, huh? | ||
2275 | |||
2276 | From now on, it is not necessary to include the #if / #endif statements to | ||
2277 | achieve the same behavior. The GNUNET_log and GNUNET_log_from macros take | ||
2278 | care of it for you, depending on the configure option: | ||
2279 | |||
2280 | @itemize @bullet | ||
2281 | @item If @code{--enable-logging} is set to @code{no}, the binary will | ||
2282 | contain no log messages at all. | ||
2283 | @item If @code{--enable-logging} is set to @code{yes}, the binary will | ||
2284 | contain no DEBUG messages, and therefore running with -L DEBUG will have | ||
2285 | no effect. Other messages (ERROR, WARNING, INFO, etc) will be included. | ||
2286 | @item If @code{--enable-logging} is set to @code{verbose}, or | ||
2287 | @code{veryverbose} the binary will contain DEBUG messages (still, it will | ||
2288 | be neccessary to run with -L DEBUG or set the DEBUG config option to show | ||
2289 | them). | ||
2290 | @end itemize | ||
2291 | |||
2292 | |||
2293 | If you are a developer: | ||
2294 | @itemize @bullet | ||
2295 | @item please make sure that you @code{./configure | ||
2296 | --enable-logging=@{verbose,veryverbose@}}, so you can see DEBUG messages. | ||
2297 | @item please remove the @code{#if} statements around @code{GNUNET_log | ||
2298 | (GNUNET_ERROR_TYPE_DEBUG, ...)} lines, to improve the readibility of your | ||
2299 | code. | ||
2300 | @end itemize | ||
2301 | |||
2302 | Since now activating DEBUG automatically makes it VERBOSE and activates | ||
2303 | @strong{all} debug messages by default, you probably want to use the | ||
2304 | https://gnunet.org/logging functionality to filter only relevant messages. | ||
2305 | A suitable configuration could be: | ||
2306 | |||
2307 | @example | ||
2308 | $ export GNUNET_FORCE_LOG="^YOUR_SUBSYSTEM$;;;;DEBUG/;;;;WARNING" | ||
2309 | @end example | ||
2310 | |||
2311 | Which will behave almost like enabling DEBUG in that subsytem before the | ||
2312 | change. Of course you can adapt it to your particular needs, this is only | ||
2313 | a quick example. | ||
2314 | |||
2315 | @cindex Interprocess communication API | ||
2316 | @cindex ICP | ||
2317 | @node Interprocess communication API (IPC) | ||
2318 | @subsection Interprocess communication API (IPC) | ||
2319 | |||
2320 | In GNUnet a variety of new message types might be defined and used in | ||
2321 | interprocess communication, in this tutorial we use the | ||
2322 | @code{struct AddressLookupMessage} as a example to introduce how to | ||
2323 | construct our own message type in GNUnet and how to implement the message | ||
2324 | communication between service and client. | ||
2325 | (Here, a client uses the @code{struct AddressLookupMessage} as a request | ||
2326 | to ask the server to return the address of any other peer connecting to | ||
2327 | the service.) | ||
2328 | |||
2329 | |||
2330 | @c *********************************************************************** | ||
2331 | @menu | ||
2332 | * Define new message types:: | ||
2333 | * Define message struct:: | ||
2334 | * Client - Establish connection:: | ||
2335 | * Client - Initialize request message:: | ||
2336 | * Client - Send request and receive response:: | ||
2337 | * Server - Startup service:: | ||
2338 | * Server - Add new handles for specified messages:: | ||
2339 | * Server - Process request message:: | ||
2340 | * Server - Response to client:: | ||
2341 | * Server - Notification of clients:: | ||
2342 | * Conversion between Network Byte Order (Big Endian) and Host Byte Order:: | ||
2343 | @end menu | ||
2344 | |||
2345 | @node Define new message types | ||
2346 | @subsubsection Define new message types | ||
2347 | |||
2348 | First of all, you should define the new message type in | ||
2349 | @file{gnunet_protocols.h}: | ||
2350 | |||
2351 | @example | ||
2352 | // Request to look addresses of peers in server. | ||
2353 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP 29 | ||
2354 | // Response to the address lookup request. | ||
2355 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY 30 | ||
2356 | @end example | ||
2357 | |||
2358 | @c *********************************************************************** | ||
2359 | @node Define message struct | ||
2360 | @subsubsection Define message struct | ||
2361 | |||
2362 | After the type definition, the specified message structure should also be | ||
2363 | described in the header file, e.g. transport.h in our case. | ||
2364 | |||
2365 | @example | ||
2366 | struct AddressLookupMessage @{ | ||
2367 | struct GNUNET_MessageHeader header; | ||
2368 | int32_t numeric_only GNUNET_PACKED; | ||
2369 | struct GNUNET_TIME_AbsoluteNBO timeout; | ||
2370 | uint32_t addrlen GNUNET_PACKED; | ||
2371 | /* followed by 'addrlen' bytes of the actual address, then | ||
2372 | followed by the 0-terminated name of the transport */ @}; | ||
2373 | GNUNET_NETWORK_STRUCT_END | ||
2374 | @end example | ||
2375 | |||
2376 | |||
2377 | Please note @code{GNUNET_NETWORK_STRUCT_BEGIN} and @code{GNUNET_PACKED} | ||
2378 | which both ensure correct alignment when sending structs over the network. | ||
2379 | |||
2380 | @menu | ||
2381 | @end menu | ||
2382 | |||
2383 | @c *********************************************************************** | ||
2384 | @node Client - Establish connection | ||
2385 | @subsubsection Client - Establish connection | ||
2386 | @c %**end of header | ||
2387 | |||
2388 | |||
2389 | At first, on the client side, the underlying API is employed to create a | ||
2390 | new connection to a service, in our example the transport service would be | ||
2391 | connected. | ||
2392 | |||
2393 | @example | ||
2394 | struct GNUNET_CLIENT_Connection *client; | ||
2395 | client = GNUNET_CLIENT_connect ("transport", cfg); | ||
2396 | @end example | ||
2397 | |||
2398 | @c *********************************************************************** | ||
2399 | @node Client - Initialize request message | ||
2400 | @subsubsection Client - Initialize request message | ||
2401 | @c %**end of header | ||
2402 | |||
2403 | When the connection is ready, we initialize the message. In this step, | ||
2404 | all the fields of the message should be properly initialized, namely the | ||
2405 | size, type, and some extra user-defined data, such as timeout, name of | ||
2406 | transport, address and name of transport. | ||
2407 | |||
2408 | @example | ||
2409 | struct AddressLookupMessage *msg; | ||
2410 | size_t len = sizeof (struct AddressLookupMessage) | ||
2411 | + addressLen | ||
2412 | + strlen (nameTrans) | ||
2413 | + 1; | ||
2414 | msg->header->size = htons (len); | ||
2415 | msg->header->type = htons | ||
2416 | (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); | ||
2417 | msg->timeout = GNUNET_TIME_absolute_hton (abs_timeout); | ||
2418 | msg->addrlen = htonl (addressLen); | ||
2419 | char *addrbuf = (char *) &msg[1]; | ||
2420 | memcpy (addrbuf, address, addressLen); | ||
2421 | char *tbuf = &addrbuf[addressLen]; | ||
2422 | memcpy (tbuf, nameTrans, strlen (nameTrans) + 1); | ||
2423 | @end example | ||
2424 | |||
2425 | Note that, here the functions @code{htonl}, @code{htons} and | ||
2426 | @code{GNUNET_TIME_absolute_hton} are applied to convert little endian | ||
2427 | into big endian, about the usage of the big/small edian order and the | ||
2428 | corresponding conversion function please refer to Introduction of | ||
2429 | Big Endian and Little Endian. | ||
2430 | |||
2431 | @c *********************************************************************** | ||
2432 | @node Client - Send request and receive response | ||
2433 | @subsubsection Client - Send request and receive response | ||
2434 | @c %**end of header | ||
2435 | |||
2436 | @b{FIXME: This is very outdated, see the tutorial for the current API!} | ||
2437 | |||
2438 | Next, the client would send the constructed message as a request to the | ||
2439 | service and wait for the response from the service. To accomplish this | ||
2440 | goal, there are a number of API calls that can be used. In this example, | ||
2441 | @code{GNUNET_CLIENT_transmit_and_get_response} is chosen as the most | ||
2442 | appropriate function to use. | ||
2443 | |||
2444 | @example | ||
2445 | GNUNET_CLIENT_transmit_and_get_response | ||
2446 | (client, msg->header, timeout, GNUNET_YES, &address_response_processor, | ||
2447 | arp_ctx); | ||
2448 | @end example | ||
2449 | |||
2450 | the argument @code{address_response_processor} is a function with | ||
2451 | @code{GNUNET_CLIENT_MessageHandler} type, which is used to process the | ||
2452 | reply message from the service. | ||
2453 | |||
2454 | @node Server - Startup service | ||
2455 | @subsubsection Server - Startup service | ||
2456 | |||
2457 | After receiving the request message, we run a standard GNUnet service | ||
2458 | startup sequence using @code{GNUNET_SERVICE_run}, as follows, | ||
2459 | |||
2460 | @example | ||
2461 | int main(int argc, char**argv) @{ | ||
2462 | GNUNET_SERVICE_run(argc, argv, "transport" | ||
2463 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)); @} | ||
2464 | @end example | ||
2465 | |||
2466 | @c *********************************************************************** | ||
2467 | @node Server - Add new handles for specified messages | ||
2468 | @subsubsection Server - Add new handles for specified messages | ||
2469 | @c %**end of header | ||
2470 | |||
2471 | in the function above the argument @code{run} is used to initiate | ||
2472 | transport service,and defined like this: | ||
2473 | |||
2474 | @example | ||
2475 | static void run (void *cls, | ||
2476 | struct GNUNET_SERVER_Handle *serv, | ||
2477 | const struct GNUNET_CONFIGURATION_Handle *cfg) @{ | ||
2478 | GNUNET_SERVER_add_handlers (serv, handlers); @} | ||
2479 | @end example | ||
2480 | |||
2481 | |||
2482 | Here, @code{GNUNET_SERVER_add_handlers} must be called in the run | ||
2483 | function to add new handlers in the service. The parameter | ||
2484 | @code{handlers} is a list of @code{struct GNUNET_SERVER_MessageHandler} | ||
2485 | to tell the service which function should be called when a particular | ||
2486 | type of message is received, and should be defined in this way: | ||
2487 | |||
2488 | @example | ||
2489 | static struct GNUNET_SERVER_MessageHandler handlers[] = @{ | ||
2490 | @{&handle_start, | ||
2491 | NULL, | ||
2492 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, | ||
2493 | 0@}, | ||
2494 | @{&handle_send, | ||
2495 | NULL, | ||
2496 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, | ||
2497 | 0@}, | ||
2498 | @{&handle_try_connect, | ||
2499 | NULL, | ||
2500 | GNUNET_MESSAGE_TYPE_TRANSPORT_TRY_CONNECT, | ||
2501 | sizeof (struct TryConnectMessage) | ||
2502 | @}, | ||
2503 | @{&handle_address_lookup, | ||
2504 | NULL, | ||
2505 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, | ||
2506 | 0@}, | ||
2507 | @{NULL, | ||
2508 | NULL, | ||
2509 | 0, | ||
2510 | 0@} | ||
2511 | @}; | ||
2512 | @end example | ||
2513 | |||
2514 | |||
2515 | As shown, the first member of the struct in the first area is a callback | ||
2516 | function, which is called to process the specified message types, given | ||
2517 | as the third member. The second parameter is the closure for the callback | ||
2518 | function, which is set to @code{NULL} in most cases, and the last | ||
2519 | parameter is the expected size of the message of this type, usually we | ||
2520 | set it to 0 to accept variable size, for special cases the exact size of | ||
2521 | the specified message also can be set. In addition, the terminator sign | ||
2522 | depicted as @code{@{NULL, NULL, 0, 0@}} is set in the last aera. | ||
2523 | |||
2524 | @c *********************************************************************** | ||
2525 | @node Server - Process request message | ||
2526 | @subsubsection Server - Process request message | ||
2527 | @c %**end of header | ||
2528 | |||
2529 | After the initialization of transport service, the request message would | ||
2530 | be processed. Before handling the main message data, the validity of this | ||
2531 | message should be checked out, e.g., to check whether the size of message | ||
2532 | is correct. | ||
2533 | |||
2534 | @example | ||
2535 | size = ntohs (message->size); | ||
2536 | if (size < sizeof (struct AddressLookupMessage)) @{ | ||
2537 | GNUNET_break_op (0); | ||
2538 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
2539 | return; @} | ||
2540 | @end example | ||
2541 | |||
2542 | |||
2543 | Note that, opposite to the construction method of the request message in | ||
2544 | the client, in the server the function @code{nothl} and @code{ntohs} | ||
2545 | should be employed during the extraction of the data from the message, so | ||
2546 | that the data in big endian order can be converted back into little | ||
2547 | endian order. See more in detail please refer to Introduction of | ||
2548 | Big Endian and Little Endian. | ||
2549 | |||
2550 | Moreover in this example, the name of the transport stored in the message | ||
2551 | is a 0-terminated string, so we should also check whether the name of the | ||
2552 | transport in the received message is 0-terminated: | ||
2553 | |||
2554 | @example | ||
2555 | nameTransport = (const char *) &address[addressLen]; | ||
2556 | if (nameTransport[size - sizeof | ||
2557 | (struct AddressLookupMessage) | ||
2558 | - addressLen - 1] != '\0') @{ | ||
2559 | GNUNET_break_op (0); | ||
2560 | GNUNET_SERVER_receive_done (client, | ||
2561 | GNUNET_SYSERR); | ||
2562 | return; @} | ||
2563 | @end example | ||
2564 | |||
2565 | Here, @code{GNUNET_SERVER_receive_done} should be called to tell the | ||
2566 | service that the request is done and can receive the next message. The | ||
2567 | argument @code{GNUNET_SYSERR} here indicates that the service didn't | ||
2568 | understand the request message, and the processing of this request would | ||
2569 | be terminated. | ||
2570 | |||
2571 | In comparison to the aforementioned situation, when the argument is equal | ||
2572 | to @code{GNUNET_OK}, the service would continue to process the requst | ||
2573 | message. | ||
2574 | |||
2575 | @c *********************************************************************** | ||
2576 | @node Server - Response to client | ||
2577 | @subsubsection Server - Response to client | ||
2578 | @c %**end of header | ||
2579 | |||
2580 | Once the processing of current request is done, the server should give the | ||
2581 | response to the client. A new @code{struct AddressLookupMessage} would be | ||
2582 | produced by the server in a similar way as the client did and sent to the | ||
2583 | client, but here the type should be | ||
2584 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY} rather than | ||
2585 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP} in client. | ||
2586 | @example | ||
2587 | struct AddressLookupMessage *msg; | ||
2588 | size_t len = sizeof (struct AddressLookupMessage) | ||
2589 | + addressLen | ||
2590 | + strlen (nameTrans) + 1; | ||
2591 | msg->header->size = htons (len); | ||
2592 | msg->header->type = htons | ||
2593 | (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
2594 | |||
2595 | // ... | ||
2596 | |||
2597 | struct GNUNET_SERVER_TransmitContext *tc; | ||
2598 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
2599 | GNUNET_SERVER_transmit_context_append_data | ||
2600 | (tc, | ||
2601 | NULL, | ||
2602 | 0, | ||
2603 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
2604 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); | ||
2605 | @end example | ||
2606 | |||
2607 | |||
2608 | Note that, there are also a number of other APIs provided to the service | ||
2609 | to send the message. | ||
2610 | |||
2611 | @c *********************************************************************** | ||
2612 | @node Server - Notification of clients | ||
2613 | @subsubsection Server - Notification of clients | ||
2614 | @c %**end of header | ||
2615 | |||
2616 | Often a service needs to (repeatedly) transmit notifications to a client | ||
2617 | or a group of clients. In these cases, the client typically has once | ||
2618 | registered for a set of events and then needs to receive a message | ||
2619 | whenever such an event happens (until the client disconnects). The use of | ||
2620 | a notification context can help manage message queues to clients and | ||
2621 | handle disconnects. Notification contexts can be used to send | ||
2622 | individualized messages to a particular client or to broadcast messages | ||
2623 | to a group of clients. An individualized notification might look like | ||
2624 | this: | ||
2625 | |||
2626 | @example | ||
2627 | GNUNET_SERVER_notification_context_unicast(nc, | ||
2628 | client, | ||
2629 | msg, | ||
2630 | GNUNET_YES); | ||
2631 | @end example | ||
2632 | |||
2633 | |||
2634 | Note that after processing the original registration message for | ||
2635 | notifications, the server code still typically needs to call | ||
2636 | @code{GNUNET_SERVER_receive_done} so that the client can transmit further | ||
2637 | messages to the server. | ||
2638 | |||
2639 | @c *********************************************************************** | ||
2640 | @node Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
2641 | @subsubsection Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
2642 | @c %** subsub? it's a referenced page on the ipc document. | ||
2643 | @c %**end of header | ||
2644 | |||
2645 | Here we can simply comprehend big endian and little endian as Network Byte | ||
2646 | Order and Host Byte Order respectively. What is the difference between | ||
2647 | both two? | ||
2648 | |||
2649 | Usually in our host computer we store the data byte as Host Byte Order, | ||
2650 | for example, we store a integer in the RAM which might occupies 4 Byte, | ||
2651 | as Host Byte Order the higher Byte would be stored at the lower address | ||
2652 | of RAM, and the lower Byte would be stored at the higher address of RAM. | ||
2653 | However, contrast to this, Network Byte Order just take the totally | ||
2654 | opposite way to store the data, says, it will store the lower Byte at the | ||
2655 | lower address, and the higher Byte will stay at higher address. | ||
2656 | |||
2657 | For the current communication of network, we normally exchange the | ||
2658 | information by surveying the data package, every two host wants to | ||
2659 | communicate with each other must send and receive data package through | ||
2660 | network. In order to maintain the identity of data through the | ||
2661 | transmission in the network, the order of the Byte storage must changed | ||
2662 | before sending and after receiving the data. | ||
2663 | |||
2664 | There ten convenient functions to realize the conversion of Byte Order in | ||
2665 | GNUnet, as following: | ||
2666 | |||
2667 | @table @asis | ||
2668 | |||
2669 | @item uint16_t htons(uint16_t hostshort) Convert host byte order to net | ||
2670 | byte order with short int | ||
2671 | @item uint32_t htonl(uint32_t hostlong) Convert host byte | ||
2672 | order to net byte order with long int | ||
2673 | @item uint16_t ntohs(uint16_t netshort) | ||
2674 | Convert net byte order to host byte order with short int | ||
2675 | @item uint32_t | ||
2676 | ntohl(uint32_t netlong) Convert net byte order to host byte order with | ||
2677 | long int | ||
2678 | @item unsigned long long GNUNET_ntohll (unsigned long long netlonglong) | ||
2679 | Convert net byte order to host byte order with long long int | ||
2680 | @item unsigned long long GNUNET_htonll (unsigned long long hostlonglong) | ||
2681 | Convert host byte order to net byte order with long long int | ||
2682 | @item struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton | ||
2683 | (struct GNUNET_TIME_Relative a) Convert relative time to network byte | ||
2684 | order. | ||
2685 | @item struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh | ||
2686 | (struct GNUNET_TIME_RelativeNBO a) Convert relative time from network | ||
2687 | byte order. | ||
2688 | @item struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton | ||
2689 | (struct GNUNET_TIME_Absolute a) Convert relative time to network byte | ||
2690 | order. | ||
2691 | @item struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh | ||
2692 | (struct GNUNET_TIME_AbsoluteNBO a) Convert relative time from network | ||
2693 | byte order. | ||
2694 | @end table | ||
2695 | |||
2696 | @cindex Cryptography API | ||
2697 | @node Cryptography API | ||
2698 | @subsection Cryptography API | ||
2699 | @c %**end of header | ||
2700 | |||
2701 | The gnunetutil APIs provides the cryptographic primitives used in GNUnet. | ||
2702 | GNUnet uses 2048 bit RSA keys for the session key exchange and for signing | ||
2703 | messages by peers and most other public-key operations. Most researchers | ||
2704 | in cryptography consider 2048 bit RSA keys as secure and practically | ||
2705 | unbreakable for a long time. The API provides functions to create a fresh | ||
2706 | key pair, read a private key from a file (or create a new file if the | ||
2707 | file does not exist), encrypt, decrypt, sign, verify and extraction of | ||
2708 | the public key into a format suitable for network transmission. | ||
2709 | |||
2710 | For the encryption of files and the actual data exchanged between peers | ||
2711 | GNUnet uses 256-bit AES encryption. Fresh, session keys are negotiated | ||
2712 | for every new connection.@ Again, there is no published technique to | ||
2713 | break this cipher in any realistic amount of time. The API provides | ||
2714 | functions for generation of keys, validation of keys (important for | ||
2715 | checking that decryptions using RSA succeeded), encryption and decryption. | ||
2716 | |||
2717 | GNUnet uses SHA-512 for computing one-way hash codes. The API provides | ||
2718 | functions to compute a hash over a block in memory or over a file on disk. | ||
2719 | |||
2720 | The crypto API also provides functions for randomizing a block of memory, | ||
2721 | obtaining a single random number and for generating a permuation of the | ||
2722 | numbers 0 to n-1. Random number generation distinguishes between WEAK and | ||
2723 | STRONG random number quality; WEAK random numbers are pseudo-random | ||
2724 | whereas STRONG random numbers use entropy gathered from the operating | ||
2725 | system. | ||
2726 | |||
2727 | Finally, the crypto API provides a means to deterministically generate a | ||
2728 | 1024-bit RSA key from a hash code. These functions should most likely not | ||
2729 | be used by most applications; most importantly, | ||
2730 | GNUNET_CRYPTO_rsa_key_create_from_hash does not create an RSA-key that | ||
2731 | should be considered secure for traditional applications of RSA. | ||
2732 | |||
2733 | @cindex Message Queue API | ||
2734 | @node Message Queue API | ||
2735 | @subsection Message Queue API | ||
2736 | @c %**end of header | ||
2737 | |||
2738 | @strong{ Introduction }@ | ||
2739 | Often, applications need to queue messages that | ||
2740 | are to be sent to other GNUnet peers, clients or services. As all of | ||
2741 | GNUnet's message-based communication APIs, by design, do not allow | ||
2742 | messages to be queued, it is common to implement custom message queues | ||
2743 | manually when they are needed. However, writing very similar code in | ||
2744 | multiple places is tedious and leads to code duplication. | ||
2745 | |||
2746 | MQ (for Message Queue) is an API that provides the functionality to | ||
2747 | implement and use message queues. We intend to eventually replace all of | ||
2748 | the custom message queue implementations in GNUnet with MQ. | ||
2749 | |||
2750 | @strong{ Basic Concepts }@ | ||
2751 | The two most important entities in MQ are queues and envelopes. | ||
2752 | |||
2753 | Every queue is backed by a specific implementation (e.g. for mesh, stream, | ||
2754 | connection, server client, etc.) that will actually deliver the queued | ||
2755 | messages. For convenience,@ some queues also allow to specify a list of | ||
2756 | message handlers. The message queue will then also wait for incoming | ||
2757 | messages and dispatch them appropriately. | ||
2758 | |||
2759 | An envelope holds the the memory for a message, as well as metadata | ||
2760 | (Where is the envelope queued? What should happen after it has been | ||
2761 | sent?). Any envelope can only be queued in one message queue. | ||
2762 | |||
2763 | @strong{ Creating Queues }@ | ||
2764 | The following is a list of currently available message queues. Note that | ||
2765 | to avoid layering issues, message queues for higher level APIs are not | ||
2766 | part of @code{libgnunetutil}, but@ the respective API itself provides the | ||
2767 | queue implementation. | ||
2768 | |||
2769 | @table @asis | ||
2770 | |||
2771 | @item @code{GNUNET_MQ_queue_for_connection_client} | ||
2772 | Transmits queued messages over a @code{GNUNET_CLIENT_Connection} handle. | ||
2773 | Also supports receiving with message handlers. | ||
2774 | |||
2775 | @item @code{GNUNET_MQ_queue_for_server_client} | ||
2776 | Transmits queued messages over a @code{GNUNET_SERVER_Client} handle. Does | ||
2777 | not support incoming message handlers. | ||
2778 | |||
2779 | @item @code{GNUNET_MESH_mq_create} Transmits queued messages over a | ||
2780 | @code{GNUNET_MESH_Tunnel} handle. Does not support incoming message | ||
2781 | handlers. | ||
2782 | |||
2783 | @item @code{GNUNET_MQ_queue_for_callbacks} This is the most general | ||
2784 | implementation. Instead of delivering and receiving messages with one of | ||
2785 | GNUnet's communication APIs, implementation callbacks are called. Refer to | ||
2786 | "Implementing Queues" for a more detailed explanation. | ||
2787 | @end table | ||
2788 | |||
2789 | |||
2790 | @strong{ Allocating Envelopes }@ | ||
2791 | A GNUnet message (as defined by the GNUNET_MessageHeader) has three | ||
2792 | parts: The size, the type, and the body. | ||
2793 | |||
2794 | MQ provides macros to allocate an envelope containing a message | ||
2795 | conveniently, automatically setting the size and type fields of the | ||
2796 | message. | ||
2797 | |||
2798 | Consider the following simple message, with the body consisting of a | ||
2799 | single number value. | ||
2800 | @c why the empy code function? | ||
2801 | @code{} | ||
2802 | |||
2803 | @example | ||
2804 | struct NumberMessage @{ | ||
2805 | /** Type: GNUNET_MESSAGE_TYPE_EXAMPLE_1 */ | ||
2806 | struct GNUNET_MessageHeader header; | ||
2807 | uint32_t number GNUNET_PACKED; | ||
2808 | @}; | ||
2809 | @end example | ||
2810 | |||
2811 | An envelope containing an instance of the NumberMessage can be | ||
2812 | constructed like this: | ||
2813 | |||
2814 | @example | ||
2815 | struct GNUNET_MQ_Envelope *ev; | ||
2816 | struct NumberMessage *msg; | ||
2817 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_EXAMPLE_1); | ||
2818 | msg->number = htonl (42); | ||
2819 | @end example | ||
2820 | |||
2821 | In the above code, @code{GNUNET_MQ_msg} is a macro. The return value is | ||
2822 | the newly allocated envelope. The first argument must be a pointer to some | ||
2823 | @code{struct} containing a @code{struct GNUNET_MessageHeader header} | ||
2824 | field, while the second argument is the desired message type, in host | ||
2825 | byte order. | ||
2826 | |||
2827 | The @code{msg} pointer now points to an allocated message, where the | ||
2828 | message type and the message size are already set. The message's size is | ||
2829 | inferred from the type of the @code{msg} pointer: It will be set to | ||
2830 | 'sizeof(*msg)', properly converted to network byte order. | ||
2831 | |||
2832 | If the message body's size is dynamic, the the macro | ||
2833 | @code{GNUNET_MQ_msg_extra} can be used to allocate an envelope whose | ||
2834 | message has additional space allocated after the @code{msg} structure. | ||
2835 | |||
2836 | If no structure has been defined for the message, | ||
2837 | @code{GNUNET_MQ_msg_header_extra} can be used to allocate additional space | ||
2838 | after the message header. The first argument then must be a pointer to a | ||
2839 | @code{GNUNET_MessageHeader}. | ||
2840 | |||
2841 | @strong{Envelope Properties}@ | ||
2842 | A few functions in MQ allow to set additional properties on envelopes: | ||
2843 | |||
2844 | @table @asis | ||
2845 | |||
2846 | @item @code{GNUNET_MQ_notify_sent} Allows to specify a function that will | ||
2847 | be called once the envelope's message has been sent irrevocably. | ||
2848 | An envelope can be canceled precisely up to the@ point where the notify | ||
2849 | sent callback has been called. | ||
2850 | |||
2851 | @item @code{GNUNET_MQ_disable_corking} No corking will be used when | ||
2852 | sending the message. Not every@ queue supports this flag, per default, | ||
2853 | envelopes are sent with corking.@ | ||
2854 | |||
2855 | @end table | ||
2856 | |||
2857 | |||
2858 | @strong{Sending Envelopes}@ | ||
2859 | Once an envelope has been constructed, it can be queued for sending with | ||
2860 | @code{GNUNET_MQ_send}. | ||
2861 | |||
2862 | Note that in order to avoid memory leaks, an envelope must either be sent | ||
2863 | (the queue will free it) or destroyed explicitly with | ||
2864 | @code{GNUNET_MQ_discard}. | ||
2865 | |||
2866 | @strong{Canceling Envelopes}@ | ||
2867 | An envelope queued with @code{GNUNET_MQ_send} can be canceled with | ||
2868 | @code{GNUNET_MQ_cancel}. Note that after the notify sent callback has | ||
2869 | been called, canceling a message results in undefined behavior. | ||
2870 | Thus it is unsafe to cancel an envelope that does not have a notify sent | ||
2871 | callback. When canceling an envelope, it is not necessary@ to call | ||
2872 | @code{GNUNET_MQ_discard}, and the envelope can't be sent again. | ||
2873 | |||
2874 | @strong{ Implementing Queues }@ | ||
2875 | @code{TODO} | ||
2876 | |||
2877 | @cindex Service API | ||
2878 | @node Service API | ||
2879 | @subsection Service API | ||
2880 | @c %**end of header | ||
2881 | |||
2882 | Most GNUnet code lives in the form of services. Services are processes | ||
2883 | that offer an API for other components of the system to build on. Those | ||
2884 | other components can be command-line tools for users, graphical user | ||
2885 | interfaces or other services. Services provide their API using an IPC | ||
2886 | protocol. For this, each service must listen on either a TCP port or a | ||
2887 | UNIX domain socket; for this, the service implementation uses the server | ||
2888 | API. This use of server is exposed directly to the users of the service | ||
2889 | API. Thus, when using the service API, one is usually also often using | ||
2890 | large parts of the server API. The service API provides various | ||
2891 | convenience functions, such as parsing command-line arguments and the | ||
2892 | configuration file, which are not found in the server API. | ||
2893 | The dual to the service/server API is the client API, which can be used to | ||
2894 | access services. | ||
2895 | |||
2896 | The most common way to start a service is to use the | ||
2897 | @code{GNUNET_SERVICE_run} function from the program's main function. | ||
2898 | @code{GNUNET_SERVICE_run} will then parse the command line and | ||
2899 | configuration files and, based on the options found there, | ||
2900 | start the server. It will then give back control to the main | ||
2901 | program, passing the server and the configuration to the | ||
2902 | @code{GNUNET_SERVICE_Main} callback. @code{GNUNET_SERVICE_run} | ||
2903 | will also take care of starting the scheduler loop. | ||
2904 | If this is inappropriate (for example, because the scheduler loop | ||
2905 | is already running), @code{GNUNET_SERVICE_start} and | ||
2906 | related functions provide an alternative to @code{GNUNET_SERVICE_run}. | ||
2907 | |||
2908 | When starting a service, the service_name option is used to determine | ||
2909 | which sections in the configuration file should be used to configure the | ||
2910 | service. A typical value here is the name of the @file{src/} | ||
2911 | sub-directory, for example "@file{statistics}". | ||
2912 | The same string would also be given to | ||
2913 | @code{GNUNET_CLIENT_connect} to access the service. | ||
2914 | |||
2915 | Once a service has been initialized, the program should use the | ||
2916 | @code{GNUNET_SERVICE_Main} callback to register message handlers | ||
2917 | using @code{GNUNET_SERVER_add_handlers}. | ||
2918 | The service will already have registered a handler for the | ||
2919 | "TEST" message. | ||
2920 | |||
2921 | @fnindex GNUNET_SERVICE_Options | ||
2922 | The option bitfield (@code{enum GNUNET_SERVICE_Options}) | ||
2923 | determines how a service should behave during shutdown. | ||
2924 | There are three key strategies: | ||
2925 | |||
2926 | @table @asis | ||
2927 | |||
2928 | @item instant (@code{GNUNET_SERVICE_OPTION_NONE}) | ||
2929 | Upon receiving the shutdown | ||
2930 | signal from the scheduler, the service immediately terminates the server, | ||
2931 | closing all existing connections with clients. | ||
2932 | @item manual (@code{GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN}) | ||
2933 | The service does nothing by itself | ||
2934 | during shutdown. The main program will need to take the appropriate | ||
2935 | action by calling GNUNET_SERVER_destroy or GNUNET_SERVICE_stop (depending | ||
2936 | on how the service was initialized) to terminate the service. This method | ||
2937 | is used by gnunet-service-arm and rather uncommon. | ||
2938 | @item soft (@code{GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN}) | ||
2939 | Upon receiving the shutdown signal from the scheduler, | ||
2940 | the service immediately tells the server to stop | ||
2941 | listening for incoming clients. Requests from normal existing clients are | ||
2942 | still processed and the server/service terminates once all normal clients | ||
2943 | have disconnected. Clients that are not expected to ever disconnect (such | ||
2944 | as clients that monitor performance values) can be marked as 'monitor' | ||
2945 | clients using GNUNET_SERVER_client_mark_monitor. Those clients will | ||
2946 | continue to be processed until all 'normal' clients have disconnected. | ||
2947 | Then, the server will terminate, closing the monitor connections. | ||
2948 | This mode is for example used by 'statistics', allowing existing 'normal' | ||
2949 | clients to set (possibly persistent) statistic values before terminating. | ||
2950 | |||
2951 | @end table | ||
2952 | |||
2953 | @c *********************************************************************** | ||
2954 | @node Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
2955 | @subsection Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
2956 | @c %**end of header | ||
2957 | |||
2958 | A commonly used data structure in GNUnet is a (multi-)hash map. It is most | ||
2959 | often used to map a peer identity to some data structure, but also to map | ||
2960 | arbitrary keys to values (for example to track requests in the distributed | ||
2961 | hash table or in file-sharing). As it is commonly used, the DHT is | ||
2962 | actually sometimes responsible for a large share of GNUnet's overall | ||
2963 | memory consumption (for some processes, 30% is not uncommon). The | ||
2964 | following text documents some API quirks (and their implications for | ||
2965 | applications) that were recently introduced to minimize the footprint of | ||
2966 | the hash map. | ||
2967 | |||
2968 | |||
2969 | @c *********************************************************************** | ||
2970 | @menu | ||
2971 | * Analysis:: | ||
2972 | * Solution:: | ||
2973 | * Migration:: | ||
2974 | * Conclusion:: | ||
2975 | * Availability:: | ||
2976 | @end menu | ||
2977 | |||
2978 | @node Analysis | ||
2979 | @subsubsection Analysis | ||
2980 | @c %**end of header | ||
2981 | |||
2982 | The main reason for the "excessive" memory consumption by the hash map is | ||
2983 | that GNUnet uses 512-bit cryptographic hash codes --- and the | ||
2984 | (multi-)hash map also uses the same 512-bit 'struct GNUNET_HashCode'. As | ||
2985 | a result, storing just the keys requires 64 bytes of memory for each key. | ||
2986 | As some applications like to keep a large number of entries in the hash | ||
2987 | map (after all, that's what maps are good for), 64 bytes per hash is | ||
2988 | significant: keeping a pointer to the value and having a linked list for | ||
2989 | collisions consume between 8 and 16 bytes, and 'malloc' may add about the | ||
2990 | same overhead per allocation, putting us in the 16 to 32 byte per entry | ||
2991 | ballpark. Adding a 64-byte key then triples the overall memory | ||
2992 | requirement for the hash map. | ||
2993 | |||
2994 | To make things "worse", most of the time storing the key in the hash map | ||
2995 | is not required: it is typically already in memory elsewhere! In most | ||
2996 | cases, the values stored in the hash map are some application-specific | ||
2997 | struct that _also_ contains the hash. Here is a simplified example: | ||
2998 | |||
2999 | @example | ||
3000 | struct MyValue @{ | ||
3001 | struct GNUNET_HashCode key; | ||
3002 | unsigned int my_data; @}; | ||
3003 | |||
3004 | // ... | ||
3005 | val = GNUNET_malloc (sizeof (struct MyValue)); | ||
3006 | val->key = key; | ||
3007 | val->my_data = 42; | ||
3008 | GNUNET_CONTAINER_multihashmap_put (map, &key, val, ...); | ||
3009 | @end example | ||
3010 | |||
3011 | This is a common pattern as later the entries might need to be removed, | ||
3012 | and at that time it is convenient to have the key immediately at hand: | ||
3013 | |||
3014 | @example | ||
3015 | GNUNET_CONTAINER_multihashmap_remove (map, &val->key, val); | ||
3016 | @end example | ||
3017 | |||
3018 | |||
3019 | Note that here we end up with two times 64 bytes for the key, plus maybe | ||
3020 | 64 bytes total for the rest of the 'struct MyValue' and the map entry in | ||
3021 | the hash map. The resulting redundant storage of the key increases | ||
3022 | overall memory consumption per entry from the "optimal" 128 bytes to 192 | ||
3023 | bytes. This is not just an extreme example: overheads in practice are | ||
3024 | actually sometimes close to those highlighted in this example. This is | ||
3025 | especially true for maps with a significant number of entries, as there | ||
3026 | we tend to really try to keep the entries small. | ||
3027 | |||
3028 | @c *********************************************************************** | ||
3029 | @node Solution | ||
3030 | @subsubsection Solution | ||
3031 | @c %**end of header | ||
3032 | |||
3033 | The solution that has now been implemented is to @strong{optionally} | ||
3034 | allow the hash map to not make a (deep) copy of the hash but instead have | ||
3035 | a pointer to the hash/key in the entry. This reduces the memory | ||
3036 | consumption for the key from 64 bytes to 4 to 8 bytes. However, it can | ||
3037 | also only work if the key is actually stored in the entry (which is the | ||
3038 | case most of the time) and if the entry does not modify the key (which in | ||
3039 | all of the code I'm aware of has been always the case if there key is | ||
3040 | stored in the entry). Finally, when the client stores an entry in the | ||
3041 | hash map, it @strong{must} provide a pointer to the key within the entry, | ||
3042 | not just a pointer to a transient location of the key. If | ||
3043 | the client code does not meet these requirements, the result is a dangling | ||
3044 | pointer and undefined behavior of the (multi-)hash map API. | ||
3045 | |||
3046 | @c *********************************************************************** | ||
3047 | @node Migration | ||
3048 | @subsubsection Migration | ||
3049 | @c %**end of header | ||
3050 | |||
3051 | To use the new feature, first check that the values contain the respective | ||
3052 | key (and never modify it). Then, all calls to | ||
3053 | @code{GNUNET_CONTAINER_multihashmap_put} on the respective map must be | ||
3054 | audited and most likely changed to pass a pointer into the value's struct. | ||
3055 | For the initial example, the new code would look like this: | ||
3056 | |||
3057 | @example | ||
3058 | struct MyValue @{ | ||
3059 | struct GNUNET_HashCode key; | ||
3060 | unsigned int my_data; @}; | ||
3061 | |||
3062 | // ... | ||
3063 | val = GNUNET_malloc (sizeof (struct MyValue)); | ||
3064 | val->key = key; val->my_data = 42; | ||
3065 | GNUNET_CONTAINER_multihashmap_put (map, &val->key, val, ...); | ||
3066 | @end example | ||
3067 | |||
3068 | |||
3069 | Note that @code{&val} was changed to @code{&val->key} in the argument to | ||
3070 | the @code{put} call. This is critical as often @code{key} is on the stack | ||
3071 | or in some other transient data structure and thus having the hash map | ||
3072 | keep a pointer to @code{key} would not work. Only the key inside of | ||
3073 | @code{val} has the same lifetime as the entry in the map (this must of | ||
3074 | course be checked as well). Naturally, @code{val->key} must be | ||
3075 | intiialized before the @code{put} call. Once all @code{put} calls have | ||
3076 | been converted and double-checked, you can change the call to create the | ||
3077 | hash map from | ||
3078 | |||
3079 | @example | ||
3080 | map = | ||
3081 | GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_NO); | ||
3082 | @end example | ||
3083 | |||
3084 | to | ||
3085 | |||
3086 | @example | ||
3087 | map = GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_YES); | ||
3088 | @end example | ||
3089 | |||
3090 | If everything was done correctly, you now use about 60 bytes less memory | ||
3091 | per entry in @code{map}. However, if now (or in the future) any call to | ||
3092 | @code{put} does not ensure that the given key is valid until the entry is | ||
3093 | removed from the map, undefined behavior is likely to be observed. | ||
3094 | |||
3095 | @c *********************************************************************** | ||
3096 | @node Conclusion | ||
3097 | @subsubsection Conclusion | ||
3098 | @c %**end of header | ||
3099 | |||
3100 | The new optimization can is often applicable and can result in a | ||
3101 | reduction in memory consumption of up to 30% in practice. However, it | ||
3102 | makes the code less robust as additional invariants are imposed on the | ||
3103 | multi hash map client. Thus applications should refrain from enabling the | ||
3104 | new mode unless the resulting performance increase is deemed significant | ||
3105 | enough. In particular, it should generally not be used in new code (wait | ||
3106 | at least until benchmarks exist). | ||
3107 | |||
3108 | @c *********************************************************************** | ||
3109 | @node Availability | ||
3110 | @subsubsection Availability | ||
3111 | @c %**end of header | ||
3112 | |||
3113 | The new multi hash map code was committed in SVN 24319 (will be in GNUnet | ||
3114 | 0.9.4). Various subsystems (transport, core, dht, file-sharing) were | ||
3115 | previously audited and modified to take advantage of the new capability. | ||
3116 | In particular, memory consumption of the file-sharing service is expected | ||
3117 | to drop by 20-30% due to this change. | ||
3118 | |||
3119 | |||
3120 | @cindex CONTAINER_MDLL API | ||
3121 | @node The CONTAINER_MDLL API | ||
3122 | @subsection The CONTAINER_MDLL API | ||
3123 | @c %**end of header | ||
3124 | |||
3125 | This text documents the GNUNET_CONTAINER_MDLL API. The | ||
3126 | GNUNET_CONTAINER_MDLL API is similar to the GNUNET_CONTAINER_DLL API in | ||
3127 | that it provides operations for the construction and manipulation of | ||
3128 | doubly-linked lists. The key difference to the (simpler) DLL-API is that | ||
3129 | the MDLL-version allows a single element (instance of a "struct") to be | ||
3130 | in multiple linked lists at the same time. | ||
3131 | |||
3132 | Like the DLL API, the MDLL API stores (most of) the data structures for | ||
3133 | the doubly-linked list with the respective elements; only the 'head' and | ||
3134 | 'tail' pointers are stored "elsewhere" --- and the application needs to | ||
3135 | provide the locations of head and tail to each of the calls in the | ||
3136 | MDLL API. The key difference for the MDLL API is that the "next" and | ||
3137 | "previous" pointers in the struct can no longer be simply called "next" | ||
3138 | and "prev" --- after all, the element may be in multiple doubly-linked | ||
3139 | lists, so we cannot just have one "next" and one "prev" pointer! | ||
3140 | |||
3141 | The solution is to have multiple fields that must have a name of the | ||
3142 | format "next_XX" and "prev_XX" where "XX" is the name of one of the | ||
3143 | doubly-linked lists. Here is a simple example: | ||
3144 | |||
3145 | @example | ||
3146 | struct MyMultiListElement @{ | ||
3147 | struct MyMultiListElement *next_ALIST; | ||
3148 | struct MyMultiListElement *prev_ALIST; | ||
3149 | struct MyMultiListElement *next_BLIST; | ||
3150 | struct MyMultiListElement *prev_BLIST; | ||
3151 | void | ||
3152 | *data; | ||
3153 | @}; | ||
3154 | @end example | ||
3155 | |||
3156 | |||
3157 | Note that by convention, we use all-uppercase letters for the list names. | ||
3158 | In addition, the program needs to have a location for the head and tail | ||
3159 | pointers for both lists, for example: | ||
3160 | |||
3161 | @example | ||
3162 | static struct MyMultiListElement *head_ALIST; | ||
3163 | static struct MyMultiListElement *tail_ALIST; | ||
3164 | static struct MyMultiListElement *head_BLIST; | ||
3165 | static struct MyMultiListElement *tail_BLIST; | ||
3166 | @end example | ||
3167 | |||
3168 | |||
3169 | Using the MDLL-macros, we can now insert an element into the ALIST: | ||
3170 | |||
3171 | @example | ||
3172 | GNUNET_CONTAINER_MDLL_insert (ALIST, head_ALIST, tail_ALIST, element); | ||
3173 | @end example | ||
3174 | |||
3175 | |||
3176 | Passing "ALIST" as the first argument to MDLL specifies which of the | ||
3177 | next/prev fields in the 'struct MyMultiListElement' should be used. The | ||
3178 | extra "ALIST" argument and the "_ALIST" in the names of the | ||
3179 | next/prev-members are the only differences between the MDDL and DLL-API. | ||
3180 | Like the DLL-API, the MDLL-API offers functions for inserting (at head, | ||
3181 | at tail, after a given element) and removing elements from the list. | ||
3182 | Iterating over the list should be done by directly accessing the | ||
3183 | "next_XX" and/or "prev_XX" members. | ||
3184 | |||
3185 | @cindex Automatic Restart Manager | ||
3186 | @cindex ARM | ||
3187 | @node The Automatic Restart Manager (ARM) | ||
3188 | @section The Automatic Restart Manager (ARM) | ||
3189 | @c %**end of header | ||
3190 | |||
3191 | GNUnet's Automated Restart Manager (ARM) is the GNUnet service responsible | ||
3192 | for system initialization and service babysitting. ARM starts and halts | ||
3193 | services, detects configuration changes and restarts services impacted by | ||
3194 | the changes as needed. It's also responsible for restarting services in | ||
3195 | case of crashes and is planned to incorporate automatic debugging for | ||
3196 | diagnosing service crashes providing developers insights about crash | ||
3197 | reasons. The purpose of this document is to give GNUnet developer an idea | ||
3198 | about how ARM works and how to interact with it. | ||
3199 | |||
3200 | @menu | ||
3201 | * Basic functionality:: | ||
3202 | * Key configuration options:: | ||
3203 | * ARM - Availability:: | ||
3204 | * Reliability:: | ||
3205 | @end menu | ||
3206 | |||
3207 | @c *********************************************************************** | ||
3208 | @node Basic functionality | ||
3209 | @subsection Basic functionality | ||
3210 | @c %**end of header | ||
3211 | |||
3212 | @itemize @bullet | ||
3213 | @item ARM source code can be found under "src/arm".@ Service processes are | ||
3214 | managed by the functions in "gnunet-service-arm.c" which is controlled | ||
3215 | with "gnunet-arm.c" (main function in that file is ARM's entry point). | ||
3216 | |||
3217 | @item The functions responsible for communicating with ARM , starting and | ||
3218 | stopping services -including ARM service itself- are provided by the | ||
3219 | ARM API "arm_api.c".@ Function: GNUNET_ARM_connect() returns to the caller | ||
3220 | an ARM handle after setting it to the caller's context (configuration and | ||
3221 | scheduler in use). This handle can be used afterwards by the caller to | ||
3222 | communicate with ARM. Functions GNUNET_ARM_start_service() and | ||
3223 | GNUNET_ARM_stop_service() are used for starting and stopping services | ||
3224 | respectively. | ||
3225 | |||
3226 | @item A typical example of using these basic ARM services can be found in | ||
3227 | file test_arm_api.c. The test case connects to ARM, starts it, then uses | ||
3228 | it to start a service "resolver", stops the "resolver" then stops "ARM". | ||
3229 | @end itemize | ||
3230 | |||
3231 | @c *********************************************************************** | ||
3232 | @node Key configuration options | ||
3233 | @subsection Key configuration options | ||
3234 | @c %**end of header | ||
3235 | |||
3236 | Configurations for ARM and services should be available in a .conf file | ||
3237 | (As an example, see test_arm_api_data.conf). When running ARM, the | ||
3238 | configuration file to use should be passed to the command: | ||
3239 | |||
3240 | @example | ||
3241 | $ gnunet-arm -s -c configuration_to_use.conf | ||
3242 | @end example | ||
3243 | |||
3244 | If no configuration is passed, the default configuration file will be used | ||
3245 | (see GNUNET_PREFIX/share/gnunet/defaults.conf which is created from | ||
3246 | contrib/defaults.conf).@ Each of the services is having a section starting | ||
3247 | by the service name between square brackets, for example: "[arm]". | ||
3248 | The following options configure how ARM configures or interacts with the | ||
3249 | various services: | ||
3250 | |||
3251 | @table @asis | ||
3252 | |||
3253 | @item PORT Port number on which the service is listening for incoming TCP | ||
3254 | connections. ARM will start the services should it notice a request at | ||
3255 | this port. | ||
3256 | |||
3257 | @item HOSTNAME Specifies on which host the service is deployed. Note | ||
3258 | that ARM can only start services that are running on the local system | ||
3259 | (but will not check that the hostname matches the local machine name). | ||
3260 | This option is used by the @code{gnunet_client_lib.h} implementation to | ||
3261 | determine which system to connect to. The default is "localhost". | ||
3262 | |||
3263 | @item BINARY The name of the service binary file. | ||
3264 | |||
3265 | @item OPTIONS To be passed to the service. | ||
3266 | |||
3267 | @item PREFIX A command to pre-pend to the actual command, for example, | ||
3268 | running a service with "valgrind" or "gdb" | ||
3269 | |||
3270 | @item DEBUG Run in debug mode (much verbosity). | ||
3271 | |||
3272 | @item AUTOSTART ARM will listen to UNIX domain socket and/or TCP port of | ||
3273 | the service and start the service on-demand. | ||
3274 | |||
3275 | @item FORCESTART ARM will always start this service when the peer | ||
3276 | is started. | ||
3277 | |||
3278 | @item ACCEPT_FROM IPv4 addresses the service accepts connections from. | ||
3279 | |||
3280 | @item ACCEPT_FROM6 IPv6 addresses the service accepts connections from. | ||
3281 | |||
3282 | @end table | ||
3283 | |||
3284 | |||
3285 | Options that impact the operation of ARM overall are in the "[arm]" | ||
3286 | section. ARM is a normal service and has (except for AUTOSTART) all of the | ||
3287 | options that other services do. In addition, ARM has the | ||
3288 | following options: | ||
3289 | |||
3290 | @table @asis | ||
3291 | |||
3292 | @item GLOBAL_PREFIX Command to be pre-pended to all services that are | ||
3293 | going to run. | ||
3294 | |||
3295 | @item GLOBAL_POSTFIX Global option that will be supplied to all the | ||
3296 | services that are going to run. | ||
3297 | |||
3298 | @end table | ||
3299 | |||
3300 | @c *********************************************************************** | ||
3301 | @node ARM - Availability | ||
3302 | @subsection ARM - Availability | ||
3303 | @c %**end of header | ||
3304 | |||
3305 | As mentioned before, one of the features provided by ARM is starting | ||
3306 | services on demand. Consider the example of one service "client" that | ||
3307 | wants to connect to another service a "server". The "client" will ask ARM | ||
3308 | to run the "server". ARM starts the "server". The "server" starts | ||
3309 | listening to incoming connections. The "client" will establish a | ||
3310 | connection with the "server". And then, they will start to communicate | ||
3311 | together.@ One problem with that scheme is that it's slow!@ | ||
3312 | The "client" service wants to communicate with the "server" service at | ||
3313 | once and is not willing wait for it to be started and listening to | ||
3314 | incoming connections before serving its request.@ One solution for that | ||
3315 | problem will be that ARM starts all services as default services. That | ||
3316 | solution will solve the problem, yet, it's not quite practical, for some | ||
3317 | services that are going to be started can never be used or are going to | ||
3318 | be used after a relatively long time.@ | ||
3319 | The approach followed by ARM to solve this problem is as follows: | ||
3320 | |||
3321 | @itemize @bullet | ||
3322 | |||
3323 | @item For each service having a PORT field in the configuration file and | ||
3324 | that is not one of the default services ( a service that accepts incoming | ||
3325 | connections from clients), ARM creates listening sockets for all addresses | ||
3326 | associated with that service. | ||
3327 | |||
3328 | @item The "client" will immediately establish a connection with | ||
3329 | the "server". | ||
3330 | |||
3331 | @item ARM --- pretending to be the "server" --- will listen on the | ||
3332 | respective port and notice the incoming connection from the "client" | ||
3333 | (but not accept it), instead | ||
3334 | |||
3335 | @item Once there is an incoming connection, ARM will start the "server", | ||
3336 | passing on the listen sockets (now, the service is started and can do its | ||
3337 | work). | ||
3338 | |||
3339 | @item Other client services now can directly connect directly to the | ||
3340 | "server". | ||
3341 | |||
3342 | @end itemize | ||
3343 | |||
3344 | @c *********************************************************************** | ||
3345 | @node Reliability | ||
3346 | @subsection Reliability | ||
3347 | |||
3348 | One of the features provided by ARM, is the automatic restart of crashed | ||
3349 | services.@ ARM needs to know which of the running services died. Function | ||
3350 | "gnunet-service-arm.c/maint_child_death()" is responsible for that. The | ||
3351 | function is scheduled to run upon receiving a SIGCHLD signal. The | ||
3352 | function, then, iterates ARM's list of services running and monitors | ||
3353 | which service has died (crashed). For all crashing services, ARM restarts | ||
3354 | them.@ | ||
3355 | Now, considering the case of a service having a serious problem causing it | ||
3356 | to crash each time it's started by ARM. If ARM keeps blindly restarting | ||
3357 | such a service, we are going to have the pattern: | ||
3358 | start-crash-restart-crash-restart-crash and so forth!! Which is of course | ||
3359 | not practical.@ | ||
3360 | For that reason, ARM schedules the service to be restarted after waiting | ||
3361 | for some delay that grows exponentially with each crash/restart of that | ||
3362 | service.@ To clarify the idea, considering the following example: | ||
3363 | |||
3364 | @itemize @bullet | ||
3365 | |||
3366 | @item Service S crashed. | ||
3367 | |||
3368 | @item ARM receives the SIGCHLD and inspects its list of services to find | ||
3369 | the dead one(s). | ||
3370 | |||
3371 | @item ARM finds S dead and schedules it for restarting after "backoff" | ||
3372 | time which is initially set to 1ms. ARM will double the backoff time | ||
3373 | correspondent to S (now backoff(S) = 2ms) | ||
3374 | |||
3375 | @item Because there is a severe problem with S, it crashed again. | ||
3376 | |||
3377 | @item Again ARM receives the SIGCHLD and detects that it's S again that's | ||
3378 | crashed. ARM schedules it for restarting but after its new backoff time | ||
3379 | (which became 2ms), and doubles its backoff time (now backoff(S) = 4). | ||
3380 | |||
3381 | @item and so on, until backoff(S) reaches a certain threshold | ||
3382 | (@code{EXPONENTIAL_BACKOFF_THRESHOLD} is set to half an hour), | ||
3383 | after reaching it, backoff(S) will remain half an hour, | ||
3384 | hence ARM won't be busy for a lot of time trying to restart a | ||
3385 | problematic service. | ||
3386 | @end itemize | ||
3387 | |||
3388 | @cindex TRANSPORT Subsystem | ||
3389 | @node GNUnet's TRANSPORT Subsystem | ||
3390 | @section GNUnet's TRANSPORT Subsystem | ||
3391 | @c %**end of header | ||
3392 | |||
3393 | This chapter documents how the GNUnet transport subsystem works. The | ||
3394 | GNUnet transport subsystem consists of three main components: the | ||
3395 | transport API (the interface used by the rest of the system to access the | ||
3396 | transport service), the transport service itself (most of the interesting | ||
3397 | functions, such as choosing transports, happens here) and the transport | ||
3398 | plugins. A transport plugin is a concrete implementation for how two | ||
3399 | GNUnet peers communicate; many plugins exist, for example for | ||
3400 | communication via TCP, UDP, HTTP, HTTPS and others. Finally, the | ||
3401 | transport subsystem uses supporting code, especially the NAT/UPnP | ||
3402 | library to help with tasks such as NAT traversal. | ||
3403 | |||
3404 | Key tasks of the transport service include: | ||
3405 | |||
3406 | @itemize @bullet | ||
3407 | |||
3408 | @item Create our HELLO message, notify clients and neighbours if our HELLO | ||
3409 | changes (using NAT library as necessary) | ||
3410 | |||
3411 | @item Validate HELLOs from other peers (send PING), allow other peers to | ||
3412 | validate our HELLO's addresses (send PONG) | ||
3413 | |||
3414 | @item Upon request, establish connections to other peers (using address | ||
3415 | selection from ATS subsystem) and maintain them (again using PINGs and | ||
3416 | PONGs) as long as desired | ||
3417 | |||
3418 | @item Accept incoming connections, give ATS service the opportunity to | ||
3419 | switch communication channels | ||
3420 | |||
3421 | @item Notify clients about peers that have connected to us or that have | ||
3422 | been disconnected from us | ||
3423 | |||
3424 | @item If a (stateful) connection goes down unexpectedly (without explicit | ||
3425 | DISCONNECT), quickly attempt to recover (without notifying clients) but do | ||
3426 | notify clients quickly if reconnecting fails | ||
3427 | |||
3428 | @item Send (payload) messages arriving from clients to other peers via | ||
3429 | transport plugins and receive messages from other peers, forwarding | ||
3430 | those to clients | ||
3431 | |||
3432 | @item Enforce inbound traffic limits (using flow-control if it is | ||
3433 | applicable); outbound traffic limits are enforced by CORE, not by us (!) | ||
3434 | |||
3435 | @item Enforce restrictions on P2P connection as specified by the blacklist | ||
3436 | configuration and blacklisting clients | ||
3437 | @end itemize | ||
3438 | |||
3439 | Note that the term "clients" in the list above really refers to the | ||
3440 | GNUnet-CORE service, as CORE is typically the only client of the | ||
3441 | transport service. | ||
3442 | |||
3443 | @menu | ||
3444 | * Address validation protocol:: | ||
3445 | @end menu | ||
3446 | |||
3447 | @node Address validation protocol | ||
3448 | @subsection Address validation protocol | ||
3449 | @c %**end of header | ||
3450 | |||
3451 | This section documents how the GNUnet transport service validates | ||
3452 | connections with other peers. It is a high-level description of the | ||
3453 | protocol necessary to understand the details of the implementation. It | ||
3454 | should be noted that when we talk about PING and PONG messages in this | ||
3455 | section, we refer to transport-level PING and PONG messages, which are | ||
3456 | different from core-level PING and PONG messages (both in implementation | ||
3457 | and function). | ||
3458 | |||
3459 | The goal of transport-level address validation is to minimize the chances | ||
3460 | of a successful man-in-the-middle attack against GNUnet peers on the | ||
3461 | transport level. Such an attack would not allow the adversary to decrypt | ||
3462 | the P2P transmissions, but a successful attacker could at least measure | ||
3463 | traffic volumes and latencies (raising the adversaries capablities by | ||
3464 | those of a global passive adversary in the worst case). The scenarios we | ||
3465 | are concerned about is an attacker, Mallory, giving a HELLO to Alice that | ||
3466 | claims to be for Bob, but contains Mallory's IP address instead of Bobs | ||
3467 | (for some transport). Mallory would then forward the traffic to Bob (by | ||
3468 | initiating a connection to Bob and claiming to be Alice). As a further | ||
3469 | complication, the scheme has to work even if say Alice is behind a NAT | ||
3470 | without traversal support and hence has no address of their own (and thus | ||
3471 | Alice must always initiate the connection to Bob). | ||
3472 | |||
3473 | An additional constraint is that HELLO messages do not contain a | ||
3474 | cryptographic signature since other peers must be able to edit | ||
3475 | (i.e. remove) addresses from the HELLO at any time (this was not true in | ||
3476 | GNUnet 0.8.x). A basic @strong{assumption} is that each peer knows the | ||
3477 | set of possible network addresses that it @strong{might} be reachable | ||
3478 | under (so for example, the external IP address of the NAT plus the LAN | ||
3479 | address(es) with the respective ports). | ||
3480 | |||
3481 | The solution is the following. If Alice wants to validate that a given | ||
3482 | address for Bob is valid (i.e. is actually established @strong{directly} | ||
3483 | with the intended target), it sends a PING message over that connection | ||
3484 | to Bob. Note that in this case, Alice initiated the connection so only | ||
3485 | Alice knows which address was used for sure (Alice maybe behind NAT, so | ||
3486 | whatever address Bob sees may not be an address Alice knows they have). | ||
3487 | Bob | ||
3488 | checks that the address given in the PING is actually one of Bob's | ||
3489 | addresses | ||
3490 | (does not belong to Mallory), and if it is, sends back a PONG (with a | ||
3491 | signature that says that Bob owns/uses the address from the PING). Alice | ||
3492 | checks the signature and is happy if it is valid and the address in the | ||
3493 | PONG is the address Alice used. | ||
3494 | This is similar to the 0.8.x protocol where the HELLO contained a | ||
3495 | signature from Bob for each address used by Bob. | ||
3496 | Here, the purpose code for the signature is | ||
3497 | @code{GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN}. After this, Alice will | ||
3498 | remember Bob's address and consider the address valid for a while (12h in | ||
3499 | the current implementation). Note that after this exchange, Alice only | ||
3500 | considers Bob's address to be valid, the connection itself is not | ||
3501 | considered 'established'. In particular, Alice may have many addresses | ||
3502 | for Bob that Alice considers valid. | ||
3503 | |||
3504 | The PONG message is protected with a nonce/challenge against replay | ||
3505 | attacks and uses an expiration time for the signature (but those are | ||
3506 | almost implementation details). | ||
3507 | |||
3508 | @cindex NAT library | ||
3509 | @node NAT library | ||
3510 | @section NAT library | ||
3511 | @c %**end of header | ||
3512 | |||
3513 | The goal of the GNUnet NAT library is to provide a general-purpose API for | ||
3514 | NAT traversal @strong{without} third-party support. So protocols that | ||
3515 | involve contacting a third peer to help establish a connection between | ||
3516 | two peers are outside of the scope of this API. That does not mean that | ||
3517 | GNUnet doesn't support involving a third peer (we can do this with the | ||
3518 | distance-vector transport or using application-level protocols), it just | ||
3519 | means that the NAT API is not concerned with this possibility. The API is | ||
3520 | written so that it will work for IPv6-NAT in the future as well as | ||
3521 | current IPv4-NAT. Furthermore, the NAT API is always used, even for peers | ||
3522 | that are not behind NAT --- in that case, the mapping provided is simply | ||
3523 | the identity. | ||
3524 | |||
3525 | NAT traversal is initiated by calling @code{GNUNET_NAT_register}. Given a | ||
3526 | set of addresses that the peer has locally bound to (TCP or UDP), the NAT | ||
3527 | library will return (via callback) a (possibly longer) list of addresses | ||
3528 | the peer @strong{might} be reachable under. Internally, depending on the | ||
3529 | configuration, the NAT library will try to punch a hole (using UPnP) or | ||
3530 | just "know" that the NAT was manually punched and generate the respective | ||
3531 | external IP address (the one that should be globally visible) based on | ||
3532 | the given information. | ||
3533 | |||
3534 | The NAT library also supports ICMP-based NAT traversal. Here, the other | ||
3535 | peer can request connection-reversal by this peer (in this special case, | ||
3536 | the peer is even allowed to configure a port number of zero). If the NAT | ||
3537 | library detects a connection-reversal request, it returns the respective | ||
3538 | target address to the client as well. It should be noted that | ||
3539 | connection-reversal is currently only intended for TCP, so other plugins | ||
3540 | @strong{must} pass @code{NULL} for the reversal callback. Naturally, the | ||
3541 | NAT library also supports requesting connection reversal from a remote | ||
3542 | peer (@code{GNUNET_NAT_run_client}). | ||
3543 | |||
3544 | Once initialized, the NAT handle can be used to test if a given address is | ||
3545 | possibly a valid address for this peer (@code{GNUNET_NAT_test_address}). | ||
3546 | This is used for validating our addresses when generating PONGs. | ||
3547 | |||
3548 | Finally, the NAT library contains an API to test if our NAT configuration | ||
3549 | is correct. Using @code{GNUNET_NAT_test_start} @strong{before} binding to | ||
3550 | the respective port, the NAT library can be used to test if the | ||
3551 | configuration works. The test function act as a local client, initialize | ||
3552 | the NAT traversal and then contact a @code{gnunet-nat-server} (running by | ||
3553 | default on @code{gnunet.org}) and ask for a connection to be established. | ||
3554 | This way, it is easy to test if the current NAT configuration is valid. | ||
3555 | |||
3556 | @node Distance-Vector plugin | ||
3557 | @section Distance-Vector plugin | ||
3558 | @c %**end of header | ||
3559 | |||
3560 | The Distance Vector (DV) transport is a transport mechanism that allows | ||
3561 | peers to act as relays for each other, thereby connecting peers that would | ||
3562 | otherwise be unable to connect. This gives a larger connection set to | ||
3563 | applications that may work better with more peers to choose from (for | ||
3564 | example, File Sharing and/or DHT). | ||
3565 | |||
3566 | The Distance Vector transport essentially has two functions. The first is | ||
3567 | "gossiping" connection information about more distant peers to directly | ||
3568 | connected peers. The second is taking messages intended for non-directly | ||
3569 | connected peers and encapsulating them in a DV wrapper that contains the | ||
3570 | required information for routing the message through forwarding peers. Via | ||
3571 | gossiping, optimal routes through the known DV neighborhood are discovered | ||
3572 | and utilized and the message encapsulation provides some benefits in | ||
3573 | addition to simply getting the message from the correct source to the | ||
3574 | proper destination. | ||
3575 | |||
3576 | The gossiping function of DV provides an up to date routing table of | ||
3577 | peers that are available up to some number of hops. We call this a | ||
3578 | fisheye view of the network (like a fish, nearby objects are known while | ||
3579 | more distant ones unknown). Gossip messages are sent only to directly | ||
3580 | connected peers, but they are sent about other knowns peers within the | ||
3581 | "fisheye distance". Whenever two peers connect, they immediately gossip | ||
3582 | to each other about their appropriate other neighbors. They also gossip | ||
3583 | about the newly connected peer to previously | ||
3584 | connected neighbors. In order to keep the routing tables up to date, | ||
3585 | disconnect notifications are propogated as gossip as well (because | ||
3586 | disconnects may not be sent/received, timeouts are also used remove | ||
3587 | stagnant routing table entries). | ||
3588 | |||
3589 | Routing of messages via DV is straightforward. When the DV transport is | ||
3590 | notified of a message destined for a non-direct neighbor, the appropriate | ||
3591 | forwarding peer is selected, and the base message is encapsulated in a DV | ||
3592 | message which contains information about the initial peer and the intended | ||
3593 | recipient. At each forwarding hop, the initial peer is validated (the | ||
3594 | forwarding peer ensures that it has the initial peer in its neighborhood, | ||
3595 | otherwise the message is dropped). Next the base message is | ||
3596 | re-encapsulated in a new DV message for the next hop in the forwarding | ||
3597 | chain (or delivered to the current peer, if it has arrived at the | ||
3598 | destination). | ||
3599 | |||
3600 | Assume a three peer network with peers Alice, Bob and Carol. Assume that | ||
3601 | Alice <-> Bob and Bob <-> Carol are direct (e.g. over TCP or UDP | ||
3602 | transports) connections, but that Alice cannot directly connect to Carol. | ||
3603 | This may be the case due to NAT or firewall restrictions, or perhaps | ||
3604 | based on one of the peers respective configurations. If the Distance | ||
3605 | Vector transport is enabled on all three peers, it will automatically | ||
3606 | discover (from the gossip protocol) that Alice and Carol can connect via | ||
3607 | Bob and provide a "virtual" Alice <-> Carol connection. Routing between | ||
3608 | Alice and Carol happens as follows; Alice creates a message destined for | ||
3609 | Carol and notifies the DV transport about it. The DV transport at Alice | ||
3610 | looks up Carol in the routing table and finds that the message must be | ||
3611 | sent through Bob for Carol. The message is encapsulated setting Alice as | ||
3612 | the initiator and Carol as the destination and sent to Bob. Bob receives | ||
3613 | the messages, verifies both Alice and Carol are known to Bob, and re-wraps | ||
3614 | the message in a new DV message for Carol. The DV transport at Carol | ||
3615 | receives this message, unwraps the original message, and delivers it to | ||
3616 | Carol as though it came directly from Alice. | ||
3617 | |||
3618 | @cindex SMTP plugin | ||
3619 | @node SMTP plugin | ||
3620 | @section SMTP plugin | ||
3621 | @c %**end of header | ||
3622 | |||
3623 | This section describes the new SMTP transport plugin for GNUnet as it | ||
3624 | exists in the 0.7.x and 0.8.x branch. SMTP support is currently not | ||
3625 | available in GNUnet 0.9.x. This page also describes the transport layer | ||
3626 | abstraction (as it existed in 0.7.x and 0.8.x) in more detail and gives | ||
3627 | some benchmarking results. The performance results presented are quite | ||
3628 | old and maybe outdated at this point. | ||
3629 | |||
3630 | @itemize @bullet | ||
3631 | @item Why use SMTP for a peer-to-peer transport? | ||
3632 | @item SMTPHow does it work? | ||
3633 | @item How do I configure my peer? | ||
3634 | @item How do I test if it works? | ||
3635 | @item How fast is it? | ||
3636 | @item Is there any additional documentation? | ||
3637 | @end itemize | ||
3638 | |||
3639 | |||
3640 | @menu | ||
3641 | * Why use SMTP for a peer-to-peer transport?:: | ||
3642 | * How does it work?:: | ||
3643 | * How do I configure my peer?:: | ||
3644 | * How do I test if it works?:: | ||
3645 | * How fast is it?:: | ||
3646 | @end menu | ||
3647 | |||
3648 | @node Why use SMTP for a peer-to-peer transport? | ||
3649 | @subsection Why use SMTP for a peer-to-peer transport? | ||
3650 | @c %**end of header | ||
3651 | |||
3652 | There are many reasons why one would not want to use SMTP: | ||
3653 | |||
3654 | @itemize @bullet | ||
3655 | @item SMTP is using more bandwidth than TCP, UDP or HTTP | ||
3656 | @item SMTP has a much higher latency. | ||
3657 | @item SMTP requires significantly more computation (encoding and decoding | ||
3658 | time) for the peers. | ||
3659 | @item SMTP is significantly more complicated to configure. | ||
3660 | @item SMTP may be abused by tricking GNUnet into sending mail to@ | ||
3661 | non-participating third parties. | ||
3662 | @end itemize | ||
3663 | |||
3664 | So why would anybody want to use SMTP? | ||
3665 | @itemize @bullet | ||
3666 | @item SMTP can be used to contact peers behind NAT boxes (in virtual | ||
3667 | private networks). | ||
3668 | @item SMTP can be used to circumvent policies that limit or prohibit | ||
3669 | peer-to-peer traffic by masking as "legitimate" traffic. | ||
3670 | @item SMTP uses E-mail addresses which are independent of a specific IP, | ||
3671 | which can be useful to address peers that use dynamic IP addresses. | ||
3672 | @item SMTP can be used to initiate a connection (e.g. initial address | ||
3673 | exchange) and peers can then negotiate the use of a more efficient | ||
3674 | protocol (e.g. TCP) for the actual communication. | ||
3675 | @end itemize | ||
3676 | |||
3677 | In summary, SMTP can for example be used to send a message to a peer | ||
3678 | behind a NAT box that has a dynamic IP to tell the peer to establish a | ||
3679 | TCP connection to a peer outside of the private network. Even an | ||
3680 | extraordinary overhead for this first message would be irrelevant in this | ||
3681 | type of situation. | ||
3682 | |||
3683 | @node How does it work? | ||
3684 | @subsection How does it work? | ||
3685 | @c %**end of header | ||
3686 | |||
3687 | When a GNUnet peer needs to send a message to another GNUnet peer that has | ||
3688 | advertised (only) an SMTP transport address, GNUnet base64-encodes the | ||
3689 | message and sends it in an E-mail to the advertised address. The | ||
3690 | advertisement contains a filter which is placed in the E-mail header, | ||
3691 | such that the receiving host can filter the tagged E-mails and forward it | ||
3692 | to the GNUnet peer process. The filter can be specified individually by | ||
3693 | each peer and be changed over time. This makes it impossible to censor | ||
3694 | GNUnet E-mail messages by searching for a generic filter. | ||
3695 | |||
3696 | @node How do I configure my peer? | ||
3697 | @subsection How do I configure my peer? | ||
3698 | @c %**end of header | ||
3699 | |||
3700 | First, you need to configure @code{procmail} to filter your inbound E-mail | ||
3701 | for GNUnet traffic. The GNUnet messages must be delivered into a pipe, for | ||
3702 | example @code{/tmp/gnunet.smtp}. You also need to define a filter that is | ||
3703 | used by @command{procmail} to detect GNUnet messages. You are free to | ||
3704 | choose whichever filter you like, but you should make sure that it does | ||
3705 | not occur in your other E-mail. In our example, we will use | ||
3706 | @code{X-mailer: GNUnet}. The @code{~/.procmailrc} configuration file then | ||
3707 | looks like this: | ||
3708 | |||
3709 | @example | ||
3710 | :0: | ||
3711 | * ^X-mailer: GNUnet | ||
3712 | /tmp/gnunet.smtp | ||
3713 | # where do you want your other e-mail delivered to | ||
3714 | # (default: /var/spool/mail/) | ||
3715 | :0: /var/spool/mail/ | ||
3716 | @end example | ||
3717 | |||
3718 | After adding this file, first make sure that your regular E-mail still | ||
3719 | works (e.g. by sending an E-mail to yourself). Then edit the GNUnet | ||
3720 | configuration. In the section @code{SMTP} you need to specify your E-mail | ||
3721 | address under @code{EMAIL}, your mail server (for outgoing mail) under | ||
3722 | @code{SERVER}, the filter (X-mailer: GNUnet in the example) under | ||
3723 | @code{FILTER} and the name of the pipe under @code{PIPE}.@ The completed | ||
3724 | section could then look like this: | ||
3725 | |||
3726 | @example | ||
3727 | EMAIL = me@@mail.gnu.org MTU = 65000 SERVER = mail.gnu.org:25 FILTER = | ||
3728 | "X-mailer: GNUnet" PIPE = /tmp/gnunet.smtp | ||
3729 | @end example | ||
3730 | |||
3731 | Finally, you need to add @code{smtp} to the list of @code{TRANSPORTS} in | ||
3732 | the @code{GNUNETD} section. GNUnet peers will use the E-mail address that | ||
3733 | you specified to contact your peer until the advertisement times out. | ||
3734 | Thus, if you are not sure if everything works properly or if you are not | ||
3735 | planning to be online for a long time, you may want to configure this | ||
3736 | timeout to be short, e.g. just one hour. For this, set | ||
3737 | @code{HELLOEXPIRES} to @code{1} in the @code{GNUNETD} section. | ||
3738 | |||
3739 | This should be it, but you may probably want to test it first. | ||
3740 | |||
3741 | @node How do I test if it works? | ||
3742 | @subsection How do I test if it works? | ||
3743 | @c %**end of header | ||
3744 | |||
3745 | Any transport can be subjected to some rudimentary tests using the | ||
3746 | @code{gnunet-transport-check} tool. The tool sends a message to the local | ||
3747 | node via the transport and checks that a valid message is received. While | ||
3748 | this test does not involve other peers and can not check if firewalls or | ||
3749 | other network obstacles prohibit proper operation, this is a great | ||
3750 | testcase for the SMTP transport since it tests pretty much nearly all of | ||
3751 | the functionality. | ||
3752 | |||
3753 | @code{gnunet-transport-check} should only be used without running | ||
3754 | @code{gnunetd} at the same time. By default, @code{gnunet-transport-check} | ||
3755 | tests all transports that are specified in the configuration file. But | ||
3756 | you can specifically test SMTP by giving the option | ||
3757 | @code{--transport=smtp}. | ||
3758 | |||
3759 | Note that this test always checks if a transport can receive and send. | ||
3760 | While you can configure most transports to only receive or only send | ||
3761 | messages, this test will only work if you have configured the transport | ||
3762 | to send and receive messages. | ||
3763 | |||
3764 | @node How fast is it? | ||
3765 | @subsection How fast is it? | ||
3766 | @c %**end of header | ||
3767 | |||
3768 | We have measured the performance of the UDP, TCP and SMTP transport layer | ||
3769 | directly and when used from an application using the GNUnet core. | ||
3770 | Measureing just the transport layer gives the better view of the actual | ||
3771 | overhead of the protocol, whereas evaluating the transport from the | ||
3772 | application puts the overhead into perspective from a practical point of | ||
3773 | view. | ||
3774 | |||
3775 | The loopback measurements of the SMTP transport were performed on three | ||
3776 | different machines spanning a range of modern SMTP configurations. We | ||
3777 | used a PIII-800 running RedHat 7.3 with the Purdue Computer Science | ||
3778 | configuration which includes filters for spam. We also used a Xenon 2 GHZ | ||
3779 | with a vanilla RedHat 8.0 sendmail configuration. Furthermore, we used | ||
3780 | qmail on a PIII-1000 running Sorcerer GNU Linux (SGL). The numbers for | ||
3781 | UDP and TCP are provided using the SGL configuration. The qmail benchmark | ||
3782 | uses qmail's internal filtering whereas the sendmail benchmarks relies on | ||
3783 | procmail to filter and deliver the mail. We used the transport layer to | ||
3784 | send a message of b bytes (excluding transport protocol headers) directly | ||
3785 | to the local machine. This way, network latency and packet loss on the | ||
3786 | wire have no impact on the timings. n messages were sent sequentially over | ||
3787 | the transport layer, sending message i+1 after the i-th message was | ||
3788 | received. All messages were sent over the same connection and the time to | ||
3789 | establish the connection was not taken into account since this overhead is | ||
3790 | miniscule in practice --- as long as a connection is used for a | ||
3791 | significant number of messages. | ||
3792 | |||
3793 | @multitable @columnfractions .20 .15 .15 .15 .15 .15 | ||
3794 | @headitem Transport @tab UDP @tab TCP @tab SMTP (Purdue sendmail) | ||
3795 | @tab SMTP (RH 8.0) @tab SMTP (SGL qmail) | ||
3796 | @item 11 bytes @tab 31 ms @tab 55 ms @tab 781 s @tab 77 s @tab 24 s | ||
3797 | @item 407 bytes @tab 37 ms @tab 62 ms @tab 789 s @tab 78 s @tab 25 s | ||
3798 | @item 1,221 bytes @tab 46 ms @tab 73 ms @tab 804 s @tab 78 s @tab 25 s | ||
3799 | @end multitable | ||
3800 | |||
3801 | The benchmarks show that UDP and TCP are, as expected, both significantly | ||
3802 | faster compared with any of the SMTP services. Among the SMTP | ||
3803 | implementations, there can be significant differences depending on the | ||
3804 | SMTP configuration. Filtering with an external tool like procmail that | ||
3805 | needs to re-parse its configuration for each mail can be very expensive. | ||
3806 | Applying spam filters can also significantly impact the performance of | ||
3807 | the underlying SMTP implementation. The microbenchmark shows that SMTP | ||
3808 | can be a viable solution for initiating peer-to-peer sessions: a couple of | ||
3809 | seconds to connect to a peer are probably not even going to be noticed by | ||
3810 | users. The next benchmark measures the possible throughput for a | ||
3811 | transport. Throughput can be measured by sending multiple messages in | ||
3812 | parallel and measuring packet loss. Note that not only UDP but also the | ||
3813 | TCP transport can actually loose messages since the TCP implementation | ||
3814 | drops messages if the @code{write} to the socket would block. While the | ||
3815 | SMTP protocol never drops messages itself, it is often so | ||
3816 | slow that only a fraction of the messages can be sent and received in the | ||
3817 | given time-bounds. For this benchmark we report the message loss after | ||
3818 | allowing t time for sending m messages. If messages were not sent (or | ||
3819 | received) after an overall timeout of t, they were considered lost. The | ||
3820 | benchmark was performed using two Xeon 2 GHZ machines running RedHat 8.0 | ||
3821 | with sendmail. The machines were connected with a direct 100 MBit ethernet | ||
3822 | connection.@ Figures udp1200, tcp1200 and smtp-MTUs show that the | ||
3823 | throughput for messages of size 1,200 octects is 2,343 kbps, 3,310 kbps | ||
3824 | and 6 kbps for UDP, TCP and SMTP respectively. The high per-message | ||
3825 | overhead of SMTP can be improved by increasing the MTU, for example, an | ||
3826 | MTU of 12,000 octets improves the throughput to 13 kbps as figure | ||
3827 | smtp-MTUs shows. Our research paper) has some more details on the | ||
3828 | benchmarking results. | ||
3829 | |||
3830 | @cindex Bluetooth plugin | ||
3831 | @node Bluetooth plugin | ||
3832 | @section Bluetooth plugin | ||
3833 | @c %**end of header | ||
3834 | |||
3835 | This page describes the new Bluetooth transport plugin for GNUnet. The | ||
3836 | plugin is still in the testing stage so don't expect it to work | ||
3837 | perfectly. If you have any questions or problems just post them here or | ||
3838 | ask on the IRC channel. | ||
3839 | |||
3840 | @itemize @bullet | ||
3841 | @item What do I need to use the Bluetooth plugin transport? | ||
3842 | @item BluetoothHow does it work? | ||
3843 | @item What possible errors should I be aware of? | ||
3844 | @item How do I configure my peer? | ||
3845 | @item How can I test it? | ||
3846 | @end itemize | ||
3847 | |||
3848 | @menu | ||
3849 | * What do I need to use the Bluetooth plugin transport?:: | ||
3850 | * How does it work2?:: | ||
3851 | * What possible errors should I be aware of?:: | ||
3852 | * How do I configure my peer2?:: | ||
3853 | * How can I test it?:: | ||
3854 | * The implementation of the Bluetooth transport plugin:: | ||
3855 | @end menu | ||
3856 | |||
3857 | @node What do I need to use the Bluetooth plugin transport? | ||
3858 | @subsection What do I need to use the Bluetooth plugin transport? | ||
3859 | @c %**end of header | ||
3860 | |||
3861 | If you are a Linux user and you want to use the Bluetooth transport plugin | ||
3862 | you should install the BlueZ development libraries (if they aren't already | ||
3863 | installed). For instructions about how to install the libraries you should | ||
3864 | check out the BlueZ site | ||
3865 | (@uref{http://www.bluez.org/, http://www.bluez.org}). If you don't know if | ||
3866 | you have the necesarry libraries, don't worry, just run the GNUnet | ||
3867 | configure script and you will be able to see a notification at the end | ||
3868 | which will warn you if you don't have the necessary libraries. | ||
3869 | |||
3870 | If you are a Windows user you should have installed the | ||
3871 | @emph{MinGW}/@emph{MSys2} with the latest updates (especially the | ||
3872 | @emph{ws2bth} header). If this is your first build of GNUnet on Windows | ||
3873 | you should check out the SBuild repository. It will semi-automatically | ||
3874 | assembles a @emph{MinGW}/@emph{MSys2} installation with a lot of extra | ||
3875 | packages which are needed for the GNUnet build. So this will ease your | ||
3876 | work!@ Finally you just have to be sure that you have the correct drivers | ||
3877 | for your Bluetooth device installed and that your device is on and in a | ||
3878 | discoverable mode. The Windows Bluetooth Stack supports only the RFCOMM | ||
3879 | protocol so we cannot turn on your device programatically! | ||
3880 | |||
3881 | @c FIXME: Change to unique title | ||
3882 | @node How does it work2? | ||
3883 | @subsection How does it work2? | ||
3884 | @c %**end of header | ||
3885 | |||
3886 | The Bluetooth transport plugin uses virtually the same code as the WLAN | ||
3887 | plugin and only the helper binary is different. The helper takes a single | ||
3888 | argument, which represents the interface name and is specified in the | ||
3889 | configuration file. Here are the basic steps that are followed by the | ||
3890 | helper binary used on Linux: | ||
3891 | |||
3892 | @itemize @bullet | ||
3893 | @item it verifies if the name corresponds to a Bluetooth interface name | ||
3894 | @item it verifies if the iterface is up (if it is not, it tries to bring | ||
3895 | it up) | ||
3896 | @item it tries to enable the page and inquiry scan in order to make the | ||
3897 | device discoverable and to accept incoming connection requests | ||
3898 | @emph{The above operations require root access so you should start the | ||
3899 | transport plugin with root privileges.} | ||
3900 | @item it finds an available port number and registers a SDP service which | ||
3901 | will be used to find out on which port number is the server listening on | ||
3902 | and switch the socket in listening mode | ||
3903 | @item it sends a HELLO message with its address | ||
3904 | @item finally it forwards traffic from the reading sockets to the STDOUT | ||
3905 | and from the STDIN to the writing socket | ||
3906 | @end itemize | ||
3907 | |||
3908 | Once in a while the device will make an inquiry scan to discover the | ||
3909 | nearby devices and it will send them randomly HELLO messages for peer | ||
3910 | discovery. | ||
3911 | |||
3912 | @node What possible errors should I be aware of? | ||
3913 | @subsection What possible errors should I be aware of? | ||
3914 | @c %**end of header | ||
3915 | |||
3916 | @emph{This section is dedicated for Linux users} | ||
3917 | |||
3918 | Well there are many ways in which things could go wrong but I will try to | ||
3919 | present some tools that you could use to debug and some scenarios. | ||
3920 | |||
3921 | @itemize @bullet | ||
3922 | |||
3923 | @item @code{bluetoothd -n -d} : use this command to enable logging in the | ||
3924 | foreground and to print the logging messages | ||
3925 | |||
3926 | @item @code{hciconfig}: can be used to configure the Bluetooth devices. | ||
3927 | If you run it without any arguments it will print information about the | ||
3928 | state of the interfaces. So if you receive an error that the device | ||
3929 | couldn't be brought up you should try to bring it manually and to see if | ||
3930 | it works (use @code{hciconfig -a hciX up}). If you can't and the | ||
3931 | Bluetooth address has the form 00:00:00:00:00:00 it means that there is | ||
3932 | something wrong with the D-Bus daemon or with the Bluetooth daemon. Use | ||
3933 | @code{bluetoothd} tool to see the logs | ||
3934 | |||
3935 | @item @code{sdptool} can be used to control and interogate SDP servers. | ||
3936 | If you encounter problems regarding the SDP server (like the SDP server is | ||
3937 | down) you should check out if the D-Bus daemon is running correctly and to | ||
3938 | see if the Bluetooth daemon started correctly(use @code{bluetoothd} tool). | ||
3939 | Also, sometimes the SDP service could work but somehow the device couldn't | ||
3940 | register his service. Use @code{sdptool browse [dev-address]} to see if | ||
3941 | the service is registered. There should be a service with the name of the | ||
3942 | interface and GNUnet as provider. | ||
3943 | |||
3944 | @item @code{hcitool} : another useful tool which can be used to configure | ||
3945 | the device and to send some particular commands to it. | ||
3946 | |||
3947 | @item @code{hcidump} : could be used for low level debugging | ||
3948 | @end itemize | ||
3949 | |||
3950 | @c FIXME: A more unique name | ||
3951 | @node How do I configure my peer2? | ||
3952 | @subsection How do I configure my peer2? | ||
3953 | @c %**end of header | ||
3954 | |||
3955 | On Linux, you just have to be sure that the interface name corresponds to | ||
3956 | the one that you want to use. Use the @code{hciconfig} tool to check that. | ||
3957 | By default it is set to hci0 but you can change it. | ||
3958 | |||
3959 | A basic configuration looks like this: | ||
3960 | |||
3961 | @example | ||
3962 | [transport-bluetooth] | ||
3963 | # Name of the interface (typically hciX) | ||
3964 | INTERFACE = hci0 | ||
3965 | # Real hardware, no testing | ||
3966 | TESTMODE = 0 TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
3967 | @end example | ||
3968 | |||
3969 | In order to use the Bluetooth transport plugin when the transport service | ||
3970 | is started, you must add the plugin name to the default transport service | ||
3971 | plugins list. For example: | ||
3972 | |||
3973 | @example | ||
3974 | [transport] ... PLUGINS = dns bluetooth ... | ||
3975 | @end example | ||
3976 | |||
3977 | If you want to use only the Bluetooth plugin set | ||
3978 | @emph{PLUGINS = bluetooth} | ||
3979 | |||
3980 | On Windows, you cannot specify which device to use. The only thing that | ||
3981 | you should do is to add @emph{bluetooth} on the plugins list of the | ||
3982 | transport service. | ||
3983 | |||
3984 | @node How can I test it? | ||
3985 | @subsection How can I test it? | ||
3986 | @c %**end of header | ||
3987 | |||
3988 | If you have two Bluetooth devices on the same machine which use Linux you | ||
3989 | must: | ||
3990 | |||
3991 | @itemize @bullet | ||
3992 | |||
3993 | @item create two different file configuration (one which will use the | ||
3994 | first interface (@emph{hci0}) and the other which will use the second | ||
3995 | interface (@emph{hci1})). Let's name them @emph{peer1.conf} and | ||
3996 | @emph{peer2.conf}. | ||
3997 | |||
3998 | @item run @emph{gnunet-peerinfo -c peerX.conf -s} in order to generate the | ||
3999 | peers private keys. The @strong{X} must be replace with 1 or 2. | ||
4000 | |||
4001 | @item run @emph{gnunet-arm -c peerX.conf -s -i=transport} in order to | ||
4002 | start the transport service. (Make sure that you have "bluetooth" on the | ||
4003 | transport plugins list if the Bluetooth transport service doesn't start.) | ||
4004 | |||
4005 | @item run @emph{gnunet-peerinfo -c peer1.conf -s} to get the first peer's | ||
4006 | ID. If you already know your peer ID (you saved it from the first | ||
4007 | command), this can be skipped. | ||
4008 | |||
4009 | @item run @emph{gnunet-transport -c peer2.conf -p=PEER1_ID -s} to start | ||
4010 | sending data for benchmarking to the other peer. | ||
4011 | |||
4012 | @end itemize | ||
4013 | |||
4014 | |||
4015 | This scenario will try to connect the second peer to the first one and | ||
4016 | then start sending data for benchmarking. | ||
4017 | |||
4018 | On Windows you cannot test the plugin functionality using two Bluetooth | ||
4019 | devices from the same machine because after you install the drivers there | ||
4020 | will occur some conflicts between the Bluetooth stacks. (At least that is | ||
4021 | what happend on my machine : I wasn't able to use the Bluesoleil stack and | ||
4022 | the WINDCOMM one in the same time). | ||
4023 | |||
4024 | If you have two different machines and your configuration files are good | ||
4025 | you can use the same scenario presented on the begining of this section. | ||
4026 | |||
4027 | Another way to test the plugin functionality is to create your own | ||
4028 | application which will use the GNUnet framework with the Bluetooth | ||
4029 | transport service. | ||
4030 | |||
4031 | @node The implementation of the Bluetooth transport plugin | ||
4032 | @subsection The implementation of the Bluetooth transport plugin | ||
4033 | @c %**end of header | ||
4034 | |||
4035 | This page describes the implementation of the Bluetooth transport plugin. | ||
4036 | |||
4037 | First I want to remind you that the Bluetooth transport plugin uses | ||
4038 | virtually the same code as the WLAN plugin and only the helper binary is | ||
4039 | different. Also the scope of the helper binary from the Bluetooth | ||
4040 | transport plugin is the same as the one used for the wlan transport | ||
4041 | plugin: it acceses the interface and then it forwards traffic in both | ||
4042 | directions between the Bluetooth interface and stdin/stdout of the | ||
4043 | process involved. | ||
4044 | |||
4045 | The Bluetooth plugin transport could be used both on Linux and Windows | ||
4046 | platforms. | ||
4047 | |||
4048 | @itemize @bullet | ||
4049 | @item Linux functionality | ||
4050 | @item Windows functionality | ||
4051 | @item Pending Features | ||
4052 | @end itemize | ||
4053 | |||
4054 | |||
4055 | |||
4056 | @menu | ||
4057 | * Linux functionality:: | ||
4058 | * THE INITIALIZATION:: | ||
4059 | * THE LOOP:: | ||
4060 | * Details about the broadcast implementation:: | ||
4061 | * Windows functionality:: | ||
4062 | * Pending features:: | ||
4063 | @end menu | ||
4064 | |||
4065 | @node Linux functionality | ||
4066 | @subsubsection Linux functionality | ||
4067 | @c %**end of header | ||
4068 | |||
4069 | In order to implement the plugin functionality on Linux I used the BlueZ | ||
4070 | stack. For the communication with the other devices I used the RFCOMM | ||
4071 | protocol. Also I used the HCI protocol to gain some control over the | ||
4072 | device. The helper binary takes a single argument (the name of the | ||
4073 | Bluetooth interface) and is separated in two stages: | ||
4074 | |||
4075 | @c %** 'THE INITIALIZATION' should be in bigger letters or stand out, not | ||
4076 | @c %** starting a new section? | ||
4077 | @node THE INITIALIZATION | ||
4078 | @subsubsection THE INITIALIZATION | ||
4079 | |||
4080 | @itemize @bullet | ||
4081 | @item first, it checks if we have root privilegies | ||
4082 | (@emph{Remember that we need to have root privilegies in order to be able | ||
4083 | to bring the interface up if it is down or to change its state.}). | ||
4084 | |||
4085 | @item second, it verifies if the interface with the given name exists. | ||
4086 | |||
4087 | @strong{If the interface with that name exists and it is a Bluetooth | ||
4088 | interface:} | ||
4089 | |||
4090 | @item it creates a RFCOMM socket which will be used for listening and call | ||
4091 | the @emph{open_device} method | ||
4092 | |||
4093 | On the @emph{open_device} method: | ||
4094 | @itemize @bullet | ||
4095 | @item creates a HCI socket used to send control events to the the device | ||
4096 | @item searches for the device ID using the interface name | ||
4097 | @item saves the device MAC address | ||
4098 | @item checks if the interface is down and tries to bring it UP | ||
4099 | @item checks if the interface is in discoverable mode and tries to make it | ||
4100 | discoverable | ||
4101 | @item closes the HCI socket and binds the RFCOMM one | ||
4102 | @item switches the RFCOMM socket in listening mode | ||
4103 | @item registers the SDP service (the service will be used by the other | ||
4104 | devices to get the port on which this device is listening on) | ||
4105 | @end itemize | ||
4106 | |||
4107 | @item drops the root privilegies | ||
4108 | |||
4109 | @strong{If the interface is not a Bluetooth interface the helper exits | ||
4110 | with a suitable error} | ||
4111 | @end itemize | ||
4112 | |||
4113 | @c %** Same as for @node entry above | ||
4114 | @node THE LOOP | ||
4115 | @subsubsection THE LOOP | ||
4116 | |||
4117 | The helper binary uses a list where it saves all the connected neighbour | ||
4118 | devices (@emph{neighbours.devices}) and two buffers (@emph{write_pout} and | ||
4119 | @emph{write_std}). The first message which is send is a control message | ||
4120 | with the device's MAC address in order to announce the peer presence to | ||
4121 | the neighbours. Here are a short description of what happens in the main | ||
4122 | loop: | ||
4123 | |||
4124 | @itemize @bullet | ||
4125 | @item Every time when it receives something from the STDIN it processes | ||
4126 | the data and saves the message in the first buffer (@emph{write_pout}). | ||
4127 | When it has something in the buffer, it gets the destination address from | ||
4128 | the buffer, searches the destination address in the list (if there is no | ||
4129 | connection with that device, it creates a new one and saves it to the | ||
4130 | list) and sends the message. | ||
4131 | @item Every time when it receives something on the listening socket it | ||
4132 | accepts the connection and saves the socket on a list with the reading | ||
4133 | sockets. @item Every time when it receives something from a reading | ||
4134 | socket it parses the message, verifies the CRC and saves it in the | ||
4135 | @emph{write_std} buffer in order to be sent later to the STDOUT. | ||
4136 | @end itemize | ||
4137 | |||
4138 | So in the main loop we use the select function to wait until one of the | ||
4139 | file descriptor saved in one of the two file descriptors sets used is | ||
4140 | ready to use. The first set (@emph{rfds}) represents the reading set and | ||
4141 | it could contain the list with the reading sockets, the STDIN file | ||
4142 | descriptor or the listening socket. The second set (@emph{wfds}) is the | ||
4143 | writing set and it could contain the sending socket or the STDOUT file | ||
4144 | descriptor. After the select function returns, we check which file | ||
4145 | descriptor is ready to use and we do what is supposed to do on that kind | ||
4146 | of event. @emph{For example:} if it is the listening socket then we | ||
4147 | accept a new connection and save the socket in the reading list; if it is | ||
4148 | the STDOUT file descriptor, then we write to STDOUT the message from the | ||
4149 | @emph{write_std} buffer. | ||
4150 | |||
4151 | To find out on which port a device is listening on we connect to the local | ||
4152 | SDP server and searche the registered service for that device. | ||
4153 | |||
4154 | @emph{You should be aware of the fact that if the device fails to connect | ||
4155 | to another one when trying to send a message it will attempt one more | ||
4156 | time. If it fails again, then it skips the message.} | ||
4157 | @emph{Also you should know that the transport Bluetooth plugin has | ||
4158 | support for @strong{broadcast messages}.} | ||
4159 | |||
4160 | @node Details about the broadcast implementation | ||
4161 | @subsubsection Details about the broadcast implementation | ||
4162 | @c %**end of header | ||
4163 | |||
4164 | First I want to point out that the broadcast functionality for the CONTROL | ||
4165 | messages is not implemented in a conventional way. Since the inquiry scan | ||
4166 | time is too big and it will take some time to send a message to all the | ||
4167 | discoverable devices I decided to tackle the problem in a different way. | ||
4168 | Here is how I did it: | ||
4169 | |||
4170 | @itemize @bullet | ||
4171 | @item If it is the first time when I have to broadcast a message I make an | ||
4172 | inquiry scan and save all the devices' addresses to a vector. | ||
4173 | @item After the inquiry scan ends I take the first address from the list | ||
4174 | and I try to connect to it. If it fails, I try to connect to the next one. | ||
4175 | If it succeeds, I save the socket to a list and send the message to the | ||
4176 | device. | ||
4177 | @item When I have to broadcast another message, first I search on the list | ||
4178 | for a new device which I'm not connected to. If there is no new device on | ||
4179 | the list I go to the beginning of the list and send the message to the | ||
4180 | old devices. After 5 cycles I make a new inquiry scan to check out if | ||
4181 | there are new discoverable devices and save them to the list. If there | ||
4182 | are no new discoverable devices I reset the cycling counter and go again | ||
4183 | through the old list and send messages to the devices saved in it. | ||
4184 | @end itemize | ||
4185 | |||
4186 | @strong{Therefore}: | ||
4187 | |||
4188 | @itemize @bullet | ||
4189 | @item every time when I have a broadcast message I look up on the list | ||
4190 | for a new device and send the message to it | ||
4191 | @item if I reached the end of the list for 5 times and I'm connected to | ||
4192 | all the devices from the list I make a new inquiry scan. | ||
4193 | @emph{The number of the list's cycles after an inquiry scan could be | ||
4194 | increased by redefining the MAX_LOOPS variable} | ||
4195 | @item when there are no new devices I send messages to the old ones. | ||
4196 | @end itemize | ||
4197 | |||
4198 | Doing so, the broadcast control messages will reach the devices but with | ||
4199 | delay. | ||
4200 | |||
4201 | @emph{NOTICE:} When I have to send a message to a certain device first I | ||
4202 | check on the broadcast list to see if we are connected to that device. If | ||
4203 | not we try to connect to it and in case of success we save the address and | ||
4204 | the socket on the list. If we are already connected to that device we | ||
4205 | simply use the socket. | ||
4206 | |||
4207 | @node Windows functionality | ||
4208 | @subsubsection Windows functionality | ||
4209 | @c %**end of header | ||
4210 | |||
4211 | For Windows I decided to use the Microsoft Bluetooth stack which has the | ||
4212 | advantage of coming standard from Windows XP SP2. The main disadvantage is | ||
4213 | that it only supports the RFCOMM protocol so we will not be able to have | ||
4214 | a low level control over the Bluetooth device. Therefore it is the user | ||
4215 | responsability to check if the device is up and in the discoverable mode. | ||
4216 | Also there are no tools which could be used for debugging in order to read | ||
4217 | the data coming from and going to a Bluetooth device, which obviously | ||
4218 | hindered my work. Another thing that slowed down the implementation of the | ||
4219 | plugin (besides that I wasn't too accomodated with the win32 API) was that | ||
4220 | there were some bugs on MinGW regarding the Bluetooth. Now they are solved | ||
4221 | but you should keep in mind that you should have the latest updates | ||
4222 | (especially the @emph{ws2bth} header). | ||
4223 | |||
4224 | Besides the fact that it uses the Windows Sockets, the Windows | ||
4225 | implemenation follows the same principles as the Linux one: | ||
4226 | |||
4227 | @itemize @bullet | ||
4228 | @item It has a initalization part where it initializes the | ||
4229 | Windows Sockets, creates a RFCOMM socket which will be binded and switched | ||
4230 | to the listening mode and registers a SDP service. In the Microsoft | ||
4231 | Bluetooth API there are two ways to work with the SDP: | ||
4232 | @itemize @bullet | ||
4233 | @item an easy way which works with very simple service records | ||
4234 | @item a hard way which is useful when you need to update or to delete the | ||
4235 | record | ||
4236 | @end itemize | ||
4237 | @end itemize | ||
4238 | |||
4239 | Since I only needed the SDP service to find out on which port the device | ||
4240 | is listening on and that did not change, I decided to use the easy way. | ||
4241 | In order to register the service I used the @emph{WSASetService} function | ||
4242 | and I generated the @emph{Universally Unique Identifier} with the | ||
4243 | @emph{guidgen.exe} Windows's tool. | ||
4244 | |||
4245 | In the loop section the only difference from the Linux implementation is | ||
4246 | that I used the GNUNET_NETWORK library for functions like @emph{accept}, | ||
4247 | @emph{bind}, @emph{connect} or @emph{select}. I decided to use the | ||
4248 | GNUNET_NETWORK library because I also needed to interact with the STDIN | ||
4249 | and STDOUT handles and on Windows the select function is only defined for | ||
4250 | sockets, and it will not work for arbitrary file handles. | ||
4251 | |||
4252 | Another difference between Linux and Windows implementation is that in | ||
4253 | Linux, the Bluetooth address is represented in 48 bits while in Windows is | ||
4254 | represented in 64 bits. Therefore I had to do some changes on | ||
4255 | @emph{plugin_transport_wlan} header. | ||
4256 | |||
4257 | Also, currently on Windows the Bluetooth plugin doesn't have support for | ||
4258 | broadcast messages. When it receives a broadcast message it will skip it. | ||
4259 | |||
4260 | @node Pending features | ||
4261 | @subsubsection Pending features | ||
4262 | @c %**end of header | ||
4263 | |||
4264 | @itemize @bullet | ||
4265 | @item Implement the broadcast functionality on Windows @emph{(currently | ||
4266 | working on)} | ||
4267 | @item Implement a testcase for the helper :@ @emph{The testcase | ||
4268 | consists of a program which emaluates the plugin and uses the helper. It | ||
4269 | will simulate connections, disconnections and data transfers.} | ||
4270 | @end itemize | ||
4271 | |||
4272 | If you have a new idea about a feature of the plugin or suggestions about | ||
4273 | how I could improve the implementation you are welcome to comment or to | ||
4274 | contact me. | ||
4275 | |||
4276 | @node WLAN plugin | ||
4277 | @section WLAN plugin | ||
4278 | @c %**end of header | ||
4279 | |||
4280 | This section documents how the wlan transport plugin works. Parts which | ||
4281 | are not implemented yet or could be better implemented are described at | ||
4282 | the end. | ||
4283 | |||
4284 | @cindex ats subsystem | ||
4285 | @node The ATS Subsystem | ||
4286 | @section The ATS Subsystem | ||
4287 | @c %**end of header | ||
4288 | |||
4289 | ATS stands for "automatic transport selection", and the function of ATS in | ||
4290 | GNUnet is to decide on which address (and thus transport plugin) should | ||
4291 | be used for two peers to communicate, and what bandwidth limits should be | ||
4292 | imposed on such an individual connection. To help ATS make an informed | ||
4293 | decision, higher-level services inform the ATS service about their | ||
4294 | requirements and the quality of the service rendered. The ATS service | ||
4295 | also interacts with the transport service to be appraised of working | ||
4296 | addresses and to communicate its resource allocation decisions. Finally, | ||
4297 | the ATS service's operation can be observed using a monitoring API. | ||
4298 | |||
4299 | The main logic of the ATS service only collects the available addresses, | ||
4300 | their performance characteristics and the applications requirements, but | ||
4301 | does not make the actual allocation decision. This last critical step is | ||
4302 | left to an ATS plugin, as we have implemented (currently three) different | ||
4303 | allocation strategies which differ significantly in their performance and | ||
4304 | maturity, and it is still unclear if any particular plugin is generally | ||
4305 | superior. | ||
4306 | |||
4307 | @cindex core subsystem | ||
4308 | @cindex CORE subsystem | ||
4309 | @node GNUnet's CORE Subsystem | ||
4310 | @section GNUnet's CORE Subsystem | ||
4311 | @c %**end of header | ||
4312 | |||
4313 | The CORE subsystem in GNUnet is responsible for securing link-layer | ||
4314 | communications between nodes in the GNUnet overlay network. CORE builds | ||
4315 | on the TRANSPORT subsystem which provides for the actual, insecure, | ||
4316 | unreliable link-layer communication (for example, via UDP or WLAN), and | ||
4317 | then adds fundamental security to the connections: | ||
4318 | |||
4319 | @itemize @bullet | ||
4320 | @item confidentiality with so-called perfect forward secrecy; we use | ||
4321 | ECDHE@footnote{@uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, Elliptic-curve Diffie---Hellman}} | ||
4322 | powered by Curve25519 | ||
4323 | @footnote{@uref{http://cr.yp.to/ecdh.html, Curve25519}} for the key | ||
4324 | exchange and then use symmetric encryption, encrypting with both AES-256 | ||
4325 | @footnote{@uref{http://en.wikipedia.org/wiki/Rijndael, AES-256}} and | ||
4326 | Twofish @footnote{@uref{http://en.wikipedia.org/wiki/Twofish, Twofish}} | ||
4327 | @item @uref{http://en.wikipedia.org/wiki/Authentication, authentication} | ||
4328 | is achieved by signing the ephemeral keys using Ed25519 | ||
4329 | @footnote{@uref{http://ed25519.cr.yp.to/, Ed25519}}, a deterministic | ||
4330 | variant of ECDSA | ||
4331 | @footnote{@uref{http://en.wikipedia.org/wiki/ECDSA, ECDSA}} | ||
4332 | @item integrity protection (using SHA-512 | ||
4333 | @footnote{@uref{http://en.wikipedia.org/wiki/SHA-2, SHA-512}} to do | ||
4334 | encrypt-then-MAC | ||
4335 | @footnote{@uref{http://en.wikipedia.org/wiki/Authenticated_encryption, encrypt-then-MAC}}) | ||
4336 | @item Replay | ||
4337 | @footnote{@uref{http://en.wikipedia.org/wiki/Replay_attack, replay}} | ||
4338 | protection (using nonces, timestamps, challenge-response, | ||
4339 | message counters and ephemeral keys) | ||
4340 | @item liveness (keep-alive messages, timeout) | ||
4341 | @end itemize | ||
4342 | |||
4343 | @menu | ||
4344 | * Limitations:: | ||
4345 | * When is a peer "connected"?:: | ||
4346 | * libgnunetcore:: | ||
4347 | * The CORE Client-Service Protocol:: | ||
4348 | * The CORE Peer-to-Peer Protocol:: | ||
4349 | @end menu | ||
4350 | |||
4351 | @cindex core subsystem limitations | ||
4352 | @node Limitations | ||
4353 | @subsection Limitations | ||
4354 | @c %**end of header | ||
4355 | |||
4356 | CORE does not perform | ||
4357 | @uref{http://en.wikipedia.org/wiki/Routing, routing}; using CORE it is | ||
4358 | only possible to communicate with peers that happen to already be | ||
4359 | "directly" connected with each other. CORE also does not have an | ||
4360 | API to allow applications to establish such "direct" connections --- for | ||
4361 | this, applications can ask TRANSPORT, but TRANSPORT might not be able to | ||
4362 | establish a "direct" connection. The TOPOLOGY subsystem is responsible for | ||
4363 | trying to keep a few "direct" connections open at all times. Applications | ||
4364 | that need to talk to particular peers should use the CADET subsystem, as | ||
4365 | it can establish arbitrary "indirect" connections. | ||
4366 | |||
4367 | Because CORE does not perform routing, CORE must only be used directly by | ||
4368 | applications that either perform their own routing logic (such as | ||
4369 | anonymous file-sharing) or that do not require routing, for example | ||
4370 | because they are based on flooding the network. CORE communication is | ||
4371 | unreliable and delivery is possibly out-of-order. Applications that | ||
4372 | require reliable communication should use the CADET service. Each | ||
4373 | application can only queue one message per target peer with the CORE | ||
4374 | service at any time; messages cannot be larger than approximately | ||
4375 | 63 kilobytes. If messages are small, CORE may group multiple messages | ||
4376 | (possibly from different applications) prior to encryption. If permitted | ||
4377 | by the application (using the @uref{http://baus.net/on-tcp_cork/, cork} | ||
4378 | option), CORE may delay transmissions to facilitate grouping of multiple | ||
4379 | small messages. If cork is not enabled, CORE will transmit the message as | ||
4380 | soon as TRANSPORT allows it (TRANSPORT is responsible for limiting | ||
4381 | bandwidth and congestion control). CORE does not allow flow control; | ||
4382 | applications are expected to process messages at line-speed. If flow | ||
4383 | control is needed, applications should use the CADET service. | ||
4384 | |||
4385 | @cindex when is a peer connected | ||
4386 | @node When is a peer "connected"? | ||
4387 | @subsection When is a peer "connected"? | ||
4388 | @c %**end of header | ||
4389 | |||
4390 | In addition to the security features mentioned above, CORE also provides | ||
4391 | one additional key feature to applications using it, and that is a | ||
4392 | limited form of protocol-compatibility checking. CORE distinguishes | ||
4393 | between TRANSPORT-level connections (which enable communication with other | ||
4394 | peers) and application-level connections. Applications using the CORE API | ||
4395 | will (typically) learn about application-level connections from CORE, and | ||
4396 | not about TRANSPORT-level connections. When a typical application uses | ||
4397 | CORE, it will specify a set of message types | ||
4398 | (from @code{gnunet_protocols.h}) that it understands. CORE will then | ||
4399 | notify the application about connections it has with other peers if and | ||
4400 | only if those applications registered an intersecting set of message | ||
4401 | types with their CORE service. Thus, it is quite possible that CORE only | ||
4402 | exposes a subset of the established direct connections to a particular | ||
4403 | application --- and different applications running above CORE might see | ||
4404 | different sets of connections at the same time. | ||
4405 | |||
4406 | A special case are applications that do not register a handler for any | ||
4407 | message type. | ||
4408 | CORE assumes that these applications merely want to monitor connections | ||
4409 | (or "all" messages via other callbacks) and will notify those applications | ||
4410 | about all connections. This is used, for example, by the | ||
4411 | @code{gnunet-core} command-line tool to display the active connections. | ||
4412 | Note that it is also possible that the TRANSPORT service has more active | ||
4413 | connections than the CORE service, as the CORE service first has to | ||
4414 | perform a key exchange with connecting peers before exchanging information | ||
4415 | about supported message types and notifying applications about the new | ||
4416 | connection. | ||
4417 | |||
4418 | @cindex libgnunetcore | ||
4419 | @node libgnunetcore | ||
4420 | @subsection libgnunetcore | ||
4421 | @c %**end of header | ||
4422 | |||
4423 | The CORE API (defined in @file{gnunet_core_service.h}) is the basic | ||
4424 | messaging API used by P2P applications built using GNUnet. It provides | ||
4425 | applications the ability to send and receive encrypted messages to the | ||
4426 | peer's "directly" connected neighbours. | ||
4427 | |||
4428 | As CORE connections are generally "direct" connections,@ applications must | ||
4429 | not assume that they can connect to arbitrary peers this way, as "direct" | ||
4430 | connections may not always be possible. Applications using CORE are | ||
4431 | notified about which peers are connected. Creating new "direct" | ||
4432 | connections must be done using the TRANSPORT API. | ||
4433 | |||
4434 | The CORE API provides unreliable, out-of-order delivery. While the | ||
4435 | implementation tries to ensure timely, in-order delivery, both message | ||
4436 | losses and reordering are not detected and must be tolerated by the | ||
4437 | application. Most important, the core will NOT perform retransmission if | ||
4438 | messages could not be delivered. | ||
4439 | |||
4440 | Note that CORE allows applications to queue one message per connected | ||
4441 | peer. The rate at which each connection operates is influenced by the | ||
4442 | preferences expressed by local application as well as restrictions | ||
4443 | imposed by the other peer. Local applications can express their | ||
4444 | preferences for particular connections using the "performance" API of the | ||
4445 | ATS service. | ||
4446 | |||
4447 | Applications that require more sophisticated transmission capabilities | ||
4448 | such as TCP-like behavior, or if you intend to send messages to arbitrary | ||
4449 | remote peers, should use the CADET API. | ||
4450 | |||
4451 | The typical use of the CORE API is to connect to the CORE service using | ||
4452 | @code{GNUNET_CORE_connect}, process events from the CORE service (such as | ||
4453 | peers connecting, peers disconnecting and incoming messages) and send | ||
4454 | messages to connected peers using | ||
4455 | @code{GNUNET_CORE_notify_transmit_ready}. Note that applications must | ||
4456 | cancel pending transmission requests if they receive a disconnect event | ||
4457 | for a peer that had a transmission pending; furthermore, queueing more | ||
4458 | than one transmission request per peer per application using the | ||
4459 | service is not permitted. | ||
4460 | |||
4461 | The CORE API also allows applications to monitor all communications of the | ||
4462 | peer prior to encryption (for outgoing messages) or after decryption (for | ||
4463 | incoming messages). This can be useful for debugging, diagnostics or to | ||
4464 | establish the presence of cover traffic (for anonymity). As monitoring | ||
4465 | applications are often not interested in the payload, the monitoring | ||
4466 | callbacks can be configured to only provide the message headers (including | ||
4467 | the message type and size) instead of copying the full data stream to the | ||
4468 | monitoring client. | ||
4469 | |||
4470 | The init callback of the @code{GNUNET_CORE_connect} function is called | ||
4471 | with the hash of the public key of the peer. This public key is used to | ||
4472 | identify the peer globally in the GNUnet network. Applications are | ||
4473 | encouraged to check that the provided hash matches the hash that they are | ||
4474 | using (as theoretically the application may be using a different | ||
4475 | configuration file with a different private key, which would result in | ||
4476 | hard to find bugs). | ||
4477 | |||
4478 | As with most service APIs, the CORE API isolates applications from crashes | ||
4479 | of the CORE service. If the CORE service crashes, the application will see | ||
4480 | disconnect events for all existing connections. Once the connections are | ||
4481 | re-established, the applications will be receive matching connect events. | ||
4482 | |||
4483 | @cindex core clinet-service protocol | ||
4484 | @node The CORE Client-Service Protocol | ||
4485 | @subsection The CORE Client-Service Protocol | ||
4486 | @c %**end of header | ||
4487 | |||
4488 | This section describes the protocol between an application using the CORE | ||
4489 | service (the client) and the CORE service process itself. | ||
4490 | |||
4491 | |||
4492 | @menu | ||
4493 | * Setup2:: | ||
4494 | * Notifications:: | ||
4495 | * Sending:: | ||
4496 | @end menu | ||
4497 | |||
4498 | @node Setup2 | ||
4499 | @subsubsection Setup2 | ||
4500 | @c %**end of header | ||
4501 | |||
4502 | When a client connects to the CORE service, it first sends a | ||
4503 | @code{InitMessage} which specifies options for the connection and a set of | ||
4504 | message type values which are supported by the application. The options | ||
4505 | bitmask specifies which events the client would like to be notified about. | ||
4506 | The options include: | ||
4507 | |||
4508 | @table @asis | ||
4509 | @item GNUNET_CORE_OPTION_NOTHING No notifications | ||
4510 | @item GNUNET_CORE_OPTION_STATUS_CHANGE Peers connecting and disconnecting | ||
4511 | @item GNUNET_CORE_OPTION_FULL_INBOUND All inbound messages (after | ||
4512 | decryption) with full payload | ||
4513 | @item GNUNET_CORE_OPTION_HDR_INBOUND Just the @code{MessageHeader} | ||
4514 | of all inbound messages | ||
4515 | @item GNUNET_CORE_OPTION_FULL_OUTBOUND All outbound | ||
4516 | messages (prior to encryption) with full payload | ||
4517 | @item GNUNET_CORE_OPTION_HDR_OUTBOUND Just the @code{MessageHeader} of all | ||
4518 | outbound messages | ||
4519 | @end table | ||
4520 | |||
4521 | Typical applications will only monitor for connection status changes. | ||
4522 | |||
4523 | The CORE service responds to the @code{InitMessage} with an | ||
4524 | @code{InitReplyMessage} which contains the peer's identity. Afterwards, | ||
4525 | both CORE and the client can send messages. | ||
4526 | |||
4527 | @node Notifications | ||
4528 | @subsubsection Notifications | ||
4529 | @c %**end of header | ||
4530 | |||
4531 | The CORE will send @code{ConnectNotifyMessage}s and | ||
4532 | @code{DisconnectNotifyMessage}s whenever peers connect or disconnect from | ||
4533 | the CORE (assuming their type maps overlap with the message types | ||
4534 | registered by the client). When the CORE receives a message that matches | ||
4535 | the set of message types specified during the @code{InitMessage} (or if | ||
4536 | monitoring is enabled in for inbound messages in the options), it sends a | ||
4537 | @code{NotifyTrafficMessage} with the peer identity of the sender and the | ||
4538 | decrypted payload. The same message format (except with | ||
4539 | @code{GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND} for the message type) is | ||
4540 | used to notify clients monitoring outbound messages; here, the peer | ||
4541 | identity given is that of the receiver. | ||
4542 | |||
4543 | @node Sending | ||
4544 | @subsubsection Sending | ||
4545 | @c %**end of header | ||
4546 | |||
4547 | When a client wants to transmit a message, it first requests a | ||
4548 | transmission slot by sending a @code{SendMessageRequest} which specifies | ||
4549 | the priority, deadline and size of the message. Note that these values | ||
4550 | may be ignored by CORE. When CORE is ready for the message, it answers | ||
4551 | with a @code{SendMessageReady} response. The client can then transmit the | ||
4552 | payload with a @code{SendMessage} message. Note that the actual message | ||
4553 | size in the @code{SendMessage} is allowed to be smaller than the size in | ||
4554 | the original request. A client may at any time send a fresh | ||
4555 | @code{SendMessageRequest}, which then superceeds the previous | ||
4556 | @code{SendMessageRequest}, which is then no longer valid. The client can | ||
4557 | tell which @code{SendMessageRequest} the CORE service's | ||
4558 | @code{SendMessageReady} message is for as all of these messages contain a | ||
4559 | "unique" request ID (based on a counter incremented by the client | ||
4560 | for each request). | ||
4561 | |||
4562 | @cindex CORE Peer-to-Peer Protocol | ||
4563 | @node The CORE Peer-to-Peer Protocol | ||
4564 | @subsection The CORE Peer-to-Peer Protocol | ||
4565 | @c %**end of header | ||
4566 | |||
4567 | |||
4568 | @menu | ||
4569 | * Creating the EphemeralKeyMessage:: | ||
4570 | * Establishing a connection:: | ||
4571 | * Encryption and Decryption:: | ||
4572 | * Type maps:: | ||
4573 | @end menu | ||
4574 | |||
4575 | @cindex EphemeralKeyMessage creation | ||
4576 | @node Creating the EphemeralKeyMessage | ||
4577 | @subsubsection Creating the EphemeralKeyMessage | ||
4578 | @c %**end of header | ||
4579 | |||
4580 | When the CORE service starts, each peer creates a fresh ephemeral (ECC) | ||
4581 | public-private key pair and signs the corresponding | ||
4582 | @code{EphemeralKeyMessage} with its long-term key (which we usually call | ||
4583 | the peer's identity; the hash of the public long term key is what results | ||
4584 | in a @code{struct GNUNET_PeerIdentity} in all GNUnet APIs. The ephemeral | ||
4585 | key is ONLY used for an ECDHE@footnote{@uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, Elliptic-curve Diffie---Hellman}} | ||
4586 | exchange by the CORE service to establish symmetric session keys. A peer | ||
4587 | will use the same @code{EphemeralKeyMessage} for all peers for | ||
4588 | @code{REKEY_FREQUENCY}, which is usually 12 hours. After that time, it | ||
4589 | will create a fresh ephemeral key (forgetting the old one) and broadcast | ||
4590 | the new @code{EphemeralKeyMessage} to all connected peers, resulting in | ||
4591 | fresh symmetric session keys. Note that peers independently decide on | ||
4592 | when to discard ephemeral keys; it is not a protocol violation to discard | ||
4593 | keys more often. Ephemeral keys are also never stored to disk; restarting | ||
4594 | a peer will thus always create a fresh ephemeral key. The use of ephemeral | ||
4595 | keys is what provides @uref{http://en.wikipedia.org/wiki/Forward_secrecy, forward secrecy}. | ||
4596 | |||
4597 | Just before transmission, the @code{EphemeralKeyMessage} is patched to | ||
4598 | reflect the current sender_status, which specifies the current state of | ||
4599 | the connection from the point of view of the sender. The possible values | ||
4600 | are: | ||
4601 | |||
4602 | @itemize @bullet | ||
4603 | @item @code{KX_STATE_DOWN} Initial value, never used on the network | ||
4604 | @item @code{KX_STATE_KEY_SENT} We sent our ephemeral key, do not know the | ||
4605 | key of the other peer | ||
4606 | @item @code{KX_STATE_KEY_RECEIVED} This peer has received a valid | ||
4607 | ephemeral key of the other peer, but we are waiting for the other peer to | ||
4608 | confirm it's authenticity (ability to decode) via challenge-response. | ||
4609 | @item @code{KX_STATE_UP} The connection is fully up from the point of | ||
4610 | view of the sender (now performing keep-alives) | ||
4611 | @item @code{KX_STATE_REKEY_SENT} The sender has initiated a rekeying | ||
4612 | operation; the other peer has so far failed to confirm a working | ||
4613 | connection using the new ephemeral key | ||
4614 | @end itemize | ||
4615 | |||
4616 | @node Establishing a connection | ||
4617 | @subsubsection Establishing a connection | ||
4618 | @c %**end of header | ||
4619 | |||
4620 | Peers begin their interaction by sending a @code{EphemeralKeyMessage} to | ||
4621 | the other peer once the TRANSPORT service notifies the CORE service about | ||
4622 | the connection. | ||
4623 | A peer receiving an @code{EphemeralKeyMessage} with a status | ||
4624 | indicating that the sender does not have the receiver's ephemeral key, the | ||
4625 | receiver's @code{EphemeralKeyMessage} is sent in response. | ||
4626 | Additionally, if the receiver has not yet confirmed the authenticity of | ||
4627 | the sender, it also sends an (encrypted)@code{PingMessage} with a | ||
4628 | challenge (and the identity of the target) to the other peer. Peers | ||
4629 | receiving a @code{PingMessage} respond with an (encrypted) | ||
4630 | @code{PongMessage} which includes the challenge. Peers receiving a | ||
4631 | @code{PongMessage} check the challenge, and if it matches set the | ||
4632 | connection to @code{KX_STATE_UP}. | ||
4633 | |||
4634 | @node Encryption and Decryption | ||
4635 | @subsubsection Encryption and Decryption | ||
4636 | @c %**end of header | ||
4637 | |||
4638 | All functions related to the key exchange and encryption/decryption of | ||
4639 | messages can be found in @file{gnunet-service-core_kx.c} (except for the | ||
4640 | cryptographic primitives, which are in @file{util/crypto*.c}). | ||
4641 | Given the key material from ECDHE, a Key derivation function | ||
4642 | @footnote{@uref{https://en.wikipedia.org/wiki/Key_derivation_function, Key derivation function}} | ||
4643 | is used to derive two pairs of encryption and decryption keys for AES-256 | ||
4644 | and TwoFish, as well as initialization vectors and authentication keys | ||
4645 | (for HMAC@footnote{@uref{https://en.wikipedia.org/wiki/HMAC, HMAC}}). | ||
4646 | The HMAC is computed over the encrypted payload. | ||
4647 | Encrypted messages include an iv_seed and the HMAC in the header. | ||
4648 | |||
4649 | Each encrypted message in the CORE service includes a sequence number and | ||
4650 | a timestamp in the encrypted payload. The CORE service remembers the | ||
4651 | largest observed sequence number and a bit-mask which represents which of | ||
4652 | the previous 32 sequence numbers were already used. | ||
4653 | Messages with sequence numbers lower than the largest observed sequence | ||
4654 | number minus 32 are discarded. Messages with a timestamp that is less | ||
4655 | than @code{REKEY_TOLERANCE} off (5 minutes) are also discarded. This of | ||
4656 | course means that system clocks need to be reasonably synchronized for | ||
4657 | peers to be able to communicate. Additionally, as the ephemeral key | ||
4658 | changes every 12 hours, a peer would not even be able to decrypt messages | ||
4659 | older than 12 hours. | ||
4660 | |||
4661 | @node Type maps | ||
4662 | @subsubsection Type maps | ||
4663 | @c %**end of header | ||
4664 | |||
4665 | Once an encrypted connection has been established, peers begin to exchange | ||
4666 | type maps. Type maps are used to allow the CORE service to determine which | ||
4667 | (encrypted) connections should be shown to which applications. A type map | ||
4668 | is an array of 65536 bits representing the different types of messages | ||
4669 | understood by applications using the CORE service. Each CORE service | ||
4670 | maintains this map, simply by setting the respective bit for each message | ||
4671 | type supported by any of the applications using the CORE service. Note | ||
4672 | that bits for message types embedded in higher-level protocols (such as | ||
4673 | MESH) will not be included in these type maps. | ||
4674 | |||
4675 | Typically, the type map of a peer will be sparse. Thus, the CORE service | ||
4676 | attempts to compress its type map using @code{gzip}-style compression | ||
4677 | ("deflate") prior to transmission. However, if the compression fails to | ||
4678 | compact the map, the map may also be transmitted without compression | ||
4679 | (resulting in @code{GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP} or | ||
4680 | @code{GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP} messages respectively). | ||
4681 | Upon receiving a type map, the respective CORE service notifies | ||
4682 | applications about the connection to the other peer if they support any | ||
4683 | message type indicated in the type map (or no message type at all). | ||
4684 | If the CORE service experience a connect or disconnect event from an | ||
4685 | application, it updates its type map (setting or unsetting the respective | ||
4686 | bits) and notifies its neighbours about the change. | ||
4687 | The CORE services of the neighbours then in turn generate connect and | ||
4688 | disconnect events for the peer that sent the type map for their respective | ||
4689 | applications. As CORE messages may be lost, the CORE service confirms | ||
4690 | receiving a type map by sending back a | ||
4691 | @code{GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP}. If such a confirmation | ||
4692 | (with the correct hash of the type map) is not received, the sender will | ||
4693 | retransmit the type map (with exponential back-off). | ||
4694 | |||
4695 | @cindex cadet subsystem | ||
4696 | @cindex CADET | ||
4697 | @node GNUnet's CADET subsystem | ||
4698 | @section GNUnet's CADET subsystem | ||
4699 | |||
4700 | The CADET subsystem in GNUnet is responsible for secure end-to-end | ||
4701 | communications between nodes in the GNUnet overlay network. CADET builds | ||
4702 | on the CORE subsystem which provides for the link-layer communication and | ||
4703 | then adds routing, forwarding and additional security to the connections. | ||
4704 | CADET offers the same cryptographic services as CORE, but on an | ||
4705 | end-to-end level. This is done so peers retransmitting traffic on behalf | ||
4706 | of other peers cannot access the payload data. | ||
4707 | |||
4708 | @itemize @bullet | ||
4709 | @item CADET provides confidentiality with so-called perfect forward | ||
4710 | secrecy; we use ECDHE powered by Curve25519 for the key exchange and then | ||
4711 | use symmetric encryption, encrypting with both AES-256 and Twofish | ||
4712 | @item authentication is achieved by signing the ephemeral keys using | ||
4713 | Ed25519, a deterministic variant of ECDSA | ||
4714 | @item integrity protection (using SHA-512 to do encrypt-then-MAC, although | ||
4715 | only 256 bits are sent to reduce overhead) | ||
4716 | @item replay protection (using nonces, timestamps, challenge-response, | ||
4717 | message counters and ephemeral keys) | ||
4718 | @item liveness (keep-alive messages, timeout) | ||
4719 | @end itemize | ||
4720 | |||
4721 | Additional to the CORE-like security benefits, CADET offers other | ||
4722 | properties that make it a more universal service than CORE. | ||
4723 | |||
4724 | @itemize @bullet | ||
4725 | @item CADET can establish channels to arbitrary peers in GNUnet. If a | ||
4726 | peer is not immediately reachable, CADET will find a path through the | ||
4727 | network and ask other peers to retransmit the traffic on its behalf. | ||
4728 | @item CADET offers (optional) reliability mechanisms. In a reliable | ||
4729 | channel traffic is guaranteed to arrive complete, unchanged and in-order. | ||
4730 | @item CADET takes care of flow and congestion control mechanisms, not | ||
4731 | allowing the sender to send more traffic than the receiver or the network | ||
4732 | are able to process. | ||
4733 | @end itemize | ||
4734 | |||
4735 | @menu | ||
4736 | * libgnunetcadet:: | ||
4737 | @end menu | ||
4738 | |||
4739 | @cindex libgnunetcadet | ||
4740 | @node libgnunetcadet | ||
4741 | @subsection libgnunetcadet | ||
4742 | |||
4743 | |||
4744 | The CADET API (defined in @file{gnunet_cadet_service.h}) is the | ||
4745 | messaging API used by P2P applications built using GNUnet. | ||
4746 | It provides applications the ability to send and receive encrypted | ||
4747 | messages to any peer participating in GNUnet. | ||
4748 | The API is heavily base on the CORE API. | ||
4749 | |||
4750 | CADET delivers messages to other peers in "channels". | ||
4751 | A channel is a permanent connection defined by a destination peer | ||
4752 | (identified by its public key) and a port number. | ||
4753 | Internally, CADET tunnels all channels towards a destiantion peer | ||
4754 | using one session key and relays the data on multiple "connections", | ||
4755 | independent from the channels. | ||
4756 | |||
4757 | Each channel has optional paramenters, the most important being the | ||
4758 | reliability flag. | ||
4759 | Should a message get lost on TRANSPORT/CORE level, if a channel is | ||
4760 | created with as reliable, CADET will retransmit the lost message and | ||
4761 | deliver it in order to the destination application. | ||
4762 | |||
4763 | To communicate with other peers using CADET, it is necessary to first | ||
4764 | connect to the service using @code{GNUNET_CADET_connect}. | ||
4765 | This function takes several parameters in form of callbacks, to allow the | ||
4766 | client to react to various events, like incoming channels or channels that | ||
4767 | terminate, as well as specify a list of ports the client wishes to listen | ||
4768 | to (at the moment it is not possible to start listening on further ports | ||
4769 | once connected, but nothing prevents a client to connect several times to | ||
4770 | CADET, even do one connection per listening port). | ||
4771 | The function returns a handle which has to be used for any further | ||
4772 | interaction with the service. | ||
4773 | |||
4774 | To connect to a remote peer a client has to call the | ||
4775 | @code{GNUNET_CADET_channel_create} function. The most important parameters | ||
4776 | given are the remote peer's identity (it public key) and a port, which | ||
4777 | specifies which application on the remote peer to connect to, similar to | ||
4778 | TCP/UDP ports. CADET will then find the peer in the GNUnet network and | ||
4779 | establish the proper low-level connections and do the necessary key | ||
4780 | exchanges to assure and authenticated, secure and verified communication. | ||
4781 | Similar to @code{GNUNET_CADET_connect},@code{GNUNET_CADET_create_channel} | ||
4782 | returns a handle to interact with the created channel. | ||
4783 | |||
4784 | For every message the client wants to send to the remote application, | ||
4785 | @code{GNUNET_CADET_notify_transmit_ready} must be called, indicating the | ||
4786 | channel on which the message should be sent and the size of the message | ||
4787 | (but not the message itself!). Once CADET is ready to send the message, | ||
4788 | the provided callback will fire, and the message contents are provided to | ||
4789 | this callback. | ||
4790 | |||
4791 | Please note the CADET does not provide an explicit notification of when a | ||
4792 | channel is connected. In loosely connected networks, like big wireless | ||
4793 | mesh networks, this can take several seconds, even minutes in the worst | ||
4794 | case. To be alerted when a channel is online, a client can call | ||
4795 | @code{GNUNET_CADET_notify_transmit_ready} immediately after | ||
4796 | @code{GNUNET_CADET_create_channel}. When the callback is activated, it | ||
4797 | means that the channel is online. The callback can give 0 bytes to CADET | ||
4798 | if no message is to be sent, this is ok. | ||
4799 | |||
4800 | If a transmission was requested but before the callback fires it is no | ||
4801 | longer needed, it can be cancelled with | ||
4802 | @code{GNUNET_CADET_notify_transmit_ready_cancel}, which uses the handle | ||
4803 | given back by @code{GNUNET_CADET_notify_transmit_ready}. | ||
4804 | As in the case of CORE, only one message can be requested at a time: a | ||
4805 | client must not call @code{GNUNET_CADET_notify_transmit_ready} again until | ||
4806 | the callback is called or the request is cancelled. | ||
4807 | |||
4808 | When a channel is no longer needed, a client can call | ||
4809 | @code{GNUNET_CADET_channel_destroy} to get rid of it. | ||
4810 | Note that CADET will try to transmit all pending traffic before notifying | ||
4811 | the remote peer of the destruction of the channel, including | ||
4812 | retransmitting lost messages if the channel was reliable. | ||
4813 | |||
4814 | Incoming channels, channels being closed by the remote peer, and traffic | ||
4815 | on any incoming or outgoing channels are given to the client when CADET | ||
4816 | executes the callbacks given to it at the time of | ||
4817 | @code{GNUNET_CADET_connect}. | ||
4818 | |||
4819 | Finally, when an application no longer wants to use CADET, it should call | ||
4820 | @code{GNUNET_CADET_disconnect}, but first all channels and pending | ||
4821 | transmissions must be closed (otherwise CADET will complain). | ||
4822 | |||
4823 | @cindex nse subsystem | ||
4824 | @cindex NSE | ||
4825 | @node GNUnet's NSE subsystem | ||
4826 | @section GNUnet's NSE subsystem | ||
4827 | |||
4828 | |||
4829 | NSE stands for @dfn{Network Size Estimation}. The NSE subsystem provides | ||
4830 | other subsystems and users with a rough estimate of the number of peers | ||
4831 | currently participating in the GNUnet overlay. | ||
4832 | The computed value is not a precise number as producing a precise number | ||
4833 | in a decentralized, efficient and secure way is impossible. | ||
4834 | While NSE's estimate is inherently imprecise, NSE also gives the expected | ||
4835 | range. For a peer that has been running in a stable network for a | ||
4836 | while, the real network size will typically (99.7% of the time) be in the | ||
4837 | range of [2/3 estimate, 3/2 estimate]. We will now give an overview of the | ||
4838 | algorithm used to calculate the estimate; | ||
4839 | all of the details can be found in this technical report. | ||
4840 | |||
4841 | @c FIXME: link to the report. | ||
4842 | |||
4843 | @menu | ||
4844 | * Motivation:: | ||
4845 | * Principle:: | ||
4846 | * libgnunetnse:: | ||
4847 | * The NSE Client-Service Protocol:: | ||
4848 | * The NSE Peer-to-Peer Protocol:: | ||
4849 | @end menu | ||
4850 | |||
4851 | @node Motivation | ||
4852 | @subsection Motivation | ||
4853 | |||
4854 | |||
4855 | Some subsytems, like DHT, need to know the size of the GNUnet network to | ||
4856 | optimize some parameters of their own protocol. The decentralized nature | ||
4857 | of GNUnet makes efficient and securely counting the exact number of peers | ||
4858 | infeasable. Although there are several decentralized algorithms to count | ||
4859 | the number of peers in a system, so far there is none to do so securely. | ||
4860 | Other protocols may allow any malicious peer to manipulate the final | ||
4861 | result or to take advantage of the system to perform | ||
4862 | @dfn{Denial of Service} (DoS) attacks against the network. | ||
4863 | GNUnet's NSE protocol avoids these drawbacks. | ||
4864 | |||
4865 | |||
4866 | |||
4867 | @menu | ||
4868 | * Security:: | ||
4869 | @end menu | ||
4870 | |||
4871 | @cindex NSE security | ||
4872 | @cindex nse security | ||
4873 | @node Security | ||
4874 | @subsubsection Security | ||
4875 | |||
4876 | |||
4877 | The NSE subsystem is designed to be resilient against these attacks. | ||
4878 | It uses @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proofs of work} | ||
4879 | to prevent one peer from impersonating a large number of participants, | ||
4880 | which would otherwise allow an adversary to artifically inflate the | ||
4881 | estimate. | ||
4882 | The DoS protection comes from the time-based nature of the protocol: | ||
4883 | the estimates are calculated periodically and out-of-time traffic is | ||
4884 | either ignored or stored for later retransmission by benign peers. | ||
4885 | In particular, peers cannot trigger global network communication at will. | ||
4886 | |||
4887 | @cindex NSE principle | ||
4888 | @cindex nse principle | ||
4889 | @node Principle | ||
4890 | @subsection Principle | ||
4891 | |||
4892 | |||
4893 | The algorithm calculates the estimate by finding the globally closest | ||
4894 | peer ID to a random, time-based value. | ||
4895 | |||
4896 | The idea is that the closer the ID is to the random value, the more | ||
4897 | "densely packed" the ID space is, and therefore, more peers are in the | ||
4898 | network. | ||
4899 | |||
4900 | |||
4901 | |||
4902 | @menu | ||
4903 | * Example:: | ||
4904 | * Algorithm:: | ||
4905 | * Target value:: | ||
4906 | * Timing:: | ||
4907 | * Controlled Flooding:: | ||
4908 | * Calculating the estimate:: | ||
4909 | @end menu | ||
4910 | |||
4911 | @node Example | ||
4912 | @subsubsection Example | ||
4913 | |||
4914 | |||
4915 | Suppose all peers have IDs between 0 and 100 (our ID space), and the | ||
4916 | random value is 42. | ||
4917 | If the closest peer has the ID 70 we can imagine that the average | ||
4918 | "distance" between peers is around 30 and therefore the are around 3 | ||
4919 | peers in the whole ID space. On the other hand, if the closest peer has | ||
4920 | the ID 44, we can imagine that the space is rather packed with peers, | ||
4921 | maybe as much as 50 of them. | ||
4922 | Naturally, we could have been rather unlucky, and there is only one peer | ||
4923 | and happens to have the ID 44. Thus, the current estimate is calculated | ||
4924 | as the average over multiple rounds, and not just a single sample. | ||
4925 | |||
4926 | @node Algorithm | ||
4927 | @subsubsection Algorithm | ||
4928 | |||
4929 | |||
4930 | Given that example, one can imagine that the job of the subsystem is to | ||
4931 | efficiently communicate the ID of the closest peer to the target value | ||
4932 | to all the other peers, who will calculate the estimate from it. | ||
4933 | |||
4934 | @node Target value | ||
4935 | @subsubsection Target value | ||
4936 | |||
4937 | @c %**end of header | ||
4938 | |||
4939 | The target value itself is generated by hashing the current time, rounded | ||
4940 | down to an agreed value. If the rounding amount is 1h (default) and the | ||
4941 | time is 12:34:56, the time to hash would be 12:00:00. The process is | ||
4942 | repeated each rouning amount (in this example would be every hour). | ||
4943 | Every repetition is called a round. | ||
4944 | |||
4945 | @node Timing | ||
4946 | @subsubsection Timing | ||
4947 | @c %**end of header | ||
4948 | |||
4949 | The NSE subsystem has some timing control to avoid everybody broadcasting | ||
4950 | its ID all at one. Once each peer has the target random value, it | ||
4951 | compares its own ID to the target and calculates the hypothetical size of | ||
4952 | the network if that peer were to be the closest. | ||
4953 | Then it compares the hypothetical size with the estimate from the previous | ||
4954 | rounds. For each value there is an assiciated point in the period, | ||
4955 | let's call it "broadcast time". If its own hypothetical estimate | ||
4956 | is the same as the previous global estimate, its "broadcast time" will be | ||
4957 | in the middle of the round. If its bigger it will be earlier and if its | ||
4958 | smaller (the most likely case) it will be later. This ensures that the | ||
4959 | peers closests to the target value start broadcasting their ID the first. | ||
4960 | |||
4961 | @node Controlled Flooding | ||
4962 | @subsubsection Controlled Flooding | ||
4963 | |||
4964 | @c %**end of header | ||
4965 | |||
4966 | When a peer receives a value, first it verifies that it is closer than the | ||
4967 | closest value it had so far, otherwise it answers the incoming message | ||
4968 | with a message containing the better value. Then it checks a proof of | ||
4969 | work that must be included in the incoming message, to ensure that the | ||
4970 | other peer's ID is not made up (otherwise a malicious peer could claim to | ||
4971 | have an ID of exactly the target value every round). Once validated, it | ||
4972 | compares the brodcast time of the received value with the current time | ||
4973 | and if it's not too early, sends the received value to its neighbors. | ||
4974 | Otherwise it stores the value until the correct broadcast time comes. | ||
4975 | This prevents unnecessary traffic of sub-optimal values, since a better | ||
4976 | value can come before the broadcast time, rendering the previous one | ||
4977 | obsolete and saving the traffic that would have been used to broadcast it | ||
4978 | to the neighbors. | ||
4979 | |||
4980 | @node Calculating the estimate | ||
4981 | @subsubsection Calculating the estimate | ||
4982 | |||
4983 | @c %**end of header | ||
4984 | |||
4985 | Once the closest ID has been spread across the network each peer gets the | ||
4986 | exact distance betweed this ID and the target value of the round and | ||
4987 | calculates the estimate with a mathematical formula described in the tech | ||
4988 | report. The estimate generated with this method for a single round is not | ||
4989 | very precise. Remember the case of the example, where the only peer is the | ||
4990 | ID 44 and we happen to generate the target value 42, thinking there are | ||
4991 | 50 peers in the network. Therefore, the NSE subsystem remembers the last | ||
4992 | 64 estimates and calculates an average over them, giving a result of which | ||
4993 | usually has one bit of uncertainty (the real size could be half of the | ||
4994 | estimate or twice as much). Note that the actual network size is | ||
4995 | calculated in powers of two of the raw input, thus one bit of uncertainty | ||
4996 | means a factor of two in the size estimate. | ||
4997 | |||
4998 | @cindex libgnunetnse | ||
4999 | @node libgnunetnse | ||
5000 | @subsection libgnunetnse | ||
5001 | |||
5002 | @c %**end of header | ||
5003 | |||
5004 | The NSE subsystem has the simplest API of all services, with only two | ||
5005 | calls: @code{GNUNET_NSE_connect} and @code{GNUNET_NSE_disconnect}. | ||
5006 | |||
5007 | The connect call gets a callback function as a parameter and this function | ||
5008 | is called each time the network agrees on an estimate. This usually is | ||
5009 | once per round, with some exceptions: if the closest peer has a late | ||
5010 | local clock and starts spreading his ID after everyone else agreed on a | ||
5011 | value, the callback might be activated twice in a round, the second value | ||
5012 | being always bigger than the first. The default round time is set to | ||
5013 | 1 hour. | ||
5014 | |||
5015 | The disconnect call disconnects from the NSE subsystem and the callback | ||
5016 | is no longer called with new estimates. | ||
5017 | |||
5018 | |||
5019 | |||
5020 | @menu | ||
5021 | * Results:: | ||
5022 | * libgnunetnse - Examples:: | ||
5023 | @end menu | ||
5024 | |||
5025 | @node Results | ||
5026 | @subsubsection Results | ||
5027 | |||
5028 | @c %**end of header | ||
5029 | |||
5030 | The callback provides two values: the average and the | ||
5031 | @uref{http://en.wikipedia.org/wiki/Standard_deviation, standard deviation} | ||
5032 | of the last 64 rounds. The values provided by the callback function are | ||
5033 | logarithmic, this means that the real estimate numbers can be obtained by | ||
5034 | calculating 2 to the power of the given value (2average). From a | ||
5035 | statistics point of view this means that: | ||
5036 | |||
5037 | @itemize @bullet | ||
5038 | @item 68% of the time the real size is included in the interval | ||
5039 | [(2average-stddev), 2] | ||
5040 | @item 95% of the time the real size is included in the interval | ||
5041 | [(2average-2*stddev, 2^average+2*stddev] | ||
5042 | @item 99.7% of the time the real size is included in the interval | ||
5043 | [(2average-3*stddev, 2average+3*stddev] | ||
5044 | @end itemize | ||
5045 | |||
5046 | The expected standard variation for 64 rounds in a network of stable size | ||
5047 | is 0.2. Thus, we can say that normally: | ||
5048 | |||
5049 | @itemize @bullet | ||
5050 | @item 68% of the time the real size is in the range [-13%, +15%] | ||
5051 | @item 95% of the time the real size is in the range [-24%, +32%] | ||
5052 | @item 99.7% of the time the real size is in the range [-34%, +52%] | ||
5053 | @end itemize | ||
5054 | |||
5055 | As said in the introduction, we can be quite sure that usually the real | ||
5056 | size is between one third and three times the estimate. This can of | ||
5057 | course vary with network conditions. | ||
5058 | Thus, applications may want to also consider the provided standard | ||
5059 | deviation value, not only the average (in particular, if the standard | ||
5060 | veriation is very high, the average maybe meaningless: the network size is | ||
5061 | changing rapidly). | ||
5062 | |||
5063 | @node libgnunetnse - Examples | ||
5064 | @subsubsection libgnunetnse -Examples | ||
5065 | |||
5066 | @c %**end of header | ||
5067 | |||
5068 | Let's close with a couple examples. | ||
5069 | |||
5070 | @table @asis | ||
5071 | |||
5072 | @item Average: 10, std dev: 1 Here the estimate would be | ||
5073 | 2^10 = 1024 peers. @footnote{The range in which we can be 95% sure is: | ||
5074 | [2^8, 2^12] = [256, 4096]. We can be very (>99.7%) sure that the network | ||
5075 | is not a hundred peers and absolutely sure that it is not a million peers, | ||
5076 | but somewhere around a thousand.} | ||
5077 | |||
5078 | @item Average 22, std dev: 0.2 Here the estimate would be | ||
5079 | 2^22 = 4 Million peers. @footnote{The range in which we can be 99.7% sure | ||
5080 | is: [2^21.4, 2^22.6] = [2.8M, 6.3M]. We can be sure that the network size | ||
5081 | is around four million, with absolutely way of it being 1 million.} | ||
5082 | |||
5083 | @end table | ||
5084 | |||
5085 | To put this in perspective, if someone remembers the LHC Higgs boson | ||
5086 | results, were announced with "5 sigma" and "6 sigma" certainties. In this | ||
5087 | case a 5 sigma minimum would be 2 million and a 6 sigma minimum, | ||
5088 | 1.8 million. | ||
5089 | |||
5090 | @node The NSE Client-Service Protocol | ||
5091 | @subsection The NSE Client-Service Protocol | ||
5092 | |||
5093 | @c %**end of header | ||
5094 | |||
5095 | As with the API, the client-service protocol is very simple, only has 2 | ||
5096 | different messages, defined in @code{src/nse/nse.h}: | ||
5097 | |||
5098 | @itemize @bullet | ||
5099 | @item @code{GNUNET_MESSAGE_TYPE_NSE_START}@ This message has no parameters | ||
5100 | and is sent from the client to the service upon connection. | ||
5101 | @item @code{GNUNET_MESSAGE_TYPE_NSE_ESTIMATE}@ This message is sent from | ||
5102 | the service to the client for every new estimate and upon connection. | ||
5103 | Contains a timestamp for the estimate, the average and the standard | ||
5104 | deviation for the respective round. | ||
5105 | @end itemize | ||
5106 | |||
5107 | When the @code{GNUNET_NSE_disconnect} API call is executed, the client | ||
5108 | simply disconnects from the service, with no message involved. | ||
5109 | |||
5110 | @cindex NSE Peer-to-Peer Protocol | ||
5111 | @node The NSE Peer-to-Peer Protocol | ||
5112 | @subsection The NSE Peer-to-Peer Protocol | ||
5113 | |||
5114 | @c %**end of header | ||
5115 | |||
5116 | The NSE subsystem only has one message in the P2P protocol, the | ||
5117 | @code{GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD} message. | ||
5118 | |||
5119 | This message key contents are the timestamp to identify the round | ||
5120 | (differences in system clocks may cause some peers to send messages way | ||
5121 | too early or way too late, so the timestamp allows other peers to | ||
5122 | identify such messages easily), the | ||
5123 | @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proof of work} | ||
5124 | used to make it difficult to mount a | ||
5125 | @uref{http://en.wikipedia.org/wiki/Sybil_attack, Sybil attack}, and the | ||
5126 | public key, which is used to verify the signature on the message. | ||
5127 | |||
5128 | Every peer stores a message for the previous, current and next round. The | ||
5129 | messages for the previous and current round are given to peers that | ||
5130 | connect to us. The message for the next round is simply stored until our | ||
5131 | system clock advances to the next round. The message for the current round | ||
5132 | is what we are flooding the network with right now. | ||
5133 | At the beginning of each round the peer does the following: | ||
5134 | |||
5135 | @itemize @bullet | ||
5136 | @item calculates his own distance to the target value | ||
5137 | @item creates, signs and stores the message for the current round (unless | ||
5138 | it has a better message in the "next round" slot which came early in the | ||
5139 | previous round) | ||
5140 | @item calculates, based on the stored round message (own or received) when | ||
5141 | to stard flooding it to its neighbors | ||
5142 | @end itemize | ||
5143 | |||
5144 | Upon receiving a message the peer checks the validity of the message | ||
5145 | (round, proof of work, signature). The next action depends on the | ||
5146 | contents of the incoming message: | ||
5147 | |||
5148 | @itemize @bullet | ||
5149 | @item if the message is worse than the current stored message, the peer | ||
5150 | sends the current message back immediately, to stop the other peer from | ||
5151 | spreading suboptimal results | ||
5152 | @item if the message is better than the current stored message, the peer | ||
5153 | stores the new message and calculates the new target time to start | ||
5154 | spreading it to its neighbors (excluding the one the message came from) | ||
5155 | @item if the message is for the previous round, it is compared to the | ||
5156 | message stored in the "previous round slot", which may then be updated | ||
5157 | @item if the message is for the next round, it is compared to the message | ||
5158 | stored in the "next round slot", which again may then be updated | ||
5159 | @end itemize | ||
5160 | |||
5161 | Finally, when it comes to send the stored message for the current round to | ||
5162 | the neighbors there is a random delay added for each neighbor, to avoid | ||
5163 | traffic spikes and minimize cross-messages. | ||
5164 | |||
5165 | @cindex HOSTLIST subsystem | ||
5166 | @cindex hostlist subsystem | ||
5167 | @node GNUnet's HOSTLIST subsystem | ||
5168 | @section GNUnet's HOSTLIST subsystem | ||
5169 | |||
5170 | @c %**end of header | ||
5171 | |||
5172 | Peers in the GNUnet overlay network need address information so that they | ||
5173 | can connect with other peers. GNUnet uses so called HELLO messages to | ||
5174 | store and exchange peer addresses. | ||
5175 | GNUnet provides several methods for peers to obtain this information: | ||
5176 | |||
5177 | @itemize @bullet | ||
5178 | @item out-of-band exchange of HELLO messages (manually, using for example | ||
5179 | gnunet-peerinfo) | ||
5180 | @item HELLO messages shipped with GNUnet (automatic with distribution) | ||
5181 | @item UDP neighbor discovery in LAN (IPv4 broadcast, IPv6 multicast) | ||
5182 | @item topology gossiping (learning from other peers we already connected | ||
5183 | to), and | ||
5184 | @item the HOSTLIST daemon covered in this section, which is particularly | ||
5185 | relevant for bootstrapping new peers. | ||
5186 | @end itemize | ||
5187 | |||
5188 | New peers have no existing connections (and thus cannot learn from gossip | ||
5189 | among peers), may not have other peers in their LAN and might be started | ||
5190 | with an outdated set of HELLO messages from the distribution. | ||
5191 | In this case, getting new peers to connect to the network requires either | ||
5192 | manual effort or the use of a HOSTLIST to obtain HELLOs. | ||
5193 | |||
5194 | @menu | ||
5195 | * HELLOs:: | ||
5196 | * Overview for the HOSTLIST subsystem:: | ||
5197 | * Interacting with the HOSTLIST daemon:: | ||
5198 | * Hostlist security address validation:: | ||
5199 | * The HOSTLIST daemon:: | ||
5200 | * The HOSTLIST server:: | ||
5201 | * The HOSTLIST client:: | ||
5202 | * Usage:: | ||
5203 | @end menu | ||
5204 | |||
5205 | @node HELLOs | ||
5206 | @subsection HELLOs | ||
5207 | |||
5208 | @c %**end of header | ||
5209 | |||
5210 | The basic information peers require to connect to other peers are | ||
5211 | contained in so called HELLO messages you can think of as a business card. | ||
5212 | Besides the identity of the peer (based on the cryptographic public key) a | ||
5213 | HELLO message may contain address information that specifies ways to | ||
5214 | contact a peer. By obtaining HELLO messages, a peer can learn how to | ||
5215 | contact other peers. | ||
5216 | |||
5217 | @node Overview for the HOSTLIST subsystem | ||
5218 | @subsection Overview for the HOSTLIST subsystem | ||
5219 | |||
5220 | @c %**end of header | ||
5221 | |||
5222 | The HOSTLIST subsystem provides a way to distribute and obtain contact | ||
5223 | information to connect to other peers using a simple HTTP GET request. | ||
5224 | It's implementation is split in three parts, the main file for the daemon | ||
5225 | itself (@file{gnunet-daemon-hostlist.c}), the HTTP client used to download | ||
5226 | peer information (@file{hostlist-client.c}) and the server component used | ||
5227 | to provide this information to other peers (@file{hostlist-server.c}). | ||
5228 | The server is basically a small HTTP web server (based on GNU | ||
5229 | libmicrohttpd) which provides a list of HELLOs known to the local peer for | ||
5230 | download. The client component is basically a HTTP client | ||
5231 | (based on libcurl) which can download hostlists from one or more websites. | ||
5232 | The hostlist format is a binary blob containing a sequence of HELLO | ||
5233 | messages. Note that any HTTP server can theoretically serve a hostlist, | ||
5234 | the build-in hostlist server makes it simply convenient to offer this | ||
5235 | service. | ||
5236 | |||
5237 | |||
5238 | @menu | ||
5239 | * Features:: | ||
5240 | * HOSTLIST - Limitations:: | ||
5241 | @end menu | ||
5242 | |||
5243 | @node Features | ||
5244 | @subsubsection Features | ||
5245 | |||
5246 | @c %**end of header | ||
5247 | |||
5248 | The HOSTLIST daemon can: | ||
5249 | |||
5250 | @itemize @bullet | ||
5251 | @item provide HELLO messages with validated addresses obtained from | ||
5252 | PEERINFO to download for other peers | ||
5253 | @item download HELLO messages and forward these message to the TRANSPORT | ||
5254 | subsystem for validation | ||
5255 | @item advertises the URL of this peer's hostlist address to other peers | ||
5256 | via gossip | ||
5257 | @item automatically learn about hostlist servers from the gossip of other | ||
5258 | peers | ||
5259 | @end itemize | ||
5260 | |||
5261 | @node HOSTLIST - Limitations | ||
5262 | @subsubsection HOSTLIST - Limitations | ||
5263 | |||
5264 | @c %**end of header | ||
5265 | |||
5266 | The HOSTLIST daemon does not: | ||
5267 | |||
5268 | @itemize @bullet | ||
5269 | @item verify the cryptographic information in the HELLO messages | ||
5270 | @item verify the address information in the HELLO messages | ||
5271 | @end itemize | ||
5272 | |||
5273 | @node Interacting with the HOSTLIST daemon | ||
5274 | @subsection Interacting with the HOSTLIST daemon | ||
5275 | |||
5276 | @c %**end of header | ||
5277 | |||
5278 | The HOSTLIST subsystem is currently implemented as a daemon, so there is | ||
5279 | no need for the user to interact with it and therefore there is no | ||
5280 | command line tool and no API to communicate with the daemon. In the | ||
5281 | future, we can envision changing this to allow users to manually trigger | ||
5282 | the download of a hostlist. | ||
5283 | |||
5284 | Since there is no command line interface to interact with HOSTLIST, the | ||
5285 | only way to interact with the hostlist is to use STATISTICS to obtain or | ||
5286 | modify information about the status of HOSTLIST: | ||
5287 | |||
5288 | @example | ||
5289 | $ gnunet-statistics -s hostlist | ||
5290 | @end example | ||
5291 | |||
5292 | @noindent | ||
5293 | In particular, HOSTLIST includes a @strong{persistent} value in statistics | ||
5294 | that specifies when the hostlist server might be queried next. As this | ||
5295 | value is exponentially increasing during runtime, developers may want to | ||
5296 | reset or manually adjust it. Note that HOSTLIST (but not STATISTICS) needs | ||
5297 | to be shutdown if changes to this value are to have any effect on the | ||
5298 | daemon (as HOSTLIST does not monitor STATISTICS for changes to the | ||
5299 | download frequency). | ||
5300 | |||
5301 | @node Hostlist security address validation | ||
5302 | @subsection Hostlist security address validation | ||
5303 | |||
5304 | @c %**end of header | ||
5305 | |||
5306 | Since information obtained from other parties cannot be trusted without | ||
5307 | validation, we have to distinguish between @emph{validated} and | ||
5308 | @emph{not validated} addresses. Before using (and so trusting) | ||
5309 | information from other parties, this information has to be double-checked | ||
5310 | (validated). Address validation is not done by HOSTLIST but by the | ||
5311 | TRANSPORT service. | ||
5312 | |||
5313 | The HOSTLIST component is functionally located between the PEERINFO and | ||
5314 | the TRANSPORT subsystem. When acting as a server, the daemon obtains valid | ||
5315 | (@emph{validated}) peer information (HELLO messages) from the PEERINFO | ||
5316 | service and provides it to other peers. When acting as a client, it | ||
5317 | contacts the HOSTLIST servers specified in the configuration, downloads | ||
5318 | the (unvalidated) list of HELLO messages and forwards these information | ||
5319 | to the TRANSPORT server to validate the addresses. | ||
5320 | |||
5321 | @cindex HOSTLIST daemon | ||
5322 | @node The HOSTLIST daemon | ||
5323 | @subsection The HOSTLIST daemon | ||
5324 | |||
5325 | @c %**end of header | ||
5326 | |||
5327 | The hostlist daemon is the main component of the HOSTLIST subsystem. It is | ||
5328 | started by the ARM service and (if configured) starts the HOSTLIST client | ||
5329 | and server components. | ||
5330 | |||
5331 | If the daemon provides a hostlist itself it can advertise it's own | ||
5332 | hostlist to other peers. To do so it sends a | ||
5333 | @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} message to other peers | ||
5334 | when they connect to this peer on the CORE level. This hostlist | ||
5335 | advertisement message contains the URL to access the HOSTLIST HTTP | ||
5336 | server of the sender. The daemon may also subscribe to this type of | ||
5337 | message from CORE service, and then forward these kind of message to the | ||
5338 | HOSTLIST client. The client then uses all available URLs to download peer | ||
5339 | information when necessary. | ||
5340 | |||
5341 | When starting, the HOSTLIST daemon first connects to the CORE subsystem | ||
5342 | and if hostlist learning is enabled, registers a CORE handler to receive | ||
5343 | this kind of messages. Next it starts (if configured) the client and | ||
5344 | server. It passes pointers to CORE connect and disconnect and receive | ||
5345 | handlers where the client and server store their functions, so the daemon | ||
5346 | can notify them about CORE events. | ||
5347 | |||
5348 | To clean up on shutdown, the daemon has a cleaning task, shutting down all | ||
5349 | subsystems and disconnecting from CORE. | ||
5350 | |||
5351 | @cindex HOSTLIST server | ||
5352 | @node The HOSTLIST server | ||
5353 | @subsection The HOSTLIST server | ||
5354 | |||
5355 | @c %**end of header | ||
5356 | |||
5357 | The server provides a way for other peers to obtain HELLOs. Basically it | ||
5358 | is a small web server other peers can connect to and download a list of | ||
5359 | HELLOs using standard HTTP; it may also advertise the URL of the hostlist | ||
5360 | to other peers connecting on CORE level. | ||
5361 | |||
5362 | |||
5363 | @menu | ||
5364 | * The HTTP Server:: | ||
5365 | * Advertising the URL:: | ||
5366 | @end menu | ||
5367 | |||
5368 | @node The HTTP Server | ||
5369 | @subsubsection The HTTP Server | ||
5370 | |||
5371 | @c %**end of header | ||
5372 | |||
5373 | During startup, the server starts a web server listening on the port | ||
5374 | specified with the HTTPPORT value (default 8080). In addition it connects | ||
5375 | to the PEERINFO service to obtain peer information. The HOSTLIST server | ||
5376 | uses the GNUNET_PEERINFO_iterate function to request HELLO information for | ||
5377 | all peers and adds their information to a new hostlist if they are | ||
5378 | suitable (expired addresses and HELLOs without addresses are both not | ||
5379 | suitable) and the maximum size for a hostlist is not exceeded | ||
5380 | (MAX_BYTES_PER_HOSTLISTS = 500000). | ||
5381 | When PEERINFO finishes (with a last NULL callback), the server destroys | ||
5382 | the previous hostlist response available for download on the web server | ||
5383 | and replaces it with the updated hostlist. The hostlist format is | ||
5384 | basically a sequence of HELLO messages (as obtained from PEERINFO) without | ||
5385 | any special tokenization. Since each HELLO message contains a size field, | ||
5386 | the response can easily be split into separate HELLO messages by the | ||
5387 | client. | ||
5388 | |||
5389 | A HOSTLIST client connecting to the HOSTLIST server will receive the | ||
5390 | hostlist as a HTTP response and the the server will terminate the | ||
5391 | connection with the result code @code{HTTP 200 OK}. | ||
5392 | The connection will be closed immediately if no hostlist is available. | ||
5393 | |||
5394 | @node Advertising the URL | ||
5395 | @subsubsection Advertising the URL | ||
5396 | |||
5397 | @c %**end of header | ||
5398 | |||
5399 | The server also advertises the URL to download the hostlist to other peers | ||
5400 | if hostlist advertisement is enabled. | ||
5401 | When a new peer connects and has hostlist learning enabled, the server | ||
5402 | sends a @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} message to this | ||
5403 | peer using the CORE service. | ||
5404 | |||
5405 | @cindex HOSTLIST client | ||
5406 | @node The HOSTLIST client | ||
5407 | @subsection The HOSTLIST client | ||
5408 | |||
5409 | @c %**end of header | ||
5410 | |||
5411 | The client provides the functionality to download the list of HELLOs from | ||
5412 | a set of URLs. | ||
5413 | It performs a standard HTTP request to the URLs configured and learned | ||
5414 | from advertisement messages received from other peers. When a HELLO is | ||
5415 | downloaded, the HOSTLIST client forwards the HELLO to the TRANSPORT | ||
5416 | service for validation. | ||
5417 | |||
5418 | The client supports two modes of operation: | ||
5419 | |||
5420 | @itemize @bullet | ||
5421 | @item download of HELLOs (bootstrapping) | ||
5422 | @item learning of URLs | ||
5423 | @end itemize | ||
5424 | |||
5425 | @menu | ||
5426 | * Bootstrapping:: | ||
5427 | * Learning:: | ||
5428 | @end menu | ||
5429 | |||
5430 | @node Bootstrapping | ||
5431 | @subsubsection Bootstrapping | ||
5432 | |||
5433 | @c %**end of header | ||
5434 | |||
5435 | For bootstrapping, it schedules a task to download the hostlist from the | ||
5436 | set of known URLs. | ||
5437 | The downloads are only performed if the number of current | ||
5438 | connections is smaller than a minimum number of connections | ||
5439 | (at the moment 4). | ||
5440 | The interval between downloads increases exponentially; however, the | ||
5441 | exponential growth is limited if it becomes longer than an hour. | ||
5442 | At that point, the frequency growth is capped at | ||
5443 | (#number of connections * 1h). | ||
5444 | |||
5445 | Once the decision has been taken to download HELLOs, the daemon chooses a | ||
5446 | random URL from the list of known URLs. URLs can be configured in the | ||
5447 | configuration or be learned from advertisement messages. | ||
5448 | The client uses a HTTP client library (libcurl) to initiate the download | ||
5449 | using the libcurl multi interface. | ||
5450 | Libcurl passes the data to the callback_download function which | ||
5451 | stores the data in a buffer if space is available and the maximum size for | ||
5452 | a hostlist download is not exceeded (MAX_BYTES_PER_HOSTLISTS = 500000). | ||
5453 | When a full HELLO was downloaded, the HOSTLIST client offers this | ||
5454 | HELLO message to the TRANSPORT service for validation. | ||
5455 | When the download is finished or failed, statistical information about the | ||
5456 | quality of this URL is updated. | ||
5457 | |||
5458 | @cindex HOSTLIST learning | ||
5459 | @node Learning | ||
5460 | @subsubsection Learning | ||
5461 | |||
5462 | @c %**end of header | ||
5463 | |||
5464 | The client also manages hostlist advertisements from other peers. The | ||
5465 | HOSTLIST daemon forwards @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} | ||
5466 | messages to the client subsystem, which extracts the URL from the message. | ||
5467 | Next, a test of the newly obtained URL is performed by triggering a | ||
5468 | download from the new URL. If the URL works correctly, it is added to the | ||
5469 | list of working URLs. | ||
5470 | |||
5471 | The size of the list of URLs is restricted, so if an additional server is | ||
5472 | added and the list is full, the URL with the worst quality ranking | ||
5473 | (determined through successful downloads and number of HELLOs e.g.) is | ||
5474 | discarded. During shutdown the list of URLs is saved to a file for | ||
5475 | persistance and loaded on startup. URLs from the configuration file are | ||
5476 | never discarded. | ||
5477 | |||
5478 | @node Usage | ||
5479 | @subsection Usage | ||
5480 | |||
5481 | @c %**end of header | ||
5482 | |||
5483 | To start HOSTLIST by default, it has to be added to the DEFAULTSERVICES | ||
5484 | section for the ARM services. This is done in the default configuration. | ||
5485 | |||
5486 | For more information on how to configure the HOSTLIST subsystem see the | ||
5487 | installation handbook:@ | ||
5488 | Configuring the hostlist to bootstrap@ | ||
5489 | Configuring your peer to provide a hostlist | ||
5490 | |||
5491 | @cindex IDENTITY | ||
5492 | @cindex identity subsystem | ||
5493 | @node GNUnet's IDENTITY subsystem | ||
5494 | @section GNUnet's IDENTITY subsystem | ||
5495 | |||
5496 | @c %**end of header | ||
5497 | |||
5498 | Identities of "users" in GNUnet are called egos. | ||
5499 | Egos can be used as pseudonyms ("fake names") or be tied to an | ||
5500 | organization (for example, "GNU") or even the actual identity of a human. | ||
5501 | GNUnet users are expected to have many egos. They might have one tied to | ||
5502 | their real identity, some for organizations they manage, and more for | ||
5503 | different domains where they want to operate under a pseudonym. | ||
5504 | |||
5505 | The IDENTITY service allows users to manage their egos. The identity | ||
5506 | service manages the private keys egos of the local user; it does not | ||
5507 | manage identities of other users (public keys). Public keys for other | ||
5508 | users need names to become manageable. GNUnet uses the | ||
5509 | @dfn{GNU Name System} (GNS) to give names to other users and manage their | ||
5510 | public keys securely. This chapter is about the IDENTITY service, | ||
5511 | which is about the management of private keys. | ||
5512 | |||
5513 | On the network, an ego corresponds to an ECDSA key (over Curve25519, | ||
5514 | using RFC 6979, as required by GNS). Thus, users can perform actions | ||
5515 | under a particular ego by using (signing with) a particular private key. | ||
5516 | Other users can then confirm that the action was really performed by that | ||
5517 | ego by checking the signature against the respective public key. | ||
5518 | |||
5519 | The IDENTITY service allows users to associate a human-readable name with | ||
5520 | each ego. This way, users can use names that will remind them of the | ||
5521 | purpose of a particular ego. | ||
5522 | The IDENTITY service will store the respective private keys and | ||
5523 | allows applications to access key information by name. | ||
5524 | Users can change the name that is locally (!) associated with an ego. | ||
5525 | Egos can also be deleted, which means that the private key will be removed | ||
5526 | and it thus will not be possible to perform actions with that ego in the | ||
5527 | future. | ||
5528 | |||
5529 | Additionally, the IDENTITY subsystem can associate service functions with | ||
5530 | egos. | ||
5531 | For example, GNS requires the ego that should be used for the shorten | ||
5532 | zone. GNS will ask IDENTITY for an ego for the "gns-short" service. | ||
5533 | The IDENTITY service has a mapping of such service strings to the name of | ||
5534 | the ego that the user wants to use for this service, for example | ||
5535 | "my-short-zone-ego". | ||
5536 | |||
5537 | Finally, the IDENTITY API provides access to a special ego, the | ||
5538 | anonymous ego. The anonymous ego is special in that its private key is not | ||
5539 | really private, but fixed and known to everyone. | ||
5540 | Thus, anyone can perform actions as anonymous. This can be useful as with | ||
5541 | this trick, code does not have to contain a special case to distinguish | ||
5542 | between anonymous and pseudonymous egos. | ||
5543 | |||
5544 | @menu | ||
5545 | * libgnunetidentity:: | ||
5546 | * The IDENTITY Client-Service Protocol:: | ||
5547 | @end menu | ||
5548 | |||
5549 | @cindex libgnunetidentity | ||
5550 | @node libgnunetidentity | ||
5551 | @subsection libgnunetidentity | ||
5552 | @c %**end of header | ||
5553 | |||
5554 | |||
5555 | @menu | ||
5556 | * Connecting to the service:: | ||
5557 | * Operations on Egos:: | ||
5558 | * The anonymous Ego:: | ||
5559 | * Convenience API to lookup a single ego:: | ||
5560 | * Associating egos with service functions:: | ||
5561 | @end menu | ||
5562 | |||
5563 | @node Connecting to the service | ||
5564 | @subsubsection Connecting to the service | ||
5565 | |||
5566 | @c %**end of header | ||
5567 | |||
5568 | First, typical clients connect to the identity service using | ||
5569 | @code{GNUNET_IDENTITY_connect}. This function takes a callback as a | ||
5570 | parameter. | ||
5571 | If the given callback parameter is non-null, it will be invoked to notify | ||
5572 | the application about the current state of the identities in the system. | ||
5573 | |||
5574 | @itemize @bullet | ||
5575 | @item First, it will be invoked on all known egos at the time of the | ||
5576 | connection. For each ego, a handle to the ego and the user's name for the | ||
5577 | ego will be passed to the callback. Furthermore, a @code{void **} context | ||
5578 | argument will be provided which gives the client the opportunity to | ||
5579 | associate some state with the ego. | ||
5580 | @item Second, the callback will be invoked with NULL for the ego, the name | ||
5581 | and the context. This signals that the (initial) iteration over all egos | ||
5582 | has completed. | ||
5583 | @item Then, the callback will be invoked whenever something changes about | ||
5584 | an ego. | ||
5585 | If an ego is renamed, the callback is invoked with the ego handle of the | ||
5586 | ego that was renamed, and the new name. If an ego is deleted, the callback | ||
5587 | is invoked with the ego handle and a name of NULL. In the deletion case, | ||
5588 | the application should also release resources stored in the context. | ||
5589 | @item When the application destroys the connection to the identity service | ||
5590 | using @code{GNUNET_IDENTITY_disconnect}, the callback is again invoked | ||
5591 | with the ego and a name of NULL (equivalent to deletion of the egos). | ||
5592 | This should again be used to clean up the per-ego context. | ||
5593 | @end itemize | ||
5594 | |||
5595 | The ego handle passed to the callback remains valid until the callback is | ||
5596 | invoked with a name of NULL, so it is safe to store a reference to the | ||
5597 | ego's handle. | ||
5598 | |||
5599 | @node Operations on Egos | ||
5600 | @subsubsection Operations on Egos | ||
5601 | |||
5602 | @c %**end of header | ||
5603 | |||
5604 | Given an ego handle, the main operations are to get its associated private | ||
5605 | key using @code{GNUNET_IDENTITY_ego_get_private_key} or its associated | ||
5606 | public key using @code{GNUNET_IDENTITY_ego_get_public_key}. | ||
5607 | |||
5608 | The other operations on egos are pretty straightforward. | ||
5609 | Using @code{GNUNET_IDENTITY_create}, an application can request the | ||
5610 | creation of an ego by specifying the desired name. | ||
5611 | The operation will fail if that name is | ||
5612 | already in use. Using @code{GNUNET_IDENTITY_rename} the name of an | ||
5613 | existing ego can be changed. Finally, egos can be deleted using | ||
5614 | @code{GNUNET_IDENTITY_delete}. All of these operations will trigger | ||
5615 | updates to the callback given to the @code{GNUNET_IDENTITY_connect} | ||
5616 | function of all applications that are connected with the identity service | ||
5617 | at the time. @code{GNUNET_IDENTITY_cancel} can be used to cancel the | ||
5618 | operations before the respective continuations would be called. | ||
5619 | It is not guaranteed that the operation will not be completed anyway, | ||
5620 | only the continuation will no longer be called. | ||
5621 | |||
5622 | @node The anonymous Ego | ||
5623 | @subsubsection The anonymous Ego | ||
5624 | |||
5625 | @c %**end of header | ||
5626 | |||
5627 | A special way to obtain an ego handle is to call | ||
5628 | @code{GNUNET_IDENTITY_ego_get_anonymous}, which returns an ego for the | ||
5629 | "anonymous" user --- anyone knows and can get the private key for this | ||
5630 | user, so it is suitable for operations that are supposed to be anonymous | ||
5631 | but require signatures (for example, to avoid a special path in the code). | ||
5632 | The anonymous ego is always valid and accessing it does not require a | ||
5633 | connection to the identity service. | ||
5634 | |||
5635 | @node Convenience API to lookup a single ego | ||
5636 | @subsubsection Convenience API to lookup a single ego | ||
5637 | |||
5638 | |||
5639 | As applications commonly simply have to lookup a single ego, there is a | ||
5640 | convenience API to do just that. Use @code{GNUNET_IDENTITY_ego_lookup} to | ||
5641 | lookup a single ego by name. Note that this is the user's name for the | ||
5642 | ego, not the service function. The resulting ego will be returned via a | ||
5643 | callback and will only be valid during that callback. The operation can | ||
5644 | be cancelled via @code{GNUNET_IDENTITY_ego_lookup_cancel} | ||
5645 | (cancellation is only legal before the callback is invoked). | ||
5646 | |||
5647 | @node Associating egos with service functions | ||
5648 | @subsubsection Associating egos with service functions | ||
5649 | |||
5650 | |||
5651 | The @code{GNUNET_IDENTITY_set} function is used to associate a particular | ||
5652 | ego with a service function. The name used by the service and the ego are | ||
5653 | given as arguments. | ||
5654 | Afterwards, the service can use its name to lookup the associated ego | ||
5655 | using @code{GNUNET_IDENTITY_get}. | ||
5656 | |||
5657 | @node The IDENTITY Client-Service Protocol | ||
5658 | @subsection The IDENTITY Client-Service Protocol | ||
5659 | |||
5660 | @c %**end of header | ||
5661 | |||
5662 | A client connecting to the identity service first sends a message with | ||
5663 | type | ||
5664 | @code{GNUNET_MESSAGE_TYPE_IDENTITY_START} to the service. After that, the | ||
5665 | client will receive information about changes to the egos by receiving | ||
5666 | messages of type @code{GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE}. | ||
5667 | Those messages contain the private key of the ego and the user's name of | ||
5668 | the ego (or zero bytes for the name to indicate that the ego was deleted). | ||
5669 | A special bit @code{end_of_list} is used to indicate the end of the | ||
5670 | initial iteration over the identity service's egos. | ||
5671 | |||
5672 | The client can trigger changes to the egos by sending @code{CREATE}, | ||
5673 | @code{RENAME} or @code{DELETE} messages. | ||
5674 | The CREATE message contains the private key and the desired name.@ | ||
5675 | The RENAME message contains the old name and the new name.@ | ||
5676 | The DELETE message only needs to include the name of the ego to delete.@ | ||
5677 | The service responds to each of these messages with a @code{RESULT_CODE} | ||
5678 | message which indicates success or error of the operation, and possibly | ||
5679 | a human-readable error message. | ||
5680 | |||
5681 | Finally, the client can bind the name of a service function to an ego by | ||
5682 | sending a @code{SET_DEFAULT} message with the name of the service function | ||
5683 | and the private key of the ego. | ||
5684 | Such bindings can then be resolved using a @code{GET_DEFAULT} message, | ||
5685 | which includes the name of the service function. The identity service | ||
5686 | will respond to a GET_DEFAULT request with a SET_DEFAULT message | ||
5687 | containing the respective information, or with a RESULT_CODE to | ||
5688 | indicate an error. | ||
5689 | |||
5690 | @cindex NAMESTORE | ||
5691 | @cindex namestore subsystem | ||
5692 | @node GNUnet's NAMESTORE Subsystem | ||
5693 | @section GNUnet's NAMESTORE Subsystem | ||
5694 | |||
5695 | The NAMESTORE subsystem provides persistent storage for local GNS zone | ||
5696 | information. All local GNS zone information are managed by NAMESTORE. It | ||
5697 | provides both the functionality to administer local GNS information (e.g. | ||
5698 | delete and add records) as well as to retrieve GNS information (e.g to | ||
5699 | list name information in a client). | ||
5700 | NAMESTORE does only manage the persistent storage of zone information | ||
5701 | belonging to the user running the service: GNS information from other | ||
5702 | users obtained from the DHT are stored by the NAMECACHE subsystem. | ||
5703 | |||
5704 | NAMESTORE uses a plugin-based database backend to store GNS information | ||
5705 | with good performance. Here sqlite, MySQL and PostgreSQL are supported | ||
5706 | database backends. | ||
5707 | NAMESTORE clients interact with the IDENTITY subsystem to obtain | ||
5708 | cryptographic information about zones based on egos as described with the | ||
5709 | IDENTITY subsystem, but internally NAMESTORE refers to zones using the | ||
5710 | ECDSA private key. | ||
5711 | In addition, it collaborates with the NAMECACHE subsystem and | ||
5712 | stores zone information when local information are modified in the | ||
5713 | GNS cache to increase look-up performance for local information. | ||
5714 | |||
5715 | NAMESTORE provides functionality to look-up and store records, to iterate | ||
5716 | over a specific or all zones and to monitor zones for changes. NAMESTORE | ||
5717 | functionality can be accessed using the NAMESTORE api or the NAMESTORE | ||
5718 | command line tool. | ||
5719 | |||
5720 | @menu | ||
5721 | * libgnunetnamestore:: | ||
5722 | @end menu | ||
5723 | |||
5724 | @cindex libgnunetnamestore | ||
5725 | @node libgnunetnamestore | ||
5726 | @subsection libgnunetnamestore | ||
5727 | |||
5728 | To interact with NAMESTORE clients first connect to the NAMESTORE service | ||
5729 | using the @code{GNUNET_NAMESTORE_connect} passing a configuration handle. | ||
5730 | As a result they obtain a NAMESTORE handle, they can use for operations, | ||
5731 | or NULL is returned if the connection failed. | ||
5732 | |||
5733 | To disconnect from NAMESTORE, clients use | ||
5734 | @code{GNUNET_NAMESTORE_disconnect} and specify the handle to disconnect. | ||
5735 | |||
5736 | NAMESTORE internally uses the ECDSA private key to refer to zones. These | ||
5737 | private keys can be obtained from the IDENTITY subsytem. | ||
5738 | Here @emph{egos} @emph{can be used to refer to zones or the default ego | ||
5739 | assigned to the GNS subsystem can be used to obtained the master zone's | ||
5740 | private key.} | ||
5741 | |||
5742 | |||
5743 | @menu | ||
5744 | * Editing Zone Information:: | ||
5745 | * Iterating Zone Information:: | ||
5746 | * Monitoring Zone Information:: | ||
5747 | @end menu | ||
5748 | |||
5749 | @node Editing Zone Information | ||
5750 | @subsubsection Editing Zone Information | ||
5751 | |||
5752 | @c %**end of header | ||
5753 | |||
5754 | NAMESTORE provides functions to lookup records stored under a label in a | ||
5755 | zone and to store records under a label in a zone. | ||
5756 | |||
5757 | To store (and delete) records, the client uses the | ||
5758 | @code{GNUNET_NAMESTORE_records_store} function and has to provide | ||
5759 | namestore handle to use, the private key of the zone, the label to store | ||
5760 | the records under, the records and number of records plus an callback | ||
5761 | function. | ||
5762 | After the operation is performed NAMESTORE will call the provided | ||
5763 | callback function with the result GNUNET_SYSERR on failure | ||
5764 | (including timeout/queue drop/failure to validate), GNUNET_NO if content | ||
5765 | was already there or not found GNUNET_YES (or other positive value) on | ||
5766 | success plus an additional error message. | ||
5767 | |||
5768 | Records are deleted by using the store command with 0 records to store. | ||
5769 | It is important to note, that records are not merged when records exist | ||
5770 | with the label. | ||
5771 | So a client has first to retrieve records, merge with existing records | ||
5772 | and then store the result. | ||
5773 | |||
5774 | To perform a lookup operation, the client uses the | ||
5775 | @code{GNUNET_NAMESTORE_records_store} function. Here he has to pass the | ||
5776 | namestore handle, the private key of the zone and the label. He also has | ||
5777 | to provide a callback function which will be called with the result of | ||
5778 | the lookup operation: | ||
5779 | the zone for the records, the label, and the records including the | ||
5780 | number of records included. | ||
5781 | |||
5782 | A special operation is used to set the preferred nickname for a zone. | ||
5783 | This nickname is stored with the zone and is automatically merged with | ||
5784 | all labels and records stored in a zone. Here the client uses the | ||
5785 | @code{GNUNET_NAMESTORE_set_nick} function and passes the private key of | ||
5786 | the zone, the nickname as string plus a the callback with the result of | ||
5787 | the operation. | ||
5788 | |||
5789 | @node Iterating Zone Information | ||
5790 | @subsubsection Iterating Zone Information | ||
5791 | |||
5792 | @c %**end of header | ||
5793 | |||
5794 | A client can iterate over all information in a zone or all zones managed | ||
5795 | by NAMESTORE. | ||
5796 | Here a client uses the @code{GNUNET_NAMESTORE_zone_iteration_start} | ||
5797 | function and passes the namestore handle, the zone to iterate over and a | ||
5798 | callback function to call with the result. | ||
5799 | If the client wants to iterate over all the, he passes NULL for the zone. | ||
5800 | A @code{GNUNET_NAMESTORE_ZoneIterator} handle is returned to be used to | ||
5801 | continue iteration. | ||
5802 | |||
5803 | NAMESTORE calls the callback for every result and expects the client to | ||
5804 | call @code{GNUNET_NAMESTORE_zone_iterator_next} to continue to iterate or | ||
5805 | @code{GNUNET_NAMESTORE_zone_iterator_stop} to interrupt the iteration. | ||
5806 | When NAMESTORE reached the last item it will call the callback with a | ||
5807 | NULL value to indicate. | ||
5808 | |||
5809 | @node Monitoring Zone Information | ||
5810 | @subsubsection Monitoring Zone Information | ||
5811 | |||
5812 | @c %**end of header | ||
5813 | |||
5814 | Clients can also monitor zones to be notified about changes. Here the | ||
5815 | clients uses the @code{GNUNET_NAMESTORE_zone_monitor_start} function and | ||
5816 | passes the private key of the zone and and a callback function to call | ||
5817 | with updates for a zone. | ||
5818 | The client can specify to obtain zone information first by iterating over | ||
5819 | the zone and specify a synchronization callback to be called when the | ||
5820 | client and the namestore are synced. | ||
5821 | |||
5822 | On an update, NAMESTORE will call the callback with the private key of the | ||
5823 | zone, the label and the records and their number. | ||
5824 | |||
5825 | To stop monitoring, the client calls | ||
5826 | @code{GNUNET_NAMESTORE_zone_monitor_stop} and passes the handle obtained | ||
5827 | from the function to start the monitoring. | ||
5828 | |||
5829 | @cindex PEERINFO | ||
5830 | @cindex peerinfo subsystem | ||
5831 | @node GNUnet's PEERINFO subsystem | ||
5832 | @section GNUnet's PEERINFO subsystem | ||
5833 | |||
5834 | @c %**end of header | ||
5835 | |||
5836 | The PEERINFO subsystem is used to store verified (validated) information | ||
5837 | about known peers in a persistent way. It obtains these addresses for | ||
5838 | example from TRANSPORT service which is in charge of address validation. | ||
5839 | Validation means that the information in the HELLO message are checked by | ||
5840 | connecting to the addresses and performing a cryptographic handshake to | ||
5841 | authenticate the peer instance stating to be reachable with these | ||
5842 | addresses. | ||
5843 | Peerinfo does not validate the HELLO messages itself but only stores them | ||
5844 | and gives them to interested clients. | ||
5845 | |||
5846 | As future work, we think about moving from storing just HELLO messages to | ||
5847 | providing a generic persistent per-peer information store. | ||
5848 | More and more subsystems tend to need to store per-peer information in | ||
5849 | persistent way. | ||
5850 | To not duplicate this functionality we plan to provide a PEERSTORE | ||
5851 | service providing this functionality. | ||
5852 | |||
5853 | @menu | ||
5854 | * PEERINFO - Features:: | ||
5855 | * PEERINFO - Limitations:: | ||
5856 | * DeveloperPeer Information:: | ||
5857 | * Startup:: | ||
5858 | * Managing Information:: | ||
5859 | * Obtaining Information:: | ||
5860 | * The PEERINFO Client-Service Protocol:: | ||
5861 | * libgnunetpeerinfo:: | ||
5862 | @end menu | ||
5863 | |||
5864 | @node PEERINFO - Features | ||
5865 | @subsection PEERINFO - Features | ||
5866 | |||
5867 | @c %**end of header | ||
5868 | |||
5869 | @itemize @bullet | ||
5870 | @item Persistent storage | ||
5871 | @item Client notification mechanism on update | ||
5872 | @item Periodic clean up for expired information | ||
5873 | @item Differentiation between public and friend-only HELLO | ||
5874 | @end itemize | ||
5875 | |||
5876 | @node PEERINFO - Limitations | ||
5877 | @subsection PEERINFO - Limitations | ||
5878 | |||
5879 | |||
5880 | @itemize @bullet | ||
5881 | @item Does not perform HELLO validation | ||
5882 | @end itemize | ||
5883 | |||
5884 | @node DeveloperPeer Information | ||
5885 | @subsection DeveloperPeer Information | ||
5886 | |||
5887 | @c %**end of header | ||
5888 | |||
5889 | The PEERINFO subsystem stores these information in the form of HELLO | ||
5890 | messages you can think of as business cards. | ||
5891 | These HELLO messages contain the public key of a peer and the addresses | ||
5892 | a peer can be reached under. | ||
5893 | The addresses include an expiration date describing how long they are | ||
5894 | valid. This information is updated regularly by the TRANSPORT service by | ||
5895 | revalidating the address. | ||
5896 | If an address is expired and not renewed, it can be removed from the | ||
5897 | HELLO message. | ||
5898 | |||
5899 | Some peer do not want to have their HELLO messages distributed to other | ||
5900 | peers, especially when GNUnet's friend-to-friend modus is enabled. | ||
5901 | To prevent this undesired distribution. PEERINFO distinguishes between | ||
5902 | @emph{public} and @emph{friend-only} HELLO messages. | ||
5903 | Public HELLO messages can be freely distributed to other (possibly | ||
5904 | unknown) peers (for example using the hostlist, gossiping, broadcasting), | ||
5905 | whereas friend-only HELLO messages may not be distributed to other peers. | ||
5906 | Friend-only HELLO messages have an additional flag @code{friend_only} set | ||
5907 | internally. For public HELLO message this flag is not set. | ||
5908 | PEERINFO does and cannot not check if a client is allowed to obtain a | ||
5909 | specific HELLO type. | ||
5910 | |||
5911 | The HELLO messages can be managed using the GNUnet HELLO library. | ||
5912 | Other GNUnet systems can obtain these information from PEERINFO and use | ||
5913 | it for their purposes. | ||
5914 | Clients are for example the HOSTLIST component providing these | ||
5915 | information to other peers in form of a hostlist or the TRANSPORT | ||
5916 | subsystem using these information to maintain connections to other peers. | ||
5917 | |||
5918 | @node Startup | ||
5919 | @subsection Startup | ||
5920 | |||
5921 | @c %**end of header | ||
5922 | |||
5923 | During startup the PEERINFO services loads persistent HELLOs from disk. | ||
5924 | First PEERINFO parses the directory configured in the HOSTS value of the | ||
5925 | @code{PEERINFO} configuration section to store PEERINFO information. | ||
5926 | For all files found in this directory valid HELLO messages are extracted. | ||
5927 | In addition it loads HELLO messages shipped with the GNUnet distribution. | ||
5928 | These HELLOs are used to simplify network bootstrapping by providing | ||
5929 | valid peer information with the distribution. | ||
5930 | The use of these HELLOs can be prevented by setting the | ||
5931 | @code{USE_INCLUDED_HELLOS} in the @code{PEERINFO} configuration section to | ||
5932 | @code{NO}. Files containing invalid information are removed. | ||
5933 | |||
5934 | @node Managing Information | ||
5935 | @subsection Managing Information | ||
5936 | |||
5937 | @c %**end of header | ||
5938 | |||
5939 | The PEERINFO services stores information about known PEERS and a single | ||
5940 | HELLO message for every peer. | ||
5941 | A peer does not need to have a HELLO if no information are available. | ||
5942 | HELLO information from different sources, for example a HELLO obtained | ||
5943 | from a remote HOSTLIST and a second HELLO stored on disk, are combined | ||
5944 | and merged into one single HELLO message per peer which will be given to | ||
5945 | clients. During this merge process the HELLO is immediately written to | ||
5946 | disk to ensure persistence. | ||
5947 | |||
5948 | PEERINFO in addition periodically scans the directory where information | ||
5949 | are stored for empty HELLO messages with expired TRANSPORT addresses. | ||
5950 | This periodic task scans all files in the directory and recreates the | ||
5951 | HELLO messages it finds. | ||
5952 | Expired TRANSPORT addresses are removed from the HELLO and if the | ||
5953 | HELLO does not contain any valid addresses, it is discarded and removed | ||
5954 | from the disk. | ||
5955 | |||
5956 | @node Obtaining Information | ||
5957 | @subsection Obtaining Information | ||
5958 | |||
5959 | @c %**end of header | ||
5960 | |||
5961 | When a client requests information from PEERINFO, PEERINFO performs a | ||
5962 | lookup for the respective peer or all peers if desired and transmits this | ||
5963 | information to the client. | ||
5964 | The client can specify if friend-only HELLOs have to be included or not | ||
5965 | and PEERINFO filters the respective HELLO messages before transmitting | ||
5966 | information. | ||
5967 | |||
5968 | To notify clients about changes to PEERINFO information, PEERINFO | ||
5969 | maintains a list of clients interested in this notifications. | ||
5970 | Such a notification occurs if a HELLO for a peer was updated (due to a | ||
5971 | merge for example) or a new peer was added. | ||
5972 | |||
5973 | @node The PEERINFO Client-Service Protocol | ||
5974 | @subsection The PEERINFO Client-Service Protocol | ||
5975 | |||
5976 | @c %**end of header | ||
5977 | |||
5978 | To connect and disconnect to and from the PEERINFO Service PEERINFO | ||
5979 | utilizes the util client/server infrastructure, so no special messages | ||
5980 | types are used here. | ||
5981 | |||
5982 | To add information for a peer, the plain HELLO message is transmitted to | ||
5983 | the service without any wrapping. All pieces of information required are | ||
5984 | stored within the HELLO message. | ||
5985 | The PEERINFO service provides a message handler accepting and processing | ||
5986 | these HELLO messages. | ||
5987 | |||
5988 | When obtaining PEERINFO information using the iterate functionality | ||
5989 | specific messages are used. To obtain information for all peers, a | ||
5990 | @code{struct ListAllPeersMessage} with message type | ||
5991 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL} and a flag | ||
5992 | include_friend_only to indicate if friend-only HELLO messages should be | ||
5993 | included are transmitted. If information for a specific peer is required | ||
5994 | a @code{struct ListAllPeersMessage} with | ||
5995 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET} containing the peer identity is | ||
5996 | used. | ||
5997 | |||
5998 | For both variants the PEERINFO service replies for each HELLO message it | ||
5999 | wants to transmit with a @code{struct ListAllPeersMessage} with type | ||
6000 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO} containing the plain HELLO. | ||
6001 | The final message is @code{struct GNUNET_MessageHeader} with type | ||
6002 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO}. If the client receives this | ||
6003 | message, it can proceed with the next request if any is pending. | ||
6004 | |||
6005 | @node libgnunetpeerinfo | ||
6006 | @subsection libgnunetpeerinfo | ||
6007 | |||
6008 | @c %**end of header | ||
6009 | |||
6010 | The PEERINFO API consists mainly of three different functionalities: | ||
6011 | |||
6012 | @itemize @bullet | ||
6013 | @item maintaining a connection to the service | ||
6014 | @item adding new information to the PEERINFO service | ||
6015 | @item retrieving information from the PEERINFO service | ||
6016 | @end itemize | ||
6017 | |||
6018 | @menu | ||
6019 | * Connecting to the PEERINFO Service:: | ||
6020 | * Adding Information to the PEERINFO Service:: | ||
6021 | * Obtaining Information from the PEERINFO Service:: | ||
6022 | @end menu | ||
6023 | |||
6024 | @node Connecting to the PEERINFO Service | ||
6025 | @subsubsection Connecting to the PEERINFO Service | ||
6026 | |||
6027 | @c %**end of header | ||
6028 | |||
6029 | To connect to the PEERINFO service the function | ||
6030 | @code{GNUNET_PEERINFO_connect} is used, taking a configuration handle as | ||
6031 | an argument, and to disconnect from PEERINFO the function | ||
6032 | @code{GNUNET_PEERINFO_disconnect}, taking the PEERINFO | ||
6033 | handle returned from the connect function has to be called. | ||
6034 | |||
6035 | @node Adding Information to the PEERINFO Service | ||
6036 | @subsubsection Adding Information to the PEERINFO Service | ||
6037 | |||
6038 | @c %**end of header | ||
6039 | |||
6040 | @code{GNUNET_PEERINFO_add_peer} adds a new peer to the PEERINFO subsystem | ||
6041 | storage. This function takes the PEERINFO handle as an argument, the HELLO | ||
6042 | message to store and a continuation with a closure to be called with the | ||
6043 | result of the operation. | ||
6044 | The @code{GNUNET_PEERINFO_add_peer} returns a handle to this operation | ||
6045 | allowing to cancel the operation with the respective cancel function | ||
6046 | @code{GNUNET_PEERINFO_add_peer_cancel}. To retrieve information from | ||
6047 | PEERINFO you can iterate over all information stored with PEERINFO or you | ||
6048 | can tell PEERINFO to notify if new peer information are available. | ||
6049 | |||
6050 | @node Obtaining Information from the PEERINFO Service | ||
6051 | @subsubsection Obtaining Information from the PEERINFO Service | ||
6052 | |||
6053 | @c %**end of header | ||
6054 | |||
6055 | To iterate over information in PEERINFO you use | ||
6056 | @code{GNUNET_PEERINFO_iterate}. | ||
6057 | This function expects the PEERINFO handle, a flag if HELLO messages | ||
6058 | intended for friend only mode should be included, a timeout how long the | ||
6059 | operation should take and a callback with a callback closure to be called | ||
6060 | for the results. | ||
6061 | If you want to obtain information for a specific peer, you can specify | ||
6062 | the peer identity, if this identity is NULL, information for all peers are | ||
6063 | returned. The function returns a handle to allow to cancel the operation | ||
6064 | using @code{GNUNET_PEERINFO_iterate_cancel}. | ||
6065 | |||
6066 | To get notified when peer information changes, you can use | ||
6067 | @code{GNUNET_PEERINFO_notify}. | ||
6068 | This function expects a configuration handle and a flag if friend-only | ||
6069 | HELLO messages should be included. The PEERINFO service will notify you | ||
6070 | about every change and the callback function will be called to notify you | ||
6071 | about changes. The function returns a handle to cancel notifications | ||
6072 | with @code{GNUNET_PEERINFO_notify_cancel}. | ||
6073 | |||
6074 | @cindex PEERSTORE subsystem | ||
6075 | @node GNUnet's PEERSTORE subsystem | ||
6076 | @section GNUnet's PEERSTORE subsystem | ||
6077 | |||
6078 | @c %**end of header | ||
6079 | |||
6080 | GNUnet's PEERSTORE subsystem offers persistent per-peer storage for other | ||
6081 | GNUnet subsystems. GNUnet subsystems can use PEERSTORE to persistently | ||
6082 | store and retrieve arbitrary data. | ||
6083 | Each data record stored with PEERSTORE contains the following fields: | ||
6084 | |||
6085 | @itemize @bullet | ||
6086 | @item subsystem: Name of the subsystem responsible for the record. | ||
6087 | @item peerid: Identity of the peer this record is related to. | ||
6088 | @item key: a key string identifying the record. | ||
6089 | @item value: binary record value. | ||
6090 | @item expiry: record expiry date. | ||
6091 | @end itemize | ||
6092 | |||
6093 | @menu | ||
6094 | * Functionality:: | ||
6095 | * Architecture:: | ||
6096 | * libgnunetpeerstore:: | ||
6097 | @end menu | ||
6098 | |||
6099 | @node Functionality | ||
6100 | @subsection Functionality | ||
6101 | |||
6102 | @c %**end of header | ||
6103 | |||
6104 | Subsystems can store any type of value under a (subsystem, peerid, key) | ||
6105 | combination. A "replace" flag set during store operations forces the | ||
6106 | PEERSTORE to replace any old values stored under the same | ||
6107 | (subsystem, peerid, key) combination with the new value. | ||
6108 | Additionally, an expiry date is set after which the record is *possibly* | ||
6109 | deleted by PEERSTORE. | ||
6110 | |||
6111 | Subsystems can iterate over all values stored under any of the following | ||
6112 | combination of fields: | ||
6113 | |||
6114 | @itemize @bullet | ||
6115 | @item (subsystem) | ||
6116 | @item (subsystem, peerid) | ||
6117 | @item (subsystem, key) | ||
6118 | @item (subsystem, peerid, key) | ||
6119 | @end itemize | ||
6120 | |||
6121 | Subsystems can also request to be notified about any new values stored | ||
6122 | under a (subsystem, peerid, key) combination by sending a "watch" | ||
6123 | request to PEERSTORE. | ||
6124 | |||
6125 | @node Architecture | ||
6126 | @subsection Architecture | ||
6127 | |||
6128 | @c %**end of header | ||
6129 | |||
6130 | PEERSTORE implements the following components: | ||
6131 | |||
6132 | @itemize @bullet | ||
6133 | @item PEERSTORE service: Handles store, iterate and watch operations. | ||
6134 | @item PEERSTORE API: API to be used by other subsystems to communicate and | ||
6135 | issue commands to the PEERSTORE service. | ||
6136 | @item PEERSTORE plugins: Handles the persistent storage. At the moment, | ||
6137 | only an "sqlite" plugin is implemented. | ||
6138 | @end itemize | ||
6139 | |||
6140 | @cindex libgnunetpeerstore | ||
6141 | @node libgnunetpeerstore | ||
6142 | @subsection libgnunetpeerstore | ||
6143 | |||
6144 | @c %**end of header | ||
6145 | |||
6146 | libgnunetpeerstore is the library containing the PEERSTORE API. Subsystems | ||
6147 | wishing to communicate with the PEERSTORE service use this API to open a | ||
6148 | connection to PEERSTORE. This is done by calling | ||
6149 | @code{GNUNET_PEERSTORE_connect} which returns a handle to the newly | ||
6150 | created connection. | ||
6151 | This handle has to be used with any further calls to the API. | ||
6152 | |||
6153 | To store a new record, the function @code{GNUNET_PEERSTORE_store} is to | ||
6154 | be used which requires the record fields and a continuation function that | ||
6155 | will be called by the API after the STORE request is sent to the | ||
6156 | PEERSTORE service. | ||
6157 | Note that calling the continuation function does not mean that the record | ||
6158 | is successfully stored, only that the STORE request has been successfully | ||
6159 | sent to the PEERSTORE service. | ||
6160 | @code{GNUNET_PEERSTORE_store_cancel} can be called to cancel the STORE | ||
6161 | request only before the continuation function has been called. | ||
6162 | |||
6163 | To iterate over stored records, the function | ||
6164 | @code{GNUNET_PEERSTORE_iterate} is | ||
6165 | to be used. @emph{peerid} and @emph{key} can be set to NULL. An iterator | ||
6166 | callback function will be called with each matching record found and a | ||
6167 | NULL record at the end to signal the end of result set. | ||
6168 | @code{GNUNET_PEERSTORE_iterate_cancel} can be used to cancel the ITERATE | ||
6169 | request before the iterator callback is called with a NULL record. | ||
6170 | |||
6171 | To be notified with new values stored under a (subsystem, peerid, key) | ||
6172 | combination, the function @code{GNUNET_PEERSTORE_watch} is to be used. | ||
6173 | This will register the watcher with the PEERSTORE service, any new | ||
6174 | records matching the given combination will trigger the callback | ||
6175 | function passed to @code{GNUNET_PEERSTORE_watch}. This continues until | ||
6176 | @code{GNUNET_PEERSTORE_watch_cancel} is called or the connection to the | ||
6177 | service is destroyed. | ||
6178 | |||
6179 | After the connection is no longer needed, the function | ||
6180 | @code{GNUNET_PEERSTORE_disconnect} can be called to disconnect from the | ||
6181 | PEERSTORE service. | ||
6182 | Any pending ITERATE or WATCH requests will be destroyed. | ||
6183 | If the @code{sync_first} flag is set to @code{GNUNET_YES}, the API will | ||
6184 | delay the disconnection until all pending STORE requests are sent to | ||
6185 | the PEERSTORE service, otherwise, the pending STORE requests will be | ||
6186 | destroyed as well. | ||
6187 | |||
6188 | @cindex SET Subsystem | ||
6189 | @node GNUnet's SET Subsystem | ||
6190 | @section GNUnet's SET Subsystem | ||
6191 | |||
6192 | @c %**end of header | ||
6193 | |||
6194 | The SET service implements efficient set operations between two peers | ||
6195 | over a mesh tunnel. | ||
6196 | Currently, set union and set intersection are the only supported | ||
6197 | operations. Elements of a set consist of an @emph{element type} and | ||
6198 | arbitrary binary @emph{data}. | ||
6199 | The size of an element's data is limited to around 62 KB. | ||
6200 | |||
6201 | @menu | ||
6202 | * Local Sets:: | ||
6203 | * Set Modifications:: | ||
6204 | * Set Operations:: | ||
6205 | * Result Elements:: | ||
6206 | * libgnunetset:: | ||
6207 | * The SET Client-Service Protocol:: | ||
6208 | * The SET Intersection Peer-to-Peer Protocol:: | ||
6209 | * The SET Union Peer-to-Peer Protocol:: | ||
6210 | @end menu | ||
6211 | |||
6212 | @node Local Sets | ||
6213 | @subsection Local Sets | ||
6214 | |||
6215 | @c %**end of header | ||
6216 | |||
6217 | Sets created by a local client can be modified and reused for multiple | ||
6218 | operations. As each set operation requires potentially expensive special | ||
6219 | auxilliary data to be computed for each element of a set, a set can only | ||
6220 | participate in one type of set operation (i.e. union or intersection). | ||
6221 | The type of a set is determined upon its creation. | ||
6222 | If a the elements of a set are needed for an operation of a different | ||
6223 | type, all of the set's element must be copied to a new set of appropriate | ||
6224 | type. | ||
6225 | |||
6226 | @node Set Modifications | ||
6227 | @subsection Set Modifications | ||
6228 | |||
6229 | @c %**end of header | ||
6230 | |||
6231 | Even when set operations are active, one can add to and remove elements | ||
6232 | from a set. | ||
6233 | However, these changes will only be visible to operations that have been | ||
6234 | created after the changes have taken place. That is, every set operation | ||
6235 | only sees a snapshot of the set from the time the operation was started. | ||
6236 | This mechanism is @emph{not} implemented by copying the whole set, but by | ||
6237 | attaching @emph{generation information} to each element and operation. | ||
6238 | |||
6239 | @node Set Operations | ||
6240 | @subsection Set Operations | ||
6241 | |||
6242 | @c %**end of header | ||
6243 | |||
6244 | Set operations can be started in two ways: Either by accepting an | ||
6245 | operation request from a remote peer, or by requesting a set operation | ||
6246 | from a remote peer. | ||
6247 | Set operations are uniquely identified by the involved @emph{peers}, an | ||
6248 | @emph{application id} and the @emph{operation type}. | ||
6249 | |||
6250 | The client is notified of incoming set operations by @emph{set listeners}. | ||
6251 | A set listener listens for incoming operations of a specific operation | ||
6252 | type and application id. | ||
6253 | Once notified of an incoming set request, the client can accept the set | ||
6254 | request (providing a local set for the operation) or reject it. | ||
6255 | |||
6256 | @node Result Elements | ||
6257 | @subsection Result Elements | ||
6258 | |||
6259 | @c %**end of header | ||
6260 | |||
6261 | The SET service has three @emph{result modes} that determine how an | ||
6262 | operation's result set is delivered to the client: | ||
6263 | |||
6264 | @itemize @bullet | ||
6265 | @item @strong{Full Result Set.} All elements of set resulting from the set | ||
6266 | operation are returned to the client. | ||
6267 | @item @strong{Added Elements.} Only elements that result from the | ||
6268 | operation and are not already in the local peer's set are returned. | ||
6269 | Note that for some operations (like set intersection) this result mode | ||
6270 | will never return any elements. | ||
6271 | This can be useful if only the remove peer is actually interested in | ||
6272 | the result of the set operation. | ||
6273 | @item @strong{Removed Elements.} Only elements that are in the local | ||
6274 | peer's initial set but not in the operation's result set are returned. | ||
6275 | Note that for some operations (like set union) this result mode will | ||
6276 | never return any elements. This can be useful if only the remove peer is | ||
6277 | actually interested in the result of the set operation. | ||
6278 | @end itemize | ||
6279 | |||
6280 | @cindex libgnunetset | ||
6281 | @node libgnunetset | ||
6282 | @subsection libgnunetset | ||
6283 | |||
6284 | @c %**end of header | ||
6285 | |||
6286 | @menu | ||
6287 | * Sets:: | ||
6288 | * Listeners:: | ||
6289 | * Operations:: | ||
6290 | * Supplying a Set:: | ||
6291 | * The Result Callback:: | ||
6292 | @end menu | ||
6293 | |||
6294 | @node Sets | ||
6295 | @subsubsection Sets | ||
6296 | |||
6297 | @c %**end of header | ||
6298 | |||
6299 | New sets are created with @code{GNUNET_SET_create}. Both the local peer's | ||
6300 | configuration (as each set has its own client connection) and the | ||
6301 | operation type must be specified. | ||
6302 | The set exists until either the client calls @code{GNUNET_SET_destroy} or | ||
6303 | the client's connection to the service is disrupted. | ||
6304 | In the latter case, the client is notified by the return value of | ||
6305 | functions dealing with sets. This return value must always be checked. | ||
6306 | |||
6307 | Elements are added and removed with @code{GNUNET_SET_add_element} and | ||
6308 | @code{GNUNET_SET_remove_element}. | ||
6309 | |||
6310 | @node Listeners | ||
6311 | @subsubsection Listeners | ||
6312 | |||
6313 | @c %**end of header | ||
6314 | |||
6315 | Listeners are created with @code{GNUNET_SET_listen}. Each time time a | ||
6316 | remote peer suggests a set operation with an application id and operation | ||
6317 | type matching a listener, the listener's callback is invoked. | ||
6318 | The client then must synchronously call either @code{GNUNET_SET_accept} | ||
6319 | or @code{GNUNET_SET_reject}. Note that the operation will not be started | ||
6320 | until the client calls @code{GNUNET_SET_commit} | ||
6321 | (see Section "Supplying a Set"). | ||
6322 | |||
6323 | @node Operations | ||
6324 | @subsubsection Operations | ||
6325 | |||
6326 | @c %**end of header | ||
6327 | |||
6328 | Operations to be initiated by the local peer are created with | ||
6329 | @code{GNUNET_SET_prepare}. Note that the operation will not be started | ||
6330 | until the client calls @code{GNUNET_SET_commit} | ||
6331 | (see Section "Supplying a Set"). | ||
6332 | |||
6333 | @node Supplying a Set | ||
6334 | @subsubsection Supplying a Set | ||
6335 | |||
6336 | @c %**end of header | ||
6337 | |||
6338 | To create symmetry between the two ways of starting a set operation | ||
6339 | (accepting and nitiating it), the operation handles returned by | ||
6340 | @code{GNUNET_SET_accept} and @code{GNUNET_SET_prepare} do not yet have a | ||
6341 | set to operate on, thus they can not do any work yet. | ||
6342 | |||
6343 | The client must call @code{GNUNET_SET_commit} to specify a set to use for | ||
6344 | an operation. @code{GNUNET_SET_commit} may only be called once per set | ||
6345 | operation. | ||
6346 | |||
6347 | @node The Result Callback | ||
6348 | @subsubsection The Result Callback | ||
6349 | |||
6350 | @c %**end of header | ||
6351 | |||
6352 | Clients must specify both a result mode and a result callback with | ||
6353 | @code{GNUNET_SET_accept} and @code{GNUNET_SET_prepare}. The result | ||
6354 | callback with a status indicating either that an element was received, or | ||
6355 | the operation failed or succeeded. | ||
6356 | The interpretation of the received element depends on the result mode. | ||
6357 | The callback needs to know which result mode it is used in, as the | ||
6358 | arguments do not indicate if an element is part of the full result set, | ||
6359 | or if it is in the difference between the original set and the final set. | ||
6360 | |||
6361 | @node The SET Client-Service Protocol | ||
6362 | @subsection The SET Client-Service Protocol | ||
6363 | |||
6364 | @c %**end of header | ||
6365 | |||
6366 | @menu | ||
6367 | * Creating Sets:: | ||
6368 | * Listeners2:: | ||
6369 | * Initiating Operations:: | ||
6370 | * Modifying Sets:: | ||
6371 | * Results and Operation Status:: | ||
6372 | * Iterating Sets:: | ||
6373 | @end menu | ||
6374 | |||
6375 | @node Creating Sets | ||
6376 | @subsubsection Creating Sets | ||
6377 | |||
6378 | @c %**end of header | ||
6379 | |||
6380 | For each set of a client, there exists a client connection to the service. | ||
6381 | Sets are created by sending the @code{GNUNET_SERVICE_SET_CREATE} message | ||
6382 | over a new client connection. Multiple operations for one set are | ||
6383 | multiplexed over one client connection, using a request id supplied by | ||
6384 | the client. | ||
6385 | |||
6386 | @node Listeners2 | ||
6387 | @subsubsection Listeners2 | ||
6388 | |||
6389 | @c %**end of header | ||
6390 | |||
6391 | Each listener also requires a seperate client connection. By sending the | ||
6392 | @code{GNUNET_SERVICE_SET_LISTEN} message, the client notifies the service | ||
6393 | of the application id and operation type it is interested in. A client | ||
6394 | rejects an incoming request by sending @code{GNUNET_SERVICE_SET_REJECT} | ||
6395 | on the listener's client connection. | ||
6396 | In contrast, when accepting an incoming request, a | ||
6397 | @code{GNUNET_SERVICE_SET_ACCEPT} message must be sent over the@ set that | ||
6398 | is supplied for the set operation. | ||
6399 | |||
6400 | @node Initiating Operations | ||
6401 | @subsubsection Initiating Operations | ||
6402 | |||
6403 | @c %**end of header | ||
6404 | |||
6405 | Operations with remote peers are initiated by sending a | ||
6406 | @code{GNUNET_SERVICE_SET_EVALUATE} message to the service. The@ client | ||
6407 | connection that this message is sent by determines the set to use. | ||
6408 | |||
6409 | @node Modifying Sets | ||
6410 | @subsubsection Modifying Sets | ||
6411 | |||
6412 | @c %**end of header | ||
6413 | |||
6414 | Sets are modified with the @code{GNUNET_SERVICE_SET_ADD} and | ||
6415 | @code{GNUNET_SERVICE_SET_REMOVE} messages. | ||
6416 | |||
6417 | |||
6418 | @c %@menu | ||
6419 | @c %* Results and Operation Status:: | ||
6420 | @c %* Iterating Sets:: | ||
6421 | @c %@end menu | ||
6422 | |||
6423 | @node Results and Operation Status | ||
6424 | @subsubsection Results and Operation Status | ||
6425 | @c %**end of header | ||
6426 | |||
6427 | The service notifies the client of result elements and success/failure of | ||
6428 | a set operation with the @code{GNUNET_SERVICE_SET_RESULT} message. | ||
6429 | |||
6430 | @node Iterating Sets | ||
6431 | @subsubsection Iterating Sets | ||
6432 | |||
6433 | @c %**end of header | ||
6434 | |||
6435 | All elements of a set can be requested by sending | ||
6436 | @code{GNUNET_SERVICE_SET_ITER_REQUEST}. The server responds with | ||
6437 | @code{GNUNET_SERVICE_SET_ITER_ELEMENT} and eventually terminates the | ||
6438 | iteration with @code{GNUNET_SERVICE_SET_ITER_DONE}. | ||
6439 | After each received element, the client | ||
6440 | must send @code{GNUNET_SERVICE_SET_ITER_ACK}. Note that only one set | ||
6441 | iteration may be active for a set at any given time. | ||
6442 | |||
6443 | @node The SET Intersection Peer-to-Peer Protocol | ||
6444 | @subsection The SET Intersection Peer-to-Peer Protocol | ||
6445 | |||
6446 | @c %**end of header | ||
6447 | |||
6448 | The intersection protocol operates over CADET and starts with a | ||
6449 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer | ||
6450 | initiating the operation to the peer listening for inbound requests. | ||
6451 | It includes the number of elements of the initiating peer, which is used | ||
6452 | to decide which side will send a Bloom filter first. | ||
6453 | |||
6454 | The listening peer checks if the operation type and application | ||
6455 | identifier are acceptable for its current state. | ||
6456 | If not, it responds with a GNUNET_MESSAGE_TYPE_SET_RESULT and a status of | ||
6457 | GNUNET_SET_STATUS_FAILURE (and terminates the CADET channel). | ||
6458 | |||
6459 | If the application accepts the request, the listener sends back a | ||
6460 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO} if it has | ||
6461 | more elements in the set than the client. | ||
6462 | Otherwise, it immediately starts with the Bloom filter exchange. | ||
6463 | If the initiator receives a | ||
6464 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO} response, | ||
6465 | it beings the Bloom filter exchange, unless the set size is indicated to | ||
6466 | be zero, in which case the intersection is considered finished after | ||
6467 | just the initial handshake. | ||
6468 | |||
6469 | |||
6470 | @menu | ||
6471 | * The Bloom filter exchange:: | ||
6472 | * Salt:: | ||
6473 | @end menu | ||
6474 | |||
6475 | @node The Bloom filter exchange | ||
6476 | @subsubsection The Bloom filter exchange | ||
6477 | |||
6478 | @c %**end of header | ||
6479 | |||
6480 | In this phase, each peer transmits a Bloom filter over the remaining | ||
6481 | keys of the local set to the other peer using a | ||
6482 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF} message. This | ||
6483 | message additionally includes the number of elements left in the sender's | ||
6484 | set, as well as the XOR over all of the keys in that set. | ||
6485 | |||
6486 | The number of bits 'k' set per element in the Bloom filter is calculated | ||
6487 | based on the relative size of the two sets. | ||
6488 | Furthermore, the size of the Bloom filter is calculated based on 'k' and | ||
6489 | the number of elements in the set to maximize the amount of data filtered | ||
6490 | per byte transmitted on the wire (while avoiding an excessively high | ||
6491 | number of iterations). | ||
6492 | |||
6493 | The receiver of the message removes all elements from its local set that | ||
6494 | do not pass the Bloom filter test. | ||
6495 | It then checks if the set size of the sender and the XOR over the keys | ||
6496 | match what is left of his own set. If they do, he sends a | ||
6497 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE} back to indicate | ||
6498 | that the latest set is the final result. | ||
6499 | Otherwise, the receiver starts another Bloom fitler exchange, except | ||
6500 | this time as the sender. | ||
6501 | |||
6502 | @node Salt | ||
6503 | @subsubsection Salt | ||
6504 | |||
6505 | @c %**end of header | ||
6506 | |||
6507 | Bloomfilter operations are probablistic: With some non-zero probability | ||
6508 | the test may incorrectly say an element is in the set, even though it is | ||
6509 | not. | ||
6510 | |||
6511 | To mitigate this problem, the intersection protocol iterates exchanging | ||
6512 | Bloom filters using a different random 32-bit salt in each iteration (the | ||
6513 | salt is also included in the message). | ||
6514 | With different salts, set operations may fail for different elements. | ||
6515 | Merging the results from the executions, the probability of failure drops | ||
6516 | to zero. | ||
6517 | |||
6518 | The iterations terminate once both peers have established that they have | ||
6519 | sets of the same size, and where the XOR over all keys computes the same | ||
6520 | 512-bit value (leaving a failure probability of 2-511). | ||
6521 | |||
6522 | @node The SET Union Peer-to-Peer Protocol | ||
6523 | @subsection The SET Union Peer-to-Peer Protocol | ||
6524 | |||
6525 | @c %**end of header | ||
6526 | |||
6527 | The SET union protocol is based on Eppstein's efficient set reconciliation | ||
6528 | without prior context. You should read this paper first if you want to | ||
6529 | understand the protocol. | ||
6530 | |||
6531 | The union protocol operates over CADET and starts with a | ||
6532 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer | ||
6533 | initiating the operation to the peer listening for inbound requests. | ||
6534 | It includes the number of elements of the initiating peer, which is | ||
6535 | currently not used. | ||
6536 | |||
6537 | The listening peer checks if the operation type and application | ||
6538 | identifier are acceptable for its current state. If not, it responds with | ||
6539 | a @code{GNUNET_MESSAGE_TYPE_SET_RESULT} and a status of | ||
6540 | @code{GNUNET_SET_STATUS_FAILURE} (and terminates the CADET channel). | ||
6541 | |||
6542 | If the application accepts the request, it sends back a strata estimator | ||
6543 | using a message of type GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE. The | ||
6544 | initiator evaluates the strata estimator and initiates the exchange of | ||
6545 | invertible Bloom filters, sending a GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
6546 | |||
6547 | During the IBF exchange, if the receiver cannot invert the Bloom filter or | ||
6548 | detects a cycle, it sends a larger IBF in response (up to a defined | ||
6549 | maximum limit; if that limit is reached, the operation fails). | ||
6550 | Elements decoded while processing the IBF are transmitted to the other | ||
6551 | peer using GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, or requested from the | ||
6552 | other peer using GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS messages, | ||
6553 | depending on the sign observed during decoding of the IBF. | ||
6554 | Peers respond to a GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS message | ||
6555 | with the respective element in a GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS | ||
6556 | message. If the IBF fully decodes, the peer responds with a | ||
6557 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE message instead of another | ||
6558 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
6559 | |||
6560 | All Bloom filter operations use a salt to mingle keys before hasing them | ||
6561 | into buckets, such that future iterations have a fresh chance of | ||
6562 | succeeding if they failed due to collisions before. | ||
6563 | |||
6564 | @cindex STATISTICS subsystem | ||
6565 | @node GNUnet's STATISTICS subsystem | ||
6566 | @section GNUnet's STATISTICS subsystem | ||
6567 | |||
6568 | @c %**end of header | ||
6569 | |||
6570 | In GNUnet, the STATISTICS subsystem offers a central place for all | ||
6571 | subsystems to publish unsigned 64-bit integer run-time statistics. | ||
6572 | Keeping this information centrally means that there is a unified way for | ||
6573 | the user to obtain data on all subsystems, and individual subsystems do | ||
6574 | not have to always include a custom data export method for performance | ||
6575 | metrics and other statistics. For example, the TRANSPORT system uses | ||
6576 | STATISTICS to update information about the number of directly connected | ||
6577 | peers and the bandwidth that has been consumed by the various plugins. | ||
6578 | This information is valuable for diagnosing connectivity and performance | ||
6579 | issues. | ||
6580 | |||
6581 | Following the GNUnet service architecture, the STATISTICS subsystem is | ||
6582 | divided into an API which is exposed through the header | ||
6583 | @strong{gnunet_statistics_service.h} and the STATISTICS service | ||
6584 | @strong{gnunet-service-statistics}. The @strong{gnunet-statistics} | ||
6585 | command-line tool can be used to obtain (and change) information about | ||
6586 | the values stored by the STATISTICS service. The STATISTICS service does | ||
6587 | not communicate with other peers. | ||
6588 | |||
6589 | Data is stored in the STATISTICS service in the form of tuples | ||
6590 | @strong{(subsystem, name, value, persistence)}. The subsystem determines | ||
6591 | to which other GNUnet's subsystem the data belongs. name is the name | ||
6592 | through which value is associated. It uniquely identifies the record | ||
6593 | from among other records belonging to the same subsystem. | ||
6594 | In some parts of the code, the pair @strong{(subsystem, name)} is called | ||
6595 | a @strong{statistic} as it identifies the values stored in the STATISTCS | ||
6596 | service.The persistence flag determines if the record has to be preserved | ||
6597 | across service restarts. A record is said to be persistent if this flag | ||
6598 | is set for it; if not, the record is treated as a non-persistent record | ||
6599 | and it is lost after service restart. Persistent records are written to | ||
6600 | and read from the file @strong{statistics.data} before shutdown | ||
6601 | and upon startup. The file is located in the HOME directory of the peer. | ||
6602 | |||
6603 | An anomaly of the STATISTICS service is that it does not terminate | ||
6604 | immediately upon receiving a shutdown signal if it has any clients | ||
6605 | connected to it. It waits for all the clients that are not monitors to | ||
6606 | close their connections before terminating itself. | ||
6607 | This is to prevent the loss of data during peer shutdown --- delaying the | ||
6608 | STATISTICS service shutdown helps other services to store important data | ||
6609 | to STATISTICS during shutdown. | ||
6610 | |||
6611 | @menu | ||
6612 | * libgnunetstatistics:: | ||
6613 | * The STATISTICS Client-Service Protocol:: | ||
6614 | @end menu | ||
6615 | |||
6616 | @cindex libgnunetstatistics | ||
6617 | @node libgnunetstatistics | ||
6618 | @subsection libgnunetstatistics | ||
6619 | |||
6620 | @c %**end of header | ||
6621 | |||
6622 | @strong{libgnunetstatistics} is the library containing the API for the | ||
6623 | STATISTICS subsystem. Any process requiring to use STATISTICS should use | ||
6624 | this API by to open a connection to the STATISTICS service. | ||
6625 | This is done by calling the function @code{GNUNET_STATISTICS_create()}. | ||
6626 | This function takes the subsystem's name which is trying to use STATISTICS | ||
6627 | and a configuration. | ||
6628 | All values written to STATISTICS with this connection will be placed in | ||
6629 | the section corresponding to the given subsystem's name. | ||
6630 | The connection to STATISTICS can be destroyed with the function | ||
6631 | @code{GNUNET_STATISTICS_destroy()}. This function allows for the | ||
6632 | connection to be destroyed immediately or upon transferring all | ||
6633 | pending write requests to the service. | ||
6634 | |||
6635 | Note: STATISTICS subsystem can be disabled by setting @code{DISABLE = YES} | ||
6636 | under the @code{[STATISTICS]} section in the configuration. With such a | ||
6637 | configuration all calls to @code{GNUNET_STATISTICS_create()} return | ||
6638 | @code{NULL} as the STATISTICS subsystem is unavailable and no other | ||
6639 | functions from the API can be used. | ||
6640 | |||
6641 | |||
6642 | @menu | ||
6643 | * Statistics retrieval:: | ||
6644 | * Setting statistics and updating them:: | ||
6645 | * Watches:: | ||
6646 | @end menu | ||
6647 | |||
6648 | @node Statistics retrieval | ||
6649 | @subsubsection Statistics retrieval | ||
6650 | |||
6651 | @c %**end of header | ||
6652 | |||
6653 | Once a connection to the statistics service is obtained, information | ||
6654 | about any other system which uses statistics can be retrieved with the | ||
6655 | function GNUNET_STATISTICS_get(). | ||
6656 | This function takes the connection handle, the name of the subsystem | ||
6657 | whose information we are interested in (a @code{NULL} value will | ||
6658 | retrieve information of all available subsystems using STATISTICS), the | ||
6659 | name of the statistic we are interested in (a @code{NULL} value will | ||
6660 | retrieve all available statistics), a continuation callback which is | ||
6661 | called when all of requested information is retrieved, an iterator | ||
6662 | callback which is called for each parameter in the retrieved information | ||
6663 | and a closure for the aforementioned callbacks. The library then invokes | ||
6664 | the iterator callback for each value matching the request. | ||
6665 | |||
6666 | Call to @code{GNUNET_STATISTICS_get()} is asynchronous and can be | ||
6667 | canceled with the function @code{GNUNET_STATISTICS_get_cancel()}. | ||
6668 | This is helpful when retrieving statistics takes too long and especially | ||
6669 | when we want to shutdown and cleanup everything. | ||
6670 | |||
6671 | @node Setting statistics and updating them | ||
6672 | @subsubsection Setting statistics and updating them | ||
6673 | |||
6674 | @c %**end of header | ||
6675 | |||
6676 | So far we have seen how to retrieve statistics, here we will learn how we | ||
6677 | can set statistics and update them so that other subsystems can retrieve | ||
6678 | them. | ||
6679 | |||
6680 | A new statistic can be set using the function | ||
6681 | @code{GNUNET_STATISTICS_set()}. | ||
6682 | This function takes the name of the statistic and its value and a flag to | ||
6683 | make the statistic persistent. | ||
6684 | The value of the statistic should be of the type @code{uint64_t}. | ||
6685 | The function does not take the name of the subsystem; it is determined | ||
6686 | from the previous @code{GNUNET_STATISTICS_create()} invocation. If | ||
6687 | the given statistic is already present, its value is overwritten. | ||
6688 | |||
6689 | An existing statistics can be updated, i.e its value can be increased or | ||
6690 | decreased by an amount with the function | ||
6691 | @code{GNUNET_STATISTICS_update()}. | ||
6692 | The parameters to this function are similar to | ||
6693 | @code{GNUNET_STATISTICS_set()}, except that it takes the amount to be | ||
6694 | changed as a type @code{int64_t} instead of the value. | ||
6695 | |||
6696 | The library will combine multiple set or update operations into one | ||
6697 | message if the client performs requests at a rate that is faster than the | ||
6698 | available IPC with the STATISTICS service. Thus, the client does not have | ||
6699 | to worry about sending requests too quickly. | ||
6700 | |||
6701 | @node Watches | ||
6702 | @subsubsection Watches | ||
6703 | |||
6704 | @c %**end of header | ||
6705 | |||
6706 | As interesting feature of STATISTICS lies in serving notifications | ||
6707 | whenever a statistic of our interest is modified. | ||
6708 | This is achieved by registering a watch through the function | ||
6709 | @code{GNUNET_STATISTICS_watch()}. | ||
6710 | The parameters of this function are similar to those of | ||
6711 | @code{GNUNET_STATISTICS_get()}. | ||
6712 | Changes to the respective statistic's value will then cause the given | ||
6713 | iterator callback to be called. | ||
6714 | Note: A watch can only be registered for a specific statistic. Hence | ||
6715 | the subsystem name and the parameter name cannot be @code{NULL} in a | ||
6716 | call to @code{GNUNET_STATISTICS_watch()}. | ||
6717 | |||
6718 | A registered watch will keep notifying any value changes until | ||
6719 | @code{GNUNET_STATISTICS_watch_cancel()} is called with the same | ||
6720 | parameters that are used for registering the watch. | ||
6721 | |||
6722 | @node The STATISTICS Client-Service Protocol | ||
6723 | @subsection The STATISTICS Client-Service Protocol | ||
6724 | @c %**end of header | ||
6725 | |||
6726 | |||
6727 | @menu | ||
6728 | * Statistics retrieval2:: | ||
6729 | * Setting and updating statistics:: | ||
6730 | * Watching for updates:: | ||
6731 | @end menu | ||
6732 | |||
6733 | @node Statistics retrieval2 | ||
6734 | @subsubsection Statistics retrieval2 | ||
6735 | |||
6736 | @c %**end of header | ||
6737 | |||
6738 | To retrieve statistics, the client transmits a message of type | ||
6739 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_GET} containing the given subsystem | ||
6740 | name and statistic parameter to the STATISTICS service. | ||
6741 | The service responds with a message of type | ||
6742 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_VALUE} for each of the statistics | ||
6743 | parameters that match the client request for the client. The end of | ||
6744 | information retrieved is signaled by the service by sending a message of | ||
6745 | type @code{GNUNET_MESSAGE_TYPE_STATISTICS_END}. | ||
6746 | |||
6747 | @node Setting and updating statistics | ||
6748 | @subsubsection Setting and updating statistics | ||
6749 | |||
6750 | @c %**end of header | ||
6751 | |||
6752 | The subsystem name, parameter name, its value and the persistence flag are | ||
6753 | communicated to the service through the message | ||
6754 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}. | ||
6755 | |||
6756 | When the service receives a message of type | ||
6757 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}, it retrieves the subsystem | ||
6758 | name and checks for a statistic parameter with matching the name given in | ||
6759 | the message. | ||
6760 | If a statistic parameter is found, the value is overwritten by the new | ||
6761 | value from the message; if not found then a new statistic parameter is | ||
6762 | created with the given name and value. | ||
6763 | |||
6764 | In addition to just setting an absolute value, it is possible to perform a | ||
6765 | relative update by sending a message of type | ||
6766 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET} with an update flag | ||
6767 | (@code{GNUNET_STATISTICS_SETFLAG_RELATIVE}) signifying that the value in | ||
6768 | the message should be treated as an update value. | ||
6769 | |||
6770 | @node Watching for updates | ||
6771 | @subsubsection Watching for updates | ||
6772 | |||
6773 | @c %**end of header | ||
6774 | |||
6775 | The function registers the watch at the service by sending a message of | ||
6776 | type @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH}. The service then sends | ||
6777 | notifications through messages of type | ||
6778 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE} whenever the statistic | ||
6779 | parameter's value is changed. | ||
6780 | |||
6781 | @cindex DHT | ||
6782 | @cindex Distributed Hash Table | ||
6783 | @node GNUnet's Distributed Hash Table (DHT) | ||
6784 | @section GNUnet's Distributed Hash Table (DHT) | ||
6785 | |||
6786 | @c %**end of header | ||
6787 | |||
6788 | GNUnet includes a generic distributed hash table that can be used by | ||
6789 | developers building P2P applications in the framework. | ||
6790 | This section documents high-level features and how developers are | ||
6791 | expected to use the DHT. | ||
6792 | We have a research paper detailing how the DHT works. | ||
6793 | Also, Nate's thesis includes a detailed description and performance | ||
6794 | analysis (in chapter 6). | ||
6795 | |||
6796 | Key features of GNUnet's DHT include: | ||
6797 | |||
6798 | @itemize @bullet | ||
6799 | @item stores key-value pairs with values up to (approximately) 63k in size | ||
6800 | @item works with many underlay network topologies (small-world, random | ||
6801 | graph), underlay does not need to be a full mesh / clique | ||
6802 | @item support for extended queries (more than just a simple 'key'), | ||
6803 | filtering duplicate replies within the network (bloomfilter) and content | ||
6804 | validation (for details, please read the subsection on the block library) | ||
6805 | @item can (optionally) return paths taken by the PUT and GET operations | ||
6806 | to the application | ||
6807 | @item provides content replication to handle churn | ||
6808 | @end itemize | ||
6809 | |||
6810 | GNUnet's DHT is randomized and unreliable. Unreliable means that there is | ||
6811 | no strict guarantee that a value stored in the DHT is always | ||
6812 | found --- values are only found with high probability. | ||
6813 | While this is somewhat true in all P2P DHTs, GNUnet developers should be | ||
6814 | particularly wary of this fact (this will help you write secure, | ||
6815 | fault-tolerant code). Thus, when writing any application using the DHT, | ||
6816 | you should always consider the possibility that a value stored in the | ||
6817 | DHT by you or some other peer might simply not be returned, or returned | ||
6818 | with a significant delay. | ||
6819 | Your application logic must be written to tolerate this (naturally, some | ||
6820 | loss of performance or quality of service is expected in this case). | ||
6821 | |||
6822 | @menu | ||
6823 | * Block library and plugins:: | ||
6824 | * libgnunetdht:: | ||
6825 | * The DHT Client-Service Protocol:: | ||
6826 | * The DHT Peer-to-Peer Protocol:: | ||
6827 | @end menu | ||
6828 | |||
6829 | @node Block library and plugins | ||
6830 | @subsection Block library and plugins | ||
6831 | |||
6832 | @c %**end of header | ||
6833 | |||
6834 | @menu | ||
6835 | * What is a Block?:: | ||
6836 | * The API of libgnunetblock:: | ||
6837 | * Queries:: | ||
6838 | * Sample Code:: | ||
6839 | * Conclusion2:: | ||
6840 | @end menu | ||
6841 | |||
6842 | @node What is a Block? | ||
6843 | @subsubsection What is a Block? | ||
6844 | |||
6845 | @c %**end of header | ||
6846 | |||
6847 | Blocks are small (< 63k) pieces of data stored under a key (struct | ||
6848 | GNUNET_HashCode). Blocks have a type (enum GNUNET_BlockType) which defines | ||
6849 | their data format. Blocks are used in GNUnet as units of static data | ||
6850 | exchanged between peers and stored (or cached) locally. | ||
6851 | Uses of blocks include file-sharing (the files are broken up into blocks), | ||
6852 | the VPN (DNS information is stored in blocks) and the DHT (all | ||
6853 | information in the DHT and meta-information for the maintenance of the | ||
6854 | DHT are both stored using blocks). | ||
6855 | The block subsystem provides a few common functions that must be | ||
6856 | available for any type of block. | ||
6857 | |||
6858 | @cindex libgnunetblock API | ||
6859 | @node The API of libgnunetblock | ||
6860 | @subsubsection The API of libgnunetblock | ||
6861 | |||
6862 | @c %**end of header | ||
6863 | |||
6864 | The block library requires for each (family of) block type(s) a block | ||
6865 | plugin (implementing @file{gnunet_block_plugin.h}) that provides basic | ||
6866 | functions that are needed by the DHT (and possibly other subsystems) to | ||
6867 | manage the block. | ||
6868 | These block plugins are typically implemented within their respective | ||
6869 | subsystems. | ||
6870 | The main block library is then used to locate, load and query the | ||
6871 | appropriate block plugin. | ||
6872 | Which plugin is appropriate is determined by the block type (which is | ||
6873 | just a 32-bit integer). Block plugins contain code that specifies which | ||
6874 | block types are supported by a given plugin. The block library loads all | ||
6875 | block plugins that are installed at the local peer and forwards the | ||
6876 | application request to the respective plugin. | ||
6877 | |||
6878 | The central functions of the block APIs (plugin and main library) are to | ||
6879 | allow the mapping of blocks to their respective key (if possible) and the | ||
6880 | ability to check that a block is well-formed and matches a given | ||
6881 | request (again, if possible). | ||
6882 | This way, GNUnet can avoid storing invalid blocks, storing blocks under | ||
6883 | the wrong key and forwarding blocks in response to a query that they do | ||
6884 | not answer. | ||
6885 | |||
6886 | One key function of block plugins is that it allows GNUnet to detect | ||
6887 | duplicate replies (via the Bloom filter). All plugins MUST support | ||
6888 | detecting duplicate replies (by adding the current response to the | ||
6889 | Bloom filter and rejecting it if it is encountered again). | ||
6890 | If a plugin fails to do this, responses may loop in the network. | ||
6891 | |||
6892 | @node Queries | ||
6893 | @subsubsection Queries | ||
6894 | @c %**end of header | ||
6895 | |||
6896 | The query format for any block in GNUnet consists of four main components. | ||
6897 | First, the type of the desired block must be specified. Second, the query | ||
6898 | must contain a hash code. The hash code is used for lookups in hash | ||
6899 | tables and databases and must not be unique for the block (however, if | ||
6900 | possible a unique hash should be used as this would be best for | ||
6901 | performance). | ||
6902 | Third, an optional Bloom filter can be specified to exclude known results; | ||
6903 | replies that hash to the bits set in the Bloom filter are considered | ||
6904 | invalid. False-positives can be eliminated by sending the same query | ||
6905 | again with a different Bloom filter mutator value, which parameterizes | ||
6906 | the hash function that is used. | ||
6907 | Finally, an optional application-specific "eXtended query" (xquery) can | ||
6908 | be specified to further constrain the results. It is entirely up to | ||
6909 | the type-specific plugin to determine whether or not a given block | ||
6910 | matches a query (type, hash, Bloom filter, and xquery). | ||
6911 | Naturally, not all xquery's are valid and some types of blocks may not | ||
6912 | support Bloom filters either, so the plugin also needs to check if the | ||
6913 | query is valid in the first place. | ||
6914 | |||
6915 | Depending on the results from the plugin, the DHT will then discard the | ||
6916 | (invalid) query, forward the query, discard the (invalid) reply, cache the | ||
6917 | (valid) reply, and/or forward the (valid and non-duplicate) reply. | ||
6918 | |||
6919 | @node Sample Code | ||
6920 | @subsubsection Sample Code | ||
6921 | |||
6922 | @c %**end of header | ||
6923 | |||
6924 | The source code in @strong{plugin_block_test.c} is a good starting point | ||
6925 | for new block plugins --- it does the minimal work by implementing a | ||
6926 | plugin that performs no validation at all. | ||
6927 | The respective @strong{Makefile.am} shows how to build and install a | ||
6928 | block plugin. | ||
6929 | |||
6930 | @node Conclusion2 | ||
6931 | @subsubsection Conclusion2 | ||
6932 | |||
6933 | @c %**end of header | ||
6934 | |||
6935 | In conclusion, GNUnet subsystems that want to use the DHT need to define a | ||
6936 | block format and write a plugin to match queries and replies. For testing, | ||
6937 | the "@code{GNUNET_BLOCK_TYPE_TEST}" block type can be used; it accepts | ||
6938 | any query as valid and any reply as matching any query. | ||
6939 | This type is also used for the DHT command line tools. | ||
6940 | However, it should NOT be used for normal applications due to the lack | ||
6941 | of error checking that results from this primitive implementation. | ||
6942 | |||
6943 | @cindex libgnunetdht | ||
6944 | @node libgnunetdht | ||
6945 | @subsection libgnunetdht | ||
6946 | |||
6947 | @c %**end of header | ||
6948 | |||
6949 | The DHT API itself is pretty simple and offers the usual GET and PUT | ||
6950 | functions that work as expected. The specified block type refers to the | ||
6951 | block library which allows the DHT to run application-specific logic for | ||
6952 | data stored in the network. | ||
6953 | |||
6954 | |||
6955 | @menu | ||
6956 | * GET:: | ||
6957 | * PUT:: | ||
6958 | * MONITOR:: | ||
6959 | * DHT Routing Options:: | ||
6960 | @end menu | ||
6961 | |||
6962 | @node GET | ||
6963 | @subsubsection GET | ||
6964 | |||
6965 | @c %**end of header | ||
6966 | |||
6967 | When using GET, the main consideration for developers (other than the | ||
6968 | block library) should be that after issuing a GET, the DHT will | ||
6969 | continuously cause (small amounts of) network traffic until the operation | ||
6970 | is explicitly canceled. | ||
6971 | So GET does not simply send out a single network request once; instead, | ||
6972 | the DHT will continue to search for data. This is needed to achieve good | ||
6973 | success rates and also handles the case where the respective PUT | ||
6974 | operation happens after the GET operation was started. | ||
6975 | Developers should not cancel an existing GET operation and then | ||
6976 | explicitly re-start it to trigger a new round of network requests; | ||
6977 | this is simply inefficient, especially as the internal automated version | ||
6978 | can be more efficient, for example by filtering results in the network | ||
6979 | that have already been returned. | ||
6980 | |||
6981 | If an application that performs a GET request has a set of replies that it | ||
6982 | already knows and would like to filter, it can call@ | ||
6983 | @code{GNUNET_DHT_get_filter_known_results} with an array of hashes over | ||
6984 | the respective blocks to tell the DHT that these results are not | ||
6985 | desired (any more). | ||
6986 | This way, the DHT will filter the respective blocks using the block | ||
6987 | library in the network, which may result in a significant reduction in | ||
6988 | bandwidth consumption. | ||
6989 | |||
6990 | @node PUT | ||
6991 | @subsubsection PUT | ||
6992 | |||
6993 | @c %**end of header | ||
6994 | |||
6995 | In contrast to GET operations, developers @strong{must} manually re-run | ||
6996 | PUT operations periodically (if they intend the content to continue to be | ||
6997 | available). Content stored in the DHT expires or might be lost due to | ||
6998 | churn. | ||
6999 | Furthermore, GNUnet's DHT typically requires multiple rounds of PUT | ||
7000 | operations before a key-value pair is consistently available to all | ||
7001 | peers (the DHT randomizes paths and thus storage locations, and only | ||
7002 | after multiple rounds of PUTs there will be a sufficient number of | ||
7003 | replicas in large DHTs). An explicit PUT operation using the DHT API will | ||
7004 | only cause network traffic once, so in order to ensure basic availability | ||
7005 | and resistance to churn (and adversaries), PUTs must be repeated. | ||
7006 | While the exact frequency depends on the application, a rule of thumb is | ||
7007 | that there should be at least a dozen PUT operations within the content | ||
7008 | lifetime. Content in the DHT typically expires after one day, so | ||
7009 | DHT PUT operations should be repeated at least every 1-2 hours. | ||
7010 | |||
7011 | @node MONITOR | ||
7012 | @subsubsection MONITOR | ||
7013 | |||
7014 | @c %**end of header | ||
7015 | |||
7016 | The DHT API also allows applications to monitor messages crossing the | ||
7017 | local DHT service. | ||
7018 | The types of messages used by the DHT are GET, PUT and RESULT messages. | ||
7019 | Using the monitoring API, applications can choose to monitor these | ||
7020 | requests, possibly limiting themselves to requests for a particular block | ||
7021 | type. | ||
7022 | |||
7023 | The monitoring API is not only usefu only for diagnostics, it can also be | ||
7024 | used to trigger application operations based on PUT operations. | ||
7025 | For example, an application may use PUTs to distribute work requests to | ||
7026 | other peers. | ||
7027 | The workers would then monitor for PUTs that give them work, instead of | ||
7028 | looking for work using GET operations. | ||
7029 | This can be beneficial, especially if the workers have no good way to | ||
7030 | guess the keys under which work would be stored. | ||
7031 | Naturally, additional protocols might be needed to ensure that the desired | ||
7032 | number of workers will process the distributed workload. | ||
7033 | |||
7034 | @node DHT Routing Options | ||
7035 | @subsubsection DHT Routing Options | ||
7036 | |||
7037 | @c %**end of header | ||
7038 | |||
7039 | There are two important options for GET and PUT requests: | ||
7040 | |||
7041 | @table @asis | ||
7042 | @item GNUNET_DHT_RO_DEMULITPLEX_EVERYWHERE This option means that all | ||
7043 | peers should process the request, even if their peer ID is not closest to | ||
7044 | the key. For a PUT request, this means that all peers that a request | ||
7045 | traverses may make a copy of the data. | ||
7046 | Similarly for a GET request, all peers will check their local database | ||
7047 | for a result. Setting this option can thus significantly improve caching | ||
7048 | and reduce bandwidth consumption --- at the expense of a larger DHT | ||
7049 | database. If in doubt, we recommend that this option should be used. | ||
7050 | @item GNUNET_DHT_RO_RECORD_ROUTE This option instructs the DHT to record | ||
7051 | the path that a GET or a PUT request is taking through the overlay | ||
7052 | network. The resulting paths are then returned to the application with | ||
7053 | the respective result. This allows the receiver of a result to construct | ||
7054 | a path to the originator of the data, which might then be used for | ||
7055 | routing. Naturally, setting this option requires additional bandwidth | ||
7056 | and disk space, so applications should only set this if the paths are | ||
7057 | needed by the application logic. | ||
7058 | @item GNUNET_DHT_RO_FIND_PEER This option is an internal option used by | ||
7059 | the DHT's peer discovery mechanism and should not be used by applications. | ||
7060 | @item GNUNET_DHT_RO_BART This option is currently not implemented. It may | ||
7061 | in the future offer performance improvements for clique topologies. | ||
7062 | @end table | ||
7063 | |||
7064 | @node The DHT Client-Service Protocol | ||
7065 | @subsection The DHT Client-Service Protocol | ||
7066 | |||
7067 | @c %**end of header | ||
7068 | |||
7069 | @menu | ||
7070 | * PUTting data into the DHT:: | ||
7071 | * GETting data from the DHT:: | ||
7072 | * Monitoring the DHT:: | ||
7073 | @end menu | ||
7074 | |||
7075 | @node PUTting data into the DHT | ||
7076 | @subsubsection PUTting data into the DHT | ||
7077 | |||
7078 | @c %**end of header | ||
7079 | |||
7080 | To store (PUT) data into the DHT, the client sends a | ||
7081 | @code{struct GNUNET_DHT_ClientPutMessage} to the service. | ||
7082 | This message specifies the block type, routing options, the desired | ||
7083 | replication level, the expiration time, key, | ||
7084 | value and a 64-bit unique ID for the operation. The service responds with | ||
7085 | a @code{struct GNUNET_DHT_ClientPutConfirmationMessage} with the same | ||
7086 | 64-bit unique ID. Note that the service sends the confirmation as soon as | ||
7087 | it has locally processed the PUT request. The PUT may still be | ||
7088 | propagating through the network at this time. | ||
7089 | |||
7090 | In the future, we may want to change this to provide (limited) feedback | ||
7091 | to the client, for example if we detect that the PUT operation had no | ||
7092 | effect because the same key-value pair was already stored in the DHT. | ||
7093 | However, changing this would also require additional state and messages | ||
7094 | in the P2P interaction. | ||
7095 | |||
7096 | @node GETting data from the DHT | ||
7097 | @subsubsection GETting data from the DHT | ||
7098 | |||
7099 | @c %**end of header | ||
7100 | |||
7101 | To retrieve (GET) data from the DHT, the client sends a | ||
7102 | @code{struct GNUNET_DHT_ClientGetMessage} to the service. The message | ||
7103 | specifies routing options, a replication level (for replicating the GET, | ||
7104 | not the content), the desired block type, the key, the (optional) | ||
7105 | extended query and unique 64-bit request ID. | ||
7106 | |||
7107 | Additionally, the client may send any number of | ||
7108 | @code{struct GNUNET_DHT_ClientGetResultSeenMessage}s to notify the | ||
7109 | service about results that the client is already aware of. | ||
7110 | These messages consist of the key, the unique 64-bit ID of the request, | ||
7111 | and an arbitrary number of hash codes over the blocks that the client is | ||
7112 | already aware of. As messages are restricted to 64k, a client that | ||
7113 | already knows more than about a thousand blocks may need to send | ||
7114 | several of these messages. Naturally, the client should transmit these | ||
7115 | messages as quickly as possible after the original GET request such that | ||
7116 | the DHT can filter those results in the network early on. Naturally, as | ||
7117 | these messages are send after the original request, it is conceivalbe | ||
7118 | that the DHT service may return blocks that match those already known | ||
7119 | to the client anyway. | ||
7120 | |||
7121 | In response to a GET request, the service will send @code{struct | ||
7122 | GNUNET_DHT_ClientResultMessage}s to the client. These messages contain the | ||
7123 | block type, expiration, key, unique ID of the request and of course the | ||
7124 | value (a block). Depending on the options set for the respective | ||
7125 | operations, the replies may also contain the path the GET and/or the PUT | ||
7126 | took through the network. | ||
7127 | |||
7128 | A client can stop receiving replies either by disconnecting or by sending | ||
7129 | a @code{struct GNUNET_DHT_ClientGetStopMessage} which must contain the | ||
7130 | key and the 64-bit unique ID of the original request. Using an | ||
7131 | explicit "stop" message is more common as this allows a client to run | ||
7132 | many concurrent GET operations over the same connection with the DHT | ||
7133 | service --- and to stop them individually. | ||
7134 | |||
7135 | @node Monitoring the DHT | ||
7136 | @subsubsection Monitoring the DHT | ||
7137 | |||
7138 | @c %**end of header | ||
7139 | |||
7140 | To begin monitoring, the client sends a | ||
7141 | @code{struct GNUNET_DHT_MonitorStartStop} message to the DHT service. | ||
7142 | In this message, flags can be set to enable (or disable) monitoring of | ||
7143 | GET, PUT and RESULT messages that pass through a peer. The message can | ||
7144 | also restrict monitoring to a particular block type or a particular key. | ||
7145 | Once monitoring is enabled, the DHT service will notify the client about | ||
7146 | any matching event using @code{struct GNUNET_DHT_MonitorGetMessage}s for | ||
7147 | GET events, @code{struct GNUNET_DHT_MonitorPutMessage} for PUT events | ||
7148 | and @code{struct GNUNET_DHT_MonitorGetRespMessage} for RESULTs. Each of | ||
7149 | these messages contains all of the information about the event. | ||
7150 | |||
7151 | @node The DHT Peer-to-Peer Protocol | ||
7152 | @subsection The DHT Peer-to-Peer Protocol | ||
7153 | @c %**end of header | ||
7154 | |||
7155 | |||
7156 | @menu | ||
7157 | * Routing GETs or PUTs:: | ||
7158 | * PUTting data into the DHT2:: | ||
7159 | * GETting data from the DHT2:: | ||
7160 | @end menu | ||
7161 | |||
7162 | @node Routing GETs or PUTs | ||
7163 | @subsubsection Routing GETs or PUTs | ||
7164 | |||
7165 | @c %**end of header | ||
7166 | |||
7167 | When routing GETs or PUTs, the DHT service selects a suitable subset of | ||
7168 | neighbours for forwarding. The exact number of neighbours can be zero or | ||
7169 | more and depends on the hop counter of the query (initially zero) in | ||
7170 | relation to the (log of) the network size estimate, the desired | ||
7171 | replication level and the peer's connectivity. | ||
7172 | Depending on the hop counter and our network size estimate, the selection | ||
7173 | of the peers maybe randomized or by proximity to the key. | ||
7174 | Furthermore, requests include a set of peers that a request has already | ||
7175 | traversed; those peers are also excluded from the selection. | ||
7176 | |||
7177 | @node PUTting data into the DHT2 | ||
7178 | @subsubsection PUTting data into the DHT2 | ||
7179 | |||
7180 | @c %**end of header | ||
7181 | |||
7182 | To PUT data into the DHT, the service sends a @code{struct PeerPutMessage} | ||
7183 | of type @code{GNUNET_MESSAGE_TYPE_DHT_P2P_PUT} to the respective | ||
7184 | neighbour. | ||
7185 | In addition to the usual information about the content (type, routing | ||
7186 | options, desired replication level for the content, expiration time, key | ||
7187 | and value), the message contains a fixed-size Bloom filter with | ||
7188 | information about which peers (may) have already seen this request. | ||
7189 | This Bloom filter is used to ensure that DHT messages never loop back to | ||
7190 | a peer that has already processed the request. | ||
7191 | Additionally, the message includes the current hop counter and, depending | ||
7192 | on the routing options, the message may include the full path that the | ||
7193 | message has taken so far. | ||
7194 | The Bloom filter should already contain the identity of the previous hop; | ||
7195 | however, the path should not include the identity of the previous hop and | ||
7196 | the receiver should append the identity of the sender to the path, not | ||
7197 | its own identity (this is done to reduce bandwidth). | ||
7198 | |||
7199 | @node GETting data from the DHT2 | ||
7200 | @subsubsection GETting data from the DHT2 | ||
7201 | |||
7202 | @c %**end of header | ||
7203 | |||
7204 | A peer can search the DHT by sending @code{struct PeerGetMessage}s of type | ||
7205 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_GET} to other peers. In addition to the | ||
7206 | usual information about the request (type, routing options, desired | ||
7207 | replication level for the request, the key and the extended query), a GET | ||
7208 | request also again contains a hop counter, a Bloom filter over the peers | ||
7209 | that have processed the request already and depending on the routing | ||
7210 | options the full path traversed by the GET. | ||
7211 | Finally, a GET request includes a variable-size second Bloom filter and a | ||
7212 | so-called Bloom filter mutator value which together indicate which | ||
7213 | replies the sender has already seen. During the lookup, each block that | ||
7214 | matches they block type, key and extended query is additionally subjected | ||
7215 | to a test against this Bloom filter. | ||
7216 | The block plugin is expected to take the hash of the block and combine it | ||
7217 | with the mutator value and check if the result is not yet in the Bloom | ||
7218 | filter. The originator of the query will from time to time modify the | ||
7219 | mutator to (eventually) allow false-positives filtered by the Bloom filter | ||
7220 | to be returned. | ||
7221 | |||
7222 | Peers that receive a GET request perform a local lookup (depending on | ||
7223 | their proximity to the key and the query options) and forward the request | ||
7224 | to other peers. | ||
7225 | They then remember the request (including the Bloom filter for blocking | ||
7226 | duplicate results) and when they obtain a matching, non-filtered response | ||
7227 | a @code{struct PeerResultMessage} of type | ||
7228 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT} is forwarded to the previous | ||
7229 | hop. | ||
7230 | Whenver a result is forwarded, the block plugin is used to update the | ||
7231 | Bloom filter accordingly, to ensure that the same result is never | ||
7232 | forwarded more than once. | ||
7233 | The DHT service may also cache forwarded results locally if the | ||
7234 | "CACHE_RESULTS" option is set to "YES" in the configuration. | ||
7235 | |||
7236 | @node The GNU Name System (GNS) | ||
7237 | @section The GNU Name System (GNS) | ||
7238 | |||
7239 | @c %**end of header | ||
7240 | |||
7241 | The GNU Name System (GNS) is a decentralized database that enables users | ||
7242 | to securely resolve names to values. | ||
7243 | Names can be used to identify other users (for example, in social | ||
7244 | networking), or network services (for example, VPN services running at a | ||
7245 | peer in GNUnet, or purely IP-based services on the Internet). | ||
7246 | Users interact with GNS by typing in a hostname that ends in ".gnu" | ||
7247 | or ".zkey". | ||
7248 | |||
7249 | Videos giving an overview of most of the GNS and the motivations behind | ||
7250 | it is available here and here. | ||
7251 | The remainder of this chapter targets developers that are familiar with | ||
7252 | high level concepts of GNS as presented in these talks. | ||
7253 | @c TODO: Add links to here and here and to these. | ||
7254 | |||
7255 | GNS-aware applications should use the GNS resolver to obtain the | ||
7256 | respective records that are stored under that name in GNS. | ||
7257 | Each record consists of a type, value, expiration time and flags. | ||
7258 | |||
7259 | The type specifies the format of the value. Types below 65536 correspond | ||
7260 | to DNS record types, larger values are used for GNS-specific records. | ||
7261 | Applications can define new GNS record types by reserving a number and | ||
7262 | implementing a plugin (which mostly needs to convert the binary value | ||
7263 | representation to a human-readable text format and vice-versa). | ||
7264 | The expiration time specifies how long the record is to be valid. | ||
7265 | The GNS API ensures that applications are only given non-expired values. | ||
7266 | The flags are typically irrelevant for applications, as GNS uses them | ||
7267 | internally to control visibility and validity of records. | ||
7268 | |||
7269 | Records are stored along with a signature. | ||
7270 | The signature is generated using the private key of the authoritative | ||
7271 | zone. This allows any GNS resolver to verify the correctness of a | ||
7272 | name-value mapping. | ||
7273 | |||
7274 | Internally, GNS uses the NAMECACHE to cache information obtained from | ||
7275 | other users, the NAMESTORE to store information specific to the local | ||
7276 | users, and the DHT to exchange data between users. | ||
7277 | A plugin API is used to enable applications to define new GNS | ||
7278 | record types. | ||
7279 | |||
7280 | @menu | ||
7281 | * libgnunetgns:: | ||
7282 | * libgnunetgnsrecord:: | ||
7283 | * GNS plugins:: | ||
7284 | * The GNS Client-Service Protocol:: | ||
7285 | * Hijacking the DNS-Traffic using gnunet-service-dns:: | ||
7286 | * Serving DNS lookups via GNS on W32:: | ||
7287 | @end menu | ||
7288 | |||
7289 | @node libgnunetgns | ||
7290 | @subsection libgnunetgns | ||
7291 | |||
7292 | @c %**end of header | ||
7293 | |||
7294 | The GNS API itself is extremely simple. Clients first connec to the | ||
7295 | GNS service using @code{GNUNET_GNS_connect}. | ||
7296 | They can then perform lookups using @code{GNUNET_GNS_lookup} or cancel | ||
7297 | pending lookups using @code{GNUNET_GNS_lookup_cancel}. | ||
7298 | Once finished, clients disconnect using @code{GNUNET_GNS_disconnect}. | ||
7299 | |||
7300 | @menu | ||
7301 | * Looking up records:: | ||
7302 | * Accessing the records:: | ||
7303 | * Creating records:: | ||
7304 | * Future work:: | ||
7305 | @end menu | ||
7306 | |||
7307 | @node Looking up records | ||
7308 | @subsubsection Looking up records | ||
7309 | |||
7310 | @c %**end of header | ||
7311 | |||
7312 | @code{GNUNET_GNS_lookup} takes a number of arguments: | ||
7313 | |||
7314 | @table @asis | ||
7315 | @item handle This is simply the GNS connection handle from | ||
7316 | @code{GNUNET_GNS_connect}. | ||
7317 | @item name The client needs to specify the name to | ||
7318 | be resolved. This can be any valid DNS or GNS hostname. | ||
7319 | @item zone The client | ||
7320 | needs to specify the public key of the GNS zone against which the | ||
7321 | resolution should be done (the ".gnu" zone). | ||
7322 | Note that a key must be provided, even if the name ends in ".zkey". | ||
7323 | This should typically be the public key of the master-zone of the user. | ||
7324 | @item type This is the desired GNS or DNS record type | ||
7325 | to look for. While all records for the given name will be returned, this | ||
7326 | can be important if the client wants to resolve record types that | ||
7327 | themselves delegate resolution, such as CNAME, PKEY or GNS2DNS. | ||
7328 | Resolving a record of any of these types will only work if the respective | ||
7329 | record type is specified in the request, as the GNS resolver will | ||
7330 | otherwise follow the delegation and return the records from the | ||
7331 | respective destination, instead of the delegating record. | ||
7332 | @item only_cached This argument should typically be set to | ||
7333 | @code{GNUNET_NO}. Setting it to @code{GNUNET_YES} disables resolution via | ||
7334 | the overlay network. | ||
7335 | @item shorten_zone_key If GNS encounters new names during resolution, | ||
7336 | their respective zones can automatically be learned and added to the | ||
7337 | "shorten zone". If this is desired, clients must pass the private key of | ||
7338 | the shorten zone. If NULL is passed, shortening is disabled. | ||
7339 | @item proc This argument identifies | ||
7340 | the function to call with the result. It is given proc_cls, the number of | ||
7341 | records found (possilby zero) and the array of the records as arguments. | ||
7342 | proc will only be called once. After proc,> has been called, the lookup | ||
7343 | must no longer be cancelled. | ||
7344 | @item proc_cls The closure for proc. | ||
7345 | @end table | ||
7346 | |||
7347 | @node Accessing the records | ||
7348 | @subsubsection Accessing the records | ||
7349 | |||
7350 | @c %**end of header | ||
7351 | |||
7352 | The @code{libgnunetgnsrecord} library provides an API to manipulate the | ||
7353 | GNS record array that is given to proc. In particular, it offers | ||
7354 | functions such as converting record values to human-readable | ||
7355 | strings (and back). However, most @code{libgnunetgnsrecord} functions are | ||
7356 | not interesting to GNS client applications. | ||
7357 | |||
7358 | For DNS records, the @code{libgnunetdnsparser} library provides | ||
7359 | functions for parsing (and serializing) common types of DNS records. | ||
7360 | |||
7361 | @node Creating records | ||
7362 | @subsubsection Creating records | ||
7363 | |||
7364 | @c %**end of header | ||
7365 | |||
7366 | Creating GNS records is typically done by building the respective record | ||
7367 | information (possibly with the help of @code{libgnunetgnsrecord} and | ||
7368 | @code{libgnunetdnsparser}) and then using the @code{libgnunetnamestore} to | ||
7369 | publish the information. The GNS API is not involved in this | ||
7370 | operation. | ||
7371 | |||
7372 | @node Future work | ||
7373 | @subsubsection Future work | ||
7374 | |||
7375 | @c %**end of header | ||
7376 | |||
7377 | In the future, we want to expand @code{libgnunetgns} to allow | ||
7378 | applications to observe shortening operations performed during GNS | ||
7379 | resolution, for example so that users can receive visual feedback when | ||
7380 | this happens. | ||
7381 | |||
7382 | @node libgnunetgnsrecord | ||
7383 | @subsection libgnunetgnsrecord | ||
7384 | |||
7385 | @c %**end of header | ||
7386 | |||
7387 | The @code{libgnunetgnsrecord} library is used to manipulate GNS | ||
7388 | records (in plaintext or in their encrypted format). | ||
7389 | Applications mostly interact with @code{libgnunetgnsrecord} by using the | ||
7390 | functions to convert GNS record values to strings or vice-versa, or to | ||
7391 | lookup a GNS record type number by name (or vice-versa). | ||
7392 | The library also provides various other functions that are mostly | ||
7393 | used internally within GNS, such as converting keys to names, checking for | ||
7394 | expiration, encrypting GNS records to GNS blocks, verifying GNS block | ||
7395 | signatures and decrypting GNS records from GNS blocks. | ||
7396 | |||
7397 | We will now discuss the four commonly used functions of the API.@ | ||
7398 | @code{libgnunetgnsrecord} does not perform these operations itself, | ||
7399 | but instead uses plugins to perform the operation. | ||
7400 | GNUnet includes plugins to support common DNS record types as well as | ||
7401 | standard GNS record types. | ||
7402 | |||
7403 | @menu | ||
7404 | * Value handling:: | ||
7405 | * Type handling:: | ||
7406 | @end menu | ||
7407 | |||
7408 | @node Value handling | ||
7409 | @subsubsection Value handling | ||
7410 | |||
7411 | @c %**end of header | ||
7412 | |||
7413 | @code{GNUNET_GNSRECORD_value_to_string} can be used to convert | ||
7414 | the (binary) representation of a GNS record value to a human readable, | ||
7415 | 0-terminated UTF-8 string. | ||
7416 | NULL is returned if the specified record type is not supported by any | ||
7417 | available plugin. | ||
7418 | |||
7419 | @code{GNUNET_GNSRECORD_string_to_value} can be used to try to convert a | ||
7420 | human readable string to the respective (binary) representation of | ||
7421 | a GNS record value. | ||
7422 | |||
7423 | @node Type handling | ||
7424 | @subsubsection Type handling | ||
7425 | |||
7426 | @c %**end of header | ||
7427 | |||
7428 | @code{GNUNET_GNSRECORD_typename_to_number} can be used to obtain the | ||
7429 | numeric value associated with a given typename. For example, given the | ||
7430 | typename "A" (for DNS A reocrds), the function will return the number 1. | ||
7431 | A list of common DNS record types is | ||
7432 | @uref{http://en.wikipedia.org/wiki/List_of_DNS_record_types, here}. | ||
7433 | Note that not all DNS record types are supported by GNUnet GNSRECORD | ||
7434 | plugins at this time. | ||
7435 | |||
7436 | @code{GNUNET_GNSRECORD_number_to_typename} can be used to obtain the | ||
7437 | typename associated with a given numeric value. | ||
7438 | For example, given the type number 1, the function will return the | ||
7439 | typename "A". | ||
7440 | |||
7441 | @node GNS plugins | ||
7442 | @subsection GNS plugins | ||
7443 | |||
7444 | @c %**end of header | ||
7445 | |||
7446 | Adding a new GNS record type typically involves writing (or extending) a | ||
7447 | GNSRECORD plugin. The plugin needs to implement the | ||
7448 | @code{gnunet_gnsrecord_plugin.h} API which provides basic functions that | ||
7449 | are needed by GNSRECORD to convert typenames and values of the respective | ||
7450 | record type to strings (and back). | ||
7451 | These gnsrecord plugins are typically implemented within their respective | ||
7452 | subsystems. | ||
7453 | Examples for such plugins can be found in the GNSRECORD, GNS and | ||
7454 | CONVERSATION subsystems. | ||
7455 | |||
7456 | The @code{libgnunetgnsrecord} library is then used to locate, load and | ||
7457 | query the appropriate gnsrecord plugin. | ||
7458 | Which plugin is appropriate is determined by the record type (which is | ||
7459 | just a 32-bit integer). The @code{libgnunetgnsrecord} library loads all | ||
7460 | block plugins that are installed at the local peer and forwards the | ||
7461 | application request to the plugins. If the record type is not | ||
7462 | supported by the plugin, it should simply return an error code. | ||
7463 | |||
7464 | The central functions of the block APIs (plugin and main library) are the | ||
7465 | same four functions for converting between values and strings, and | ||
7466 | typenames and numbers documented in the previous subsection. | ||
7467 | |||
7468 | @node The GNS Client-Service Protocol | ||
7469 | @subsection The GNS Client-Service Protocol | ||
7470 | @c %**end of header | ||
7471 | |||
7472 | The GNS client-service protocol consists of two simple messages, the | ||
7473 | @code{LOOKUP} message and the @code{LOOKUP_RESULT}. Each @code{LOOKUP} | ||
7474 | message contains a unique 32-bit identifier, which will be included in the | ||
7475 | corresponding response. Thus, clients can send many lookup requests in | ||
7476 | parallel and receive responses out-of-order. | ||
7477 | A @code{LOOKUP} request also includes the public key of the GNS zone, | ||
7478 | the desired record type and fields specifying whether shortening is | ||
7479 | enabled or networking is disabled. Finally, the @code{LOOKUP} message | ||
7480 | includes the name to be resolved. | ||
7481 | |||
7482 | The response includes the number of records and the records themselves | ||
7483 | in the format created by @code{GNUNET_GNSRECORD_records_serialize}. | ||
7484 | They can thus be deserialized using | ||
7485 | @code{GNUNET_GNSRECORD_records_deserialize}. | ||
7486 | |||
7487 | @node Hijacking the DNS-Traffic using gnunet-service-dns | ||
7488 | @subsection Hijacking the DNS-Traffic using gnunet-service-dns | ||
7489 | |||
7490 | @c %**end of header | ||
7491 | |||
7492 | This section documents how the gnunet-service-dns (and the | ||
7493 | gnunet-helper-dns) intercepts DNS queries from the local system. | ||
7494 | This is merely one method for how we can obtain GNS queries. | ||
7495 | It is also possible to change @code{resolv.conf} to point to a machine | ||
7496 | running @code{gnunet-dns2gns} or to modify libc's name system switch | ||
7497 | (NSS) configuration to include a GNS resolution plugin. | ||
7498 | The method described in this chaper is more of a last-ditch catch-all | ||
7499 | approach. | ||
7500 | |||
7501 | @code{gnunet-service-dns} enables intercepting DNS traffic using policy | ||
7502 | based routing. | ||
7503 | We MARK every outgoing DNS-packet if it was not sent by our application. | ||
7504 | Using a second routing table in the Linux kernel these marked packets are | ||
7505 | then routed through our virtual network interface and can thus be | ||
7506 | captured unchanged. | ||
7507 | |||
7508 | Our application then reads the query and decides how to handle it: A | ||
7509 | query to an address ending in ".gnu" or ".zkey" is hijacked by | ||
7510 | @code{gnunet-service-gns} and resolved internally using GNS. | ||
7511 | In the future, a reverse query for an address of the configured virtual | ||
7512 | network could be answered with records kept about previous forward | ||
7513 | queries. | ||
7514 | Queries that are not hijacked by some application using the DNS service | ||
7515 | will be sent to the original recipient. | ||
7516 | The answer to the query will always be sent back through the virtual | ||
7517 | interface with the original nameserver as source address. | ||
7518 | |||
7519 | |||
7520 | @menu | ||
7521 | * Network Setup Details:: | ||
7522 | @end menu | ||
7523 | |||
7524 | @node Network Setup Details | ||
7525 | @subsubsection Network Setup Details | ||
7526 | |||
7527 | @c %**end of header | ||
7528 | |||
7529 | The DNS interceptor adds the following rules to the Linux kernel: | ||
7530 | @example | ||
7531 | iptables -t mangle -I OUTPUT 1 -p udp --sport $LOCALPORT --dport 53 \ | ||
7532 | -j ACCEPT iptables -t mangle -I OUTPUT 2 -p udp --dport 53 -j MARK \ | ||
7533 | --set-mark 3 ip rule add fwmark 3 table2 ip route add default via \ | ||
7534 | $VIRTUALDNS table2 | ||
7535 | @end example | ||
7536 | |||
7537 | @c FIXME: Rewrite to reflect display which is no longer content by line | ||
7538 | @c FIXME: due to the < 74 characters limit. | ||
7539 | Line 1 makes sure that all packets coming from a port our application | ||
7540 | opened beforehand (@code{$LOCALPORT}) will be routed normally. | ||
7541 | Line 2 marks every other packet to a DNS-Server with mark 3 (chosen | ||
7542 | arbitrarily). The third line adds a routing policy based on this mark | ||
7543 | 3 via the routing table. | ||
7544 | |||
7545 | @node Serving DNS lookups via GNS on W32 | ||
7546 | @subsection Serving DNS lookups via GNS on W32 | ||
7547 | |||
7548 | @c %**end of header | ||
7549 | |||
7550 | This section documents how the libw32nsp (and | ||
7551 | gnunet-gns-helper-service-w32) do DNS resolutions of DNS queries on the | ||
7552 | local system. This only applies to GNUnet running on W32. | ||
7553 | |||
7554 | W32 has a concept of "Namespaces" and "Namespace providers". | ||
7555 | These are used to present various name systems to applications in a | ||
7556 | generic way. | ||
7557 | Namespaces include DNS, mDNS, NLA and others. For each namespace any | ||
7558 | number of providers could be registered, and they are queried in an order | ||
7559 | of priority (which is adjustable). | ||
7560 | |||
7561 | Applications can resolve names by using WSALookupService*() family of | ||
7562 | functions. | ||
7563 | |||
7564 | However, these are WSA-only facilities. Common BSD socket functions for | ||
7565 | namespace resolutions are gethostbyname and getaddrinfo (among others). | ||
7566 | These functions are implemented internally (by default - by mswsock, | ||
7567 | which also implements the default DNS provider) as wrappers around | ||
7568 | WSALookupService*() functions (see "Sample Code for a Service Provider" | ||
7569 | on MSDN). | ||
7570 | |||
7571 | On W32 GNUnet builds a libw32nsp - a namespace provider, which can then be | ||
7572 | installed into the system by using w32nsp-install (and uninstalled by | ||
7573 | w32nsp-uninstall), as described in "Installation Handbook". | ||
7574 | |||
7575 | libw32nsp is very simple and has almost no dependencies. As a response to | ||
7576 | NSPLookupServiceBegin(), it only checks that the provider GUID passed to | ||
7577 | it by the caller matches GNUnet DNS Provider GUID, checks that name being | ||
7578 | resolved ends in ".gnu" or ".zkey", then connects to | ||
7579 | gnunet-gns-helper-service-w32 at 127.0.0.1:5353 (hardcoded) and sends the | ||
7580 | name resolution request there, returning the connected socket to the | ||
7581 | caller. | ||
7582 | |||
7583 | When the caller invokes NSPLookupServiceNext(), libw32nsp reads a | ||
7584 | completely formed reply from that socket, unmarshalls it, then gives | ||
7585 | it back to the caller. | ||
7586 | |||
7587 | At the moment gnunet-gns-helper-service-w32 is implemented to ever give | ||
7588 | only one reply, and subsequent calls to NSPLookupServiceNext() will fail | ||
7589 | with WSA_NODATA (first call to NSPLookupServiceNext() might also fail if | ||
7590 | GNS failed to find the name, or there was an error connecting to it). | ||
7591 | |||
7592 | gnunet-gns-helper-service-w32 does most of the processing: | ||
7593 | |||
7594 | @itemize @bullet | ||
7595 | @item Maintains a connection to GNS. | ||
7596 | @item Reads GNS config and loads appropriate keys. | ||
7597 | @item Checks service GUID and decides on the type of record to look up, | ||
7598 | refusing to make a lookup outright when unsupported service GUID is | ||
7599 | passed. | ||
7600 | @item Launches the lookup | ||
7601 | @end itemize | ||
7602 | |||
7603 | When lookup result arrives, gnunet-gns-helper-service-w32 forms a complete | ||
7604 | reply (including filling a WSAQUERYSETW structure and, possibly, a binary | ||
7605 | blob with a hostent structure for gethostbyname() client), marshalls it, | ||
7606 | and sends it back to libw32nsp. If no records were found, it sends an | ||
7607 | empty header. | ||
7608 | |||
7609 | This works for most normal applications that use gethostbyname() or | ||
7610 | getaddrinfo() to resolve names, but fails to do anything with | ||
7611 | applications that use alternative means of resolving names (such as | ||
7612 | sending queries to a DNS server directly by themselves). | ||
7613 | This includes some of well known utilities, like "ping" and "nslookup". | ||
7614 | |||
7615 | @node The GNS Namecache | ||
7616 | @section The GNS Namecache | ||
7617 | |||
7618 | @c %**end of header | ||
7619 | |||
7620 | The NAMECACHE subsystem is responsible for caching (encrypted) resolution | ||
7621 | results of the GNU Name System (GNS). GNS makes zone information available | ||
7622 | to other users via the DHT. However, as accessing the DHT for every | ||
7623 | lookup is expensive (and as the DHT's local cache is lost whenever the | ||
7624 | peer is restarted), GNS uses the NAMECACHE as a more persistent cache for | ||
7625 | DHT lookups. | ||
7626 | Thus, instead of always looking up every name in the DHT, GNS first | ||
7627 | checks if the result is already available locally in the NAMECACHE. | ||
7628 | Only if there is no result in the NAMECACHE, GNS queries the DHT. | ||
7629 | The NAMECACHE stores data in the same (encrypted) format as the DHT. | ||
7630 | It thus makes no sense to iterate over all items in the | ||
7631 | NAMECACHE --- the NAMECACHE does not have a way to provide the keys | ||
7632 | required to decrypt the entries. | ||
7633 | |||
7634 | Blocks in the NAMECACHE share the same expiration mechanism as blocks in | ||
7635 | the DHT --- the block expires wheneever any of the records in | ||
7636 | the (encrypted) block expires. | ||
7637 | The expiration time of the block is the only information stored in | ||
7638 | plaintext. The NAMECACHE service internally performs all of the required | ||
7639 | work to expire blocks, clients do not have to worry about this. | ||
7640 | Also, given that NAMECACHE stores only GNS blocks that local users | ||
7641 | requested, there is no configuration option to limit the size of the | ||
7642 | NAMECACHE. It is assumed to be always small enough (a few MB) to fit on | ||
7643 | the drive. | ||
7644 | |||
7645 | The NAMECACHE supports the use of different database backends via a | ||
7646 | plugin API. | ||
7647 | |||
7648 | @menu | ||
7649 | * libgnunetnamecache:: | ||
7650 | * The NAMECACHE Client-Service Protocol:: | ||
7651 | * The NAMECACHE Plugin API:: | ||
7652 | @end menu | ||
7653 | |||
7654 | @node libgnunetnamecache | ||
7655 | @subsection libgnunetnamecache | ||
7656 | |||
7657 | @c %**end of header | ||
7658 | |||
7659 | The NAMECACHE API consists of five simple functions. First, there is | ||
7660 | @code{GNUNET_NAMECACHE_connect} to connect to the NAMECACHE service. | ||
7661 | This returns the handle required for all other operations on the | ||
7662 | NAMECACHE. Using @code{GNUNET_NAMECACHE_block_cache} clients can insert a | ||
7663 | block into the cache. | ||
7664 | @code{GNUNET_NAMECACHE_lookup_block} can be used to lookup blocks that | ||
7665 | were stored in the NAMECACHE. Both operations can be cancelled using | ||
7666 | @code{GNUNET_NAMECACHE_cancel}. Note that cancelling a | ||
7667 | @code{GNUNET_NAMECACHE_block_cache} operation can result in the block | ||
7668 | being stored in the NAMECACHE --- or not. Cancellation primarily ensures | ||
7669 | that the continuation function with the result of the operation will no | ||
7670 | longer be invoked. | ||
7671 | Finally, @code{GNUNET_NAMECACHE_disconnect} closes the connection to the | ||
7672 | NAMECACHE. | ||
7673 | |||
7674 | The maximum size of a block that can be stored in the NAMECACHE is | ||
7675 | @code{GNUNET_NAMECACHE_MAX_VALUE_SIZE}, which is defined to be 63 kB. | ||
7676 | |||
7677 | @node The NAMECACHE Client-Service Protocol | ||
7678 | @subsection The NAMECACHE Client-Service Protocol | ||
7679 | |||
7680 | @c %**end of header | ||
7681 | |||
7682 | All messages in the NAMECACHE IPC protocol start with the | ||
7683 | @code{struct GNUNET_NAMECACHE_Header} which adds a request | ||
7684 | ID (32-bit integer) to the standard message header. | ||
7685 | The request ID is used to match requests with the | ||
7686 | respective responses from the NAMECACHE, as they are allowed to happen | ||
7687 | out-of-order. | ||
7688 | |||
7689 | |||
7690 | @menu | ||
7691 | * Lookup:: | ||
7692 | * Store:: | ||
7693 | @end menu | ||
7694 | |||
7695 | @node Lookup | ||
7696 | @subsubsection Lookup | ||
7697 | |||
7698 | @c %**end of header | ||
7699 | |||
7700 | The @code{struct LookupBlockMessage} is used to lookup a block stored in | ||
7701 | the cache. | ||
7702 | It contains the query hash. The NAMECACHE always responds with a | ||
7703 | @code{struct LookupBlockResponseMessage}. If the NAMECACHE has no | ||
7704 | response, it sets the expiration time in the response to zero. | ||
7705 | Otherwise, the response is expected to contain the expiration time, the | ||
7706 | ECDSA signature, the derived key and the (variable-size) encrypted data | ||
7707 | of the block. | ||
7708 | |||
7709 | @node Store | ||
7710 | @subsubsection Store | ||
7711 | |||
7712 | @c %**end of header | ||
7713 | |||
7714 | The @code{struct BlockCacheMessage} is used to cache a block in the | ||
7715 | NAMECACHE. | ||
7716 | It has the same structure as the @code{struct LookupBlockResponseMessage}. | ||
7717 | The service responds with a @code{struct BlockCacheResponseMessage} which | ||
7718 | contains the result of the operation (success or failure). | ||
7719 | In the future, we might want to make it possible to provide an error | ||
7720 | message as well. | ||
7721 | |||
7722 | @node The NAMECACHE Plugin API | ||
7723 | @subsection The NAMECACHE Plugin API | ||
7724 | @c %**end of header | ||
7725 | |||
7726 | The NAMECACHE plugin API consists of two functions, @code{cache_block} to | ||
7727 | store a block in the database, and @code{lookup_block} to lookup a block | ||
7728 | in the database. | ||
7729 | |||
7730 | |||
7731 | @menu | ||
7732 | * Lookup2:: | ||
7733 | * Store2:: | ||
7734 | @end menu | ||
7735 | |||
7736 | @node Lookup2 | ||
7737 | @subsubsection Lookup2 | ||
7738 | |||
7739 | @c %**end of header | ||
7740 | |||
7741 | The @code{lookup_block} function is expected to return at most one block | ||
7742 | to the iterator, and return @code{GNUNET_NO} if there were no non-expired | ||
7743 | results. | ||
7744 | If there are multiple non-expired results in the cache, the lookup is | ||
7745 | supposed to return the result with the largest expiration time. | ||
7746 | |||
7747 | @node Store2 | ||
7748 | @subsubsection Store2 | ||
7749 | |||
7750 | @c %**end of header | ||
7751 | |||
7752 | The @code{cache_block} function is expected to try to store the block in | ||
7753 | the database, and return @code{GNUNET_SYSERR} if this was not possible | ||
7754 | for any reason. | ||
7755 | Furthermore, @code{cache_block} is expected to implicitly perform cache | ||
7756 | maintenance and purge blocks from the cache that have expired. Note that | ||
7757 | @code{cache_block} might encounter the case where the database already has | ||
7758 | another block stored under the same key. In this case, the plugin must | ||
7759 | ensure that the block with the larger expiration time is preserved. | ||
7760 | Obviously, this can done either by simply adding new blocks and selecting | ||
7761 | for the most recent expiration time during lookup, or by checking which | ||
7762 | block is more recent during the store operation. | ||
7763 | |||
7764 | @node The REVOCATION Subsystem | ||
7765 | @section The REVOCATION Subsystem | ||
7766 | @c %**end of header | ||
7767 | |||
7768 | The REVOCATION subsystem is responsible for key revocation of Egos. | ||
7769 | If a user learns that theis private key has been compromised or has lost | ||
7770 | it, they can use the REVOCATION system to inform all of the other users | ||
7771 | that their private key is no longer valid. | ||
7772 | The subsystem thus includes ways to query for the validity of keys and to | ||
7773 | propagate revocation messages. | ||
7774 | |||
7775 | @menu | ||
7776 | * Dissemination:: | ||
7777 | * Revocation Message Design Requirements:: | ||
7778 | * libgnunetrevocation:: | ||
7779 | * The REVOCATION Client-Service Protocol:: | ||
7780 | * The REVOCATION Peer-to-Peer Protocol:: | ||
7781 | @end menu | ||
7782 | |||
7783 | @node Dissemination | ||
7784 | @subsection Dissemination | ||
7785 | |||
7786 | @c %**end of header | ||
7787 | |||
7788 | When a revocation is performed, the revocation is first of all | ||
7789 | disseminated by flooding the overlay network. | ||
7790 | The goal is to reach every peer, so that when a peer needs to check if a | ||
7791 | key has been revoked, this will be purely a local operation where the | ||
7792 | peer looks at his local revocation list. Flooding the network is also the | ||
7793 | most robust form of key revocation --- an adversary would have to control | ||
7794 | a separator of the overlay graph to restrict the propagation of the | ||
7795 | revocation message. Flooding is also very easy to implement --- peers that | ||
7796 | receive a revocation message for a key that they have never seen before | ||
7797 | simply pass the message to all of their neighbours. | ||
7798 | |||
7799 | Flooding can only distribute the revocation message to peers that are | ||
7800 | online. | ||
7801 | In order to notify peers that join the network later, the revocation | ||
7802 | service performs efficient set reconciliation over the sets of known | ||
7803 | revocation messages whenever two peers (that both support REVOCATION | ||
7804 | dissemination) connect. | ||
7805 | The SET service is used to perform this operation efficiently. | ||
7806 | |||
7807 | @node Revocation Message Design Requirements | ||
7808 | @subsection Revocation Message Design Requirements | ||
7809 | |||
7810 | @c %**end of header | ||
7811 | |||
7812 | However, flooding is also quite costly, creating O(|E|) messages on a | ||
7813 | network with |E| edges. | ||
7814 | Thus, revocation messages are required to contain a proof-of-work, the | ||
7815 | result of an expensive computation (which, however, is cheap to verify). | ||
7816 | Only peers that have expended the CPU time necessary to provide | ||
7817 | this proof will be able to flood the network with the revocation message. | ||
7818 | This ensures that an attacker cannot simply flood the network with | ||
7819 | millions of revocation messages. The proof-of-work required by GNUnet is | ||
7820 | set to take days on a typical PC to compute; if the ability to quickly | ||
7821 | revoke a key is needed, users have the option to pre-compute revocation | ||
7822 | messages to store off-line and use instantly after their key has expired. | ||
7823 | |||
7824 | Revocation messages must also be signed by the private key that is being | ||
7825 | revoked. Thus, they can only be created while the private key is in the | ||
7826 | possession of the respective user. This is another reason to create a | ||
7827 | revocation message ahead of time and store it in a secure location. | ||
7828 | |||
7829 | @node libgnunetrevocation | ||
7830 | @subsection libgnunetrevocation | ||
7831 | |||
7832 | @c %**end of header | ||
7833 | |||
7834 | The REVOCATION API consists of two parts, to query and to issue | ||
7835 | revocations. | ||
7836 | |||
7837 | |||
7838 | @menu | ||
7839 | * Querying for revoked keys:: | ||
7840 | * Preparing revocations:: | ||
7841 | * Issuing revocations:: | ||
7842 | @end menu | ||
7843 | |||
7844 | @node Querying for revoked keys | ||
7845 | @subsubsection Querying for revoked keys | ||
7846 | |||
7847 | @c %**end of header | ||
7848 | |||
7849 | @code{GNUNET_REVOCATION_query} is used to check if a given ECDSA public | ||
7850 | key has been revoked. | ||
7851 | The given callback will be invoked with the result of the check. | ||
7852 | The query can be cancelled using @code{GNUNET_REVOCATION_query_cancel} on | ||
7853 | the return value. | ||
7854 | |||
7855 | @node Preparing revocations | ||
7856 | @subsubsection Preparing revocations | ||
7857 | |||
7858 | @c %**end of header | ||
7859 | |||
7860 | It is often desirable to create a revocation record ahead-of-time and | ||
7861 | store it in an off-line location to be used later in an emergency. | ||
7862 | This is particularly true for GNUnet revocations, where performing the | ||
7863 | revocation operation itself is computationally expensive and thus is | ||
7864 | likely to take some time. | ||
7865 | Thus, if users want the ability to perform revocations quickly in an | ||
7866 | emergency, they must pre-compute the revocation message. | ||
7867 | The revocation API enables this with two functions that are used to | ||
7868 | compute the revocation message, but not trigger the actual revocation | ||
7869 | operation. | ||
7870 | |||
7871 | @code{GNUNET_REVOCATION_check_pow} should be used to calculate the | ||
7872 | proof-of-work required in the revocation message. This function takes the | ||
7873 | public key, the required number of bits for the proof of work (which in | ||
7874 | GNUnet is a network-wide constant) and finally a proof-of-work number as | ||
7875 | arguments. | ||
7876 | The function then checks if the given proof-of-work number is a valid | ||
7877 | proof of work for the given public key. Clients preparing a revocation | ||
7878 | are expected to call this function repeatedly (typically with a | ||
7879 | monotonically increasing sequence of numbers of the proof-of-work number) | ||
7880 | until a given number satisfies the check. | ||
7881 | That number should then be saved for later use in the revocation | ||
7882 | operation. | ||
7883 | |||
7884 | @code{GNUNET_REVOCATION_sign_revocation} is used to generate the | ||
7885 | signature that is required in a revocation message. | ||
7886 | It takes the private key that (possibly in the future) is to be revoked | ||
7887 | and returns the signature. | ||
7888 | The signature can again be saved to disk for later use, which will then | ||
7889 | allow performing a revocation even without access to the private key. | ||
7890 | |||
7891 | @node Issuing revocations | ||
7892 | @subsubsection Issuing revocations | ||
7893 | |||
7894 | |||
7895 | Given a ECDSA public key, the signature from @code{GNUNET_REVOCATION_sign} | ||
7896 | and the proof-of-work, | ||
7897 | @code{GNUNET_REVOCATION_revoke} can be used to perform the | ||
7898 | actual revocation. The given callback is called upon completion of the | ||
7899 | operation. @code{GNUNET_REVOCATION_revoke_cancel} can be used to stop the | ||
7900 | library from calling the continuation; however, in that case it is | ||
7901 | undefined whether or not the revocation operation will be executed. | ||
7902 | |||
7903 | @node The REVOCATION Client-Service Protocol | ||
7904 | @subsection The REVOCATION Client-Service Protocol | ||
7905 | |||
7906 | |||
7907 | The REVOCATION protocol consists of four simple messages. | ||
7908 | |||
7909 | A @code{QueryMessage} containing a public ECDSA key is used to check if a | ||
7910 | particular key has been revoked. The service responds with a | ||
7911 | @code{QueryResponseMessage} which simply contains a bit that says if the | ||
7912 | given public key is still valid, or if it has been revoked. | ||
7913 | |||
7914 | The second possible interaction is for a client to revoke a key by | ||
7915 | passing a @code{RevokeMessage} to the service. The @code{RevokeMessage} | ||
7916 | contains the ECDSA public key to be revoked, a signature by the | ||
7917 | corresponding private key and the proof-of-work, The service responds | ||
7918 | with a @code{RevocationResponseMessage} which can be used to indicate | ||
7919 | that the @code{RevokeMessage} was invalid (i.e. proof of work incorrect), | ||
7920 | or otherwise indicates that the revocation has been processed | ||
7921 | successfully. | ||
7922 | |||
7923 | @node The REVOCATION Peer-to-Peer Protocol | ||
7924 | @subsection The REVOCATION Peer-to-Peer Protocol | ||
7925 | |||
7926 | @c %**end of header | ||
7927 | |||
7928 | Revocation uses two disjoint ways to spread revocation information among | ||
7929 | peers. | ||
7930 | First of all, P2P gossip exchanged via CORE-level neighbours is used to | ||
7931 | quickly spread revocations to all connected peers. | ||
7932 | Second, whenever two peers (that both support revocations) connect, | ||
7933 | the SET service is used to compute the union of the respective revocation | ||
7934 | sets. | ||
7935 | |||
7936 | In both cases, the exchanged messages are @code{RevokeMessage}s which | ||
7937 | contain the public key that is being revoked, a matching ECDSA signature, | ||
7938 | and a proof-of-work. | ||
7939 | Whenever a peer learns about a new revocation this way, it first | ||
7940 | validates the signature and the proof-of-work, then stores it to disk | ||
7941 | (typically to a file $GNUNET_DATA_HOME/revocation.dat) and finally | ||
7942 | spreads the information to all directly connected neighbours. | ||
7943 | |||
7944 | For computing the union using the SET service, the peer with the smaller | ||
7945 | hashed peer identity will connect (as a "client" in the two-party set | ||
7946 | protocol) to the other peer after one second (to reduce traffic spikes | ||
7947 | on connect) and initiate the computation of the set union. | ||
7948 | All revocation services use a common hash to identify the SET operation | ||
7949 | over revocation sets. | ||
7950 | |||
7951 | The current implementation accepts revocation set union operations from | ||
7952 | all peers at any time; however, well-behaved peers should only initiate | ||
7953 | this operation once after establishing a connection to a peer with a | ||
7954 | larger hashed peer identity. | ||
7955 | |||
7956 | @cindex gnunet-fs | ||
7957 | @cindex FS | ||
7958 | @cindex FS subsystem | ||
7959 | @node GNUnet's File-sharing (FS) Subsystem | ||
7960 | @section GNUnet's File-sharing (FS) Subsystem | ||
7961 | |||
7962 | @c %**end of header | ||
7963 | |||
7964 | This chapter describes the details of how the file-sharing service works. | ||
7965 | As with all services, it is split into an API (libgnunetfs), the service | ||
7966 | process (gnunet-service-fs) and user interface(s). | ||
7967 | The file-sharing service uses the datastore service to store blocks and | ||
7968 | the DHT (and indirectly datacache) for lookups for non-anonymous | ||
7969 | file-sharing. | ||
7970 | Furthermore, the file-sharing service uses the block library (and the | ||
7971 | block fs plugin) for validation of DHT operations. | ||
7972 | |||
7973 | In contrast to many other services, libgnunetfs is rather complex since | ||
7974 | the client library includes a large number of high-level abstractions; | ||
7975 | this is necessary since the Fs service itself largely only operates on | ||
7976 | the block level. | ||
7977 | The FS library is responsible for providing a file-based abstraction to | ||
7978 | applications, including directories, meta data, keyword search, | ||
7979 | verification, and so on. | ||
7980 | |||
7981 | The method used by GNUnet to break large files into blocks and to use | ||
7982 | keyword search is called the | ||
7983 | "Encoding for Censorship Resistant Sharing" (ECRS). | ||
7984 | ECRS is largely implemented in the fs library; block validation is also | ||
7985 | reflected in the block FS plugin and the FS service. | ||
7986 | ECRS on-demand encoding is implemented in the FS service. | ||
7987 | |||
7988 | NOTE: The documentation in this chapter is quite incomplete. | ||
7989 | |||
7990 | @menu | ||
7991 | * Encoding for Censorship-Resistant Sharing (ECRS):: | ||
7992 | * File-sharing persistence directory structure:: | ||
7993 | @end menu | ||
7994 | |||
7995 | @cindex ecrs | ||
7996 | @cindex Encoding for Censorship-Resistant Sharing | ||
7997 | @node Encoding for Censorship-Resistant Sharing (ECRS) | ||
7998 | @subsection Encoding for Censorship-Resistant Sharing (ECRS) | ||
7999 | |||
8000 | @c %**end of header | ||
8001 | |||
8002 | When GNUnet shares files, it uses a content encoding that is called ECRS, | ||
8003 | the Encoding for Censorship-Resistant Sharing. | ||
8004 | Most of ECRS is described in the (so far unpublished) research paper | ||
8005 | attached to this page. ECRS obsoletes the previous ESED and ESED II | ||
8006 | encodings which were used in GNUnet before version 0.7.0. | ||
8007 | The rest of this page assumes that the reader is familiar with the | ||
8008 | attached paper. What follows is a description of some minor extensions | ||
8009 | that GNUnet makes over what is described in the paper. | ||
8010 | The reason why these extensions are not in the paper is that we felt | ||
8011 | that they were obvious or trivial extensions to the original scheme and | ||
8012 | thus did not warrant space in the research report. | ||
8013 | |||
8014 | @menu | ||
8015 | * Namespace Advertisements:: | ||
8016 | * KSBlocks:: | ||
8017 | @end menu | ||
8018 | |||
8019 | @node Namespace Advertisements | ||
8020 | @subsubsection Namespace Advertisements | ||
8021 | |||
8022 | @c %**end of header | ||
8023 | @c %**FIXME: all zeroses -> ? | ||
8024 | |||
8025 | An @code{SBlock} with identifier all zeros is a signed | ||
8026 | advertisement for a namespace. This special @code{SBlock} contains | ||
8027 | metadata describing the content of the namespace. | ||
8028 | Instead of the name of the identifier for a potential update, it contains | ||
8029 | the identifier for the root of the namespace. | ||
8030 | The URI should always be empty. The @code{SBlock} is signed with the | ||
8031 | content provder's RSA private key (just like any other SBlock). Peers | ||
8032 | can search for @code{SBlock}s in order to find out more about a namespace. | ||
8033 | |||
8034 | @node KSBlocks | ||
8035 | @subsubsection KSBlocks | ||
8036 | |||
8037 | @c %**end of header | ||
8038 | |||
8039 | GNUnet implements @code{KSBlocks} which are @code{KBlocks} that, instead | ||
8040 | of encrypting a CHK and metadata, encrypt an @code{SBlock} instead. | ||
8041 | In other words, @code{KSBlocks} enable GNUnet to find @code{SBlocks} | ||
8042 | using the global keyword search. | ||
8043 | Usually the encrypted @code{SBlock} is a namespace advertisement. | ||
8044 | The rationale behind @code{KSBlock}s and @code{SBlock}s is to enable | ||
8045 | peers to discover namespaces via keyword searches, and, to associate | ||
8046 | useful information with namespaces. When GNUnet finds @code{KSBlocks} | ||
8047 | during a normal keyword search, it adds the information to an internal | ||
8048 | list of discovered namespaces. Users looking for interesting namespaces | ||
8049 | can then inspect this list, reducing the need for out-of-band discovery | ||
8050 | of namespaces. | ||
8051 | Naturally, namespaces (or more specifically, namespace advertisements) can | ||
8052 | also be referenced from directories, but @code{KSBlock}s should make it | ||
8053 | easier to advertise namespaces for the owner of the pseudonym since they | ||
8054 | eliminate the need to first create a directory. | ||
8055 | |||
8056 | Collections are also advertised using @code{KSBlock}s. | ||
8057 | |||
8058 | @table @asis | ||
8059 | @item Attachment Size | ||
8060 | @item ecrs.pdf 270.68 KB | ||
8061 | @item https://gnunet.org/sites/default/files/ecrs.pdf | ||
8062 | @end table | ||
8063 | |||
8064 | @node File-sharing persistence directory structure | ||
8065 | @subsection File-sharing persistence directory structure | ||
8066 | |||
8067 | @c %**end of header | ||
8068 | |||
8069 | This section documents how the file-sharing library implements | ||
8070 | persistence of file-sharing operations and specifically the resulting | ||
8071 | directory structure. | ||
8072 | This code is only active if the @code{GNUNET_FS_FLAGS_PERSISTENCE} flag | ||
8073 | was set when calling @code{GNUNET_FS_start}. | ||
8074 | In this case, the file-sharing library will try hard to ensure that all | ||
8075 | major operations (searching, downloading, publishing, unindexing) are | ||
8076 | persistent, that is, can live longer than the process itself. | ||
8077 | More specifically, an operation is supposed to live until it is | ||
8078 | explicitly stopped. | ||
8079 | |||
8080 | If @code{GNUNET_FS_stop} is called before an operation has been stopped, a | ||
8081 | @code{SUSPEND} event is generated and then when the process calls | ||
8082 | @code{GNUNET_FS_start} next time, a @code{RESUME} event is generated. | ||
8083 | Additionally, even if an application crashes (segfault, SIGKILL, system | ||
8084 | crash) and hence @code{GNUNET_FS_stop} is never called and no | ||
8085 | @code{SUSPEND} events are generated, operations are still resumed (with | ||
8086 | @code{RESUME} events). | ||
8087 | This is implemented by constantly writing the current state of the | ||
8088 | file-sharing operations to disk. | ||
8089 | Specifically, the current state is always written to disk whenever | ||
8090 | anything significant changes (the exception are block-wise progress in | ||
8091 | publishing and unindexing, since those operations would be slowed down | ||
8092 | significantly and can be resumed cheaply even without detailed | ||
8093 | accounting). | ||
8094 | Note that if the process crashes (or is killed) during a serialization | ||
8095 | operation, FS does not guarantee that this specific operation is | ||
8096 | recoverable (no strict transactional semantics, again for performance | ||
8097 | reasons). However, all other unrelated operations should resume nicely. | ||
8098 | |||
8099 | Since we need to serialize the state continuously and want to recover as | ||
8100 | much as possible even after crashing during a serialization operation, | ||
8101 | we do not use one large file for serialization. | ||
8102 | Instead, several directories are used for the various operations. | ||
8103 | When @code{GNUNET_FS_start} executes, the master directories are scanned | ||
8104 | for files describing operations to resume. | ||
8105 | Sometimes, these operations can refer to related operations in child | ||
8106 | directories which may also be resumed at this point. | ||
8107 | Note that corrupted files are cleaned up automatically. | ||
8108 | However, dangling files in child directories (those that are not | ||
8109 | referenced by files from the master directories) are not automatically | ||
8110 | removed. | ||
8111 | |||
8112 | Persistence data is kept in a directory that begins with the "STATE_DIR" | ||
8113 | prefix from the configuration file | ||
8114 | (by default, "$SERVICEHOME/persistence/") followed by the name of the | ||
8115 | client as given to @code{GNUNET_FS_start} (for example, "gnunet-gtk") | ||
8116 | followed by the actual name of the master or child directory. | ||
8117 | |||
8118 | The names for the master directories follow the names of the operations: | ||
8119 | |||
8120 | @itemize @bullet | ||
8121 | @item "search" | ||
8122 | @item "download" | ||
8123 | @item "publish" | ||
8124 | @item "unindex" | ||
8125 | @end itemize | ||
8126 | |||
8127 | Each of the master directories contains names (chosen at random) for each | ||
8128 | active top-level (master) operation. | ||
8129 | Note that a download that is associated with a search result is not a | ||
8130 | top-level operation. | ||
8131 | |||
8132 | In contrast to the master directories, the child directories are only | ||
8133 | consulted when another operation refers to them. | ||
8134 | For each search, a subdirectory (named after the master search | ||
8135 | synchronization file) contains the search results. | ||
8136 | Search results can have an associated download, which is then stored in | ||
8137 | the general "download-child" directory. | ||
8138 | Downloads can be recursive, in which case children are stored in | ||
8139 | subdirectories mirroring the structure of the recursive download | ||
8140 | (either starting in the master "download" directory or in the | ||
8141 | "download-child" directory depending on how the download was initiated). | ||
8142 | For publishing operations, the "publish-file" directory contains | ||
8143 | information about the individual files and directories that are part of | ||
8144 | the publication. | ||
8145 | However, this directory structure is flat and does not mirror the | ||
8146 | structure of the publishing operation. | ||
8147 | Note that unindex operations cannot have associated child operations. | ||
8148 | |||
8149 | @cindex REGEX subsystem | ||
8150 | @cindex regex subsystem | ||
8151 | @node GNUnet's REGEX Subsystem | ||
8152 | @section GNUnet's REGEX Subsystem | ||
8153 | |||
8154 | @c %**end of header | ||
8155 | |||
8156 | Using the REGEX subsystem, you can discover peers that offer a particular | ||
8157 | service using regular expressions. | ||
8158 | The peers that offer a service specify it using a regular expressions. | ||
8159 | Peers that want to patronize a service search using a string. | ||
8160 | The REGEX subsystem will then use the DHT to return a set of matching | ||
8161 | offerers to the patrons. | ||
8162 | |||
8163 | For the technical details, we have Max's defense talk and Max's Master's | ||
8164 | thesis. | ||
8165 | |||
8166 | @c An additional publication is under preparation and available to | ||
8167 | @c team members (in Git). | ||
8168 | @c FIXME: Where is the file? Point to it. Assuming that it's szengel2012ms | ||
8169 | |||
8170 | @menu | ||
8171 | * How to run the regex profiler:: | ||
8172 | @end menu | ||
8173 | |||
8174 | @node How to run the regex profiler | ||
8175 | @subsection How to run the regex profiler | ||
8176 | |||
8177 | @c %**end of header | ||
8178 | |||
8179 | The gnunet-regex-profiler can be used to profile the usage of mesh/regex | ||
8180 | for a given set of regular expressions and strings. | ||
8181 | Mesh/regex allows you to announce your peer ID under a certain regex and | ||
8182 | search for peers matching a particular regex using a string. | ||
8183 | See @uref{https://gnunet.org/szengel2012ms, szengel2012ms} for a full | ||
8184 | introduction. | ||
8185 | |||
8186 | First of all, the regex profiler uses GNUnet testbed, thus all the | ||
8187 | implications for testbed also apply to the regex profiler | ||
8188 | (for example you need password-less ssh login to the machines listed in | ||
8189 | your hosts file). | ||
8190 | |||
8191 | @strong{Configuration} | ||
8192 | |||
8193 | Moreover, an appropriate configuration file is needed. | ||
8194 | Generally you can refer to the | ||
8195 | @file{contrib/regex_profiler_infiniband.conf} file in the sourcecode | ||
8196 | of GNUnet for an example configuration. | ||
8197 | In the following paragraph the important details are highlighted. | ||
8198 | |||
8199 | Announcing of the regular expressions is done by the | ||
8200 | gnunet-daemon-regexprofiler, therefore you have to make sure it is | ||
8201 | started, by adding it to the AUTOSTART set of ARM: | ||
8202 | |||
8203 | @example | ||
8204 | [regexprofiler] | ||
8205 | AUTOSTART = YES | ||
8206 | @end example | ||
8207 | |||
8208 | @noindent | ||
8209 | Furthermore you have to specify the location of the binary: | ||
8210 | |||
8211 | @example | ||
8212 | [regexprofiler] | ||
8213 | # Location of the gnunet-daemon-regexprofiler binary. | ||
8214 | BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-daemon-regexprofiler | ||
8215 | # Regex prefix that will be applied to all regular expressions and | ||
8216 | # search string. | ||
8217 | REGEX_PREFIX = "GNVPN-0001-PAD" | ||
8218 | @end example | ||
8219 | |||
8220 | @noindent | ||
8221 | When running the profiler with a large scale deployment, you probably | ||
8222 | want to reduce the workload of each peer. | ||
8223 | Use the following options to do this. | ||
8224 | |||
8225 | @example | ||
8226 | [dht] | ||
8227 | # Force network size estimation | ||
8228 | FORCE_NSE = 1 | ||
8229 | |||
8230 | [dhtcache] | ||
8231 | DATABASE = heap | ||
8232 | # Disable RC-file for Bloom filter? (for benchmarking with limited IO | ||
8233 | # availability) | ||
8234 | DISABLE_BF_RC = YES | ||
8235 | # Disable Bloom filter entirely | ||
8236 | DISABLE_BF = YES | ||
8237 | |||
8238 | [nse] | ||
8239 | # Minimize proof-of-work CPU consumption by NSE | ||
8240 | WORKBITS = 1 | ||
8241 | @end example | ||
8242 | |||
8243 | @noindent | ||
8244 | @strong{Options} | ||
8245 | |||
8246 | To finally run the profiler some options and the input data need to be | ||
8247 | specified on the command line. | ||
8248 | |||
8249 | @example | ||
8250 | gnunet-regex-profiler -c config-file -d log-file -n num-links \ | ||
8251 | -p path-compression-length -s search-delay -t matching-timeout \ | ||
8252 | -a num-search-strings hosts-file policy-dir search-strings-file | ||
8253 | @end example | ||
8254 | |||
8255 | @noindent | ||
8256 | Where... | ||
8257 | |||
8258 | @itemize @bullet | ||
8259 | @item ... @code{config-file} means the configuration file created earlier. | ||
8260 | @item ... @code{log-file} is the file where to write statistics output. | ||
8261 | @item ... @code{num-links} indicates the number of random links between | ||
8262 | started peers. | ||
8263 | @item ... @code{path-compression-length} is the maximum path compression | ||
8264 | length in the DFA. | ||
8265 | @item ... @code{search-delay} time to wait between peers finished linking | ||
8266 | and starting to match strings. | ||
8267 | @item ... @code{matching-timeout} timeout after which to cancel the | ||
8268 | searching. | ||
8269 | @item ... @code{num-search-strings} number of strings in the | ||
8270 | search-strings-file. | ||
8271 | @item ... the @code{hosts-file} should contain a list of hosts for the | ||
8272 | testbed, one per line in the following format: | ||
8273 | |||
8274 | @itemize @bullet | ||
8275 | @item @code{user@@host_ip:port} | ||
8276 | @end itemize | ||
8277 | @item ... the @code{policy-dir} is a folder containing text files | ||
8278 | containing one or more regular expressions. A peer is started for each | ||
8279 | file in that folder and the regular expressions in the corresponding file | ||
8280 | are announced by this peer. | ||
8281 | @item ... the @code{search-strings-file} is a text file containing search | ||
8282 | strings, one in each line. | ||
8283 | @end itemize | ||
8284 | |||
8285 | @noindent | ||
8286 | You can create regular expressions and search strings for every AS in the | ||
8287 | Internet using the attached scripts. You need one of the | ||
8288 | @uref{http://data.caida.org/datasets/routing/routeviews-prefix2as/, CAIDA routeviews prefix2as} | ||
8289 | data files for this. Run | ||
8290 | |||
8291 | @example | ||
8292 | create_regex.py <filename> <output path> | ||
8293 | @end example | ||
8294 | |||
8295 | @noindent | ||
8296 | to create the regular expressions and | ||
8297 | |||
8298 | @example | ||
8299 | create_strings.py <input path> <outfile> | ||
8300 | @end example | ||
8301 | |||
8302 | @noindent | ||
8303 | to create a search strings file from the previously created | ||
8304 | regular expressions. | ||
diff --git a/doc/documentation/chapters/installation.texi b/doc/documentation/chapters/installation.texi new file mode 100644 index 000000000..dfd94d037 --- /dev/null +++ b/doc/documentation/chapters/installation.texi | |||
@@ -0,0 +1,3995 @@ | |||
1 | @node GNUnet Installation Handbook | ||
2 | @chapter GNUnet Installation Handbook | ||
3 | |||
4 | This handbook describes how to install (build setup, compilation) and | ||
5 | setup (configuration, start) GNUnet 0.10.x. After following these | ||
6 | instructions you should be able to install and then start user-interfaces | ||
7 | to interact with the network. | ||
8 | |||
9 | This manual is far from complete, and we welcome informed contributions, | ||
10 | be it in the form of new chapters or insightful comments. | ||
11 | |||
12 | @menu | ||
13 | * Dependencies:: | ||
14 | * Pre-installation notes:: | ||
15 | * Generic installation instructions:: | ||
16 | * Build instructions for Ubuntu 12.04 using Git:: | ||
17 | * Build Instructions for Microsoft Windows Platforms:: | ||
18 | * Build instructions for Debian 7.5:: | ||
19 | * Installing GNUnet from Git on Ubuntu 14.4:: | ||
20 | * Build instructions for Debian 8:: | ||
21 | * Outdated build instructions for previous revisions:: | ||
22 | @c * Portable GNUnet:: | ||
23 | * The graphical configuration interface:: | ||
24 | * How to start and stop a GNUnet peer:: | ||
25 | @end menu | ||
26 | |||
27 | @node Dependencies | ||
28 | @section Dependencies | ||
29 | @c %**end of header | ||
30 | |||
31 | This section lists the various known dependencies for | ||
32 | GNUnet @value{EDITION}. | ||
33 | Suggestions for missing dependencies or wrong version numbers are welcome. | ||
34 | |||
35 | @menu | ||
36 | * External dependencies:: | ||
37 | * Fixing libgnurl build issues:: | ||
38 | * Optional dependencies:: | ||
39 | * Internal dependencies:: | ||
40 | @end menu | ||
41 | |||
42 | @node External dependencies | ||
43 | @subsection External dependencies | ||
44 | @c %**end of header | ||
45 | |||
46 | These packages must be installed before a typical GNUnet installation | ||
47 | can be performed: | ||
48 | |||
49 | @itemize @bullet | ||
50 | @item autoconf | ||
51 | @item automake | ||
52 | @item pkg-config | ||
53 | @item libltdl | ||
54 | @item gstreamer | ||
55 | @item gst-plugins-base | ||
56 | @item perl | ||
57 | @item python (only 2.7 supported)@footnote{tests and gnunet-qr} | ||
58 | @item jansson | ||
59 | @item nss | ||
60 | @item glib | ||
61 | @item gmp | ||
62 | @item bluez | ||
63 | @item miniupnpc | ||
64 | @item gettext | ||
65 | @item which | ||
66 | @item texinfo | ||
67 | @item GNU libmicrohttpd @geq{} 0.9.30 @footnote{We recommend to build it | ||
68 | with a GnuTLS version that was configured with libunbound} | ||
69 | @item GNU libextractor @geq{} 1.0 | ||
70 | @item GNU libtool @geq{} 2.2 | ||
71 | @item GNU libunistring @geq{} 0.9.1.1 | ||
72 | @item GNU libidn @geq{} 1.0.0 | ||
73 | @item @uref{https://gnupg.org/software/libgcrypt/, GNU libgcrypt} @geq{} | ||
74 | @uref{https://gnupg.org/ftp/gcrypt/libgcrypt/, 1.6.0} | ||
75 | @item @uref{https://gnutls.org/, GnuTLS} @geq{} 3.2.7 | ||
76 | @footnote{We recommend to compile with libunbound for DANE support; | ||
77 | GnuTLS also requires GNU nettle 2.7 (update: GnuTLS 3.2.7 appears NOT | ||
78 | to work against GNU nettle > 2.7, due to some API updatings done by | ||
79 | nettle. Thus it should be compiled against nettle 2.7 | ||
80 | and, in case you get some error on the reference to `rpl_strerror' being | ||
81 | undefined, follow the instructions on | ||
82 | @uref{http://lists.gnupg.org/pipermail/gnutls-devel/2013-November/006588.html, this} | ||
83 | post (and the link inside it)).} | ||
84 | @item @uref{https://gnunet.org/gnurl, gnURL} libgnurl @geq{} 7.34.0 | ||
85 | @footnote{must be compiled after @code{GnuTLS}} | ||
86 | @item libglpk @geq{} 4.45 | ||
87 | @item @uref{http://www.openssl.org/, OpenSSL} @geq{} 1.0 | ||
88 | @item TeX Live @geq{} 2012, optional (for gnunet-bcd) | ||
89 | @item Texinfo @geq{} 5.2 (for documentation) | ||
90 | @item libsqlite @geq{} 3.8.0 @footnote{(note that the code will | ||
91 | compile and often work with lower version numbers, but you may get subtle | ||
92 | bugs with respect to quota management in certain rare cases); | ||
93 | alternatively, MySQL or Postgres can also be installed, but those | ||
94 | databases will require more complex configurations (not | ||
95 | recommended for first-time users)} | ||
96 | @item zlib | ||
97 | @end itemize | ||
98 | |||
99 | @node Fixing libgnurl build issues | ||
100 | @subsection Fixing libgnurl build issues | ||
101 | |||
102 | If you have to compile libgnurl from source since the version included in | ||
103 | your distribution is to old you perhaps get an error message while | ||
104 | running the @file{configure} script: | ||
105 | |||
106 | @example | ||
107 | $ configure | ||
108 | ... | ||
109 | checking for 64-bit curl_off_t data type... unknown | ||
110 | checking for 32-bit curl_off_t data type... unknown | ||
111 | checking for 16-bit curl_off_t data type... unknown | ||
112 | configure: error: cannot find data type for curl_off_t. | ||
113 | @end example | ||
114 | |||
115 | @noindent | ||
116 | Solution: | ||
117 | |||
118 | Before running the configure script, set: | ||
119 | |||
120 | @example | ||
121 | CFLAGS="-I. -I$BUILD_ROOT/include" | ||
122 | @end example | ||
123 | |||
124 | @node Optional dependencies | ||
125 | @subsection Optional dependencies | ||
126 | |||
127 | These applications must be installed for various experimental or otherwise | ||
128 | optional features such as @code{gnunet-conversation}, @code{gnunet-gtk}. | ||
129 | |||
130 | @itemize @bullet | ||
131 | @item libpulse 2.0 or higher, optional (for gnunet-conversation) | ||
132 | @item libopus 1.0.1 or higher, optional (for gnunet-conversation) | ||
133 | @item libogg 1.3.0 or higher, optional (for gnunet-conversation) | ||
134 | @item certool (binary) optional @footnote{for convenient installation of | ||
135 | the GNS proxy (available as part of Debian's libnss3-tools)} | ||
136 | @item python-zbar 0.10 or higher, optional (for gnunet-qr) | ||
137 | @item Gtk+ 3.0 or higher, optional (for gnunet-gtk) | ||
138 | @item libgladeui must match Gtk+ version, optional (for gnunet-gtk) | ||
139 | @item libqrencode 3.0 or higher, optional (for gnunet-namestore-gtk) | ||
140 | @end itemize | ||
141 | |||
142 | @node Internal dependencies | ||
143 | @subsection Internal dependencies | ||
144 | |||
145 | This section tries to give an overview of what processes a typical GNUnet | ||
146 | peer running a particular application would consist of. All of the | ||
147 | processes listed here should be automatically started by | ||
148 | @code{gnunet-arm -s}. | ||
149 | The list is given as a rough first guide to users for failure diagnostics. | ||
150 | Ideally, end-users should never have to worry about these internal | ||
151 | dependencies. | ||
152 | In terms of internal dependencies, a minimum file-sharing system consists | ||
153 | of the following GNUnet processes (in order of dependency): | ||
154 | |||
155 | @itemize @bullet | ||
156 | @item gnunet-service-arm | ||
157 | @item gnunet-service-resolver (required by all) | ||
158 | @item gnunet-service-statistics (required by all) | ||
159 | @item gnunet-service-peerinfo | ||
160 | @item gnunet-service-transport (requires peerinfo) | ||
161 | @item gnunet-service-core (requires transport) | ||
162 | @item gnunet-daemon-hostlist (requires core) | ||
163 | @item gnunet-daemon-topology (requires hostlist, peerinfo) | ||
164 | @item gnunet-service-datastore | ||
165 | @item gnunet-service-dht (requires core) | ||
166 | @item gnunet-service-identity | ||
167 | @item gnunet-service-fs (requires identity, mesh, dht, datastore, core) | ||
168 | @end itemize | ||
169 | |||
170 | @noindent | ||
171 | A minimum VPN system consists of the following GNUnet processes (in | ||
172 | order of dependency): | ||
173 | |||
174 | @itemize @bullet | ||
175 | @item gnunet-service-arm | ||
176 | @item gnunet-service-resolver (required by all) | ||
177 | @item gnunet-service-statistics (required by all) | ||
178 | @item gnunet-service-peerinfo | ||
179 | @item gnunet-service-transport (requires peerinfo) | ||
180 | @item gnunet-service-core (requires transport) | ||
181 | @item gnunet-daemon-hostlist (requires core) | ||
182 | @item gnunet-service-dht (requires core) | ||
183 | @item gnunet-service-mesh (requires dht, core) | ||
184 | @item gnunet-service-dns (requires dht) | ||
185 | @item gnunet-service-regex (requires dht) | ||
186 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
187 | @end itemize | ||
188 | |||
189 | @noindent | ||
190 | A minimum GNS system consists of the following GNUnet processes (in | ||
191 | order of dependency): | ||
192 | |||
193 | @itemize @bullet | ||
194 | @item gnunet-service-arm | ||
195 | @item gnunet-service-resolver (required by all) | ||
196 | @item gnunet-service-statistics (required by all) | ||
197 | @item gnunet-service-peerinfo | ||
198 | @item gnunet-service-transport (requires peerinfo) | ||
199 | @item gnunet-service-core (requires transport) | ||
200 | @item gnunet-daemon-hostlist (requires core) | ||
201 | @item gnunet-service-dht (requires core) | ||
202 | @item gnunet-service-mesh (requires dht, core) | ||
203 | @item gnunet-service-dns (requires dht) | ||
204 | @item gnunet-service-regex (requires dht) | ||
205 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
206 | @item gnunet-service-identity | ||
207 | @item gnunet-service-namestore (requires identity) | ||
208 | @item gnunet-service-gns (requires vpn, dns, dht, namestore, identity) | ||
209 | @end itemize | ||
210 | |||
211 | @node Pre-installation notes | ||
212 | @section Pre-installation notes | ||
213 | |||
214 | Please note that in the code instructions for the installation, | ||
215 | @emph{#} indicates commands run as privileged root user and | ||
216 | @emph{$} shows commands run as unprivileged ("normal") system user. | ||
217 | |||
218 | |||
219 | @node Generic installation instructions | ||
220 | @section Generic installation instructions | ||
221 | |||
222 | First, in addition to the GNUnet sources you might require downloading the | ||
223 | latest version of various dependencies, depending on how recent the | ||
224 | software versions in your distribution of GNU/Linux are. | ||
225 | Most distributions do not include sufficiently recent versions of these | ||
226 | dependencies. | ||
227 | Thus, a typically installation on a "modern" GNU/Linux distribution | ||
228 | requires you to install the following dependencies (ideally in this | ||
229 | order): | ||
230 | |||
231 | @itemize @bullet | ||
232 | @item libgpgerror and libgcrypt | ||
233 | @item libnettle and libunbound (possibly from distribution), GnuTLS | ||
234 | @item libgnurl (read the README) | ||
235 | @item GNU libmicrohttpd | ||
236 | @item GNU libextractor | ||
237 | @end itemize | ||
238 | |||
239 | Make sure to first install the various mandatory and optional | ||
240 | dependencies including development headers from your distribution. | ||
241 | |||
242 | Other dependencies that you should strongly consider to install is a | ||
243 | database (MySQL, sqlite or Postgres). | ||
244 | The following instructions will assume that you installed at least sqlite. | ||
245 | For most distributions you should be able to find pre-build packages for | ||
246 | the database. Again, make sure to install the client libraries and the | ||
247 | respective development headers (if they are packaged separately) as well. | ||
248 | |||
249 | You can find specific, detailed instructions for installing of the | ||
250 | dependencies (and possibly the rest of the GNUnet installation) in the | ||
251 | platform-specific descriptions, which can be found in the Index. | ||
252 | Please consult them now. | ||
253 | If your distribution is not listed, please study the instructions for | ||
254 | Debian stable carefully as you try to install the dependencies for your | ||
255 | own distribution. | ||
256 | Contributing additional instructions for further platforms is always | ||
257 | appreciated. | ||
258 | Please take in mind that operating system development tends to move at | ||
259 | a rather fast speed. Due to this you should be aware that some of | ||
260 | the instructionss could be outdated by the time you are reading this. | ||
261 | If you find a mistake, please tell us about it (or even better: send | ||
262 | a patch to the documentation to fix it!). | ||
263 | |||
264 | Before proceeding further, please double-check the dependency list. | ||
265 | Note that in addition to satisfying the dependencies, you might have to | ||
266 | make sure that development headers for the various libraries are also | ||
267 | installed. | ||
268 | There maybe files for other distributions, or you might be able to find | ||
269 | equivalent packages for your distribution. | ||
270 | |||
271 | While it is possible to build and install GNUnet without having root | ||
272 | access, we will assume that you have full control over your system in | ||
273 | these instructions. | ||
274 | First, you should create a system user @emph{gnunet} and an additional | ||
275 | group @emph{gnunetdns}. On Debian and Ubuntu GNU/Linux, type: | ||
276 | |||
277 | @example | ||
278 | # adduser --system --home /var/lib/gnunet --group \ | ||
279 | --disabled-password gnunet | ||
280 | # addgroup --system gnunetdns | ||
281 | @end example | ||
282 | |||
283 | @noindent | ||
284 | On other Unixes, this should have the same effect: | ||
285 | |||
286 | @example | ||
287 | # useradd --system --groups gnunet --home-dir /var/lib/gnunet | ||
288 | # addgroup --system gnunetdns | ||
289 | @end example | ||
290 | |||
291 | Now compile and install GNUnet using: | ||
292 | |||
293 | @example | ||
294 | $ tar xvf gnunet-0.10.?.tar.gz | ||
295 | $ cd gnunet-0.10.? | ||
296 | $ ./configure --with-sudo=sudo --with-nssdir=/lib | ||
297 | $ make | ||
298 | $ sudo make install | ||
299 | @end example | ||
300 | |||
301 | If you want to be able to enable DEBUG-level log messages, add | ||
302 | @code{--enable-logging=verbose} to the end of the | ||
303 | @code{./configure} command. | ||
304 | DEBUG-level log messages are in English-only and should only be useful for | ||
305 | developers (or for filing really detailed bug reports). | ||
306 | |||
307 | Finally, you probably want to compile @code{gnunet-gtk}, which | ||
308 | includes gnunet-setup (graphical tool for configuration) | ||
309 | and @code{gnunet-fs-gtk} (graphical tool for file-sharing): | ||
310 | |||
311 | @example | ||
312 | $ tar xvf gnunet-gtk-0.10.?.tar.gz | ||
313 | $ cd gnunet-gtk-0.10.? | ||
314 | $ ./configure --with-gnunet=/usr/local/ | ||
315 | $ make | ||
316 | $ sudo make install | ||
317 | $ cd .. | ||
318 | # just to be safe run this: | ||
319 | $ sudo ldconfig | ||
320 | @end example | ||
321 | |||
322 | @noindent | ||
323 | Next, edit the file @file{/etc/gnunet.conf} to contain the following: | ||
324 | |||
325 | @example | ||
326 | [arm] | ||
327 | SYSTEM_ONLY = YES | ||
328 | USER_ONLY = NO | ||
329 | @end example | ||
330 | |||
331 | @noindent | ||
332 | You may need to update your ld.so cache to include files installed in | ||
333 | @file{/usr/local/lib}: | ||
334 | |||
335 | @example | ||
336 | # ldconfig | ||
337 | @end example | ||
338 | |||
339 | @noindent | ||
340 | Then, switch from user root to user gnunet to start the peer: | ||
341 | |||
342 | @example | ||
343 | # su -s /bin/sh - gnunet | ||
344 | $ gnunet-arm -c /etc/gnunet.conf -s | ||
345 | @end example | ||
346 | |||
347 | You may also want to add the last line in the gnunet users @file{crontab} | ||
348 | prefixed with @code{@@reboot} so that it is executed whenever the system | ||
349 | is booted: | ||
350 | |||
351 | @example | ||
352 | @@reboot /usr/local/bin/gnunet-arm -c /etc/gnunet.conf -s@ | ||
353 | @end example | ||
354 | |||
355 | @noindent | ||
356 | This will only start the system-wide GNUnet services. | ||
357 | Type exit to get back your root shell. | ||
358 | Now, you need to configure the per-user part. For each | ||
359 | $USER on the system, run: | ||
360 | |||
361 | @example | ||
362 | # adduser $USER gnunet | ||
363 | @end example | ||
364 | |||
365 | @noindent | ||
366 | to allow them to access the system-wide GNUnet services. Then, each | ||
367 | user should create a configuration file @file{~/.config/gnunet.conf} | ||
368 | with the lines: | ||
369 | |||
370 | @example | ||
371 | [arm] | ||
372 | SYSTEM_ONLY = NO | ||
373 | USER_ONLY = YES | ||
374 | DEFAULTSERVICES = gns | ||
375 | @end example | ||
376 | |||
377 | @noindent | ||
378 | and start the per-user services using | ||
379 | |||
380 | @example | ||
381 | $ gnunet-arm -c ~/.config/gnunet.conf -s | ||
382 | @end example | ||
383 | |||
384 | @noindent | ||
385 | Again, adding a @code{crontab} entry to autostart the peer is advised: | ||
386 | |||
387 | @example | ||
388 | @@reboot /usr/local/bin/gnunet-arm -c $HOME/.config/gnunet.conf -s | ||
389 | @end example | ||
390 | |||
391 | @noindent | ||
392 | Note that some GNUnet services (such as SOCKS5 proxies) may need a | ||
393 | system-wide TCP port for each user. | ||
394 | For those services, systems with more than one user may require each user | ||
395 | to specify a different port number in their personal configuration file. | ||
396 | |||
397 | Finally, the user should perform the basic initial setup for the GNU Name | ||
398 | System. This is done by running two commands: | ||
399 | |||
400 | @example | ||
401 | $ gnunet-gns-import.sh | ||
402 | $ gnunet-gns-proxy-setup-ca | ||
403 | @end example | ||
404 | |||
405 | @noindent | ||
406 | The first generates the default zones, wheras the second setups the GNS | ||
407 | Certificate Authority with the user's browser. Now, to actiave GNS in the | ||
408 | normal DNS resolution process, you need to edit your | ||
409 | @file{/etc/nsswitch.conf} where you should find a line like this: | ||
410 | |||
411 | @example | ||
412 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
413 | @end example | ||
414 | |||
415 | @noindent | ||
416 | The exact details may differ a bit, which is fine. Add the text | ||
417 | @emph{"gns [NOTFOUND=return]"} after @emph{"files"}. | ||
418 | Keep in mind that we included a backslash ("\") here just for | ||
419 | markup reasons. You should write the text below on @b{one line} | ||
420 | and @b{without} the "\": | ||
421 | |||
422 | @example | ||
423 | hosts: files gns [NOTFOUND=return] mdns4_minimal \ | ||
424 | [NOTFOUND=return] dns mdns4 | ||
425 | @end example | ||
426 | |||
427 | @c FIXME: Document new behavior. | ||
428 | You might want to make sure that @file{/lib/libnss_gns.so.2} exists on | ||
429 | your system, it should have been created during the installation. | ||
430 | |||
431 | @node Build instructions for Ubuntu 12.04 using Git | ||
432 | @section Build instructions for Ubuntu 12.04 using Git | ||
433 | |||
434 | |||
435 | @menu | ||
436 | * Install the required build tools:: | ||
437 | * Install libgcrypt 1.6 and libgpg-error:: | ||
438 | * Install gnutls with DANE support:: | ||
439 | * Install libgnurl:: | ||
440 | * Install libmicrohttpd from Git:: | ||
441 | * Install libextractor from Git:: | ||
442 | * Install GNUnet dependencies:: | ||
443 | * Build GNUnet:: | ||
444 | * Install the GNUnet-gtk user interface from Git:: | ||
445 | @end menu | ||
446 | |||
447 | @node Install the required build tools | ||
448 | @subsection Install the required build tools | ||
449 | |||
450 | First, make sure Git is installed on your system: | ||
451 | |||
452 | @example | ||
453 | $ sudo apt-get install git | ||
454 | @end example | ||
455 | |||
456 | Install the essential buildtools: | ||
457 | |||
458 | @example | ||
459 | $ sudo apt-get install automake autopoint autoconf libtool | ||
460 | @end example | ||
461 | |||
462 | @node Install libgcrypt 1.6 and libgpg-error | ||
463 | @subsection Install libgcrypt 1.6 and libgpg-error | ||
464 | |||
465 | @example | ||
466 | $ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.12.tar.bz2 | ||
467 | $ tar xf libgpg-error-1.12.tar.bz2 | ||
468 | $ cd libgpg-error-1.12 | ||
469 | $ ./configure | ||
470 | $ sudo make install ; cd .. | ||
471 | @end example | ||
472 | |||
473 | @node Install gnutls with DANE support | ||
474 | @subsection Install gnutls with DANE support | ||
475 | |||
476 | @example | ||
477 | $ wget http://www.lysator.liu.se/~nisse/archive/nettle-2.7.1.tar.gz | ||
478 | $ tar xf nettle-2.7.1.tar.gz | ||
479 | $ cd nettle-2.7.1 | ||
480 | $ ./configure | ||
481 | $ sudo make install ; cd .. | ||
482 | @end example | ||
483 | |||
484 | @example | ||
485 | $ wget https://www.nlnetlabs.nl/downloads/ldns/ldns-1.6.16.tar.gz | ||
486 | $ tar xf ldns-1.6.16.tar.gz | ||
487 | $ cd ldns-1.6.16 | ||
488 | $ ./configure | ||
489 | $ sudo make install ; cd .. | ||
490 | @end example | ||
491 | |||
492 | @example | ||
493 | $ wget https://unbound.net/downloads/unbound-1.4.21.tar.gz | ||
494 | $ tar xf unbound-1.4.21.tar.gz | ||
495 | $ cd unbound-1.4.21 | ||
496 | $ ./configure | ||
497 | $ sudo make install ; cd .. | ||
498 | @end example | ||
499 | |||
500 | @example | ||
501 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.1/gnutls-3.1.17.tar.xz | ||
502 | $ tar xf gnutls-3.1.17.tar.xz | ||
503 | $ cd gnutls-3.1.17 | ||
504 | $ ./configure | ||
505 | $ sudo make install ; cd .. | ||
506 | @end example | ||
507 | |||
508 | @example | ||
509 | $ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.0.tar.bz2 | ||
510 | $ tar xf libgcrypt-1.6.0.tar.bz2 | ||
511 | $ cd libgcrypt-1.6.0 | ||
512 | $ ./configure | ||
513 | $ sudo make install ; cd .. | ||
514 | @end example | ||
515 | |||
516 | @node Install libgnurl | ||
517 | @subsection Install libgnurl | ||
518 | |||
519 | @example | ||
520 | $ wget https://gnunet.org/sites/default/files/gnurl-7.34.0.tar.bz2 | ||
521 | $ tar xf gnurl-7.34.0.tar.bz2 | ||
522 | $ cd gnurl-7.34.0 | ||
523 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
524 | --without-libmetalink --without-winidn --without-librtmp \ | ||
525 | --without-nghttp2 --without-nss --without-cyassl \ | ||
526 | --without-polarssl --without-ssl --without-winssl \ | ||
527 | --without-darwinssl --disable-sspi --disable-ntlm-wb \ | ||
528 | --disable-ldap --disable-rtsp --disable-dict --disable-telnet \ | ||
529 | --disable-tftp --disable-pop3 --disable-imap --disable-smtp \ | ||
530 | --disable-gopher --disable-file --disable-ftp | ||
531 | $ sudo make install ; cd .. | ||
532 | @end example | ||
533 | |||
534 | @node Install libmicrohttpd from Git | ||
535 | @subsection Install libmicrohttpd from Git | ||
536 | |||
537 | @example | ||
538 | $ git clone https://gnunet.org/git/libmicrohttpd | ||
539 | $ cd libmicrohttpd/ | ||
540 | $ ./bootstrap | ||
541 | $ ./configure | ||
542 | $ sudo make install ; cd .. | ||
543 | @end example | ||
544 | |||
545 | @node Install libextractor from Git | ||
546 | @subsection Install libextractor from Git | ||
547 | |||
548 | Install libextractor dependencies: | ||
549 | |||
550 | @example | ||
551 | $ sudo apt-get install zlib1g-dev libgsf-1-dev libmpeg2-4-dev \ | ||
552 | libpoppler-dev libvorbis-dev libexiv2-dev libjpeg-dev \ | ||
553 | libtiff-dev libgif-dev libvorbis-dev libflac-dev libsmf-dev \ | ||
554 | g++ | ||
555 | @end example | ||
556 | |||
557 | Build libextractor: | ||
558 | |||
559 | @example | ||
560 | $ git clone https://gnunet.org/git/libextractor | ||
561 | $ cd libextractor | ||
562 | $ ./bootstrap | ||
563 | $ ./configure | ||
564 | $ sudo make install ; cd .. | ||
565 | @end example | ||
566 | |||
567 | @node Install GNUnet dependencies | ||
568 | @subsection Install GNUnet dependencies | ||
569 | |||
570 | @example | ||
571 | $ sudo apt-get install libidn11-dev libunistring-dev libglpk-dev \ | ||
572 | libpulse-dev libbluetooth-dev libsqlite-dev | ||
573 | @end example | ||
574 | |||
575 | Install libopus: | ||
576 | |||
577 | @example | ||
578 | $ wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz | ||
579 | $ tar xf opus-1.1.tar.gz | ||
580 | $ cd opus-1.1/ | ||
581 | $ ./configure | ||
582 | $ sudo make install ; cd .. | ||
583 | @end example | ||
584 | |||
585 | Choose one or more database backends: | ||
586 | |||
587 | SQLite3: | ||
588 | @example | ||
589 | $ sudo apt-get install libsqlite3-dev | ||
590 | @end example | ||
591 | MySQL: | ||
592 | @example | ||
593 | $ sudo apt-get install libmysqlclient-dev | ||
594 | @end example | ||
595 | PostgreSQL: | ||
596 | @example | ||
597 | $ sudo apt-get install libpq-dev postgresql | ||
598 | @end example | ||
599 | |||
600 | |||
601 | |||
602 | @node Build GNUnet | ||
603 | @subsection Build GNUnet | ||
604 | |||
605 | |||
606 | |||
607 | @menu | ||
608 | * Configuring the installation path:: | ||
609 | * Configuring the system:: | ||
610 | * Installing components requiring sudo permission:: | ||
611 | * Build:: | ||
612 | @end menu | ||
613 | |||
614 | @node Configuring the installation path | ||
615 | @subsubsection Configuring the installation path | ||
616 | |||
617 | You can specify the location of the GNUnet installation by setting the | ||
618 | prefix when calling the configure script with @code{--prefix=DIRECTORY} | ||
619 | |||
620 | @example | ||
621 | $ export PATH=$PATH:DIRECTORY/bin | ||
622 | @end example | ||
623 | |||
624 | @node Configuring the system | ||
625 | @subsubsection Configuring the system | ||
626 | |||
627 | Please make sure NOW that you have created a user and group 'gnunet' | ||
628 | and additionally a group 'gnunetdns': | ||
629 | |||
630 | @example | ||
631 | $ sudo addgroup gnunet | ||
632 | $ sudo addgroup gnunetdns | ||
633 | $ sudo adduser gnunet | ||
634 | @end example | ||
635 | |||
636 | Each GNUnet user should be added to the 'gnunet' group (may | ||
637 | require fresh login to come into effect): | ||
638 | |||
639 | @example | ||
640 | $ sudo useradd -G gnunet | ||
641 | @end example | ||
642 | |||
643 | @node Installing components requiring sudo permission | ||
644 | @subsubsection Installing components requiring sudo permission | ||
645 | |||
646 | Some components, like the nss plugin required for GNS, may require root | ||
647 | permissions. To allow these few components to be installed use: | ||
648 | |||
649 | @example | ||
650 | $ ./configure --with-sudo | ||
651 | @end example | ||
652 | |||
653 | @node Build | ||
654 | @subsubsection Build | ||
655 | |||
656 | @example | ||
657 | $ git clone https://gnunet.org/git/gnunet/ | ||
658 | $ cd gnunet/ | ||
659 | $ ./bootstrap | ||
660 | @end example | ||
661 | |||
662 | Use the required configure call including the optional installation prefix | ||
663 | PREFIX or the sudo permissions: | ||
664 | |||
665 | @example | ||
666 | $ ./configure [ --with-sudo | --with-prefix=PREFIX ] | ||
667 | @end example | ||
668 | |||
669 | @example | ||
670 | $ make; sudo make install | ||
671 | @end example | ||
672 | |||
673 | After installing it, you need to create an empty configuration file: | ||
674 | |||
675 | @example | ||
676 | mkdir ~/.gnunet; touch ~/.gnunet/gnunet.conf | ||
677 | @end example | ||
678 | |||
679 | And finally you can start GNUnet with: | ||
680 | |||
681 | @example | ||
682 | $ gnunet-arm -s | ||
683 | @end example | ||
684 | |||
685 | @node Install the GNUnet-gtk user interface from Git | ||
686 | @subsection Install the GNUnet-gtk user interface from Git | ||
687 | |||
688 | |||
689 | Install depencies: | ||
690 | |||
691 | @example | ||
692 | $ sudo apt-get install libgtk-3-dev libunique-3.0-dev libgladeui-dev \ | ||
693 | libqrencode-dev | ||
694 | @end example | ||
695 | |||
696 | To build GNUnet (with an optional prefix)and execute: | ||
697 | |||
698 | @example | ||
699 | $ git clone https://gnunet.org/git/gnunet-gtk/ | ||
700 | $ cd gnunet-gtk/ | ||
701 | $ ./bootstrap | ||
702 | $ ./configure [--prefix=PREFIX] --with-gnunet=DIRECTORY | ||
703 | $ make; sudo make install | ||
704 | @end example | ||
705 | |||
706 | @node Build Instructions for Microsoft Windows Platforms | ||
707 | @section Build Instructions for Microsoft Windows Platforms | ||
708 | |||
709 | @menu | ||
710 | * Introduction to building on MS Windows:: | ||
711 | * Requirements:: | ||
712 | * Dependencies & Initial Setup:: | ||
713 | * GNUnet Installation:: | ||
714 | * Adjusting Windows for running and testing GNUnet:: | ||
715 | * Building the GNUnet Installer:: | ||
716 | * Using GNUnet with Netbeans on Windows:: | ||
717 | @end menu | ||
718 | |||
719 | @node Introduction to building on MS Windows | ||
720 | @subsection Introduction to building on MS Windows | ||
721 | |||
722 | |||
723 | This document is a guide to building GNUnet and its dependencies on | ||
724 | Windows platforms. GNUnet development is mostly done under GNU/Linux and | ||
725 | especially git checkouts may not build out of the box. | ||
726 | We regret any inconvenience, and if you have problems, please report | ||
727 | them. | ||
728 | |||
729 | @node Requirements | ||
730 | @subsection Requirements | ||
731 | |||
732 | The Howto is based upon a @strong{Windows Server 2008 32bit} | ||
733 | @strong{Installation}, @strong{sbuild} and thus a | ||
734 | @uref{http://www.mingw.org/wiki/MSYS, MSYS+MinGW} | ||
735 | (W32-GCC-Compiler-Suite + Unix-like Userland) installation. sbuild | ||
736 | is a convenient set of scripts which creates a working msys/mingw | ||
737 | installation and installs most dependencies required for GNUnet. | ||
738 | |||
739 | As of the point of the creation of these instructions, | ||
740 | GNUnet @strong{requires} a Windows @strong{Server} 2003 or | ||
741 | newer for full feature support. | ||
742 | Windows Vista and later will also work, but | ||
743 | @strong{non-server version can not run a VPN-Exit-Node} as the NAT | ||
744 | features have been removed as of Windows Vista. | ||
745 | |||
746 | @node Dependencies & Initial Setup | ||
747 | @subsection Dependencies & Initial Setup | ||
748 | |||
749 | |||
750 | @itemize @bullet | ||
751 | |||
752 | @item | ||
753 | Install a fresh version of @strong{Python 2.x}, even if you are using a | ||
754 | x64-OS, install a 32-bit version for use with sbuild. | ||
755 | Python 3.0 currently is incompatible. | ||
756 | |||
757 | @item | ||
758 | Install your favorite @uref{http://code.google.com/p/tortoisegit/, GIT} & | ||
759 | @uref{http://tortoisesvn.net/, SVN}-clients. | ||
760 | |||
761 | @item | ||
762 | You will also need some archive-manager like | ||
763 | @uref{http://www.7-zip.org/, 7zip}. | ||
764 | |||
765 | @item | ||
766 | Pull a copy of sbuild to a directory of your choice, which will be used | ||
767 | in the remainder of this guide. For now, we will use | ||
768 | @file{c:\gnunet\sbuild\} | ||
769 | |||
770 | @item | ||
771 | in @file{sbuild\src\mingw\mingw32-buildall.sh}, comment out the packages | ||
772 | @strong{gnunet-svn} and @strong{gnunet-gtk-svn}, as we don't want sbuild | ||
773 | to compile/install those for us. | ||
774 | |||
775 | @item | ||
776 | Follow LRN's sbuild installation instructions.- | ||
777 | @end itemize | ||
778 | |||
779 | Please note that sbuild may (or will most likely) fail during | ||
780 | installation, thus you really HAVE to @strong{check the logfiles} created | ||
781 | during the installation process. | ||
782 | Certain packages may fail to build initially due to missing dependencies, | ||
783 | thus you may have to | ||
784 | @strong{substitute those with binary-versions initially}. Later on once | ||
785 | dependencies are satisfied you can re-build the newer package versions. | ||
786 | |||
787 | @strong{It is normal that you may have to repeat this step multiple times | ||
788 | and there is no uniform way to fix all compile-time issues, as the | ||
789 | build-process of many of the dependencies installed are rather unstable | ||
790 | on win32 and certain releases may not even compile at all.} | ||
791 | |||
792 | Most dependencies for GNUnet have been set up by sbuild, thus we now | ||
793 | should add the @file{bin/} directories in your new msys and mingw | ||
794 | installations to PATH. You will want to create a backup of your finished | ||
795 | msys-environment by now. | ||
796 | |||
797 | @node GNUnet Installation | ||
798 | @subsection GNUnet Installation | ||
799 | |||
800 | First, we need to launch our msys-shell, you can do this via | ||
801 | |||
802 | @file{C:\gnunet\sbuild\msys\msys.bat} | ||
803 | |||
804 | You might wish to take a look at this file and adjust some | ||
805 | login-parameters to your msys environment. | ||
806 | |||
807 | Also, sbuild added two pointpoints to your msys-environment, though those | ||
808 | might remain invisible: | ||
809 | |||
810 | @itemize @bullet | ||
811 | |||
812 | @item | ||
813 | /mingw, which will mount your mingw-directory from sbuild/mingw and the | ||
814 | other one is | ||
815 | |||
816 | @item | ||
817 | /src which contains all the installation sources sbuild just compiled. | ||
818 | @end itemize | ||
819 | |||
820 | Check out the current GNUnet sources (git HEAD) from the | ||
821 | GNUnet repository "gnunet.git", we will do this in your home directory: | ||
822 | |||
823 | @code{git clone https://gnunet.org/git/gnunet/ ~/gnunet} | ||
824 | |||
825 | Now, we will first need to bootstrap the checked out installation and then | ||
826 | configure it accordingly. | ||
827 | |||
828 | @example | ||
829 | cd ~/gnunet | ||
830 | ./bootstrap | ||
831 | STRIP=true CPPFLAGS="-DUSE_IPV6=1 -DW32_VEH" CFLAGS="$CFLAGS -g -O2" \ | ||
832 | ./configure --prefix=/ --docdir=/share/doc/gnunet \ | ||
833 | --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw \ | ||
834 | --with-libcurl=/mingw --with-extractor=/mingw --with-sqlite=/mingw \ | ||
835 | --with-microhttpd=/mingw --with-plibc=/mingw --enable-benchmarks \ | ||
836 | --enable-expensivetests --enable-experimental --with-qrencode=/mingw \ | ||
837 | --enable-silent-rules --enable-experimental 2>&1 | tee -a ./configure.log | ||
838 | @end example | ||
839 | |||
840 | The parameters above will configure for a reasonable GNUnet installation | ||
841 | to the your msys-root directory. | ||
842 | Depending on which features your would like to build or you may need to | ||
843 | specify additional dependencies. Sbuild installed most libs into | ||
844 | the /mingw subdirectory, so remember to prefix library locations with | ||
845 | this path. | ||
846 | |||
847 | Like on a unixoid system, you might want to use your home directory as | ||
848 | prefix for your own GNUnet installation for development, without tainting | ||
849 | the buildenvironment. Just change the "prefix" parameter to point towards | ||
850 | ~/ in this case. | ||
851 | |||
852 | Now it's time to compile GNUnet as usual. Though this will take some time, | ||
853 | so you may fetch yourself a coffee or some Mate now... | ||
854 | |||
855 | @example | ||
856 | make ; make install | ||
857 | @end example | ||
858 | |||
859 | @node Adjusting Windows for running and testing GNUnet | ||
860 | @subsection Adjusting Windows for running and testing GNUnet | ||
861 | |||
862 | Assuming the build succeeded and you | ||
863 | @strong{added the bin directory of your GNUnet to PATH}, you can now use | ||
864 | your gnunet-installation as usual. | ||
865 | Remember that UAC or the windows firewall may popup initially, blocking | ||
866 | further execution of gnunet until you acknowledge them. | ||
867 | |||
868 | You will also have to take the usual steps to get peer-to-peer (p2p) | ||
869 | software running properly (port forwarding, ...), | ||
870 | and GNUnet will require administrative permissions as it may even | ||
871 | install a device-driver (in case you are using gnunet-vpn and/or | ||
872 | gnunet-exit). | ||
873 | |||
874 | @node Building the GNUnet Installer | ||
875 | @subsection Building the GNUnet Installer | ||
876 | |||
877 | The GNUnet installer is made with | ||
878 | @uref{http://nsis.sourceforge.net/, NSIS}. | ||
879 | The installer script is located in @file{contrib\win} in the | ||
880 | GNUnet source tree. | ||
881 | |||
882 | @node Using GNUnet with Netbeans on Windows | ||
883 | @subsection Using GNUnet with Netbeans on Windows | ||
884 | |||
885 | TODO | ||
886 | |||
887 | @node Build instructions for Debian 7.5 | ||
888 | @section Build instructions for Debian 7.5 | ||
889 | |||
890 | |||
891 | These are the installation instructions for Debian 7.5. They were tested | ||
892 | using a minimal, fresh Debian 7.5 AMD64 installation without non-free | ||
893 | software (no contrib or non-free). | ||
894 | By "minimal", we mean that during installation, we did not select any | ||
895 | desktop environment, servers or system utilities during the "tasksel" | ||
896 | step. Note that the packages and the dependencies that we will install | ||
897 | during this chapter take about 1.5 GB of disk space. | ||
898 | Combined with GNUnet and space for objects during compilation, you should | ||
899 | not even attempt this unless you have about 2.5 GB free after the minimal | ||
900 | Debian installation. | ||
901 | Using these instructions to build a VM image is likely to require a | ||
902 | minimum of 4-5 GB for the VM (as you will likely also want a desktop | ||
903 | manager). | ||
904 | |||
905 | GNUnet's security model assumes that your @file{/home} directory is | ||
906 | encrypted. Thus, if possible, you should encrypt your home partition | ||
907 | (or per-user home directory). | ||
908 | |||
909 | Naturally, the exact details of the starting state for your installation | ||
910 | should not matter much. For example, if you selected any of those | ||
911 | installation groups you might simply already have some of the necessary | ||
912 | packages installed. | ||
913 | We did this for testing, as this way we are less likely to forget to | ||
914 | mention a required package. | ||
915 | Note that we will not install a desktop environment, but of course you | ||
916 | will need to install one to use GNUnet's graphical user interfaces. | ||
917 | Thus, it is suggested that you simply install the desktop environment of | ||
918 | your choice before beginning with the instructions. | ||
919 | |||
920 | |||
921 | |||
922 | @menu | ||
923 | * Update:: | ||
924 | * Stable? Hah!:: | ||
925 | * Update again:: | ||
926 | * Installing packages:: | ||
927 | * Installing dependencies from source:: | ||
928 | * Installing GNUnet from source:: | ||
929 | * But wait there is more!:: | ||
930 | @end menu | ||
931 | |||
932 | @node Update | ||
933 | @subsection Update | ||
934 | |||
935 | After any installation, you should begin by running | ||
936 | |||
937 | @example | ||
938 | # apt-get update ; apt-get upgrade | ||
939 | @end example | ||
940 | |||
941 | to ensure that all of your packages are up-to-date. Note that the "#" is | ||
942 | used to indicate that you need to type in this command as "root" | ||
943 | (or prefix with "sudo"), whereas "$" is used to indicate typing in a | ||
944 | command as a normal user. | ||
945 | |||
946 | @node Stable? Hah! | ||
947 | @subsection Stable? Hah! | ||
948 | |||
949 | Yes, we said we start with a Debian 7.5 "stable" system. However, to | ||
950 | reduce the amount of compilation by hand, we will begin by allowing the | ||
951 | installation of packages from the testing and unstable distributions as | ||
952 | well. | ||
953 | We will stick to "stable" packages where possible, but some packages will | ||
954 | be taken from the other distributions. | ||
955 | Start by modifying @file{/etc/apt/sources.list} to contain the | ||
956 | following (possibly adjusted to point to your mirror of choice): | ||
957 | |||
958 | @example | ||
959 | # These were there before: | ||
960 | deb http://ftp.de.debian.org/debian/ wheezy main | ||
961 | deb-src http://ftp.de.debian.org/debian/ wheezy main | ||
962 | deb http://security.debian.org/ wheezy/updates main | ||
963 | deb-src http://security.debian.org/ wheezy/updates main | ||
964 | deb http://ftp.de.debian.org/debian/ wheezy-updates main | ||
965 | deb-src http://ftp.de.debian.org/debian/ wheezy-updates main | ||
966 | |||
967 | # Add these lines (feel free to adjust the mirror): | ||
968 | deb http://ftp.de.debian.org/debian/ testing main | ||
969 | deb http://ftp.de.debian.org/debian/ unstable main | ||
970 | @end example | ||
971 | |||
972 | The next step is to create/edit your @file{/etc/apt/preferences} | ||
973 | file to look like this: | ||
974 | |||
975 | @example | ||
976 | Package: * | ||
977 | Pin: release a=stable,n=wheezy | ||
978 | Pin-Priority: 700 | ||
979 | |||
980 | Package: * | ||
981 | Pin: release o=Debian,a=testing | ||
982 | Pin-Priority: 650 | ||
983 | |||
984 | Package: * | ||
985 | Pin: release o=Debian,a=unstable | ||
986 | Pin-Priority: 600 | ||
987 | @end example | ||
988 | |||
989 | You can read more about Apt Preferences here and here. | ||
990 | Note that other pinnings are likely to also work for GNUnet, the key | ||
991 | thing is that you need some packages from unstable (as shown below). | ||
992 | However, as unstable is unlikely to be comprehensive (missing packages) | ||
993 | or might be problematic (crashing packages), you probably want others | ||
994 | from stable and/or testing. | ||
995 | |||
996 | @node Update again | ||
997 | @subsection Update again | ||
998 | |||
999 | Now, run again@ | ||
1000 | |||
1001 | @example | ||
1002 | # apt-get update@ | ||
1003 | # apt-get upgrade@ | ||
1004 | @end example | ||
1005 | |||
1006 | to ensure that all your new distribution indices are downloaded, and | ||
1007 | that your pinning is correct: the upgrade step should cause no changes | ||
1008 | at all. | ||
1009 | |||
1010 | @node Installing packages | ||
1011 | @subsection Installing packages | ||
1012 | |||
1013 | We begin by installing a few Debian packages from stable:@ | ||
1014 | |||
1015 | @example | ||
1016 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ | ||
1017 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev \ | ||
1018 | texlive libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev \ | ||
1019 | libbz2-dev libexiv2-dev libflac-dev libgif-dev libglib2.0-dev \ | ||
1020 | libgtk-3-dev libmagic-dev libjpeg8-dev libmpeg2-4-dev libmp4v2-dev \ | ||
1021 | librpm-dev libsmf-dev libtidy-dev libtiff5-dev libvorbis-dev \ | ||
1022 | libogg-dev zlib1g-dev g++ gettext libgsf-1-dev libunbound-dev \ | ||
1023 | libqrencode-dev libgladeui-dev nasm texlive-latex-extra \ | ||
1024 | libunique-3.0-dev gawk miniupnpc libfuse-dev libbluetooth-dev | ||
1025 | @end example | ||
1026 | |||
1027 | After that, we install a few more packages from unstable:@ | ||
1028 | |||
1029 | @example | ||
1030 | # apt-get install -t unstable nettle-dev libgstreamer1.0-dev \ | ||
1031 | gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ | ||
1032 | libgstreamer-plugins-base1.0-dev | ||
1033 | @end example | ||
1034 | |||
1035 | @node Installing dependencies from source | ||
1036 | @subsection Installing dependencies from source | ||
1037 | |||
1038 | Next, we need to install a few dependencies from source. | ||
1039 | You might want to do this as a "normal" user and only run the | ||
1040 | @code{make install} steps as root (hence the @code{sudo} in the | ||
1041 | commands below). Also, you do this from any | ||
1042 | directory. We begin by downloading all dependencies, then extracting the | ||
1043 | sources, and finally compiling and installing the libraries:@ | ||
1044 | |||
1045 | @example | ||
1046 | $ wget https://libav.org/releases/libav-9.10.tar.xz | ||
1047 | $ wget http://ftp.gnu.org/gnu/libextractor/libextractor-1.3.tar.gz | ||
1048 | $ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.12.tar.bz2 | ||
1049 | $ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.0.tar.bz2 | ||
1050 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.2/gnutls-3.2.7.tar.xz | ||
1051 | $ wget http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.33.tar.gz | ||
1052 | $ wget https://gnunet.org/sites/default/files/gnurl-7.34.0.tar.bz2 | ||
1053 | $ tar xvf libextractor-1.3.tar.gz | ||
1054 | $ tar xvf libgpg-error-1.12.tar.bz2 | ||
1055 | $ tar xvf libgcrypt-1.6.0.tar.bz2 | ||
1056 | $ tar xvf gnutls-3.2.7.tar.xz | ||
1057 | $ tar xvf libmicrohttpd-0.9.33.tar.gz | ||
1058 | $ tar xvf gnurl-7.34.0.tar.bz2 | ||
1059 | $ cd libav-0.9 ; ./configure --enable-shared; | ||
1060 | $ make; sudo make install; cd .. | ||
1061 | $ cd libextractor-1.3 ; ./configure; | ||
1062 | $ make ; sudo make install; cd .. | ||
1063 | $ cd libgpg-error-1.12; ./configure; | ||
1064 | $ make ; sudo make install; cd .. | ||
1065 | $ cd libgcrypt-1.6.0; ./configure --with-gpg-error-prefix=/usr/local; | ||
1066 | $ make ; sudo make install ; cd .. | ||
1067 | $ cd gnutls-3.2.7 ; ./configure; | ||
1068 | $ make ; sudo make install ; cd .. | ||
1069 | $ cd libmicrohttpd-0.9.33; ./configure; | ||
1070 | $ make ; sudo make install ; cd .. | ||
1071 | $ cd gnurl-7.34.0 | ||
1072 | $ ./configure --enable-ipv6 --with-gnutls=/usr/local --without-libssh2 \ | ||
1073 | --without-libmetalink --without-winidn --without-librtmp \ | ||
1074 | --without-nghttp2 --without-nss --without-cyassl --without-polarssl \ | ||
1075 | --without-ssl --without-winssl --without-darwinssl --disable-sspi \ | ||
1076 | --disable-ntlm-wb --disable-ldap --disable-rtsp --disable-dict \ | ||
1077 | --disable-telnet --disable-tftp --disable-pop3 --disable-imap \ | ||
1078 | --disable-smtp --disable-gopher --disable-file --disable-ftp | ||
1079 | $ make ; sudo make install; cd .. | ||
1080 | @end example | ||
1081 | |||
1082 | @node Installing GNUnet from source | ||
1083 | @subsection Installing GNUnet from source | ||
1084 | |||
1085 | |||
1086 | For this, simply follow the generic installation instructions from | ||
1087 | here. | ||
1088 | |||
1089 | @node But wait there is more! | ||
1090 | @subsection But wait there is more! | ||
1091 | |||
1092 | So far, we installed all of the packages and dependencies required to | ||
1093 | ensure that all of GNUnet would be built. | ||
1094 | However, while for example the plugins to interact with the MySQL or | ||
1095 | Postgres databases have been created, we did not actually install or | ||
1096 | configure those databases. Thus, you will need to install | ||
1097 | and configure those databases or stick with the default Sqlite database. | ||
1098 | Sqlite is usually fine for most applications, but MySQL can offer better | ||
1099 | performance and Postgres better resillience. | ||
1100 | |||
1101 | |||
1102 | @node Installing GNUnet from Git on Ubuntu 14.4 | ||
1103 | @section Installing GNUnet from Git on Ubuntu 14.4 | ||
1104 | |||
1105 | @strong{Install the required build tools:} | ||
1106 | |||
1107 | @example | ||
1108 | $ sudo apt-get install git automake autopoint autoconf | ||
1109 | @end example | ||
1110 | |||
1111 | @strong{Install the required dependencies} | ||
1112 | |||
1113 | @example | ||
1114 | $ sudo apt-get install libltdl-dev libgpg-error-dev libidn11-dev \ | ||
1115 | libunistring-dev libglpk-dev libbluetooth-dev libextractor-dev \ | ||
1116 | libmicrohttpd-dev libgnutls28-dev | ||
1117 | @end example | ||
1118 | |||
1119 | @strong{Choose one or more database backends} | ||
1120 | |||
1121 | @itemize @bullet | ||
1122 | |||
1123 | @item SQLite3: | ||
1124 | |||
1125 | @example | ||
1126 | $ sudo apt-get install libsqlite3-dev | ||
1127 | @end example | ||
1128 | |||
1129 | @item MySQL: | ||
1130 | |||
1131 | @example | ||
1132 | $ sudo apt-get install libmysqlclient-dev | ||
1133 | @end example | ||
1134 | |||
1135 | @item PostgreSQL: | ||
1136 | |||
1137 | @example | ||
1138 | $ sudo apt-get install libpq-dev postgresql | ||
1139 | @end example | ||
1140 | |||
1141 | @end itemize | ||
1142 | |||
1143 | @strong{Install the optional dependencies for gnunet-conversation:} | ||
1144 | |||
1145 | @example | ||
1146 | $ sudo apt-get install gstreamer1.0 libpulse-dev libopus-dev | ||
1147 | @end example | ||
1148 | |||
1149 | @strong{Install the libgrypt 1.6.1:} | ||
1150 | |||
1151 | @itemize @bullet | ||
1152 | |||
1153 | @item For Ubuntu 14.04: | ||
1154 | |||
1155 | @example | ||
1156 | $ sudo apt-get install libgcrypt20-dev | ||
1157 | @end example | ||
1158 | |||
1159 | @item For Ubuntu older 14.04: | ||
1160 | |||
1161 | @example | ||
1162 | $ wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.1.tar.bz2 | ||
1163 | $ tar xf libgcrypt-1.6.1.tar.bz2 | ||
1164 | $ cd libgcrypt-1.6.1 | ||
1165 | $ ./configure | ||
1166 | $ sudo make install | ||
1167 | $ cd .. | ||
1168 | @end example | ||
1169 | |||
1170 | @end itemize | ||
1171 | |||
1172 | @strong{Install libgnurl} | ||
1173 | |||
1174 | @example | ||
1175 | $ wget https://gnunet.org/sites/default/files/gnurl-7.35.0.tar.bz2 | ||
1176 | $ tar xf gnurl-7.35.0.tar.bz2 | ||
1177 | $ cd gnurl-7.35.0 | ||
1178 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
1179 | --without-libmetalink --without-winidn --without-librtmp \ | ||
1180 | --without-nghttp2 --without-nss --without-cyassl --without-polarssl \ | ||
1181 | --without-ssl --without-winssl --without-darwinssl --disable-sspi \ | ||
1182 | --disable-ntlm-wb --disable-ldap --disable-rtsp --disable-dict \ | ||
1183 | --disable-telnet --disable-tftp --disable-pop3 --disable-imap \ | ||
1184 | --disable-smtp --disable-gopher --disable-file --disable-ftp | ||
1185 | $ sudo make install | ||
1186 | $ cd .. | ||
1187 | @end example | ||
1188 | |||
1189 | @strong{Install GNUnet} | ||
1190 | |||
1191 | @example | ||
1192 | $ git clone https://gnunet.org/git/gnunet/ | ||
1193 | $ cd gnunet/ | ||
1194 | $ ./bootstrap | ||
1195 | @end example | ||
1196 | |||
1197 | If you want to: | ||
1198 | |||
1199 | @itemize @bullet | ||
1200 | |||
1201 | @item Install to a different directory: | ||
1202 | |||
1203 | @example | ||
1204 | --prefix=PREFIX | ||
1205 | @end example | ||
1206 | |||
1207 | @item | ||
1208 | Have sudo permission, but do not want to compile as root: | ||
1209 | |||
1210 | @example | ||
1211 | --with-sudo | ||
1212 | @end example | ||
1213 | |||
1214 | @item | ||
1215 | Want debug message enabled: | ||
1216 | |||
1217 | @example | ||
1218 | --enable-logging=verbose | ||
1219 | @end example | ||
1220 | |||
1221 | @end itemize | ||
1222 | |||
1223 | |||
1224 | @example | ||
1225 | $ ./configure [ --with-sudo | --prefix=PREFIX | --enable-logging=verbose] | ||
1226 | $ make; sudo make install | ||
1227 | @end example | ||
1228 | |||
1229 | After installing it, you need to create an empty configuration file: | ||
1230 | |||
1231 | @example | ||
1232 | touch ~/.config/gnunet.conf | ||
1233 | @end example | ||
1234 | |||
1235 | And finally you can start GNUnet with | ||
1236 | |||
1237 | @example | ||
1238 | $ gnunet-arm -s | ||
1239 | @end example | ||
1240 | |||
1241 | @node Build instructions for Debian 8 | ||
1242 | @section Build instructions for Debian 8 | ||
1243 | @c FIXME: I -> we | ||
1244 | |||
1245 | These are the installation instructions for Debian 8. They were tested | ||
1246 | sing a fresh Debian 8 AMD64 installation without non-free software (no | ||
1247 | contrib or non-free). During installation, I only selected "lxde" for the | ||
1248 | desktop environment. | ||
1249 | Note that the packages and the dependencies that we will install during | ||
1250 | this chapter take about 1.5 GB of disk space. Combined with GNUnet and | ||
1251 | space for objects during compilation, you should not even attempt this | ||
1252 | unless you have about 2.5 GB free after the Debian installation. | ||
1253 | Using these instructions to build a VM image is likely to require a | ||
1254 | minimum of 4-5 GB for the VM (as you will likely also want a desktop | ||
1255 | manager). | ||
1256 | |||
1257 | GNUnet's security model assumes that your @code{/home} directory is | ||
1258 | encrypted. | ||
1259 | Thus, if possible, you should encrypt your entire disk, or at least just | ||
1260 | your home partition (or per-user home directory). | ||
1261 | |||
1262 | Naturally, the exact details of the starting state for your installation | ||
1263 | should not matter much. | ||
1264 | For example, if you selected any of those installation groups you might | ||
1265 | simply already have some of the necessary packages installed. Thus, it is | ||
1266 | suggested that you simply install the desktop environment of your choice | ||
1267 | before beginning with the instructions. | ||
1268 | |||
1269 | |||
1270 | @menu | ||
1271 | * Update Debian:: | ||
1272 | * Installing Debian Packages:: | ||
1273 | * Installing Dependencies from Source2:: | ||
1274 | * Installing GNUnet from Source2:: | ||
1275 | * But wait (again) there is more!:: | ||
1276 | @end menu | ||
1277 | |||
1278 | @node Update Debian | ||
1279 | @subsection Update Debian | ||
1280 | |||
1281 | After any installation, you should begin by running | ||
1282 | |||
1283 | @example | ||
1284 | # apt-get update | ||
1285 | # apt-get upgrade | ||
1286 | @end example | ||
1287 | |||
1288 | to ensure that all of your packages are up-to-date. Note that the "#" is | ||
1289 | used to indicate that you need to type in this command as "root" (or | ||
1290 | prefix with "sudo"), whereas "$" is used to indicate typing in a command | ||
1291 | as a normal user. | ||
1292 | |||
1293 | @node Installing Debian Packages | ||
1294 | @subsection Installing Debian Packages | ||
1295 | |||
1296 | We begin by installing a few Debian packages from stable: | ||
1297 | |||
1298 | @example | ||
1299 | # apt-get install gcc make python-zbar libltdl-dev libsqlite3-dev \ | ||
1300 | libunistring-dev libopus-dev libpulse-dev openssl libglpk-dev texlive \ | ||
1301 | libidn11-dev libmysqlclient-dev libpq-dev libarchive-dev libbz2-dev \ | ||
1302 | libflac-dev libgif-dev libglib2.0-dev libgtk-3-dev libmpeg2-4-dev \ | ||
1303 | libtidy-dev libvorbis-dev libogg-dev zlib1g-dev g++ gettext \ | ||
1304 | libgsf-1-dev libunbound-dev libqrencode-dev libgladeui-dev nasm \ | ||
1305 | texlive-latex-extra libunique-3.0-dev gawk miniupnpc libfuse-dev \ | ||
1306 | libbluetooth-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ | ||
1307 | libgstreamer-plugins-base1.0-dev nettle-dev libextractor-dev \ | ||
1308 | libgcrypt20-dev libmicrohttpd-dev | ||
1309 | @end example | ||
1310 | |||
1311 | @node Installing Dependencies from Source2 | ||
1312 | @subsection Installing Dependencies from Source2 | ||
1313 | |||
1314 | Yes, we said we start with a Debian 8 "stable" system, but because Debian | ||
1315 | linked GnuTLS without support for DANE, we need to compile a few things, | ||
1316 | in addition to GNUnet, still by hand. Yes, you can run GNUnet using the | ||
1317 | respective Debian packages, but then you will not get DANE support. | ||
1318 | |||
1319 | Next, we need to install a few dependencies from source. You might want | ||
1320 | to do this as a "normal" user and only run the @code{make install} steps | ||
1321 | as root (hence the @code{sudo} in the commands below). Also, you do this | ||
1322 | from any directory. We begin by downloading all dependencies, then | ||
1323 | extracting the sources, and finally compiling and installing the | ||
1324 | libraries: | ||
1325 | |||
1326 | @example | ||
1327 | $ wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/gnutls-3.3.12.tar.xz | ||
1328 | $ wget https://gnunet.org/sites/default/files/gnurl-7.40.0.tar.bz2 | ||
1329 | $ tar xvf gnutls-3.3.12.tar.xz | ||
1330 | $ tar xvf gnurl-7.40.0.tar.bz2 | ||
1331 | $ cd gnutls-3.3.12 ; ./configure ; make ; sudo make install ; cd .. | ||
1332 | $ cd gnurl-7.40.0 | ||
1333 | $ ./configure --enable-ipv6 --with-gnutls=/usr/local --without-libssh2 \ | ||
1334 | --without-libmetalink --without-winidn --without-librtmp \ | ||
1335 | --without-nghttp2 --without-nss --without-cyassl --without-polarssl \ | ||
1336 | --without-ssl --without-winssl --without-darwinssl --disable-sspi \ | ||
1337 | --disable-ntlm-wb --disable-ldap --disable-rtsp --disable-dict \ | ||
1338 | --disable-telnet --disable-tftp --disable-pop3 --disable-imap \ | ||
1339 | --disable-smtp --disable-gopher --disable-file --disable-ftp \ | ||
1340 | --disable-smb | ||
1341 | $ make ; sudo make install; cd .. | ||
1342 | @end example | ||
1343 | |||
1344 | @node Installing GNUnet from Source2 | ||
1345 | @subsection Installing GNUnet from Source2 | ||
1346 | |||
1347 | For this, simply follow the generic installation instructions from@ | ||
1348 | here. | ||
1349 | |||
1350 | @node But wait (again) there is more! | ||
1351 | @subsection But wait (again) there is more! | ||
1352 | |||
1353 | So far, we installed all of the packages and dependencies required to | ||
1354 | ensure that all of GNUnet would be built. However, while for example the | ||
1355 | plugins to interact with the MySQL or Postgres databases have been | ||
1356 | created, we did not actually install or configure those databases. | ||
1357 | Thus, you will need to install and configure those databases or stick | ||
1358 | with the default Sqlite database. Sqlite is usually fine for most | ||
1359 | applications, but MySQL can offer better performance and Postgres better | ||
1360 | resillience. | ||
1361 | |||
1362 | @node Outdated build instructions for previous revisions | ||
1363 | @section Outdated build instructions for previous revisions | ||
1364 | |||
1365 | This chapter contains a collection of outdated, older installation guides. | ||
1366 | They are mostly intended to serve as a starting point for writing | ||
1367 | up-to-date instructions and should not be expected to work for | ||
1368 | GNUnet 0.10.x. | ||
1369 | A set of older installation instructions can also be found in the | ||
1370 | file @file{doc/outdated-and-old-installation-instructions.txt} in the | ||
1371 | source tree of GNUnet. | ||
1372 | |||
1373 | This file covers old instructions which no longer receive security | ||
1374 | updates or any kind of support. | ||
1375 | |||
1376 | @menu | ||
1377 | * Installing GNUnet 0.10.1 on Ubuntu 14.04:: | ||
1378 | * Building GLPK for MinGW:: | ||
1379 | * GUI build instructions for Ubuntu 12.04 using Subversion:: | ||
1380 | @c * Installation with gnunet-update:: | ||
1381 | * Instructions for Microsoft Windows Platforms (Old):: | ||
1382 | @end menu | ||
1383 | |||
1384 | |||
1385 | @node Installing GNUnet 0.10.1 on Ubuntu 14.04 | ||
1386 | @subsection Installing GNUnet 0.10.1 on Ubuntu 14.04 | ||
1387 | |||
1388 | Install the required dependencies: | ||
1389 | |||
1390 | @example | ||
1391 | $ sudo apt-get install libltdl-dev libgpg-error-dev libidn11-dev \ | ||
1392 | libunistring-dev libglpk-dev libbluetooth-dev libextractor-dev \ | ||
1393 | libmicrohttpd-dev libgnutls28-dev | ||
1394 | @end example | ||
1395 | |||
1396 | Choose one or more database backends: | ||
1397 | |||
1398 | @itemize @bullet | ||
1399 | |||
1400 | @item SQLite3 | ||
1401 | |||
1402 | @example | ||
1403 | $ sudo apt-get install libsqlite3-dev@ | ||
1404 | @end example | ||
1405 | |||
1406 | @item MySQL | ||
1407 | |||
1408 | @example | ||
1409 | $ sudo apt-get install libmysqlclient-dev@ | ||
1410 | @end example | ||
1411 | |||
1412 | @item PostgreSQL | ||
1413 | |||
1414 | @example | ||
1415 | $ sudo apt-get install libpq-dev postgresql@ | ||
1416 | @end example | ||
1417 | |||
1418 | @end itemize | ||
1419 | |||
1420 | Install the optional dependencies for gnunet-conversation: | ||
1421 | |||
1422 | @example | ||
1423 | $ sudo apt-get install gstreamer1.0 libpulse-dev libopus-dev | ||
1424 | @end example | ||
1425 | |||
1426 | Install libgcrypt 1.6: | ||
1427 | |||
1428 | @itemize @bullet | ||
1429 | |||
1430 | @item For Ubuntu 14.04: | ||
1431 | |||
1432 | @example | ||
1433 | $ sudo apt-get install libgcrypt20-dev | ||
1434 | @end example | ||
1435 | |||
1436 | @item For Ubuntu older than 14.04: | ||
1437 | |||
1438 | @example | ||
1439 | wget ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.6.1.tar.bz2 | ||
1440 | $ tar xf libgcrypt-1.6.1.tar.bz2 | ||
1441 | $ cd libgcrypt-1.6.1 | ||
1442 | $ ./configure | ||
1443 | $ sudo make install | ||
1444 | $ cd .. | ||
1445 | @end example | ||
1446 | @end itemize | ||
1447 | |||
1448 | Install libgnurl: | ||
1449 | |||
1450 | @example | ||
1451 | $ wget https://gnunet.org/sites/default/files/gnurl-7.35.0.tar.bz2 | ||
1452 | $ tar xf gnurl-7.35.0.tar.bz2 | ||
1453 | $ cd gnurl-7.35.0 | ||
1454 | $ ./configure --enable-ipv6 --with-gnutls --without-libssh2 \ | ||
1455 | --without-libmetalink --without-winidn --without-librtmp | ||
1456 | --without-nghttp2 --without-nss --without-cyassl --without-polarssl \ | ||
1457 | --without-ssl --without-winssl --without-darwinssl --disable-sspi \ | ||
1458 | --disable-ntlm-wb --disable-ldap --disable-rtsp --disable-dict \ | ||
1459 | --disable-telnet --disable-tftp --disable-pop3 --disable-imap \ | ||
1460 | --disable-smtp --disable-gopher --disable-file --disable-ftp | ||
1461 | $ sudo make install@ | ||
1462 | $ cd ..@ | ||
1463 | @end example | ||
1464 | |||
1465 | Install GNUnet: | ||
1466 | |||
1467 | @example | ||
1468 | $ wget http://ftpmirror.gnu.org/gnunet/gnunet-0.10.1.tar.gz | ||
1469 | $ tar xf gnunet-0.10.1.tar.gz | ||
1470 | $ cd gnunet-0.10.1 | ||
1471 | @end example | ||
1472 | |||
1473 | If you want to: | ||
1474 | |||
1475 | @itemize @bullet | ||
1476 | |||
1477 | @item | ||
1478 | Install to a different directory: | ||
1479 | |||
1480 | @example | ||
1481 | --prefix=PREFIX | ||
1482 | @end example | ||
1483 | |||
1484 | @item | ||
1485 | Have sudo permission, but do not want to compile as root: | ||
1486 | |||
1487 | @example | ||
1488 | --with-sudo | ||
1489 | @end example | ||
1490 | |||
1491 | @item | ||
1492 | Want debug message enabled: | ||
1493 | |||
1494 | @example | ||
1495 | --enable-logging=verbose | ||
1496 | @end example | ||
1497 | |||
1498 | @end itemize | ||
1499 | |||
1500 | @example | ||
1501 | $ ./configure [ --with-sudo | --prefix=PREFIX | --enable-logging=verbose] | ||
1502 | $ make; sudo make install | ||
1503 | @end example | ||
1504 | |||
1505 | After installing it, you need to create an empty configuration file: | ||
1506 | |||
1507 | @example | ||
1508 | touch ~/.config/gnunet.conf | ||
1509 | @end example | ||
1510 | |||
1511 | And finally you can start GNUnet with | ||
1512 | |||
1513 | @example | ||
1514 | $ gnunet-arm -s | ||
1515 | @end example | ||
1516 | |||
1517 | @node Building GLPK for MinGW | ||
1518 | @subsection Building GLPK for MinGW | ||
1519 | |||
1520 | GNUnet now requires the GNU Linear Programming Kit (GLPK). | ||
1521 | Since there's is no package you can install with @code{mingw-get} you | ||
1522 | have to compile it from source: | ||
1523 | |||
1524 | @itemize @bullet | ||
1525 | |||
1526 | @item Download the latest version from | ||
1527 | @uref{http://ftp.gnu.org/gnu/glpk/} | ||
1528 | |||
1529 | @item Unzip the downloaded source tarball using your favourite | ||
1530 | unzipper application In the MSYS shell | ||
1531 | |||
1532 | @item change to the respective directory | ||
1533 | |||
1534 | @item Configure glpk for "i686-pc-mingw32": | ||
1535 | |||
1536 | @example | ||
1537 | ./configure '--build=i686-pc-mingw32' | ||
1538 | @end example | ||
1539 | |||
1540 | @item run | ||
1541 | |||
1542 | @example | ||
1543 | make install check | ||
1544 | @end example | ||
1545 | |||
1546 | @end itemize | ||
1547 | |||
1548 | MinGW does not automatically detect the correct buildtype so you have to | ||
1549 | specify it manually. | ||
1550 | |||
1551 | |||
1552 | @node GUI build instructions for Ubuntu 12.04 using Subversion | ||
1553 | @subsection GUI build instructions for Ubuntu 12.04 using Subversion | ||
1554 | |||
1555 | After installing GNUnet you can continue installing the GNUnet GUI tools: | ||
1556 | |||
1557 | First, install the required dependencies: | ||
1558 | |||
1559 | @example | ||
1560 | $ sudo apt-get install libgladeui-dev libqrencode-dev | ||
1561 | @end example | ||
1562 | |||
1563 | Please ensure that the GNUnet shared libraries can be found by the linker. | ||
1564 | If you installed GNUnet libraries in a non standard path | ||
1565 | (say GNUNET_PREFIX=/usr/local/lib/), you can | ||
1566 | |||
1567 | @itemize @bullet | ||
1568 | |||
1569 | @item set the environmental variable permanently to: | ||
1570 | |||
1571 | @example | ||
1572 | LD_LIBRARY_PATH=$GNUNET_PREFIX | ||
1573 | @end example | ||
1574 | |||
1575 | @item or add @code{$GNUNET_PREFIX} to @file{/etc/ld.so.conf} | ||
1576 | |||
1577 | @end itemize | ||
1578 | |||
1579 | Now you can checkout and compile the GNUnet GUI tools: | ||
1580 | |||
1581 | @example | ||
1582 | $ git clone https://gnunet.org/git/gnunet-gtk | ||
1583 | $ cd gnunet-gtk | ||
1584 | $ ./bootstrap | ||
1585 | $ ./configure --prefix=$GNUNET_PREFIX/.. --with-gnunet=$GNUNET_PREFIX/.. | ||
1586 | $ make install | ||
1587 | @end example | ||
1588 | |||
1589 | @c @node Installation with gnunet-update | ||
1590 | @c @subsection Installation with gnunet-update | ||
1591 | |||
1592 | @c gnunet-update project is an effort to introduce updates to GNUnet | ||
1593 | @c installations. An interesting to-be-implemented-feature of gnunet-update | ||
1594 | @c is that these updates are propagated through GNUnet's peer-to-peer | ||
1595 | @c network. More information about gnunet-update can be found at | ||
1596 | @c @c FIXME: Use correct cgit URL | ||
1597 | @c @uref{https://gnunet.org/git/gnunet-update.git/tree/plain/README}. | ||
1598 | |||
1599 | @c While the project is still under development, we have implemented the | ||
1600 | @c following features which we believe may be helpful for users and we | ||
1601 | @c would like them to be tested: | ||
1602 | |||
1603 | @c @itemize @bullet | ||
1604 | |||
1605 | @c @item | ||
1606 | @c Packaging GNUnet installation along with its run-time dependencies into | ||
1607 | @c update packages | ||
1608 | |||
1609 | @c @item | ||
1610 | @c Installing update packages into compatible hosts | ||
1611 | |||
1612 | @c @item | ||
1613 | @c Updating an existing installation (which had been installed by | ||
1614 | @c gnunet-update) to a newer one | ||
1615 | |||
1616 | @c @end itemize | ||
1617 | |||
1618 | @c The above said features of gnunet-update are currently available for | ||
1619 | @c testing on GNU/Linux systems. | ||
1620 | |||
1621 | @c The following is a guide to help you get started with gnunet-update. | ||
1622 | @c It shows you how to install the testing binary packages of GNUnet | ||
1623 | @c 0.9.1 we have at @uref{https://gnunet.org/install/}. | ||
1624 | |||
1625 | @c gnunet-update needs the following dependencies: | ||
1626 | |||
1627 | @c @itemize @bullet | ||
1628 | @c @item | ||
1629 | @c python @geq{} 2.6 | ||
1630 | |||
1631 | @c @item | ||
1632 | @c gnupg | ||
1633 | |||
1634 | @c @item | ||
1635 | @c python-gpgme | ||
1636 | @c @end itemize | ||
1637 | |||
1638 | |||
1639 | @c Checkout gnunet-update: | ||
1640 | |||
1641 | @c @c FIXME: git! | ||
1642 | @c @example | ||
1643 | @c $ svn checkout -r24905 https://gnunet.org/svn/gnunet-update@ | ||
1644 | @c @end example | ||
1645 | |||
1646 | @c For security reasons, all packages released for gnunet-update from us are | ||
1647 | @c signed with the key at @uref{https://gnunet.org/install/key.txt}. | ||
1648 | @c You would need to import this key into your gpg key ring. | ||
1649 | @c gnunet-update uses this key to verify the integrity of the packages it | ||
1650 | @c installs: | ||
1651 | |||
1652 | @c @example | ||
1653 | @c $ gpg --recv-keys 7C613D78@ | ||
1654 | @c @end example | ||
1655 | |||
1656 | @c Download the packages relevant to your architecture (currently I have | ||
1657 | @c access to GNU/Linux machines on x86_64 and i686, so only two for now, | ||
1658 | @c hopefully more later) from https://gnunet.org/install/. | ||
1659 | |||
1660 | @c To install the downloaded package into the directory /foo: | ||
1661 | |||
1662 | @c @example | ||
1663 | @c gnunet-update/bin/gnunet-update install downloaded/package /foo | ||
1664 | @c @end example | ||
1665 | |||
1666 | @c The installer reports the directories into which shared libraries and | ||
1667 | @c dependencies have been installed. You may need to add the reported shared | ||
1668 | @c library installation paths to LD_LIBRARY_PATH before you start running any | ||
1669 | @c installed binaries. | ||
1670 | |||
1671 | @c Please report bugs at https://gnunet.org/bugs/ under the project | ||
1672 | @c 'gnunet-update'. | ||
1673 | |||
1674 | @node Instructions for Microsoft Windows Platforms (Old) | ||
1675 | @subsection Instructions for Microsoft Windows Platforms (Old) | ||
1676 | |||
1677 | This document is a @b{DEPRECATED} installation guide for GNUnet on | ||
1678 | Windows. | ||
1679 | It will not work for recent GNUnet versions, but maybe it will be of | ||
1680 | some use if problems arise. | ||
1681 | |||
1682 | The Windows build uses a UNIX emulator for Windows, | ||
1683 | @uref{http://www.mingw.org/, MinGW}, to build the executable modules. | ||
1684 | These modules run natively on Windows and do not require additional | ||
1685 | emulation software besides the usual dependencies. | ||
1686 | |||
1687 | GNUnet development is mostly done under GNU/Linux and especially git | ||
1688 | checkouts may not build out of the box. | ||
1689 | We regret any inconvenience, and if you have problems, please report them. | ||
1690 | |||
1691 | @menu | ||
1692 | * Hardware and OS requirements:: | ||
1693 | * Software installation:: | ||
1694 | * Building libextractor and GNUnet:: | ||
1695 | * Installer:: | ||
1696 | * Source:: | ||
1697 | @end menu | ||
1698 | |||
1699 | @node Hardware and OS requirements | ||
1700 | @subsubsection Hardware and OS requirements | ||
1701 | |||
1702 | @itemize @bullet | ||
1703 | |||
1704 | @item Pentium II or equivalent processor, @geq{} 350 MHz | ||
1705 | |||
1706 | @item 128 MB RAM | ||
1707 | |||
1708 | @item 600 MB free disk space | ||
1709 | |||
1710 | @item Windows 2000 or Windows XP are recommended | ||
1711 | |||
1712 | @end itemize | ||
1713 | |||
1714 | @node Software installation | ||
1715 | @subsubsection Software installation | ||
1716 | |||
1717 | @itemize @bullet | ||
1718 | |||
1719 | @item | ||
1720 | @strong{Compression software}@ | ||
1721 | |||
1722 | The software packages GNUnet depends on are usually compressed using UNIX | ||
1723 | tools like @command{tar}, @command{gzip}, @command{xzip} and | ||
1724 | @command{bzip2}. | ||
1725 | If you do not already have an utility that is able to extract such | ||
1726 | archives, get @uref{http://www.7-zip.org/, 7-Zip}. | ||
1727 | |||
1728 | @item | ||
1729 | @strong{UNIX environment}@ | ||
1730 | |||
1731 | The MinGW project provides the compiler toolchain that is used to build | ||
1732 | GNUnet. | ||
1733 | Get the following packages from the | ||
1734 | @uref{http://sourceforge.net/projects/mingw/files/, MinGW} project: | ||
1735 | |||
1736 | @itemize @bullet | ||
1737 | |||
1738 | @item GCC core | ||
1739 | @item GCC g++ | ||
1740 | @item MSYS | ||
1741 | @item MSYS Developer Tool Kit (msysDTK) | ||
1742 | @item MSYS Developer Tool Kit - msys-autoconf (bin) | ||
1743 | @item MSYS Developer Tool Kit - msys-automake (bin) | ||
1744 | @item MinGW Runtime | ||
1745 | @item MinGW Utilities | ||
1746 | @item Windows API | ||
1747 | @item Binutils | ||
1748 | @item make | ||
1749 | @item pdcurses | ||
1750 | @item GDB (snapshot) | ||
1751 | @end itemize | ||
1752 | |||
1753 | @itemize @bullet | ||
1754 | |||
1755 | |||
1756 | @item Install MSYS (to c:\mingw, for example.)@ | ||
1757 | Do @strong{not} use spaces in the pathname. | ||
1758 | For example, avoid a location such as @file{c:\program files\mingw}. | ||
1759 | |||
1760 | @item Install MinGW runtime, utilities and GCC to a subdirectory | ||
1761 | (to @file{c:\mingw\mingw}, for example) | ||
1762 | |||
1763 | @item Install the Development Kit to the MSYS directory | ||
1764 | (@file{c:\mingw}) | ||
1765 | |||
1766 | @item Create a batch file bash.bat in your MSYS directory with | ||
1767 | the files: | ||
1768 | |||
1769 | @example | ||
1770 | bin\sh.exe --login | ||
1771 | @end example | ||
1772 | |||
1773 | This batch file opens a shell which is used to invoke the build | ||
1774 | processes. | ||
1775 | MinGW's standard shell (@command{msys.bat}) is not suitable | ||
1776 | because it opens a separate console window. | ||
1777 | On Vista, @command{bash.bat} needs to be run as Administrator. | ||
1778 | |||
1779 | @item | ||
1780 | Start @command{bash.sh} and rename | ||
1781 | @file{c:\mingw\mingw\lib\libstdc++.la} to avoid problems: | ||
1782 | |||
1783 | @example | ||
1784 | mv /usr/mingw/lib/libstdc++.la /usr/mingw/lib/libstdc++.la.broken | ||
1785 | @end example | ||
1786 | |||
1787 | @item | ||
1788 | Unpack the Windows API to the MinGW directory (@file{c:\mingw\mingw\}) and | ||
1789 | remove the declaration of DATADIR from | ||
1790 | (@file{c:\mingw\mingw\include\objidl.h} (lines 55-58) | ||
1791 | |||
1792 | @item | ||
1793 | Unpack autoconf, automake to the MSYS directory (@file{c:\mingw}) | ||
1794 | |||
1795 | @item | ||
1796 | Install all other packages to the MinGW directory (@file{c:\mingw\mingw\}) | ||
1797 | @end itemize | ||
1798 | |||
1799 | |||
1800 | @item @strong{GNU Libtool}@ | ||
1801 | GNU Libtool is required to use shared libraries. | ||
1802 | Get the prebuilt package from here and unpack it to the | ||
1803 | MinGW directory (@file{c:\mingw}) | ||
1804 | |||
1805 | @item @strong{Pthreads}@ | ||
1806 | GNUnet uses the portable POSIX thread library for multi-threading: | ||
1807 | |||
1808 | @itemize @bullet | ||
1809 | |||
1810 | @item Save | ||
1811 | @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x86/libpthreadGC2.a, libpthreadGC2.a} | ||
1812 | (x86) or | ||
1813 | @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x64/libpthreadGC2.a, libpthreadGC2.a} | ||
1814 | (x64) as libpthread.a into the @file{lib} | ||
1815 | directory (@file{c:\mingw\mingw\lib\libpthread.a}). | ||
1816 | |||
1817 | @item Save | ||
1818 | @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x86/pthreadGC2.dll, pthreadGC2.dll} | ||
1819 | (x86) or | ||
1820 | @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/lib/x64/pthreadGC2.dll, libpthreadGC2.a} | ||
1821 | (x64) into the MinGW @file{bin} directory (@file{c:\mingw\mingw\bin}). | ||
1822 | |||
1823 | @item Download all header files from | ||
1824 | @uref{ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/include/, include/} | ||
1825 | to the @file{include} directory (@file{c:\mingw\mingw\include}). | ||
1826 | @end itemize | ||
1827 | |||
1828 | |||
1829 | @item @strong{GNU MP}@ | ||
1830 | GNUnet uses the GNU Multiple Precision library for special cryptographic | ||
1831 | operations. Get the GMP binary package from the | ||
1832 | @uref{http://sourceforge.net/projects/mingwrep/, MinGW repository} and | ||
1833 | unpack it to the MinGW directory (@file{c:\mingw\mingw}) | ||
1834 | |||
1835 | @item @strong{GNU Gettext}@ | ||
1836 | GNU gettext is used to provide national language support. | ||
1837 | Get the prebuilt package from hereand unpack it to the MinGW | ||
1838 | directory (@file{c:\mingw\mingw}) | ||
1839 | |||
1840 | @item @strong{GNU iconv}@ | ||
1841 | GNU Libiconv is used for character encoding conversion. | ||
1842 | Get the prebuilt package from here and unpack it to the MinGW | ||
1843 | directory (@file{c:\mingw\mingw}). | ||
1844 | |||
1845 | @item @strong{SQLite}@ | ||
1846 | GNUnet uses the SQLite database to store data. | ||
1847 | Get the prebuilt binary from here and unpack it to your MinGW directory. | ||
1848 | |||
1849 | @item @strong{MySQL}@ | ||
1850 | As an alternative to SQLite, GNUnet also supports MySQL. | ||
1851 | |||
1852 | @itemize @bullet | ||
1853 | |||
1854 | @item Get the binary installer from the | ||
1855 | @uref{http://dev.mysql.com/downloads/mysql/4.1.html#Windows, MySQL project} | ||
1856 | (version 4.1), install it and follow the instructions in | ||
1857 | @file{README.mysql}. | ||
1858 | |||
1859 | @item Create a temporary build directory (@file{c:\mysql}) | ||
1860 | |||
1861 | @item Copy the directories @file{include\} and @file{lib\} from the | ||
1862 | MySQL directory to the new directory | ||
1863 | |||
1864 | @item Get the patches from | ||
1865 | @uref{http://bugs.mysql.com/bug.php?id=8906&files=1, Bug #8906} and | ||
1866 | @uref{http://bugs.mysql.com/bug.php?id=8872&files=1, Bug #8872} (the | ||
1867 | latter is only required for MySQL | ||
1868 | |||
1869 | @example | ||
1870 | patch -p 0 | ||
1871 | @end example | ||
1872 | |||
1873 | @item Move @file{lib\opt\libmysql.dll} to @file{lib\libmysql.dll} | ||
1874 | |||
1875 | @item Change to @file{lib\} and create an import library: | ||
1876 | |||
1877 | @example | ||
1878 | dlltool --input-def ../include/libmySQL.def \ | ||
1879 | --dllname libmysql.dll \ | ||
1880 | --output-lib libmysqlclient.a -k | ||
1881 | @end example | ||
1882 | |||
1883 | @item Copy include\* to include\mysql\ | ||
1884 | |||
1885 | @item Pass "@code{--with-mysql=/c/mysql}" to | ||
1886 | @command{./configure} and copy @file{libmysql.dll} | ||
1887 | to your PATH or GNUnet's @file{bin} directory | ||
1888 | @end itemize | ||
1889 | |||
1890 | |||
1891 | @item @strong{GTK+}@ | ||
1892 | @command{gnunet-gtk} and @command{libextractor} depend on GTK. | ||
1893 | Get the the binary and developer packages of @command{atk}, | ||
1894 | @command{glib}, @command{gtk}, @command{iconv}, | ||
1895 | @command{gettext-runtime}, @command{pango} from | ||
1896 | @uref{ftp://ftp.gtk.org/pub/gtk/v2.6/win32, gtk.org} and unpack them | ||
1897 | to the MinGW directory (@file{c:\mingw\mingw}). | ||
1898 | @c FIXME: The URL below for pkg-config seems wrong. | ||
1899 | Get @uref{http://www.gtk.org/download/win32.php, pkg-config} and | ||
1900 | @command{libpng} and unpack them to the MinGW directory | ||
1901 | (@file{c:\mingw\mingw}). | ||
1902 | Here is an all-in-one package for the | ||
1903 | @uref{http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip, gtk+dependencies} | ||
1904 | . Do not overwrite any existing files! | ||
1905 | |||
1906 | @item @strong{Glade}@ | ||
1907 | @command{gnunet-gtk} and @command{gnunet-setup} were created using | ||
1908 | this interface builder | ||
1909 | |||
1910 | @itemize @bullet | ||
1911 | |||
1912 | @item Get the Glade and libglade (-bin and -devel) packages | ||
1913 | (without GTK!) from | ||
1914 | @uref{http://gladewin32.sourceforge.net/, GladeWin32} and unpack them to | ||
1915 | the MinGW directory (@file{c:\mingw\mingw}). | ||
1916 | |||
1917 | @item Get @command{libxml} from here and unpack it to the MinGW | ||
1918 | directory (@file{c:\mingw\mingw}). | ||
1919 | @end itemize | ||
1920 | |||
1921 | @c FIXME: URLs | ||
1922 | @item @strong{zLib}@ | ||
1923 | @command{libextractor} requires @command{zLib} to decompress some file | ||
1924 | formats. GNUnet uses it to (de)compress meta-data. | ||
1925 | Get zLib from here (Signature) and unpack it to the MinGW directory | ||
1926 | (@file{c:\mingw\mingw}). | ||
1927 | |||
1928 | @item @strong{Bzip2}@ | ||
1929 | @command{libextractor} also requires @command{Bzip2} to | ||
1930 | decompress some file formats. | ||
1931 | Get the Bzip2 (binary and developer package) from | ||
1932 | @uref{http://gnuwin32.sourceforge.net/packages/bzip2.htm, GnuWin32} and | ||
1933 | unpack it to the MinGW directory (@file{c:\mingw\mingw}). | ||
1934 | |||
1935 | @item @strong{Libgcrypt}@ | ||
1936 | @command{Libgcrypt} provides the cryptographic functions used by GNUnet. | ||
1937 | Get Libgcrypt from @uref{ftp://ftp.gnupg.org/gcrypt/libgcrypt/, here}, | ||
1938 | compile and place it in the MinGW directory | ||
1939 | (@file{c:\mingw\mingw}). Currently libgcrypt @geq{} 1.4.2 is required to | ||
1940 | compile GNUnet. | ||
1941 | |||
1942 | @item @strong{PlibC}@ | ||
1943 | PlibC emulates Unix functions under Windows. Get PlibC from here and | ||
1944 | unpack it to the MinGW directory (c:\mingw\mingw) | ||
1945 | |||
1946 | @item @strong{OGG Vorbis}@ | ||
1947 | @command{OGG Vorbis} is used to extract meta-data from @file{.ogg} files. | ||
1948 | Get the packages | ||
1949 | @uref{http://www.gnunet.org/libextractor/download/win/libogg-1.1.4.zip, libogg} | ||
1950 | and | ||
1951 | @uref{http://www.gnunet.org/libextractor/download/win/libvorbis-1.2.3.zip, libvorbis} | ||
1952 | from the | ||
1953 | @uref{http://ftp.gnu.org/gnu/libextractor/libextractor-w32-1.0.0.zip, libextractor win32 build} | ||
1954 | and unpack them to the MinGW directory (c:\mingw\mingw). | ||
1955 | |||
1956 | @item @strong{Exiv2}@ | ||
1957 | (lib)Exiv2 is used to extract meta-data from files with Exiv2 meta-data. | ||
1958 | Download | ||
1959 | @uref{http://www.gnunet.org/libextractor/download/win/exiv2-0.18.2.zip, Exiv2} | ||
1960 | and unpack it to the MSYS directory (c:\mingw). | ||
1961 | @end itemize | ||
1962 | |||
1963 | @node Building libextractor and GNUnet | ||
1964 | @subsubsection Building libextractor and GNUnet | ||
1965 | |||
1966 | Before you compile @command{libextractor} or @command{GNUnet}, | ||
1967 | be sure to set @code{PKG_CONFIG_PATH}: | ||
1968 | |||
1969 | @example | ||
1970 | export PKG_CONFIG_PATH=/mingw/lib/pkgconfig | ||
1971 | @end example | ||
1972 | |||
1973 | @noindent | ||
1974 | @xref{GNUnet Installation Handbook}, for basic instructions on building | ||
1975 | @command{libextractor} and @command{GNUnet}. | ||
1976 | By default, all modules that are created in this way contain | ||
1977 | debug information and are quite large. To compile release versions | ||
1978 | (small and fast) set the variable @code{CFLAGS}: | ||
1979 | |||
1980 | @example | ||
1981 | export CFLAGS='-O2 -march=pentium -fomit-frame-pointer' | ||
1982 | ./configure --prefix=$HOME --with-extractor=$HOME | ||
1983 | @end example | ||
1984 | |||
1985 | @node Installer | ||
1986 | @subsubsection Installer | ||
1987 | |||
1988 | The GNUnet installer is made with | ||
1989 | @uref{http://nsis.sourceforge.net/, NSIS}. The installer script is | ||
1990 | located in @file{contrib\win} in the GNUnet source tree. | ||
1991 | |||
1992 | @node Source | ||
1993 | @subsubsection Source | ||
1994 | |||
1995 | @c FIXME: URL | ||
1996 | The sources of all dependencies are available here. | ||
1997 | |||
1998 | @c @node Portable GNUnet | ||
1999 | @c @section Portable GNUnet | ||
2000 | |||
2001 | @c Quick instructions on how to use the most recent GNUnet on most GNU/Linux | ||
2002 | @c distributions | ||
2003 | |||
2004 | @c Currently this has only been tested on Ubuntu 12.04, 12.10, 13.04, Debian | ||
2005 | @c and CentOS 6, but it should work on almost any GNU/Linux distribution. | ||
2006 | @c More in-detail information can be found in the handbook. | ||
2007 | |||
2008 | @c Note 2017-10: Currently this section assumes the old SVN repo of GNUnet | ||
2009 | @c which no longer exists. | ||
2010 | |||
2011 | @c @menu | ||
2012 | @c * Prerequisites:: | ||
2013 | @c * Download & set up gnunet-update:: | ||
2014 | @c * Install GNUnet:: | ||
2015 | @c @end menu | ||
2016 | |||
2017 | @c @node Prerequisites | ||
2018 | @c @subsection Prerequisites | ||
2019 | |||
2020 | @c Open a terminal and paste this line into it to install all required tools | ||
2021 | @c needed: | ||
2022 | |||
2023 | @c @example | ||
2024 | @c sudo apt-get install python-gpgme subversion | ||
2025 | @c @end example | ||
2026 | |||
2027 | @c @node Download & set up gnunet-update | ||
2028 | @c @subsection Download & set up gnunet-update | ||
2029 | |||
2030 | @c The following command will download a working version of gnunet-update | ||
2031 | @c with the subversion tool and import the public key which is needed for | ||
2032 | @c authentication: | ||
2033 | |||
2034 | @c @example | ||
2035 | @c svn checkout -r24905 https://gnunet.org/svn/gnunet-update ~/gnunet-update | ||
2036 | @c cd ~/gnunet-update | ||
2037 | @c gpg --keyserver "hkp://keys.gnupg.net" --recv-keys 7C613D78 | ||
2038 | @c @end example | ||
2039 | |||
2040 | @c @node Install GNUnet | ||
2041 | @c @subsection Install GNUnet | ||
2042 | |||
2043 | @c Download and install GNUnet binaries which can be found here and set | ||
2044 | @c library paths: | ||
2045 | |||
2046 | @c @example | ||
2047 | @c wget -P /tmp https://gnunet.org/install/packs/gnunet-0.9.4-`uname -m`.tgz | ||
2048 | @c ./bin/gnunet-update install /tmp/gnunet-0.9*.tgz ~ | ||
2049 | @c echo "PATH DEFAULT=$@{PATH@}:$HOME/bin" >> ~/.pam_environment | ||
2050 | @c echo -e "$@{HOME@}/lib\n$@{HOME@}/lib/gnunet-deps" | sudo tee \ | ||
2051 | @c /etc/ld.so.conf.d/gnunet.conf > /dev/null | ||
2052 | @c sudo ldconfig | ||
2053 | @c @end example | ||
2054 | |||
2055 | @c You may need to re-login once after executing these last commands | ||
2056 | |||
2057 | @c That's it, GNUnet is installed in your home directory now. GNUnet can be | ||
2058 | @c configured and afterwards started by executing: | ||
2059 | |||
2060 | @c @example | ||
2061 | @c gnunet-arm -s | ||
2062 | @c @end example | ||
2063 | |||
2064 | @node The graphical configuration interface | ||
2065 | @section The graphical configuration interface | ||
2066 | |||
2067 | If you also would like to use @command{gnunet-gtk} and | ||
2068 | @command{gnunet-setup} (highly recommended for beginners), do: | ||
2069 | |||
2070 | @example | ||
2071 | wget -P /tmp \ | ||
2072 | https://gnunet.org/install/packs/gnunet-0.9.4-gtk-0.9.4-`uname -m`.tgz | ||
2073 | sh ~/gnunet-update/bin/gnunet-update install /tmp/gnunet-*gtk*.tgz ~ | ||
2074 | sudo ldconfig | ||
2075 | @end example | ||
2076 | |||
2077 | Now you can run @command{gnunet-setup} for easy configuration of your | ||
2078 | GNUnet peer. | ||
2079 | |||
2080 | @menu | ||
2081 | * Configuring your peer:: | ||
2082 | * Configuring the Friend-to-Friend (F2F) mode:: | ||
2083 | * Configuring the hostlist to bootstrap:: | ||
2084 | * Configuration of the HOSTLIST proxy settings:: | ||
2085 | * Configuring your peer to provide a hostlist :: | ||
2086 | * Configuring the datastore:: | ||
2087 | * Configuring the MySQL database:: | ||
2088 | * Reasons for using MySQL:: | ||
2089 | * Reasons for not using MySQL:: | ||
2090 | * Setup Instructions:: | ||
2091 | * Testing:: | ||
2092 | * Performance Tuning:: | ||
2093 | * Setup for running Testcases:: | ||
2094 | * Configuring the Postgres database:: | ||
2095 | * Reasons to use Postgres:: | ||
2096 | * Reasons not to use Postgres:: | ||
2097 | * Manual setup instructions:: | ||
2098 | * Testing the setup manually:: | ||
2099 | * Configuring the datacache:: | ||
2100 | * Configuring the file-sharing service:: | ||
2101 | * Configuring logging:: | ||
2102 | * Configuring the transport service and plugins:: | ||
2103 | * Configuring the wlan transport plugin:: | ||
2104 | * Configuring HTTP(S) reverse proxy functionality using Apache or nginx:: | ||
2105 | * Blacklisting peers:: | ||
2106 | * Configuration of the HTTP and HTTPS transport plugins:: | ||
2107 | * Configuring the GNU Name System:: | ||
2108 | * Configuring the GNUnet VPN:: | ||
2109 | * Bandwidth Configuration:: | ||
2110 | * Configuring NAT:: | ||
2111 | * Peer configuration for distributions:: | ||
2112 | @end menu | ||
2113 | |||
2114 | @node Configuring your peer | ||
2115 | @subsection Configuring your peer | ||
2116 | |||
2117 | This chapter will describe the various configuration options in GNUnet. | ||
2118 | |||
2119 | The easiest way to configure your peer is to use the | ||
2120 | @command{gnunet-setup} tool. | ||
2121 | @command{gnunet-setup} is part of the @command{gnunet-gtk} | ||
2122 | application. You might have to install it separately. | ||
2123 | |||
2124 | Many of the specific sections from this chapter actually are linked from | ||
2125 | within @command{gnunet-setup} to help you while using the setup tool. | ||
2126 | |||
2127 | While you can also configure your peer by editing the configuration | ||
2128 | file by hand, this is not recommended for anyone except for developers | ||
2129 | as it requires a more in-depth understanding of the configuration files | ||
2130 | and internal dependencies of GNUnet. | ||
2131 | |||
2132 | |||
2133 | @node Configuring the Friend-to-Friend (F2F) mode | ||
2134 | @subsection Configuring the Friend-to-Friend (F2F) mode | ||
2135 | |||
2136 | GNUnet knows three basic modes of operation: | ||
2137 | @itemize @bullet | ||
2138 | @item In standard "peer-to-peer" mode, | ||
2139 | your peer will connect to any peer. | ||
2140 | @item In the pure "friend-to-friend" | ||
2141 | mode, your peer will ONLY connect to peers from a list of friends | ||
2142 | specified in the configuration. | ||
2143 | @item Finally, in mixed mode, | ||
2144 | GNUnet will only connect to arbitrary peers if it | ||
2145 | has at least a specified number of connections to friends. | ||
2146 | @end itemize | ||
2147 | |||
2148 | When configuring any of the F2F ("friend-to-friend") modes, | ||
2149 | you first need to create a file with the peer identities | ||
2150 | of your friends. Ask your friends to run | ||
2151 | |||
2152 | @example | ||
2153 | $ gnunet-peerinfo -sq | ||
2154 | @end example | ||
2155 | |||
2156 | @noindent | ||
2157 | The resulting output of this command needs to be added to your | ||
2158 | @file{friends} file, which is simply a plain text file with one line | ||
2159 | per friend with the output from the above command. | ||
2160 | |||
2161 | You then specify the location of your @file{friends} file in the | ||
2162 | "FRIENDS" option of the "topology" section. | ||
2163 | |||
2164 | Once you have created the @file{friends} file, you can tell GNUnet to only | ||
2165 | connect to your friends by setting the "FRIENDS-ONLY" option (again in | ||
2166 | the "topology" section) to YES. | ||
2167 | |||
2168 | If you want to run in mixed-mode, set "FRIENDS-ONLY" to NO and configure a | ||
2169 | minimum number of friends to have (before connecting to arbitrary peers) | ||
2170 | under the "MINIMUM-FRIENDS" option. | ||
2171 | |||
2172 | If you want to operate in normal P2P-only mode, simply set | ||
2173 | "MINIMUM-FRIENDS" to zero and "FRIENDS_ONLY" to NO. | ||
2174 | This is the default. | ||
2175 | |||
2176 | @node Configuring the hostlist to bootstrap | ||
2177 | @subsection Configuring the hostlist to bootstrap | ||
2178 | |||
2179 | After installing the software you need to get connected to the GNUnet | ||
2180 | network. The configuration file included in your download is already | ||
2181 | configured to connect you to the GNUnet network. | ||
2182 | In this section the relevant configuration settings are explained. | ||
2183 | |||
2184 | To get an initial connection to the GNUnet network and to get to know | ||
2185 | peers already connected to the network you can use the so called | ||
2186 | "bootstrap servers". | ||
2187 | These servers can give you a list of peers connected to the network. | ||
2188 | To use these bootstrap servers you have to configure the hostlist daemon | ||
2189 | to activate bootstrapping. | ||
2190 | |||
2191 | To activate bootstrapping, edit the @code{[hostlist]}-section in your | ||
2192 | configuration file. You have to set the argument "-b" in the | ||
2193 | options line: | ||
2194 | |||
2195 | @example | ||
2196 | [hostlist] | ||
2197 | OPTIONS = -b | ||
2198 | @end example | ||
2199 | |||
2200 | Additionally you have to specify which server you want to use. | ||
2201 | The default bootstrapping server is | ||
2202 | "@uref{http://v10.gnunet.org/hostlist, http://v10.gnunet.org/hostlist}". | ||
2203 | [^] To set the server you have to edit the line "SERVERS" in the hostlist | ||
2204 | section. To use the default server you should set the lines to | ||
2205 | |||
2206 | @example | ||
2207 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
2208 | @end example | ||
2209 | |||
2210 | @noindent | ||
2211 | To use bootstrapping your configuration file should include these lines: | ||
2212 | |||
2213 | @example | ||
2214 | [hostlist] | ||
2215 | OPTIONS = -b | ||
2216 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
2217 | @end example | ||
2218 | |||
2219 | @noindent | ||
2220 | Besides using bootstrap servers you can configure your GNUnet peer to | ||
2221 | recieve hostlist advertisements. | ||
2222 | Peers offering hostlists to other peers can send advertisement messages | ||
2223 | to peers that connect to them. If you configure your peer to receive these | ||
2224 | messages, your peer can download these lists and connect to the peers | ||
2225 | included. These lists are persistent, which means that they are saved to | ||
2226 | your hard disk regularly and are loaded during startup. | ||
2227 | |||
2228 | To activate hostlist learning you have to add the "-e" switch to the | ||
2229 | OPTIONS line in the hostlist section: | ||
2230 | |||
2231 | @example | ||
2232 | [hostlist] | ||
2233 | OPTIONS = -b -e | ||
2234 | @end example | ||
2235 | |||
2236 | @noindent | ||
2237 | Furthermore you can specify in which file the lists are saved. | ||
2238 | To save the lists in the file "hostlists.file" just add the line: | ||
2239 | |||
2240 | @example | ||
2241 | HOSTLISTFILE = hostlists.file | ||
2242 | @end example | ||
2243 | |||
2244 | @noindent | ||
2245 | Best practice is to activate both bootstrapping and hostlist learning. | ||
2246 | So your configuration file should include these lines: | ||
2247 | |||
2248 | @example | ||
2249 | [hostlist] | ||
2250 | OPTIONS = -b -e | ||
2251 | HTTPPORT = 8080 | ||
2252 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
2253 | HOSTLISTFILE = $SERVICEHOME/hostlists.file | ||
2254 | @end example | ||
2255 | |||
2256 | @node Configuration of the HOSTLIST proxy settings | ||
2257 | @subsection Configuration of the HOSTLIST proxy settings | ||
2258 | |||
2259 | The hostlist client can be configured to use a proxy to connect to the | ||
2260 | hostlist server. | ||
2261 | This functionality can be configured in the configuration file directly | ||
2262 | or using the gnunet-setup tool. | ||
2263 | |||
2264 | The hostlist client supports the following proxy types at the moment: | ||
2265 | |||
2266 | @itemize @bullet | ||
2267 | @item HTTP and HTTP 1.0 only proxy | ||
2268 | @item SOCKS 4/4a/5/5 with hostname | ||
2269 | @end itemize | ||
2270 | |||
2271 | In addition authentication at the proxy with username and password can be | ||
2272 | configured. | ||
2273 | |||
2274 | To configure proxy support for the hostlist client in the | ||
2275 | @command{gnunet-setup} tool, select the "hostlist" tab and select | ||
2276 | the appropriate proxy type. | ||
2277 | The hostname or IP address (including port if required) has to be entered | ||
2278 | in the "Proxy hostname" textbox. If required, enter username and password | ||
2279 | in the "Proxy username" and "Proxy password" boxes. | ||
2280 | Be aware that this information will be stored in the configuration in | ||
2281 | plain text (TODO: Add explanation and generalize the part in Chapter 3.6 | ||
2282 | about the encrypted home). | ||
2283 | |||
2284 | To provide these options directly in the configuration, you can | ||
2285 | enter the following settings in the @code{[hostlist]} section of | ||
2286 | the configuration: | ||
2287 | |||
2288 | @example | ||
2289 | # Type of proxy server, | ||
2290 | # Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME | ||
2291 | # Default: HTTP | ||
2292 | # PROXY_TYPE = HTTP | ||
2293 | |||
2294 | # Hostname or IP of proxy server | ||
2295 | # PROXY = | ||
2296 | # User name for proxy server | ||
2297 | # PROXY_USERNAME = | ||
2298 | # User password for proxy server | ||
2299 | # PROXY_PASSWORD = | ||
2300 | @end example | ||
2301 | |||
2302 | @node Configuring your peer to provide a hostlist | ||
2303 | @subsection Configuring your peer to provide a hostlist | ||
2304 | |||
2305 | If you operate a peer permanently connected to GNUnet you can configure | ||
2306 | your peer to act as a hostlist server, providing other peers the list of | ||
2307 | peers known to him. | ||
2308 | |||
2309 | Yor server can act as a bootstrap server and peers needing to obtain a | ||
2310 | list of peers can contact it to download this list. | ||
2311 | To download this hostlist the peer uses HTTP. | ||
2312 | For this reason you have to build your peer with libcurl and microhttpd | ||
2313 | support. How you build your peer with this options can be found here: | ||
2314 | @uref{https://gnunet.org/generic_installation} | ||
2315 | |||
2316 | To configure your peer to act as a bootstrap server you have to add the | ||
2317 | "@code{-p}" option to OPTIONS in the @code{[hostlist]} section of your | ||
2318 | configuration file. Besides that you have to specify a port number for | ||
2319 | the http server. | ||
2320 | In conclusion you have to add the following lines: | ||
2321 | |||
2322 | @example | ||
2323 | [hostlist] | ||
2324 | HTTPPORT = 12980 | ||
2325 | OPTIONS = -p | ||
2326 | @end example | ||
2327 | |||
2328 | @noindent | ||
2329 | If your peer acts as a bootstrap server other peers should know about | ||
2330 | that. You can advertise the hostlist your are providing to other peers. | ||
2331 | Peers connecting to your peer will get a message containing an | ||
2332 | advertisement for your hostlist and the URL where it can be downloaded. | ||
2333 | If this peer is in learning mode, it will test the hostlist and, in the | ||
2334 | case it can obtain the list successfully, it will save it for | ||
2335 | bootstrapping. | ||
2336 | |||
2337 | To activate hostlist advertisement on your peer, you have to set the | ||
2338 | following lines in your configuration file: | ||
2339 | |||
2340 | @example | ||
2341 | [hostlist] | ||
2342 | EXTERNAL_DNS_NAME = example.org | ||
2343 | HTTPPORT = 12981 | ||
2344 | OPTIONS = -p -a | ||
2345 | @end example | ||
2346 | |||
2347 | @noindent | ||
2348 | With this configuration your peer will a act as a bootstrap server and | ||
2349 | advertise this hostlist to other peers connecting to it. | ||
2350 | The URL used to download the list will be | ||
2351 | @code{@uref{http://example.org:12981/, http://example.org:12981/}}. | ||
2352 | |||
2353 | Please notice: | ||
2354 | |||
2355 | @itemize @bullet | ||
2356 | @item The hostlist is not human readable, so you should not try to | ||
2357 | download it using your webbrowser. Just point your GNUnet peer to the | ||
2358 | address! | ||
2359 | @item Advertising without providing a hostlist does not make sense and | ||
2360 | will not work. | ||
2361 | @end itemize | ||
2362 | |||
2363 | @node Configuring the datastore | ||
2364 | @subsection Configuring the datastore | ||
2365 | |||
2366 | The datastore is what GNUnet uses to for long-term storage of file-sharing | ||
2367 | data. Note that long-term does not mean 'forever' since content does have | ||
2368 | an expiration date, and of course storage space is finite (and hence | ||
2369 | sometimes content may have to be discarded). | ||
2370 | |||
2371 | Use the "QUOTA" option to specify how many bytes of storage space you are | ||
2372 | willing to dedicate to GNUnet. | ||
2373 | |||
2374 | In addition to specifying the maximum space GNUnet is allowed to use for | ||
2375 | the datastore, you need to specify which database GNUnet should use to do | ||
2376 | so. Currently, you have the choice between sqLite, MySQL and Postgres. | ||
2377 | |||
2378 | @node Configuring the MySQL database | ||
2379 | @subsection Configuring the MySQL database | ||
2380 | |||
2381 | This section describes how to setup the MySQL database for GNUnet. | ||
2382 | |||
2383 | Note that the mysql plugin does NOT work with mysql before 4.1 since we | ||
2384 | need prepared statements. | ||
2385 | We are generally testing the code against MySQL 5.1 at this point. | ||
2386 | |||
2387 | @node Reasons for using MySQL | ||
2388 | @subsection Reasons for using MySQL | ||
2389 | |||
2390 | @itemize @bullet | ||
2391 | |||
2392 | @item On up-to-date hardware wher | ||
2393 | mysql can be used comfortably, this module | ||
2394 | will have better performance than the other database choices (according | ||
2395 | to our tests). | ||
2396 | |||
2397 | @item Its often possible to recover the mysql database from internal | ||
2398 | inconsistencies. Some of the other databases do not support repair. | ||
2399 | @end itemize | ||
2400 | |||
2401 | @node Reasons for not using MySQL | ||
2402 | @subsection Reasons for not using MySQL | ||
2403 | |||
2404 | @itemize @bullet | ||
2405 | @item Memory usage (likely not an issue if you have more than 1 GB) | ||
2406 | @item Complex manual setup | ||
2407 | @end itemize | ||
2408 | |||
2409 | @node Setup Instructions | ||
2410 | @subsection Setup Instructions | ||
2411 | |||
2412 | @itemize @bullet | ||
2413 | |||
2414 | @item In @code{gnunet.conf} set in section "DATASTORE" the value for | ||
2415 | "DATABASE" to "mysql". | ||
2416 | |||
2417 | @item Access mysql as root: | ||
2418 | |||
2419 | @example | ||
2420 | $ mysql -u root -p | ||
2421 | @end example | ||
2422 | |||
2423 | @noindent | ||
2424 | and issue the following commands, replacing $USER with the username | ||
2425 | that will be running gnunet-arm (so typically "gnunet"): | ||
2426 | |||
2427 | @example | ||
2428 | CREATE DATABASE gnunet; | ||
2429 | GRANT select,insert,update,delete,create,alter,drop,create \ | ||
2430 | temporary tables ON gnunet.* TO $USER@@localhost; | ||
2431 | SET PASSWORD FOR $USER@@localhost=PASSWORD('$the_password_you_like'); | ||
2432 | FLUSH PRIVILEGES; | ||
2433 | @end example | ||
2434 | |||
2435 | @item | ||
2436 | In the $HOME directory of $USER, create a "@file{.my.cnf}" file with the | ||
2437 | following lines | ||
2438 | |||
2439 | @example | ||
2440 | [client] | ||
2441 | user=$USER | ||
2442 | password=$the_password_you_like | ||
2443 | @end example | ||
2444 | |||
2445 | @end itemize | ||
2446 | |||
2447 | Thats it. Note that @file{.my.cnf} file is a slight security risk unless | ||
2448 | its on a safe partition. The @file{$HOME/.my.cnf} can of course be | ||
2449 | a symbolic link. | ||
2450 | Luckily $USER has only priviledges to mess up GNUnet's tables, | ||
2451 | which should be pretty harmless. | ||
2452 | |||
2453 | @node Testing | ||
2454 | @subsection Testing | ||
2455 | |||
2456 | You should briefly try if the database connection works. First, login | ||
2457 | as $USER. Then use: | ||
2458 | |||
2459 | @example | ||
2460 | $ mysql -u $USER | ||
2461 | mysql> use gnunet; | ||
2462 | @end example | ||
2463 | |||
2464 | @noindent | ||
2465 | If you get the message "Database changed" it probably works. | ||
2466 | |||
2467 | If you get "ERROR 2002: Can't connect to local MySQL server@ | ||
2468 | through socket '/tmp/mysql.sock' (2)" it may be resolvable by | ||
2469 | |||
2470 | @example | ||
2471 | ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock | ||
2472 | @end example | ||
2473 | |||
2474 | so there may be some additional trouble depending on your mysql setup. | ||
2475 | |||
2476 | @node Performance Tuning | ||
2477 | @subsection Performance Tuning | ||
2478 | |||
2479 | For GNUnet, you probably want to set the option | ||
2480 | |||
2481 | @example | ||
2482 | innodb_flush_log_at_trx_commit = 0 | ||
2483 | @end example | ||
2484 | |||
2485 | @noindent | ||
2486 | for a rather dramatic boost in MySQL performance. However, this reduces | ||
2487 | the "safety" of your database as with this options you may loose | ||
2488 | transactions during a power outage. | ||
2489 | While this is totally harmless for GNUnet, the option applies to all | ||
2490 | applications using MySQL. So you should set it if (and only if) GNUnet is | ||
2491 | the only application on your system using MySQL. | ||
2492 | |||
2493 | @node Setup for running Testcases | ||
2494 | @subsection Setup for running Testcases | ||
2495 | |||
2496 | If you want to run the testcases, you must create a second database | ||
2497 | "gnunetcheck" with the same username and password. This database will | ||
2498 | then be used for testing ("make check"). | ||
2499 | |||
2500 | @node Configuring the Postgres database | ||
2501 | @subsection Configuring the Postgres database | ||
2502 | |||
2503 | This text describes how to setup the Postgres database for GNUnet. | ||
2504 | |||
2505 | This Postgres plugin was developed for Postgres 8.3 but might work for | ||
2506 | earlier versions as well. | ||
2507 | |||
2508 | @node Reasons to use Postgres | ||
2509 | @subsection Reasons to use Postgres | ||
2510 | |||
2511 | @itemize @bullet | ||
2512 | @item Easier to setup than MySQL | ||
2513 | @item Real database | ||
2514 | @end itemize | ||
2515 | |||
2516 | @node Reasons not to use Postgres | ||
2517 | @subsection Reasons not to use Postgres | ||
2518 | |||
2519 | @itemize @bullet | ||
2520 | @item Quite slow | ||
2521 | @item Still some manual setup required | ||
2522 | @end itemize | ||
2523 | |||
2524 | @node Manual setup instructions | ||
2525 | @subsection Manual setup instructions | ||
2526 | |||
2527 | @itemize @bullet | ||
2528 | @item In @code{gnunet.conf} set in section "DATASTORE" the value for | ||
2529 | "DATABASE" to "postgres". | ||
2530 | @item Access Postgres to create a user:@ | ||
2531 | |||
2532 | @table @asis | ||
2533 | @item with Postgres 8.x, use: | ||
2534 | |||
2535 | @example | ||
2536 | # su - postgres | ||
2537 | $ createuser | ||
2538 | @end example | ||
2539 | |||
2540 | @noindent | ||
2541 | and enter the name of the user running GNUnet for the role interactively. | ||
2542 | Then, when prompted, do not set it to superuser, allow the creation of | ||
2543 | databases, and do not allow the creation of new roles.@ | ||
2544 | |||
2545 | @item with Postgres 9.x, use: | ||
2546 | |||
2547 | @example | ||
2548 | # su - postgres | ||
2549 | $ createuser -d $GNUNET_USER | ||
2550 | @end example | ||
2551 | |||
2552 | @noindent | ||
2553 | where $GNUNET_USER is the name of the user running GNUnet.@ | ||
2554 | |||
2555 | @end table | ||
2556 | |||
2557 | |||
2558 | @item | ||
2559 | As that user (so typically as user "gnunet"), create a database (or two): | ||
2560 | |||
2561 | @example | ||
2562 | $ createdb gnunet | ||
2563 | # this way you can run "make check" | ||
2564 | $ createdb gnunetcheck | ||
2565 | @end example | ||
2566 | |||
2567 | @end itemize | ||
2568 | |||
2569 | Now you should be able to start @code{gnunet-arm}. | ||
2570 | |||
2571 | @node Testing the setup manually | ||
2572 | @subsection Testing the setup manually | ||
2573 | |||
2574 | You may want to try if the database connection works. First, again login | ||
2575 | as the user who will run @command{gnunet-arm}. Then use: | ||
2576 | |||
2577 | @example | ||
2578 | $ psql gnunet # or gnunetcheck | ||
2579 | gnunet=> \dt | ||
2580 | @end example | ||
2581 | |||
2582 | @noindent | ||
2583 | If, after you have started @command{gnunet-arm} at least once, you get | ||
2584 | a @code{gn090} table here, it probably works. | ||
2585 | |||
2586 | @node Configuring the datacache | ||
2587 | @subsection Configuring the datacache | ||
2588 | @c %**end of header | ||
2589 | |||
2590 | The datacache is what GNUnet uses for storing temporary data. This data is | ||
2591 | expected to be wiped completely each time GNUnet is restarted (or the | ||
2592 | system is rebooted). | ||
2593 | |||
2594 | You need to specify how many bytes GNUnet is allowed to use for the | ||
2595 | datacache using the "QUOTA" option in the section "dhtcache". | ||
2596 | Furthermore, you need to specify which database backend should be used to | ||
2597 | store the data. Currently, you have the choice between | ||
2598 | sqLite, MySQL and Postgres. | ||
2599 | |||
2600 | @node Configuring the file-sharing service | ||
2601 | @subsection Configuring the file-sharing service | ||
2602 | |||
2603 | In order to use GNUnet for file-sharing, you first need to make sure | ||
2604 | that the file-sharing service is loaded. | ||
2605 | This is done by setting the AUTOSTART option in section "fs" to "YES". | ||
2606 | Alternatively, you can run | ||
2607 | |||
2608 | @example | ||
2609 | $ gnunet-arm -i fs | ||
2610 | @end example | ||
2611 | |||
2612 | @noindent | ||
2613 | to start the file-sharing service by hand. | ||
2614 | |||
2615 | Except for configuring the database and the datacache the only important | ||
2616 | option for file-sharing is content migration. | ||
2617 | |||
2618 | Content migration allows your peer to cache content from other peers as | ||
2619 | well as send out content stored on your system without explicit requests. | ||
2620 | This content replication has positive and negative impacts on both system | ||
2621 | performance and privacy. | ||
2622 | |||
2623 | FIXME: discuss the trade-offs. Here is some older text about it... | ||
2624 | |||
2625 | Setting this option to YES allows gnunetd to migrate data to the local | ||
2626 | machine. Setting this option to YES is highly recommended for efficiency. | ||
2627 | Its also the default. If you set this value to YES, GNUnet will store | ||
2628 | content on your machine that you cannot decrypt. | ||
2629 | While this may protect you from liability if the judge is sane, it may | ||
2630 | not (IANAL). If you put illegal content on your machine yourself, setting | ||
2631 | this option to YES will probably increase your chances to get away with it | ||
2632 | since you can plausibly deny that you inserted the content. | ||
2633 | Note that in either case, your anonymity would have to be broken first | ||
2634 | (which may be possible depending on the size of the GNUnet network and the | ||
2635 | strength of the adversary). | ||
2636 | |||
2637 | @node Configuring logging | ||
2638 | @subsection Configuring logging | ||
2639 | |||
2640 | Logging in GNUnet 0.9.0 is controlled via the "-L" and "-l" options. | ||
2641 | Using "-L", a log level can be specified. With log level "@code{ERROR}" | ||
2642 | only serious errors are logged. | ||
2643 | The default log level is "@code{WARNING}" which causes anything of | ||
2644 | concern to be logged. | ||
2645 | Log level "@code{INFO}" can be used to log anything that might be | ||
2646 | interesting information whereas | ||
2647 | "@code{DEBUG}" can be used by developers to log debugging messages | ||
2648 | (but you need to run @code{./configure} with | ||
2649 | @code{--enable-logging=verbose} to get them compiled). | ||
2650 | The "-l" option is used to specify the log file. | ||
2651 | |||
2652 | Since most GNUnet services are managed by @code{gnunet-arm}, using the | ||
2653 | "-l" or "-L" options directly is not possible. | ||
2654 | Instead, they can be specified using the "OPTIONS" configuration value in | ||
2655 | the respective section for the respective service. | ||
2656 | In order to enable logging globally without editing the "OPTIONS" values | ||
2657 | for each service, @code{gnunet-arm} supports a "GLOBAL_POSTFIX" option. | ||
2658 | The value specified here is given as an extra option to all services for | ||
2659 | which the configuration does contain a service-specific "OPTIONS" field. | ||
2660 | |||
2661 | "GLOBAL_POSTFIX" can contain the special sequence "@{@}" which is replaced | ||
2662 | by the name of the service that is being started. Furthermore, | ||
2663 | @code{GLOBAL_POSTFIX} is special in that sequences starting with "$" | ||
2664 | anywhere in the string are expanded (according to options in "PATHS"); | ||
2665 | this expansion otherwise is only happening for filenames and then the "$" | ||
2666 | must be the first character in the option. Both of these restrictions do | ||
2667 | not apply to "GLOBAL_POSTFIX". | ||
2668 | Note that specifying @code{%} anywhere in the "GLOBAL_POSTFIX" disables | ||
2669 | both of these features. | ||
2670 | |||
2671 | In summary, in order to get all services to log at level "INFO" to | ||
2672 | log-files called @code{SERVICENAME-logs}, the following global prefix | ||
2673 | should be used: | ||
2674 | |||
2675 | @example | ||
2676 | GLOBAL_POSTFIX = -l $SERVICEHOME/@{@}-logs -L INFO | ||
2677 | @end example | ||
2678 | |||
2679 | @node Configuring the transport service and plugins | ||
2680 | @subsection Configuring the transport service and plugins | ||
2681 | |||
2682 | The transport service in GNUnet is responsible to maintain basic | ||
2683 | connectivity to other peers. | ||
2684 | Besides initiating and keeping connections alive it is also responsible | ||
2685 | for address validation. | ||
2686 | |||
2687 | The GNUnet transport supports more than one transport protocol. | ||
2688 | These protocols are configured together with the transport service. | ||
2689 | |||
2690 | The configuration section for the transport service itself is quite | ||
2691 | similar to all the other services | ||
2692 | |||
2693 | @example | ||
2694 | AUTOSTART = YES | ||
2695 | @@UNIXONLY@@ PORT = 2091 | ||
2696 | HOSTNAME = localhost | ||
2697 | HOME = $SERVICEHOME | ||
2698 | CONFIG = $DEFAULTCONFIG | ||
2699 | BINARY = gnunet-service-transport | ||
2700 | #PREFIX = valgrind | ||
2701 | NEIGHBOUR_LIMIT = 50 | ||
2702 | ACCEPT_FROM = 127.0.0.1; | ||
2703 | ACCEPT_FROM6 = ::1; | ||
2704 | PLUGINS = tcp udp | ||
2705 | UNIXPATH = /tmp/gnunet-service-transport.sock | ||
2706 | @end example | ||
2707 | |||
2708 | Different are the settings for the plugins to load @code{PLUGINS}. | ||
2709 | The first setting specifies which transport plugins to load. | ||
2710 | |||
2711 | @itemize @bullet | ||
2712 | @item transport-unix | ||
2713 | A plugin for local only communication with UNIX domain sockets. Used for | ||
2714 | testing and available on unix systems only. Just set the port | ||
2715 | |||
2716 | @example | ||
2717 | [transport-unix] | ||
2718 | PORT = 22086 | ||
2719 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2720 | @end example | ||
2721 | |||
2722 | @item transport-tcp | ||
2723 | A plugin for communication with TCP. Set port to 0 for client mode with | ||
2724 | outbound only connections | ||
2725 | |||
2726 | @example | ||
2727 | [transport-tcp] | ||
2728 | # Use 0 to ONLY advertise as a peer behind NAT (no port binding) | ||
2729 | PORT = 2086 | ||
2730 | ADVERTISED_PORT = 2086 | ||
2731 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2732 | # Maximum number of open TCP connections allowed | ||
2733 | MAX_CONNECTIONS = 128 | ||
2734 | @end example | ||
2735 | |||
2736 | @item transport-udp | ||
2737 | A plugin for communication with UDP. Supports peer discovery using | ||
2738 | broadcasts. | ||
2739 | |||
2740 | @example | ||
2741 | [transport-udp] | ||
2742 | PORT = 2086 | ||
2743 | BROADCAST = YES | ||
2744 | BROADCAST_INTERVAL = 30 s | ||
2745 | MAX_BPS = 1000000 | ||
2746 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2747 | @end example | ||
2748 | |||
2749 | @item transport-http | ||
2750 | HTTP and HTTPS support is split in two part: a client plugin initiating | ||
2751 | outbound connections and a server part accepting connections from the | ||
2752 | client. The client plugin just takes the maximum number of connections as | ||
2753 | an argument. | ||
2754 | |||
2755 | @example | ||
2756 | [transport-http_client] | ||
2757 | MAX_CONNECTIONS = 128 | ||
2758 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2759 | @end example | ||
2760 | |||
2761 | @example | ||
2762 | [transport-https_client] | ||
2763 | MAX_CONNECTIONS = 128 | ||
2764 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2765 | @end example | ||
2766 | |||
2767 | @noindent | ||
2768 | The server has a port configured and the maximum nunber of connections. | ||
2769 | The HTTPS part has two files with the certificate key and the certificate | ||
2770 | file. | ||
2771 | |||
2772 | The server plugin supports reverse proxies, so a external hostname can be | ||
2773 | set using the @code{EXTERNAL_HOSTNAME} setting. | ||
2774 | The webserver under this address should forward the request to the peer | ||
2775 | and the configure port. | ||
2776 | |||
2777 | @example | ||
2778 | [transport-http_server] | ||
2779 | EXTERNAL_HOSTNAME = fulcrum.net.in.tum.de/gnunet | ||
2780 | PORT = 1080 | ||
2781 | MAX_CONNECTIONS = 128 | ||
2782 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2783 | @end example | ||
2784 | |||
2785 | @example | ||
2786 | [transport-https_server] | ||
2787 | PORT = 4433 | ||
2788 | CRYPTO_INIT = NORMAL | ||
2789 | KEY_FILE = https.key | ||
2790 | CERT_FILE = https.cert | ||
2791 | MAX_CONNECTIONS = 128 | ||
2792 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2793 | @end example | ||
2794 | |||
2795 | @item transport-wlan | ||
2796 | |||
2797 | The next section describes how to setup the WLAN plugin, | ||
2798 | so here only the settings. Just specify the interface to use: | ||
2799 | |||
2800 | @example | ||
2801 | [transport-wlan] | ||
2802 | # Name of the interface in monitor mode (typically monX) | ||
2803 | INTERFACE = mon0 | ||
2804 | # Real hardware, no testing | ||
2805 | TESTMODE = 0 | ||
2806 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
2807 | @end example | ||
2808 | @end itemize | ||
2809 | |||
2810 | @node Configuring the wlan transport plugin | ||
2811 | @subsection Configuring the wlan transport plugin | ||
2812 | |||
2813 | The wlan transport plugin enables GNUnet to send and to receive data on a | ||
2814 | wlan interface. | ||
2815 | It has not to be connected to a wlan network as long as sender and | ||
2816 | receiver are on the same channel. This enables you to get connection to | ||
2817 | GNUnet where no internet access is possible, for example during | ||
2818 | catastrophes or when censorship cuts you off from the internet. | ||
2819 | |||
2820 | |||
2821 | @menu | ||
2822 | * Requirements for the WLAN plugin:: | ||
2823 | * Configuration:: | ||
2824 | * Before starting GNUnet:: | ||
2825 | * Limitations and known bugs:: | ||
2826 | @end menu | ||
2827 | |||
2828 | |||
2829 | @node Requirements for the WLAN plugin | ||
2830 | @subsubsection Requirements for the WLAN plugin | ||
2831 | |||
2832 | @itemize @bullet | ||
2833 | |||
2834 | @item wlan network card with monitor support and packet injection | ||
2835 | (see @uref{http://www.aircrack-ng.org/, aircrack-ng.org}) | ||
2836 | |||
2837 | @item Linux kernel with mac80211 stack, introduced in 2.6.22, tested with | ||
2838 | 2.6.35 and 2.6.38 | ||
2839 | |||
2840 | @item Wlantools to create the a monitor interface, tested with airmon-ng | ||
2841 | of the aircrack-ng package | ||
2842 | @end itemize | ||
2843 | |||
2844 | @node Configuration | ||
2845 | @subsubsection Configuration | ||
2846 | |||
2847 | There are the following options for the wlan plugin (they should be like | ||
2848 | this in your default config file, you only need to adjust them if the | ||
2849 | values are incorrect for your system) | ||
2850 | |||
2851 | @example | ||
2852 | # section for the wlan transport plugin | ||
2853 | [transport-wlan] | ||
2854 | # interface to use, more information in the | ||
2855 | # "Before starting GNUnet" section of the handbook. | ||
2856 | INTERFACE = mon0 | ||
2857 | # testmode for developers: | ||
2858 | # 0 use wlan interface, | ||
2859 | #1 or 2 use loopback driver for tests 1 = server, 2 = client | ||
2860 | TESTMODE = 0 | ||
2861 | @end example | ||
2862 | |||
2863 | @node Before starting GNUnet | ||
2864 | @subsubsection Before starting GNUnet | ||
2865 | |||
2866 | Before starting GNUnet, you have to make sure that your wlan interface is | ||
2867 | in monitor mode. | ||
2868 | One way to put the wlan interface into monitor mode (if your interface | ||
2869 | name is wlan0) is by executing: | ||
2870 | |||
2871 | @example | ||
2872 | sudo airmon-ng start wlan0 | ||
2873 | @end example | ||
2874 | |||
2875 | @noindent | ||
2876 | Here is an example what the result should look like: | ||
2877 | |||
2878 | @example | ||
2879 | Interface Chipset Driver | ||
2880 | wlan0 Intel 4965 a/b/g/n iwl4965 - [phy0] | ||
2881 | (monitor mode enabled on mon0) | ||
2882 | @end example | ||
2883 | |||
2884 | @noindent | ||
2885 | The monitor interface is mon0 is the one that you have to put into the | ||
2886 | configuration file. | ||
2887 | |||
2888 | @node Limitations and known bugs | ||
2889 | @subsubsection Limitations and known bugs | ||
2890 | |||
2891 | Wlan speed is at the maximum of 1 Mbit/s because support for choosing the | ||
2892 | wlan speed with packet injection was removed in newer kernels. | ||
2893 | Please pester the kernel developers about fixing this. | ||
2894 | |||
2895 | The interface channel depends on the wlan network that the card is | ||
2896 | connected to. If no connection has been made since the start of the | ||
2897 | computer, it is usually the first channel of the card. | ||
2898 | Peers will only find each other and communicate if they are on the same | ||
2899 | channel. Channels must be set manually (i.e. using | ||
2900 | @code{iwconfig wlan0 channel 1}). | ||
2901 | |||
2902 | |||
2903 | @node Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
2904 | @subsection Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
2905 | |||
2906 | The HTTP plugin supports data transfer using reverse proxies. A reverse | ||
2907 | proxy forwards the HTTP request he receives with a certain URL to another | ||
2908 | webserver, here a GNUnet peer. | ||
2909 | |||
2910 | So if you have a running Apache or nginx webserver you can configure it to | ||
2911 | be a GNUnet reverse proxy. Especially if you have a well-known webiste | ||
2912 | this improves censorship resistance since it looks as normal surfing | ||
2913 | behaviour. | ||
2914 | |||
2915 | To do so, you have to do two things: | ||
2916 | |||
2917 | @itemize @bullet | ||
2918 | @item Configure your webserver to forward the GNUnet HTTP traffic | ||
2919 | @item Configure your GNUnet peer to announce the respective address | ||
2920 | @end itemize | ||
2921 | |||
2922 | As an example we want to use GNUnet peer running: | ||
2923 | |||
2924 | @itemize @bullet | ||
2925 | |||
2926 | @item HTTP server plugin on @code{gnunet.foo.org:1080} | ||
2927 | |||
2928 | @item HTTPS server plugin on @code{gnunet.foo.org:4433} | ||
2929 | |||
2930 | @item A apache or nginx webserver on | ||
2931 | @uref{http://www.foo.org/, http://www.foo.org:80/} | ||
2932 | |||
2933 | @item A apache or nginx webserver on https://www.foo.org:443/ | ||
2934 | @end itemize | ||
2935 | |||
2936 | And we want the webserver to accept GNUnet traffic under | ||
2937 | @code{http://www.foo.org/bar/}. The required steps are described here: | ||
2938 | |||
2939 | @strong{Configure your Apache2 HTTP webserver} | ||
2940 | |||
2941 | First of all you need mod_proxy installed. | ||
2942 | |||
2943 | Edit your webserver configuration. Edit | ||
2944 | @code{/etc/apache2/apache2.conf} or the site-specific configuration file. | ||
2945 | |||
2946 | In the respective @code{server config},@code{virtual host} or | ||
2947 | @code{directory} section add the following lines: | ||
2948 | |||
2949 | @example | ||
2950 | ProxyTimeout 300 | ||
2951 | ProxyRequests Off | ||
2952 | <Location /bar/ > | ||
2953 | ProxyPass http://gnunet.foo.org:1080/ | ||
2954 | ProxyPassReverse http://gnunet.foo.org:1080/ | ||
2955 | </Location> | ||
2956 | @end example | ||
2957 | |||
2958 | @noindent | ||
2959 | @strong{Configure your Apache2 HTTPS webserver} | ||
2960 | |||
2961 | We assume that you already have an HTTPS server running, if not please | ||
2962 | check how to configure a HTTPS host. An easy to use example is the | ||
2963 | @file{apache2/sites-available/default-ssl} example configuration file. | ||
2964 | |||
2965 | In the respective HTTPS @code{server config},@code{virtual host} or | ||
2966 | @code{directory} section add the following lines: | ||
2967 | |||
2968 | @example | ||
2969 | SSLProxyEngine On | ||
2970 | ProxyTimeout 300 | ||
2971 | ProxyRequests Off | ||
2972 | <Location /bar/ > | ||
2973 | ProxyPass https://gnunet.foo.org:4433/ | ||
2974 | ProxyPassReverse https://gnunet.foo.org:4433/ | ||
2975 | </Location> | ||
2976 | @end example | ||
2977 | |||
2978 | @noindent | ||
2979 | More information about the apache mod_proxy configuration can be found | ||
2980 | here: @uref{http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass} | ||
2981 | . | ||
2982 | |||
2983 | @strong{Configure your nginx HTTPS webserver} | ||
2984 | |||
2985 | Since nginx does not support chunked encoding, you first of all have to | ||
2986 | install @code{chunkin}: @uref{http://wiki.nginx.org/HttpChunkinModule}. | ||
2987 | |||
2988 | To enable chunkin add: | ||
2989 | |||
2990 | @example | ||
2991 | chunkin on; | ||
2992 | error_page 411 = @@my_411_error; | ||
2993 | location @@my_411_error @{ | ||
2994 | chunkin_resume; | ||
2995 | @} | ||
2996 | @end example | ||
2997 | |||
2998 | @noindent | ||
2999 | Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or | ||
3000 | the site-specific configuration file. | ||
3001 | |||
3002 | In the @code{server} section add: | ||
3003 | |||
3004 | @example | ||
3005 | location /bar/ | ||
3006 | @{ | ||
3007 | proxy_pass http://gnunet.foo.org:1080/; | ||
3008 | proxy_buffering off; | ||
3009 | proxy_connect_timeout 5; # more than http_server | ||
3010 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout | ||
3011 | proxy_http_version 1.1; # 1.0 default | ||
3012 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504; | ||
3013 | @} | ||
3014 | @end example | ||
3015 | |||
3016 | @noindent | ||
3017 | @strong{Configure your nginx HTTPS webserver} | ||
3018 | |||
3019 | Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or | ||
3020 | the site-specific configuration file. | ||
3021 | |||
3022 | In the @code{server} section add: | ||
3023 | |||
3024 | @example | ||
3025 | ssl_session_timeout 6m; | ||
3026 | location /bar/ | ||
3027 | @{ | ||
3028 | proxy_pass https://gnunet.foo.org:4433/; | ||
3029 | proxy_buffering off; | ||
3030 | proxy_connect_timeout 5; # more than http_server | ||
3031 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout | ||
3032 | proxy_http_version 1.1; # 1.0 default | ||
3033 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504; | ||
3034 | @} | ||
3035 | @end example | ||
3036 | |||
3037 | @noindent | ||
3038 | @strong{Configure your GNUnet peer} | ||
3039 | |||
3040 | To have your GNUnet peer announce the address, you have to specify the | ||
3041 | @code{EXTERNAL_HOSTNAME} option in the @code{[transport-http_server]} | ||
3042 | section: | ||
3043 | |||
3044 | @example | ||
3045 | [transport-http_server] | ||
3046 | EXTERNAL_HOSTNAME = http://www.foo.org/bar/ | ||
3047 | @end example | ||
3048 | |||
3049 | @noindent | ||
3050 | and/or @code{[transport-https_server]} section: | ||
3051 | |||
3052 | @example | ||
3053 | [transport-https_server] | ||
3054 | EXTERNAL_HOSTNAME = https://www.foo.org/bar/ | ||
3055 | @end example | ||
3056 | |||
3057 | @noindent | ||
3058 | Now restart your webserver and your peer... | ||
3059 | |||
3060 | @node Blacklisting peers | ||
3061 | @subsection Blacklisting peers | ||
3062 | |||
3063 | Transport service supports to deny connecting to a specific peer of to a | ||
3064 | specific peer with a specific transport plugin using te blacklisting | ||
3065 | component of transport service. With@ blacklisting it is possible to deny | ||
3066 | connections to specific peers of@ to use a specific plugin to a specific | ||
3067 | peer. Peers can be blacklisted using@ the configuration or a blacklist | ||
3068 | client can be asked. | ||
3069 | |||
3070 | To blacklist peers using the configuration you have to add a section to | ||
3071 | your configuration containing the peer id of the peer to blacklist and | ||
3072 | the plugin@ if required. | ||
3073 | |||
3074 | Examples: | ||
3075 | |||
3076 | To blacklist connections to P565... on peer AG2P... using tcp add: | ||
3077 | |||
3078 | @c FIXME: This is too long and produces errors in the pdf. | ||
3079 | @example | ||
3080 | [transport-blacklist AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520] | ||
3081 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = tcp | ||
3082 | @end example | ||
3083 | |||
3084 | To blacklist connections to P565... on peer AG2P... using all plugins add: | ||
3085 | |||
3086 | @example | ||
3087 | [transport-blacklist-AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520] | ||
3088 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = | ||
3089 | @end example | ||
3090 | |||
3091 | You can also add a blacklist client usign the blacklist API. On a | ||
3092 | blacklist check, blacklisting first checks internally if the peer is | ||
3093 | blacklisted and if not, it asks the blacklisting clients. Clients are | ||
3094 | asked if it is OK to connect to a peer ID, the plugin is omitted. | ||
3095 | |||
3096 | On blacklist check for (peer, plugin) | ||
3097 | @itemize @bullet | ||
3098 | @item Do we have a local blacklist entry for this peer and this plugin?@ | ||
3099 | @item YES: disallow connection@ | ||
3100 | @item Do we have a local blacklist entry for this peer and all plugins?@ | ||
3101 | @item YES: disallow connection@ | ||
3102 | @item Does one of the clients disallow?@ | ||
3103 | @item YES: disallow connection | ||
3104 | @end itemize | ||
3105 | |||
3106 | @node Configuration of the HTTP and HTTPS transport plugins | ||
3107 | @subsection Configuration of the HTTP and HTTPS transport plugins | ||
3108 | |||
3109 | The client parts of the http and https transport plugins can be configured | ||
3110 | to use a proxy to connect to the hostlist server. This functionality can | ||
3111 | be configured in the configuration file directly or using the | ||
3112 | gnunet-setup tool. | ||
3113 | |||
3114 | Both the HTTP and HTTPS clients support the following proxy types at | ||
3115 | the moment: | ||
3116 | |||
3117 | @itemize @bullet | ||
3118 | @item HTTP 1.1 proxy | ||
3119 | @item SOCKS 4/4a/5/5 with hostname | ||
3120 | @end itemize | ||
3121 | |||
3122 | In addition authentication at the proxy with username and password can be | ||
3123 | configured. | ||
3124 | |||
3125 | To configure proxy support for the clients in the gnunet-setup tool, | ||
3126 | select the "transport" tab and activate the respective plugin. Now you | ||
3127 | can select the appropriate proxy type. The hostname or IP address | ||
3128 | (including port if required) has to be entered in the "Proxy hostname" | ||
3129 | textbox. If required, enter username and password in the "Proxy username" | ||
3130 | and "Proxy password" boxes. Be aware that these information will be stored | ||
3131 | in the configuration in plain text. | ||
3132 | |||
3133 | To configure these options directly in the configuration, you can | ||
3134 | configure the following settings in the @code{[transport-http_client]} | ||
3135 | and @code{[transport-https_client]} section of the configuration: | ||
3136 | |||
3137 | @example | ||
3138 | # Type of proxy server, | ||
3139 | # Valid values: HTTP, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME | ||
3140 | # Default: HTTP | ||
3141 | # PROXY_TYPE = HTTP | ||
3142 | |||
3143 | # Hostname or IP of proxy server | ||
3144 | # PROXY = | ||
3145 | # User name for proxy server | ||
3146 | # PROXY_USERNAME = | ||
3147 | # User password for proxy server | ||
3148 | # PROXY_PASSWORD = | ||
3149 | @end example | ||
3150 | |||
3151 | @node Configuring the GNU Name System | ||
3152 | @subsection Configuring the GNU Name System | ||
3153 | |||
3154 | @menu | ||
3155 | * Configuring system-wide DNS interception:: | ||
3156 | * Configuring the GNS nsswitch plugin:: | ||
3157 | * Configuring GNS on W32:: | ||
3158 | * GNS Proxy Setup:: | ||
3159 | * Setup of the GNS CA:: | ||
3160 | * Testing the GNS setup:: | ||
3161 | * Automatic Shortening in the GNU Name System:: | ||
3162 | @end menu | ||
3163 | |||
3164 | |||
3165 | @node Configuring system-wide DNS interception | ||
3166 | @subsubsection Configuring system-wide DNS interception | ||
3167 | |||
3168 | Before you install GNUnet, make sure you have a user and group 'gnunet' | ||
3169 | as well as an empty group 'gnunetdns'. | ||
3170 | |||
3171 | When using GNUnet with system-wide DNS interception, it is absolutely | ||
3172 | necessary for all GNUnet service processes to be started by | ||
3173 | @code{gnunet-service-arm} as user and group 'gnunet'. You also need to be | ||
3174 | sure to run @code{make install} as root (or use the @code{sudo} option to | ||
3175 | configure) to grant GNUnet sufficient privileges. | ||
3176 | |||
3177 | With this setup, all that is required for enabling system-wide DNS | ||
3178 | interception is for some GNUnet component (VPN or GNS) to request it. | ||
3179 | The @code{gnunet-service-dns} will then start helper programs that will | ||
3180 | make the necessary changes to your firewall (@code{iptables}) rules. | ||
3181 | |||
3182 | Note that this will NOT work if your system sends out DNS traffic to a | ||
3183 | link-local IPv6 address, as in this case GNUnet can intercept the traffic, | ||
3184 | but not inject the responses from the link-local IPv6 address. Hence you | ||
3185 | cannot use system-wide DNS interception in conjunction with link-local | ||
3186 | IPv6-based DNS servers. If such a DNS server is used, it will bypass | ||
3187 | GNUnet's DNS traffic interception. | ||
3188 | |||
3189 | Using the GNU Name System (GNS) requires two different configuration | ||
3190 | steps. | ||
3191 | First of all, GNS needs to be integrated with the operating system. Most | ||
3192 | of this section is about the operating system level integration. | ||
3193 | |||
3194 | Additionally, each individual user who wants to use the system must also | ||
3195 | initialize their GNS zones. This can be done by running (after starting | ||
3196 | GNUnet) | ||
3197 | |||
3198 | @example | ||
3199 | $ gnunet-gns-import.sh | ||
3200 | @end example | ||
3201 | |||
3202 | @noindent | ||
3203 | after the local GNUnet peer has been started. Note that the namestore (in | ||
3204 | particular the namestore database backend) should not be reconfigured | ||
3205 | afterwards (as records are not automatically migrated between backends). | ||
3206 | |||
3207 | The remainder of this chapter will detail the various methods for | ||
3208 | configuring the use of GNS with your operating system. | ||
3209 | |||
3210 | At this point in time you have different options depending on your OS: | ||
3211 | |||
3212 | @table @asis | ||
3213 | |||
3214 | @item Use the gnunet-gns-proxy This approach works for all operating | ||
3215 | systems and is likely the easiest. However, it enables GNS only for | ||
3216 | browsers, not for other applications that might be using DNS, such as SSH. | ||
3217 | Still, using the proxy is required for using HTTP with GNS and is thus | ||
3218 | recommended for all users. To do this, you simply have to run the | ||
3219 | @code{gnunet-gns-proxy-setup-ca} script as the user who will run the | ||
3220 | browser (this will create a GNS certificate authority (CA) on your system | ||
3221 | and import its key into your browser), then start @code{gnunet-gns-proxy} | ||
3222 | and inform your browser to use the Socks5 proxy which | ||
3223 | @code{gnunet-gns-proxy} makes available by default on port 7777. | ||
3224 | @item Use a nsswitch plugin (recommended on GNU systems) | ||
3225 | This approach has the advantage of offering fully personalized resolution | ||
3226 | even on multi-user systems. A potential disadvantage is that some | ||
3227 | applications might be able to bypass GNS. | ||
3228 | @item Use a W32 resolver plugin (recommended on W32) | ||
3229 | This is currently the only option on W32 systems. | ||
3230 | @item Use system-wide DNS packet interception | ||
3231 | This approach is recommended for the GNUnet VPN. It can be used to handle | ||
3232 | GNS at the same time; however, if you only use this method, you will only | ||
3233 | get one root zone per machine (not so great for multi-user systems). | ||
3234 | @end table | ||
3235 | |||
3236 | You can combine system-wide DNS packet interception with the nsswitch | ||
3237 | plugin. | ||
3238 | The setup of the system-wide DNS interception is described here. All of | ||
3239 | the other GNS-specific configuration steps are described in the following | ||
3240 | sections. | ||
3241 | |||
3242 | @node Configuring the GNS nsswitch plugin | ||
3243 | @subsubsection Configuring the GNS nsswitch plugin | ||
3244 | |||
3245 | The Name Service Switch (NSS) is a facility in Unix-like operating systems | ||
3246 | @footnote{More accurate: NSS is a functionality of the GNU C Library} | ||
3247 | that provides a variety of sources for common configuration databases and | ||
3248 | name resolution mechanisms. | ||
3249 | A superuser (system administrator) usually configures the | ||
3250 | operating system's name services using the file | ||
3251 | @file{/etc/nsswitch.conf}. | ||
3252 | |||
3253 | GNS provides a NSS plugin to integrate GNS name resolution with the | ||
3254 | operating system's name resolution process. | ||
3255 | To use the GNS NSS plugin you have to either | ||
3256 | |||
3257 | @itemize @bullet | ||
3258 | @item install GNUnet as root or | ||
3259 | @item compile GNUnet with the @code{--with-sudo=yes} switch. | ||
3260 | @end itemize | ||
3261 | |||
3262 | Name resolution is controlled by the @emph{hosts} section in the NSS | ||
3263 | configuration. By default this section first performs a lookup in the | ||
3264 | @file{/etc/hosts} file and then in DNS. | ||
3265 | The nsswitch file should contain a line similar to: | ||
3266 | |||
3267 | @example | ||
3268 | hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4 | ||
3269 | @end example | ||
3270 | |||
3271 | @noindent | ||
3272 | Here the GNS NSS plugin can be added to perform a GNS lookup before | ||
3273 | performing a DNS lookup. | ||
3274 | The GNS NSS plugin has to be added to the "hosts" section in | ||
3275 | @file{/etc/nsswitch.conf} file before DNS related plugins: | ||
3276 | |||
3277 | @example | ||
3278 | ... | ||
3279 | hosts: files gns [NOTFOUND=return] dns mdns4_minimal mdns4 | ||
3280 | ... | ||
3281 | @end example | ||
3282 | |||
3283 | @noindent | ||
3284 | The @code{NOTFOUND=return} will ensure that if a @code{.gnu} name is not | ||
3285 | found in GNS it will not be queried in DNS. | ||
3286 | |||
3287 | @node Configuring GNS on W32 | ||
3288 | @subsubsection Configuring GNS on W32 | ||
3289 | |||
3290 | This document is a guide to configuring GNU Name System on W32-compatible | ||
3291 | platforms. | ||
3292 | |||
3293 | After GNUnet is installed, run the w32nsp-install tool: | ||
3294 | |||
3295 | @example | ||
3296 | w32nsp-install.exe libw32nsp-0.dll | ||
3297 | @end example | ||
3298 | |||
3299 | @noindent | ||
3300 | ('0' is the library version of W32 NSP; it might increase in the future, | ||
3301 | change the invocation accordingly). | ||
3302 | |||
3303 | This will install GNS namespace provider into the system and allow other | ||
3304 | applications to resolve names that end in '@strong{gnu}' | ||
3305 | and '@strong{zkey}'. Note that namespace provider requires | ||
3306 | gnunet-gns-helper-service-w32 to be running, as well as gns service | ||
3307 | itself (and its usual dependencies). | ||
3308 | |||
3309 | Namespace provider is hardcoded to connect to @strong{127.0.0.1:5353}, | ||
3310 | and this is where gnunet-gns-helper-service-w32 should be listening to | ||
3311 | (and is configured to listen to by default). | ||
3312 | |||
3313 | To uninstall the provider, run: | ||
3314 | |||
3315 | @example | ||
3316 | w32nsp-uninstall.exe | ||
3317 | @end example | ||
3318 | |||
3319 | @noindent | ||
3320 | (uses provider GUID to uninstall it, does not need a dll name). | ||
3321 | |||
3322 | Note that while MSDN claims that other applications will only be able to | ||
3323 | use the new namespace provider after re-starting, in reality they might | ||
3324 | stat to use it without that. Conversely, they might stop using the | ||
3325 | provider after it's been uninstalled, even if they were not re-started. | ||
3326 | W32 will not permit namespace provider library to be deleted or | ||
3327 | overwritten while the provider is installed, and while there is at least | ||
3328 | one process still using it (even after it was uninstalled). | ||
3329 | |||
3330 | @node GNS Proxy Setup | ||
3331 | @subsubsection GNS Proxy Setup | ||
3332 | |||
3333 | When using the GNU Name System (GNS) to browse the WWW, there are several | ||
3334 | issues that can be solved by adding the GNS Proxy to your setup: | ||
3335 | |||
3336 | @itemize @bullet | ||
3337 | |||
3338 | @item If the target website does not support GNS, it might assume that it | ||
3339 | is operating under some name in the legacy DNS system (such as | ||
3340 | example.com). It may then attempt to set cookies for that domain, and the | ||
3341 | web server might expect a @code{Host: example.com} header in the request | ||
3342 | from your browser. | ||
3343 | However, your browser might be using @code{example.gnu} for the | ||
3344 | @code{Host} header and might only accept (and send) cookies for | ||
3345 | @code{example.gnu}. The GNS Proxy will perform the necessary translations | ||
3346 | of the hostnames for cookies and HTTP headers (using the LEHO record for | ||
3347 | the target domain as the desired substitute). | ||
3348 | |||
3349 | @item If using HTTPS, the target site might include an SSL certificate | ||
3350 | which is either only valid for the LEHO domain or might match a TLSA | ||
3351 | record in GNS. However, your browser would expect a valid certificate for | ||
3352 | @code{example.gnu}, not for some legacy domain name. The proxy will | ||
3353 | validate the certificate (either against LEHO or TLSA) and then | ||
3354 | on-the-fly produce a valid certificate for the exchange, signed by your | ||
3355 | own CA. Assuming you installed the CA of your proxy in your browser's | ||
3356 | certificate authority list, your browser will then trust the | ||
3357 | HTTPS/SSL/TLS connection, as the hostname mismatch is hidden by the proxy. | ||
3358 | |||
3359 | @item Finally, the proxy will in the future indicate to the server that it | ||
3360 | speaks GNS, which will enable server operators to deliver GNS-enabled web | ||
3361 | sites to your browser (and continue to deliver legacy links to legacy | ||
3362 | browsers) | ||
3363 | @end itemize | ||
3364 | |||
3365 | @node Setup of the GNS CA | ||
3366 | @subsubsection Setup of the GNS CA | ||
3367 | |||
3368 | First you need to create a CA certificate that the proxy can use. | ||
3369 | To do so use the provided script gnunet-gns-proxy-ca: | ||
3370 | |||
3371 | @example | ||
3372 | $ gnunet-gns-proxy-setup-ca | ||
3373 | @end example | ||
3374 | |||
3375 | @noindent | ||
3376 | This will create a personal certification authority for you and add this | ||
3377 | authority to the firefox and chrome database. The proxy will use the this | ||
3378 | CA certificate to generate @code{*.gnu} client certificates on the fly. | ||
3379 | |||
3380 | Note that the proxy uses libcurl. Make sure your version of libcurl uses | ||
3381 | GnuTLS and NOT OpenSSL. The proxy will @b{not} work with libcurl compiled | ||
3382 | against OpenSSL. | ||
3383 | |||
3384 | You can check the configuration your libcurl was build with by | ||
3385 | running: | ||
3386 | |||
3387 | @example | ||
3388 | curl --version | ||
3389 | @end example | ||
3390 | |||
3391 | the output will look like this (without the linebreaks): | ||
3392 | |||
3393 | @example | ||
3394 | gnurl --version | ||
3395 | curl 7.56.0 (x86_64-unknown-linux-gnu) libcurl/7.56.0 \ | ||
3396 | GnuTLS/3.5.13 zlib/1.2.11 libidn2/2.0.4 | ||
3397 | Release-Date: 2017-10-08 | ||
3398 | Protocols: http https | ||
3399 | Features: AsynchDNS IDN IPv6 Largefile NTLM SSL libz \ | ||
3400 | TLS-SRP UnixSockets HTTPS-proxy | ||
3401 | @end example | ||
3402 | |||
3403 | @node Testing the GNS setup | ||
3404 | @subsubsection Testing the GNS setup | ||
3405 | |||
3406 | Now for testing purposes we can create some records in our zone to test | ||
3407 | the SSL functionality of the proxy: | ||
3408 | |||
3409 | @example | ||
3410 | $ gnunet-namestore -a -e "1 d" -n "homepage" -t A -V 131.159.74.67 | ||
3411 | $ gnunet-namestore -a -e "1 d" -n "homepage" -t LEHO -V "gnunet.org" | ||
3412 | @end example | ||
3413 | |||
3414 | @noindent | ||
3415 | At this point we can start the proxy. Simply execute | ||
3416 | |||
3417 | @example | ||
3418 | $ gnunet-gns-proxy | ||
3419 | @end example | ||
3420 | |||
3421 | @noindent | ||
3422 | Configure your browser to use this SOCKSv5 proxy on port 7777 and visit | ||
3423 | this link. | ||
3424 | If you use @command{Firefox} (or one of its deriviates/forks such as | ||
3425 | Icecat) you also have to go to @code{about:config} and set the key | ||
3426 | @code{network.proxy.socks_remote_dns} to @code{true}. | ||
3427 | |||
3428 | When you visit @code{https://homepage.gnu/}, you should get to the | ||
3429 | @code{https://gnunet.org/} frontpage and the browser (with the correctly | ||
3430 | configured proxy) should give you a valid SSL certificate for | ||
3431 | @code{homepage.gnu} and no warnings. It should look like this: | ||
3432 | |||
3433 | @c FIXME: Image does not exist, create it or save it from Drupal? | ||
3434 | @c @image{images/gnunethpgns.png,5in,, picture of homepage.gnu in Webbrowser} | ||
3435 | |||
3436 | @node Automatic Shortening in the GNU Name System | ||
3437 | @subsubsection Automatic Shortening in the GNU Name System | ||
3438 | |||
3439 | This page describes a possible option for 'automatic name shortening', | ||
3440 | which you can choose to enable with the GNU Name System. | ||
3441 | |||
3442 | When GNS encounters a name for the first time, it can use the 'NICK' | ||
3443 | record of the originating zone to automatically generate a name for the | ||
3444 | zone. If automatic shortening is enabled, those auto-generated names will | ||
3445 | be placed (as private records) into your personal 'shorten' zone (to | ||
3446 | prevent confusion with manually selected names). | ||
3447 | Then, in the future, if the same name is encountered again, GNS will | ||
3448 | display the shortened name instead (the first time, the long name will | ||
3449 | still be used as shortening typically happens asynchronously as looking up | ||
3450 | the 'NICK' record takes some time). Using this feature can be a convenient | ||
3451 | way to avoid very long @code{.gnu} names; however, note that names from | ||
3452 | the shorten-zone are assigned on a first-come-first-serve basis and should | ||
3453 | not be trusted. Furthermore, if you enable this feature, you will no | ||
3454 | longer see the full delegation chain for zones once shortening has been | ||
3455 | applied. | ||
3456 | |||
3457 | @node Configuring the GNUnet VPN | ||
3458 | @subsection Configuring the GNUnet VPN | ||
3459 | |||
3460 | @menu | ||
3461 | * IPv4 address for interface:: | ||
3462 | * IPv6 address for interface:: | ||
3463 | * Configuring the GNUnet VPN DNS:: | ||
3464 | * Configuring the GNUnet VPN Exit Service:: | ||
3465 | * IP Address of external DNS resolver:: | ||
3466 | * IPv4 address for Exit interface:: | ||
3467 | * IPv6 address for Exit interface:: | ||
3468 | @end menu | ||
3469 | |||
3470 | Before configuring the GNUnet VPN, please make sure that system-wide DNS | ||
3471 | interception is configured properly as described in the section on the | ||
3472 | GNUnet DNS setup. @pxref{Configuring the GNU Name System}, | ||
3473 | if you haven't done so already. | ||
3474 | |||
3475 | The default options for the GNUnet VPN are usually sufficient to use | ||
3476 | GNUnet as a Layer 2 for your Internet connection. | ||
3477 | However, what you always have to specify is which IP protocol you want | ||
3478 | to tunnel: IPv4, IPv6 or both. | ||
3479 | Furthermore, if you tunnel both, you most likely should also tunnel | ||
3480 | all of your DNS requests. | ||
3481 | You theoretically can tunnel "only" your DNS traffic, but that usually | ||
3482 | makes little sense. | ||
3483 | |||
3484 | The other options as shown on the gnunet-setup tool are: | ||
3485 | |||
3486 | @node IPv4 address for interface | ||
3487 | @subsubsection IPv4 address for interface | ||
3488 | |||
3489 | This is the IPv4 address the VPN interface will get. You should pick an | ||
3490 | 'private' IPv4 network that is not yet in use for you system. For example, | ||
3491 | if you use @code{10.0.0.1/255.255.0.0} already, you might use | ||
3492 | @code{10.1.0.1/255.255.0.0}. | ||
3493 | If you use @code{10.0.0.1/255.0.0.0} already, then you might use | ||
3494 | @code{192.168.0.1/255.255.0.0}. | ||
3495 | If your system is not in a private IP-network, using any of the above will | ||
3496 | work fine. | ||
3497 | You should try to make the mask of the address big enough | ||
3498 | (@code{255.255.0.0} or, even better, @code{255.0.0.0}) to allow more | ||
3499 | mappings of remote IP Addresses into this range. | ||
3500 | However, even a @code{255.255.255.0} mask will suffice for most users. | ||
3501 | |||
3502 | @node IPv6 address for interface | ||
3503 | @subsubsection IPv6 address for interface | ||
3504 | |||
3505 | The IPv6 address the VPN interface will get. Here you can specify any | ||
3506 | non-link-local address (the address should not begin with "@code{fe80:}"). | ||
3507 | A subnet Unique Local Unicast (@code{fd00::/8} prefix) that you are | ||
3508 | currently not using would be a good choice. | ||
3509 | |||
3510 | @node Configuring the GNUnet VPN DNS | ||
3511 | @subsubsection Configuring the GNUnet VPN DNS | ||
3512 | |||
3513 | To resolve names for remote nodes, activate the DNS exit option. | ||
3514 | |||
3515 | @node Configuring the GNUnet VPN Exit Service | ||
3516 | @subsubsection Configuring the GNUnet VPN Exit Service | ||
3517 | |||
3518 | If you want to allow other users to share your Internet connection (yes, | ||
3519 | this may be dangerous, just as running a Tor exit node) or want to | ||
3520 | provide access to services on your host (this should be less dangerous, | ||
3521 | as long as those services are secure), you have to enable the GNUnet exit | ||
3522 | daemon. | ||
3523 | |||
3524 | You then get to specify which exit functions you want to provide. By | ||
3525 | enabling the exit daemon, you will always automatically provide exit | ||
3526 | functions for manually configured local services (this component of the | ||
3527 | system is under | ||
3528 | development and not documented further at this time). As for those | ||
3529 | services you explicitly specify the target IP address and port, there is | ||
3530 | no significant security risk in doing so. | ||
3531 | |||
3532 | Furthermore, you can serve as a DNS, IPv4 or IPv6 exit to the Internet. | ||
3533 | Being a DNS exit is usually pretty harmless. However, enabling IPv4 or | ||
3534 | IPv6-exit without further precautions may enable adversaries to access | ||
3535 | your local network, send spam, attack other systems from your Internet | ||
3536 | connection and to other mischief that will appear to come from your | ||
3537 | machine. This may or may not get you into legal trouble. | ||
3538 | If you want to allow IPv4 or IPv6-exit functionality, you should strongly | ||
3539 | consider adding additional firewall rules manually to protect your local | ||
3540 | network and to restrict outgoing TCP traffic (i.e. by not allowing access | ||
3541 | to port 25). While we plan to improve exit-filtering in the future, | ||
3542 | you're currently on your own here. | ||
3543 | Essentially, be prepared for any kind of IP-traffic to exit the respective | ||
3544 | TUN interface (and GNUnet will enable IP-forwarding and NAT for the | ||
3545 | interface automatically). | ||
3546 | |||
3547 | Additional configuration options of the exit as shown by the gnunet-setup | ||
3548 | tool are: | ||
3549 | |||
3550 | @node IP Address of external DNS resolver | ||
3551 | @subsubsection IP Address of external DNS resolver | ||
3552 | |||
3553 | If DNS traffic is to exit your machine, it will be send to this DNS | ||
3554 | resolver. You can specify an IPv4 or IPv6 address. | ||
3555 | |||
3556 | @node IPv4 address for Exit interface | ||
3557 | @subsubsection IPv4 address for Exit interface | ||
3558 | |||
3559 | This is the IPv4 address the Interface will get. Make the mask of the | ||
3560 | address big enough (255.255.0.0 or, even better, 255.0.0.0) to allow more | ||
3561 | mappings of IP addresses into this range. As for the VPN interface, any | ||
3562 | unused, private IPv4 address range will do. | ||
3563 | |||
3564 | @node IPv6 address for Exit interface | ||
3565 | @subsubsection IPv6 address for Exit interface | ||
3566 | |||
3567 | The public IPv6 address the interface will get. If your kernel is not a | ||
3568 | very recent kernel and you are willing to manually enable IPv6-NAT, the | ||
3569 | IPv6 address you specify here must be a globally routed IPv6 address of | ||
3570 | your host. | ||
3571 | |||
3572 | Suppose your host has the address @code{2001:4ca0::1234/64}, then | ||
3573 | using @code{2001:4ca0::1:0/112} would be fine (keep the first 64 bits, | ||
3574 | then change at least one bit in the range before the bitmask, in the | ||
3575 | example above we changed bit 111 from 0 to 1). | ||
3576 | |||
3577 | You may also have to configure your router to route traffic for the entire | ||
3578 | subnet (@code{2001:4ca0::1:0/112} for example) through your computer (this | ||
3579 | should be automatic with IPv6, but obviously anything can be | ||
3580 | disabled). | ||
3581 | |||
3582 | @node Bandwidth Configuration | ||
3583 | @subsection Bandwidth Configuration | ||
3584 | |||
3585 | You can specify how many bandwidth GNUnet is allowed to use to receive | ||
3586 | and send data. This is important for users with limited bandwidth or | ||
3587 | traffic volume. | ||
3588 | |||
3589 | @node Configuring NAT | ||
3590 | @subsection Configuring NAT | ||
3591 | |||
3592 | Most hosts today do not have a normal global IP address but instead are | ||
3593 | behind a router performing Network Address Translation (NAT) which assigns | ||
3594 | each host in the local network a private IP address. | ||
3595 | As a result, these machines cannot trivially receive inbound connections | ||
3596 | from the Internet. GNUnet supports NAT traversal to enable these machines | ||
3597 | to receive incoming connections from other peers despite their | ||
3598 | limitations. | ||
3599 | |||
3600 | In an ideal world, you can press the "Attempt automatic configuration" | ||
3601 | button in gnunet-setup to automatically configure your peer correctly. | ||
3602 | Alternatively, your distribution might have already triggered this | ||
3603 | automatic configuration during the installation process. | ||
3604 | However, automatic configuration can fail to determine the optimal | ||
3605 | settings, resulting in your peer either not receiving as many connections | ||
3606 | as possible, or in the worst case it not connecting to the network at all. | ||
3607 | |||
3608 | To manually configure the peer, you need to know a few things about your | ||
3609 | network setup. First, determine if you are behind a NAT in the first | ||
3610 | place. | ||
3611 | This is always the case if your IP address starts with "10.*" or | ||
3612 | "192.168.*". Next, if you have control over your NAT router, you may | ||
3613 | choose to manually configure it to allow GNUnet traffic to your host. | ||
3614 | If you have configured your NAT to forward traffic on ports 2086 (and | ||
3615 | possibly 1080) to your host, you can check the "NAT ports have been opened | ||
3616 | manually" option, which corresponds to the "PUNCHED_NAT" option in the | ||
3617 | configuration file. If you did not punch your NAT box, it may still be | ||
3618 | configured to support UPnP, which allows GNUnet to automatically | ||
3619 | configure it. In that case, you need to install the "upnpc" command, | ||
3620 | enable UPnP (or PMP) on your NAT box and set the "Enable NAT traversal | ||
3621 | via UPnP or PMP" option (corresponding to "ENABLE_UPNP" in the | ||
3622 | configuration file). | ||
3623 | |||
3624 | Some NAT boxes can be traversed using the autonomous NAT traversal method. | ||
3625 | This requires certain GNUnet components to be installed with "SUID" | ||
3626 | prividledges on your system (so if you're installing on a system you do | ||
3627 | not have administrative rights to, this will not work). | ||
3628 | If you installed as 'root', you can enable autonomous NAT traversal by | ||
3629 | checking the "Enable NAT traversal using ICMP method". | ||
3630 | The ICMP method requires a way to determine your NAT's external (global) | ||
3631 | IP address. This can be done using either UPnP, DynDNS, or by manual | ||
3632 | configuration. If you have a DynDNS name or know your external IP address, | ||
3633 | you should enter that name under "External (public) IPv4 address" (which | ||
3634 | corresponds to the "EXTERNAL_ADDRESS" option in the configuration file). | ||
3635 | If you leave the option empty, GNUnet will try to determine your external | ||
3636 | IP address automatically (which may fail, in which case autonomous | ||
3637 | NAT traversal will then not work). | ||
3638 | |||
3639 | Finally, if you yourself are not behind NAT but want to be able to | ||
3640 | connect to NATed peers using autonomous NAT traversal, you need to check | ||
3641 | the "Enable connecting to NATed peers using ICMP method" box. | ||
3642 | |||
3643 | |||
3644 | @node Peer configuration for distributions | ||
3645 | @subsection Peer configuration for distributions | ||
3646 | |||
3647 | The "GNUNET_DATA_HOME" in "[path]" in @file{/etc/gnunet.conf} should be | ||
3648 | manually set to "/var/lib/gnunet/data/" as the default | ||
3649 | "~/.local/share/gnunet/" is probably not that appropriate in this case. | ||
3650 | Similarly, distributions may consider pointing "GNUNET_RUNTIME_DIR" to | ||
3651 | "/var/run/gnunet/" and "GNUNET_HOME" to "/var/lib/gnunet/". Also, should a | ||
3652 | distribution decide to override system defaults, all of these changes | ||
3653 | should be done in a custom @file{/etc/gnunet.conf} and not in the files | ||
3654 | in the @file{config.d/} directory. | ||
3655 | |||
3656 | Given the proposed access permissions, the "gnunet-setup" tool must be | ||
3657 | run as use "gnunet" (and with option "-c /etc/gnunet.conf" so that it | ||
3658 | modifies the system configuration). As always, gnunet-setup should be run | ||
3659 | after the GNUnet peer was stopped using "gnunet-arm -e". Distributions | ||
3660 | might want to include a wrapper for gnunet-setup that allows the | ||
3661 | desktop-user to "sudo" (i.e. using gtksudo) to the "gnunet" user account | ||
3662 | and then runs "gnunet-arm -e", "gnunet-setup" and "gnunet-arm -s" in | ||
3663 | sequence. | ||
3664 | |||
3665 | @node How to start and stop a GNUnet peer | ||
3666 | @section How to start and stop a GNUnet peer | ||
3667 | |||
3668 | This section describes how to start a GNUnet peer. It assumes that you | ||
3669 | have already compiled and installed GNUnet and its' dependencies. | ||
3670 | Before you start a GNUnet peer, you may want to create a configuration | ||
3671 | file using gnunet-setup (but you do not have to). | ||
3672 | Sane defaults should exist in your | ||
3673 | @file{$GNUNET_PREFIX/share/gnunet/config.d/} directory, so in practice | ||
3674 | you could simply start without any configuration. If you want to | ||
3675 | configure your peer later, you need to stop it before invoking the | ||
3676 | @code{gnunet-setup} tool to customize further and to test your | ||
3677 | configuration (@code{gnunet-setup} has build-in test functions). | ||
3678 | |||
3679 | The most important option you might have to still set by hand is in | ||
3680 | [PATHS]. Here, you use the option "GNUNET_HOME" to specify the path where | ||
3681 | GNUnet should store its data. | ||
3682 | It defaults to @code{$HOME/}, which again should work for most users. | ||
3683 | Make sure that the directory specified as GNUNET_HOME is writable to | ||
3684 | the user that you will use to run GNUnet (note that you can run frontends | ||
3685 | using other users, GNUNET_HOME must only be accessible to the user used to | ||
3686 | run the background processes). | ||
3687 | |||
3688 | You will also need to make one central decision: should all of GNUnet be | ||
3689 | run under your normal UID, or do you want distinguish between system-wide | ||
3690 | (user-independent) GNUnet services and personal GNUnet services. The | ||
3691 | multi-user setup is slightly more complicated, but also more secure and | ||
3692 | generally recommended. | ||
3693 | |||
3694 | @menu | ||
3695 | * The Single-User Setup:: | ||
3696 | * The Multi-User Setup:: | ||
3697 | * Killing GNUnet services:: | ||
3698 | * Access Control for GNUnet:: | ||
3699 | @end menu | ||
3700 | |||
3701 | @node The Single-User Setup | ||
3702 | @subsection The Single-User Setup | ||
3703 | |||
3704 | For the single-user setup, you do not need to do anything special and can | ||
3705 | just start the GNUnet background processes using @code{gnunet-arm}. | ||
3706 | By default, GNUnet looks in @file{~/.config/gnunet.conf} for a | ||
3707 | configuration (or @code{$XDG_CONFIG_HOME/gnunet.conf} if@ | ||
3708 | @code{$XDG_CONFIG_HOME} is defined). If your configuration lives | ||
3709 | elsewhere, you need to pass the @code{-c FILENAME} option to all GNUnet | ||
3710 | commands. | ||
3711 | |||
3712 | Assuming the configuration file is called @file{~/.config/gnunet.conf}, | ||
3713 | you start your peer using the @code{gnunet-arm} command (say as user | ||
3714 | @code{gnunet}) using: | ||
3715 | |||
3716 | @example | ||
3717 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
3718 | @end example | ||
3719 | |||
3720 | @noindent | ||
3721 | The "-s" option here is for "start". The command should return almost | ||
3722 | instantly. If you want to stop GNUnet, you can use: | ||
3723 | |||
3724 | @example | ||
3725 | gnunet-arm -c ~/.config/gnunet.conf -e | ||
3726 | @end example | ||
3727 | |||
3728 | @noindent | ||
3729 | The "-e" option here is for "end". | ||
3730 | |||
3731 | Note that this will only start the basic peer, no actual applications | ||
3732 | will be available. | ||
3733 | If you want to start the file-sharing service, use (after starting | ||
3734 | GNUnet): | ||
3735 | |||
3736 | @example | ||
3737 | gnunet-arm -c ~/.config/gnunet.conf -i fs | ||
3738 | @end example | ||
3739 | |||
3740 | @noindent | ||
3741 | The "-i fs" option here is for "initialize" the "fs" (file-sharing) | ||
3742 | application. You can also selectively kill only file-sharing support using | ||
3743 | |||
3744 | @example | ||
3745 | gnunet-arm -c ~/.config/gnunet.conf -k fs | ||
3746 | @end example | ||
3747 | |||
3748 | @noindent | ||
3749 | Assuming that you want certain services (like file-sharing) to be always | ||
3750 | automatically started whenever you start GNUnet, you can activate them by | ||
3751 | setting "FORCESTART=YES" in the respective section of the configuration | ||
3752 | file (for example, "[fs]"). Then GNUnet with file-sharing support would | ||
3753 | be started whenever you@ enter: | ||
3754 | |||
3755 | @example | ||
3756 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
3757 | @end example | ||
3758 | |||
3759 | @noindent | ||
3760 | Alternatively, you can combine the two options: | ||
3761 | |||
3762 | @example | ||
3763 | gnunet-arm -c ~/.config/gnunet.conf -s -i fs | ||
3764 | @end example | ||
3765 | |||
3766 | @noindent | ||
3767 | Using @code{gnunet-arm} is also the preferred method for initializing | ||
3768 | GNUnet from @code{init}. | ||
3769 | |||
3770 | Finally, you should edit your @code{crontab} (using the @code{crontab} | ||
3771 | command) and insert a line@ | ||
3772 | |||
3773 | @example | ||
3774 | @@reboot gnunet-arm -c ~/.config/gnunet.conf -s | ||
3775 | @end example | ||
3776 | |||
3777 | to automatically start your peer whenever your system boots. | ||
3778 | |||
3779 | @node The Multi-User Setup | ||
3780 | @subsection The Multi-User Setup | ||
3781 | |||
3782 | This requires you to create a user @code{gnunet} and an additional group | ||
3783 | @code{gnunetdns}, prior to running @code{make install} during | ||
3784 | installation. | ||
3785 | Then, you create a configuration file @file{/etc/gnunet.conf} which should | ||
3786 | contain the lines:@ | ||
3787 | |||
3788 | @example | ||
3789 | [arm] | ||
3790 | SYSTEM_ONLY = YES | ||
3791 | USER_ONLY = NO | ||
3792 | @end example | ||
3793 | |||
3794 | @noindent | ||
3795 | Then, perform the same steps to run GNUnet as in the per-user | ||
3796 | configuration, except as user @code{gnunet} (including the | ||
3797 | @code{crontab} installation). | ||
3798 | You may also want to run @code{gnunet-setup} to configure your peer | ||
3799 | (databases, etc.). | ||
3800 | Make sure to pass @code{-c /etc/gnunet.conf} to all commands. If you | ||
3801 | run @code{gnunet-setup} as user @code{gnunet}, you might need to change | ||
3802 | permissions on @file{/etc/gnunet.conf} so that the @code{gnunet} user can | ||
3803 | write to the file (during setup). | ||
3804 | |||
3805 | Afterwards, you need to perform another setup step for each normal user | ||
3806 | account from which you want to access GNUnet. First, grant the normal user | ||
3807 | (@code{$USER}) permission to the group gnunet: | ||
3808 | |||
3809 | @example | ||
3810 | # adduser $USER gnunet | ||
3811 | @end example | ||
3812 | |||
3813 | @noindent | ||
3814 | Then, create a configuration file in @file{~/.config/gnunet.conf} for the | ||
3815 | $USER with the lines: | ||
3816 | |||
3817 | @example | ||
3818 | [arm] | ||
3819 | SYSTEM_ONLY = NO | ||
3820 | USER_ONLY = YES | ||
3821 | @end example | ||
3822 | |||
3823 | @noindent | ||
3824 | This will ensure that @code{gnunet-arm} when started by the normal user | ||
3825 | will only run services that are per-user, and otherwise rely on the | ||
3826 | system-wide services. | ||
3827 | Note that the normal user may run gnunet-setup, but the | ||
3828 | configuration would be ineffective as the system-wide services will use | ||
3829 | @file{/etc/gnunet.conf} and ignore options set by individual users. | ||
3830 | |||
3831 | Again, each user should then start the peer using | ||
3832 | @file{gnunet-arm -s} --- and strongly consider adding logic to start | ||
3833 | the peer automatically to their crontab. | ||
3834 | |||
3835 | Afterwards, you should see two (or more, if you have more than one USER) | ||
3836 | @code{gnunet-service-arm} processes running in your system. | ||
3837 | |||
3838 | @node Killing GNUnet services | ||
3839 | @subsection Killing GNUnet services | ||
3840 | |||
3841 | It is not necessary to stop GNUnet services explicitly when shutting | ||
3842 | down your computer. | ||
3843 | |||
3844 | It should be noted that manually killing "most" of the | ||
3845 | @code{gnunet-service} processes is generally not a successful method for | ||
3846 | stopping a peer (since @code{gnunet-service-arm} will instantly restart | ||
3847 | them). The best way to explicitly stop a peer is using | ||
3848 | @code{gnunet-arm -e}; note that the per-user services may need to be | ||
3849 | terminated before the system-wide services will terminate normally. | ||
3850 | |||
3851 | @node Access Control for GNUnet | ||
3852 | @subsection Access Control for GNUnet | ||
3853 | |||
3854 | This chapter documents how we plan to make access control work within the | ||
3855 | GNUnet system for a typical peer. It should be read as a best-practice | ||
3856 | installation guide for advanced users and builders of binary | ||
3857 | distributions. The recommendations in this guide apply to POSIX-systems | ||
3858 | with full support for UNIX domain sockets only. | ||
3859 | |||
3860 | Note that this is an advanced topic. The discussion presumes a very good | ||
3861 | understanding of users, groups and file permissions. Normal users on | ||
3862 | hosts with just a single user can just install GNUnet under their own | ||
3863 | account (and possibly allow the installer to use SUDO to grant additional | ||
3864 | permissions for special GNUnet tools that need additional rights). | ||
3865 | The discussion below largely applies to installations where multiple users | ||
3866 | share a system and to installations where the best possible security is | ||
3867 | paramount. | ||
3868 | |||
3869 | A typical GNUnet system consists of components that fall into four | ||
3870 | categories: | ||
3871 | |||
3872 | @table @asis | ||
3873 | |||
3874 | @item User interfaces | ||
3875 | User interfaces are not security sensitive and are supposed to be run and | ||
3876 | used by normal system users. | ||
3877 | The GTK GUIs and most command-line programs fall into this category. | ||
3878 | Some command-line tools (like gnunet-transport) should be excluded as they | ||
3879 | offer low-level access that normal users should not need. | ||
3880 | @item System services and support tools | ||
3881 | System services should always run and offer services that can then be | ||
3882 | accessed by the normal users. | ||
3883 | System services do not require special permissions, but as they are not | ||
3884 | specific to a particular user, they probably should not run as a | ||
3885 | particular user. Also, there should typically only be one GNUnet peer per | ||
3886 | host. System services include the gnunet-service and gnunet-daemon | ||
3887 | programs; support tools include command-line programs such as gnunet-arm. | ||
3888 | @item Priviledged helpers | ||
3889 | Some GNUnet components require root rights to open raw sockets or perform | ||
3890 | other special operations. These gnunet-helper binaries are typically | ||
3891 | installed SUID and run from services or daemons. | ||
3892 | @item Critical services | ||
3893 | Some GNUnet services (such as the DNS service) can manipulate the service | ||
3894 | in deep and possibly highly security sensitive ways. For example, the DNS | ||
3895 | service can be used to intercept and alter any DNS query originating from | ||
3896 | the local machine. Access to the APIs of these critical services and their | ||
3897 | priviledged helpers must be tightly controlled. | ||
3898 | @end table | ||
3899 | |||
3900 | @c FIXME: The titles of these chapters are too long in the index. | ||
3901 | |||
3902 | @menu | ||
3903 | * Recommendation - Disable access to services via TCP:: | ||
3904 | * Recommendation - Run most services as system user "gnunet":: | ||
3905 | * Recommendation - Control access to services using group "gnunet":: | ||
3906 | * Recommendation - Limit access to certain SUID binaries by group "gnunet":: | ||
3907 | * Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns":: | ||
3908 | * Differences between "make install" and these recommendations:: | ||
3909 | @end menu | ||
3910 | |||
3911 | @node Recommendation - Disable access to services via TCP | ||
3912 | @subsubsection Recommendation - Disable access to services via TCP | ||
3913 | |||
3914 | GNUnet services allow two types of access: via TCP socket or via UNIX | ||
3915 | domain socket. | ||
3916 | If the service is available via TCP, access control can only be | ||
3917 | implemented by restricting connections to a particular range of IP | ||
3918 | addresses. | ||
3919 | This is acceptable for non-critical services that are supposed to be | ||
3920 | available to all users on the local system or local network. | ||
3921 | However, as TCP is generally less efficient and it is rarely the case | ||
3922 | that a single GNUnet peer is supposed to serve an entire local network, | ||
3923 | the default configuration should disable TCP access to all GNUnet | ||
3924 | services on systems with support for UNIX domain sockets. | ||
3925 | As of GNUnet 0.9.2, configuration files with TCP access disabled should be | ||
3926 | generated by default. Users can re-enable TCP access to particular | ||
3927 | services simply by specifying a non-zero port number in the section of | ||
3928 | the respective service. | ||
3929 | |||
3930 | |||
3931 | @node Recommendation - Run most services as system user "gnunet" | ||
3932 | @subsubsection Recommendation - Run most services as system user "gnunet" | ||
3933 | |||
3934 | GNUnet's main services should be run as a separate user "gnunet" in a | ||
3935 | special group "gnunet". | ||
3936 | The user "gnunet" should start the peer using "gnunet-arm -s" during | ||
3937 | system startup. The home directory for this user should be | ||
3938 | @file{/var/lib/gnunet} and the configuration file should be | ||
3939 | @file{/etc/gnunet.conf}. | ||
3940 | Only the @code{gnunet} user should have the right to access | ||
3941 | @file{/var/lib/gnunet} (@emph{mode: 700}). | ||
3942 | |||
3943 | @node Recommendation - Control access to services using group "gnunet" | ||
3944 | @subsubsection Recommendation - Control access to services using group "gnunet" | ||
3945 | |||
3946 | Users that should be allowed to use the GNUnet peer should be added to the | ||
3947 | group "gnunet". Using GNUnet's access control mechanism for UNIX domain | ||
3948 | sockets, those services that are considered useful to ordinary users | ||
3949 | should be made available by setting "UNIX_MATCH_GID=YES" for those | ||
3950 | services. | ||
3951 | Again, as shipped, GNUnet provides reasonable defaults. | ||
3952 | Permissions to access the transport and core subsystems might additionally | ||
3953 | be granted without necessarily causing security concerns. | ||
3954 | Some services, such as DNS, must NOT be made accessible to the "gnunet" | ||
3955 | group (and should thus only be accessible to the "gnunet" user and | ||
3956 | services running with this UID). | ||
3957 | |||
3958 | @node Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
3959 | @subsubsection Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
3960 | |||
3961 | Most of GNUnet's SUID binaries should be safe even if executed by normal | ||
3962 | users. However, it is possible to reduce the risk a little bit more by | ||
3963 | making these binaries owned by the group "gnunet" and restricting their | ||
3964 | execution to user of the group "gnunet" as well (4750). | ||
3965 | |||
3966 | @node Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
3967 | @subsubsection Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
3968 | |||
3969 | A special group "gnunetdns" should be created for controlling access to | ||
3970 | the "gnunet-helper-dns". | ||
3971 | The binary should then be owned by root and be in group "gnunetdns" and | ||
3972 | be installed SUID and only be group-executable (2750). | ||
3973 | @b{Note that the group "gnunetdns" should have no users in it at all, | ||
3974 | ever.} | ||
3975 | The "gnunet-service-dns" program should be executed by user "gnunet" (via | ||
3976 | gnunet-service-arm) with the binary owned by the user "root" and the group | ||
3977 | "gnunetdns" and be SGID (2700). This way, @strong{only} | ||
3978 | "gnunet-service-dns" can change its group to "gnunetdns" and execute the | ||
3979 | helper, and the helper can then run as root (as per SUID). | ||
3980 | Access to the API offered by "gnunet-service-dns" is in turn restricted | ||
3981 | to the user "gnunet" (not the group!), which means that only | ||
3982 | "benign" services can manipulate DNS queries using "gnunet-service-dns". | ||
3983 | |||
3984 | @node Differences between "make install" and these recommendations | ||
3985 | @subsubsection Differences between "make install" and these recommendations | ||
3986 | |||
3987 | The current build system does not set all permissions automatically based | ||
3988 | on the recommendations above. In particular, it does not use the group | ||
3989 | "gnunet" at all (so setting gnunet-helpers other than the | ||
3990 | gnunet-helper-dns to be owned by group "gnunet" must be done manually). | ||
3991 | Furthermore, 'make install' will silently fail to set the DNS binaries to | ||
3992 | be owned by group "gnunetdns" unless that group already exists (!). | ||
3993 | An alternative name for the "gnunetdns" group can be specified using the | ||
3994 | @code{--with-gnunetdns=GRPNAME} configure option. | ||
3995 | |||
diff --git a/doc/chapters/philosophy.texi b/doc/documentation/chapters/philosophy.texi index 9f4702b49..10006ebe1 100644 --- a/doc/chapters/philosophy.texi +++ b/doc/documentation/chapters/philosophy.texi | |||
@@ -1,4 +1,4 @@ | |||
1 | @c *************************************************************************** | 1 | @cindex Philosopy |
2 | @node Philosophy | 2 | @node Philosophy |
3 | @chapter Philosophy | 3 | @chapter Philosophy |
4 | 4 | ||
@@ -22,8 +22,8 @@ generation of decentralized Internet protocols. | |||
22 | * Key Concepts:: | 22 | * Key Concepts:: |
23 | @end menu | 23 | @end menu |
24 | 24 | ||
25 | 25 | @cindex Design Goals | |
26 | @c *************************************************************************** | 26 | @cindex Design Goals |
27 | @node Design Goals | 27 | @node Design Goals |
28 | @section Design Goals | 28 | @section Design Goals |
29 | 29 | ||
@@ -31,85 +31,100 @@ These are the core GNUnet design goals, in order of relative importance: | |||
31 | 31 | ||
32 | @itemize | 32 | @itemize |
33 | @item GNUnet must be implemented as free software. | 33 | @item GNUnet must be implemented as free software. |
34 | @item GNUnet must only disclose the minimal amount of information necessary. | 34 | @item GNUnet must only disclose the minimal amount of information |
35 | @item GNUnet must be decentralised and survive Byzantine failures in any position in the network. | 35 | necessary. |
36 | @item GNUnet must make it explicit to the user which entities must be trustworthy when establishing secured communications. | 36 | @item GNUnet must be decentralised and survive Byzantine failures in any |
37 | @item GNUnet must use compartmentalization to protect sensitive information. | 37 | position in the network. |
38 | @item GNUnet must make it explicit to the user which entities must be | ||
39 | trustworthy when establishing secured communications. | ||
40 | @item GNUnet must use compartmentalization to protect sensitive | ||
41 | information. | ||
38 | @item GNUnet must be open and permit new peers to join. | 42 | @item GNUnet must be open and permit new peers to join. |
39 | @item GNUnet must be self-organizing and not depend on administrators. | 43 | @item GNUnet must be self-organizing and not depend on administrators. |
40 | @item GNUnet must support a diverse range of applications and devices. | 44 | @item GNUnet must support a diverse range of applications and devices. |
41 | @item The GNUnet architecture must be cost effective. | 45 | @item The GNUnet architecture must be cost effective. |
42 | @item GNUnet must provide incentives for peers to contribute more resources than they consume. | 46 | @item GNUnet must provide incentives for peers to contribute more |
47 | resources than they consume. | ||
43 | @end itemize | 48 | @end itemize |
44 | 49 | ||
45 | 50 | ||
51 | @cindex Security and Privacy | ||
46 | @node Security & Privacy | 52 | @node Security & Privacy |
47 | @section Security & Privacy | 53 | @section Security & Privacy |
48 | 54 | ||
49 | GNUnet's primary design goals are to protect the privacy of its users and to | 55 | GNUnet's primary design goals are to protect the privacy of its users and |
50 | guard itself against attacks or abuse. GNUnet does not have any mechanisms | 56 | to guard itself against attacks or abuse. |
51 | to control, track or censor users. Instead, the GNUnet protocols aim to make | 57 | GNUnet does not have any mechanisms to control, track or censor users. |
52 | it as hard as possible to find out what is happening on the network or to | 58 | Instead, the GNUnet protocols aim to make it as hard as possible to |
53 | disrupt operations. | 59 | find out what is happening on the network or to disrupt operations. |
54 | 60 | ||
61 | @cindex Versatility | ||
55 | @node Versatility | 62 | @node Versatility |
56 | @section Versatility | 63 | @section Versatility |
57 | 64 | ||
58 | We call GNUnet a peer-to-peer framework because we want to support many | 65 | We call GNUnet a peer-to-peer framework because we want to support many |
59 | different forms of peer-to-peer applications. GNUnet uses a plugin | 66 | different forms of peer-to-peer applications. GNUnet uses a plugin |
60 | architecture to make the system extensible and to encourage code reuse. | 67 | architecture to make the system extensible and to encourage code reuse. |
61 | While the first versions of the system only supported anonymous file-sharing, | 68 | While the first versions of the system only supported anonymous |
62 | other applications are being worked on and more will hopefully follow in the | 69 | file-sharing, other applications are being worked on and more will |
63 | future. A powerful synergy regarding anonymity services is created by a large | 70 | hopefully follow in the future. |
71 | A powerful synergy regarding anonymity services is created by a large | ||
64 | community utilizing many diverse applications over the same software | 72 | community utilizing many diverse applications over the same software |
65 | infrastructure. The reason is that link encryption hides the specifics | 73 | infrastructure. The reason is that link encryption hides the specifics |
66 | of the traffic for non-participating observers. This way, anonymity can | 74 | of the traffic for non-participating observers. This way, anonymity can |
67 | get stronger with additional (GNUnet) traffic, even if the additional | 75 | get stronger with additional (GNUnet) traffic, even if the additional |
68 | traffic is not related to anonymous communication. Increasing anonymity is | 76 | traffic is not related to anonymous communication. Increasing anonymity is |
69 | the primary reason why GNUnet is developed to become a peer-to-peer | 77 | the primary reason why GNUnet is developed to become a peer-to-peer |
70 | framework where many applications share the lower layers of an increasingly | 78 | framework where many applications share the lower layers of an |
71 | complex protocol stack. If merging traffic to hinder traffic analysis was | 79 | increasingly complex protocol stack. |
72 | not important, we could have just developed a dozen stand-alone applications | 80 | If merging traffic to hinder traffic analysis was not important, |
81 | we could have just developed a dozen stand-alone applications | ||
73 | and a few shared libraries. | 82 | and a few shared libraries. |
74 | 83 | ||
84 | @cindex Practicality | ||
75 | @node Practicality | 85 | @node Practicality |
76 | @section Practicality | 86 | @section Practicality |
77 | 87 | ||
78 | GNUnet allows participants to trade various amounts of security in exchange | 88 | GNUnet allows participants to trade various amounts of security in |
79 | for increased efficiency. However, it is not possible for any user's security | 89 | exchange for increased efficiency. However, it is not possible for any |
80 | and efficiency requirements to compromise the security and efficiency of | 90 | user's security and efficiency requirements to compromise the security |
81 | any other user. | 91 | and efficiency of any other user. |
82 | 92 | ||
83 | For GNUnet, efficiency is not paramount. If there is a more secure and still | 93 | For GNUnet, efficiency is not paramount. If there is a more secure and |
84 | practical approach, we would choose to take the more secure alternative. | 94 | still practical approach, we would choose to take the more secure |
85 | @command{telnet} is more efficient than @command{ssh}, yet it is obsolete. | 95 | alternative. @command{telnet} is more efficient than @command{ssh}, yet |
96 | it is obsolete. | ||
86 | Hardware gets faster, and code can be optimized. Fixing security issues as | 97 | Hardware gets faster, and code can be optimized. Fixing security issues as |
87 | an afterthought is much harder. | 98 | an afterthought is much harder. |
88 | 99 | ||
89 | While security is paramount, practicability is still a requirement. The most | 100 | While security is paramount, practicability is still a requirement. |
90 | secure system is always the one that nobody can use. Similarly, any | 101 | The most secure system is always the one that nobody can use. |
91 | anonymous system that is extremely inefficient will only find few users. | 102 | Similarly, any anonymous system that is extremely inefficient will only |
103 | find few users. | ||
92 | However, good anonymity requires a large and diverse user base. Since | 104 | However, good anonymity requires a large and diverse user base. Since |
93 | individual security requirements may vary, the only good solution here is to | 105 | individual security requirements may vary, the only good solution here is |
94 | allow individuals to trade-off security and efficiency. The primary challenge | 106 | to allow individuals to trade-off security and efficiency. |
95 | in allowing this is to ensure that the economic incentives work properly. | 107 | The primary challenge in allowing this is to ensure that the economic |
108 | incentives work properly. | ||
96 | In particular, this means that it must be impossible for a user to gain | 109 | In particular, this means that it must be impossible for a user to gain |
97 | security at the expense of other users. Many designs (e.g. anonymity via | 110 | security at the expense of other users. Many designs (e.g. anonymity via |
98 | broadcast) fail to give users an incentive to choose a less secure but more | 111 | broadcast) fail to give users an incentive to choose a less secure but |
99 | efficient mode of operation. GNUnet should avoid where ever possible to | 112 | more efficient mode of operation. |
100 | rely on protocols that will only work if the participants are benevolent. | 113 | GNUnet should avoid where ever possible to rely on protocols that will |
114 | only work if the participants are benevolent. | ||
101 | While some designs have had widespread success while relying on parties | 115 | While some designs have had widespread success while relying on parties |
102 | to observe a protocol that may be sub-optimal for the individuals (e.g. | 116 | to observe a protocol that may be sub-optimal for the individuals (e.g. |
103 | TCP Nagle), a protocol that ensures that individual goals never conflict | 117 | TCP Nagle), a protocol that ensures that individual goals never conflict |
104 | with the goals of the group is always preferable. | 118 | with the goals of the group is always preferable. |
105 | 119 | ||
120 | @cindex Key Concepts | ||
106 | @node Key Concepts | 121 | @node Key Concepts |
107 | @section Key Concepts | 122 | @section Key Concepts |
108 | 123 | ||
109 | In this section, the fundamental concepts of GNUnet are explained. Most of | 124 | In this section, the fundamental concepts of GNUnet are explained. |
110 | them are also described in our research papers. First, some of the concepts | 125 | Most of them are also described in our research papers. |
111 | used in the GNUnet framework are detailed. The second part describes concepts | 126 | First, some of the concepts used in the GNUnet framework are detailed. |
112 | specific to anonymous file-sharing. | 127 | The second part describes concepts specific to anonymous file-sharing. |
113 | 128 | ||
114 | @menu | 129 | @menu |
115 | * Authentication:: | 130 | * Authentication:: |
@@ -122,6 +137,7 @@ specific to anonymous file-sharing. | |||
122 | * Egos:: | 137 | * Egos:: |
123 | @end menu | 138 | @end menu |
124 | 139 | ||
140 | @cindex Authentication | ||
125 | @node Authentication | 141 | @node Authentication |
126 | @subsection Authentication | 142 | @subsection Authentication |
127 | 143 | ||
@@ -148,63 +164,74 @@ IP protocol at all (by running directly on layer 2). | |||
148 | GNUnet uses a special type of message to communicate a binding between | 164 | GNUnet uses a special type of message to communicate a binding between |
149 | public (ECC) keys to their current network address. These messages are | 165 | public (ECC) keys to their current network address. These messages are |
150 | commonly called HELLOs or peer advertisements. They contain the public key | 166 | commonly called HELLOs or peer advertisements. They contain the public key |
151 | of the peer and its current network addresses for various transport services. | 167 | of the peer and its current network addresses for various transport |
168 | services. | ||
152 | A transport service is a special kind of shared library that | 169 | A transport service is a special kind of shared library that |
153 | provides (possibly unreliable, out-of-order) message delivery between peers. | 170 | provides (possibly unreliable, out-of-order) message delivery between |
154 | For the UDP and TCP transport services, a network address is an IP and a port. | 171 | peers. |
172 | For the UDP and TCP transport services, a network address is an IP and a | ||
173 | port. | ||
155 | GNUnet can also use other transports (HTTP, HTTPS, WLAN, etc.) which use | 174 | GNUnet can also use other transports (HTTP, HTTPS, WLAN, etc.) which use |
156 | various other forms of addresses. Note that any node can have many different | 175 | various other forms of addresses. Note that any node can have many |
176 | different | ||
157 | active transport services at the same time, and each of these can have a | 177 | active transport services at the same time, and each of these can have a |
158 | different addresses. Binding messages expire after at most a week (the | 178 | different addresses. Binding messages expire after at most a week (the |
159 | timeout can be shorter if the user configures the node appropriately). This | 179 | timeout can be shorter if the user configures the node appropriately). |
160 | expiration ensures that the network will eventually get rid of outdated | 180 | This expiration ensures that the network will eventually get rid of |
161 | advertisements.@ | 181 | outdated advertisements.@footnote{More details can be found in |
162 | More details can be found in the paper @uref{https://gnunet.org/transports, A Transport Layer Abstraction for Peer-to-Peer Networks}. | 182 | @uref{https://gnunet.org/transports, A Transport Layer Abstraction for Peer-to-Peer Networks}} |
163 | 183 | ||
184 | @cindex Resource Sharing | ||
164 | @node Accounting to Encourage Resource Sharing | 185 | @node Accounting to Encourage Resource Sharing |
165 | @subsection Accounting to Encourage Resource Sharing | 186 | @subsection Accounting to Encourage Resource Sharing |
166 | 187 | ||
167 | Most distributed P2P networks suffer from a lack of defenses or precautions | 188 | Most distributed P2P networks suffer from a lack of defenses or |
168 | against attacks in the form of freeloading. While the intentions of an | 189 | precautions against attacks in the form of freeloading. |
169 | attacker and a freeloader are different, their effect on the network is the | 190 | While the intentions of an attacker and a freeloader are different, their |
170 | same; they both render it useless. Most simple attacks on networks such as | 191 | effect on the network is the same; they both render it useless. |
171 | Gnutella involve flooding the network with traffic, particularly with | 192 | Most simple attacks on networks such as Gnutella involve flooding the |
172 | queries that are, in the worst case, multiplied by the network. | 193 | network with traffic, particularly with queries that are, in the worst |
194 | case, multiplied by the network. | ||
173 | 195 | ||
174 | In order to ensure that freeloaders or attackers have a minimal impact on the | 196 | In order to ensure that freeloaders or attackers have a minimal impact on |
175 | network, GNUnet's file-sharing implementation tries to distinguish | 197 | the network, GNUnet's file-sharing implementation tries to distinguish |
176 | good (contributing) nodes from malicious (freeloading) nodes. In GNUnet, | 198 | good (contributing) nodes from malicious (freeloading) nodes. In GNUnet, |
177 | every file-sharing node keeps track of the behavior of every other node it | 199 | every file-sharing node keeps track of the behavior of every other node it |
178 | has been in contact with. Many requests (depending on the application) are | 200 | has been in contact with. Many requests (depending on the application) are |
179 | transmitted with a priority (or importance) level. That priority is used to | 201 | transmitted with a priority (or importance) level. That priority is used |
180 | establish how important the sender believes this request is. If a peer | 202 | to establish how important the sender believes this request is. If a peer |
181 | responds to an important request, the recipient will increase its trust in the | 203 | responds to an important request, the recipient will increase its trust in |
182 | responder: the responder contributed resources. If a peer is too busy to | 204 | the responder: the responder contributed resources. If a peer is too busy |
183 | answer all requests, it needs to prioritize. For that, peers to not take the | 205 | to answer all requests, it needs to prioritize. For that, peers to not |
184 | priorities of the requests received at face value. First, they check how much | 206 | take the priorities of the requests received at face value. |
185 | they trust the sender, and depending on that amount of trust they assign the | 207 | First, they check how much they trust the sender, and depending on that |
186 | request a (possibly lower) effective priority. Then, they drop the requests | 208 | amount of trust they assign the request a (possibly lower) effective |
187 | with the lowest effective priority to satisfy their resource constraints. This | 209 | priority. Then, they drop the requests with the lowest effective priority |
188 | way, GNUnet's economic model ensures that nodes that are not currently | 210 | to satisfy their resource constraints. This way, GNUnet's economic model |
189 | considered to have a surplus in contributions will not be served if the | 211 | ensures that nodes that are not currently considered to have a surplus in |
190 | network load is high. More details can be found in @uref{https://gnunet.org/ebe, this paper}. | 212 | contributions will not be served if the network load is high.@footnote{Mor |
191 | 213 | e details can be found in @uref{https://gnunet.org/ebe, this paper}} | |
214 | |||
215 | @cindex Confidentiality | ||
192 | @node Confidentiality | 216 | @node Confidentiality |
193 | @subsection Confidentiality | 217 | @subsection Confidentiality |
194 | 218 | ||
195 | Adversaries outside of GNUnet are not supposed to know what kind of actions a | 219 | Adversaries outside of GNUnet are not supposed to know what kind of |
196 | peer is involved in. Only the specific neighbor of a peer that is the | 220 | actions a peer is involved in. Only the specific neighbor of a peer that |
197 | corresponding sender or recipient of a message may know its contents, and even | 221 | is the corresponding sender or recipient of a message may know its |
198 | then application protocols may place further restrictions on that knowledge. | 222 | contents, and even then application protocols may place further |
199 | In order to ensure confidentiality, GNUnet uses link encryption, that is each | 223 | restrictions on that knowledge. |
200 | message exchanged between two peers is encrypted using a pair of keys only | 224 | In order to ensure confidentiality, GNUnet uses link encryption, that is |
201 | known to these two peers. Encrypting traffic like this makes any kind of | 225 | each message exchanged between two peers is encrypted using a pair of |
202 | traffic analysis much harder. Naturally, for some applications, it may still | 226 | keys only known to these two peers. |
203 | be desirable if even neighbors cannot determine the concrete contents of a | 227 | Encrypting traffic like this makes any kind of traffic analysis much |
204 | message. In GNUnet, this problem is addressed by the specific | 228 | harder. Naturally, for some applications, it may still be desirable if |
205 | application-level protocols (see for example, deniability and anonymity in | 229 | even neighbors cannot determine the concrete contents of a message. |
206 | anonymous file sharing). | 230 | In GNUnet, this problem is addressed by the specific application-level |
207 | 231 | protocols (see for example, deniability and anonymity in anonymous file | |
232 | sharing). | ||
233 | |||
234 | @cindex Anonymity | ||
208 | @node Anonymity | 235 | @node Anonymity |
209 | @subsection Anonymity | 236 | @subsection Anonymity |
210 | 237 | ||
@@ -213,58 +240,71 @@ anonymous file sharing). | |||
213 | @end menu | 240 | @end menu |
214 | 241 | ||
215 | Providing anonymity for users is the central goal for the anonymous | 242 | Providing anonymity for users is the central goal for the anonymous |
216 | file-sharing application. Many other design decisions follow in the footsteps | 243 | file-sharing application. Many other design decisions follow in the |
217 | of this requirement. Anonymity is never absolute. While there are various | 244 | footsteps of this requirement. |
218 | @uref{https://gnunet.org/anonymity_metric, scientific metrics} that can help quantify the level of anonymity that a | 245 | Anonymity is never absolute. While there are various |
219 | given mechanism provides, there is no such thing as complete anonymity. | 246 | @uref{https://gnunet.org/anonymity_metric, scientific metrics} that can |
247 | help quantify the level of anonymity that a given mechanism provides, | ||
248 | there is no such thing as complete anonymity. | ||
220 | GNUnet's file-sharing implementation allows users to select for each | 249 | GNUnet's file-sharing implementation allows users to select for each |
221 | operation (publish, search, download) the desired level of anonymity. | 250 | operation (publish, search, download) the desired level of anonymity. |
222 | The metric used is the amount of cover traffic available to hide the request. | 251 | The metric used is the amount of cover traffic available to hide the |
252 | request. | ||
223 | While this metric is not as good as, for example, the theoretical metric | 253 | While this metric is not as good as, for example, the theoretical metric |
224 | given in @uref{https://gnunet.org/anonymity_metric, scientific metrics}, it is probably the best metric available to | 254 | given in @uref{https://gnunet.org/anonymity_metric, scientific metrics}, |
225 | a peer with a purely local view of the world that does not rely on unreliable | 255 | it is probably the best metric available to a peer with a purely local |
226 | external information. The default anonymity level is 1, which uses anonymous | 256 | view of the world that does not rely on unreliable external information. |
227 | routing but imposes no minimal requirements on cover traffic. It is possible | 257 | The default anonymity level is 1, which uses anonymous routing but |
258 | imposes no minimal requirements on cover traffic. It is possible | ||
228 | to forego anonymity when this is not required. The anonymity level of 0 | 259 | to forego anonymity when this is not required. The anonymity level of 0 |
229 | allows GNUnet to use more efficient, non-anonymous routing. | 260 | allows GNUnet to use more efficient, non-anonymous routing. |
230 | 261 | ||
262 | @cindex How file-sharing achieves Anonymity | ||
231 | @node How file-sharing achieves Anonymity | 263 | @node How file-sharing achieves Anonymity |
232 | @subsubsection How file-sharing achieves Anonymity | 264 | @subsubsection How file-sharing achieves Anonymity |
233 | 265 | ||
234 | Contrary to other designs, we do not believe that users achieve strong | 266 | Contrary to other designs, we do not believe that users achieve strong |
235 | anonymity just because their requests are obfuscated by a couple of | 267 | anonymity just because their requests are obfuscated by a couple of |
236 | indirections. This is not sufficient if the adversary uses traffic analysis. | 268 | indirections. This is not sufficient if the adversary uses traffic |
237 | The threat model used for anonymous file sharing in GNUnet assumes that the | 269 | analysis. |
238 | adversary is quite powerful. In particular, we assume that the adversary can | 270 | The threat model used for anonymous file sharing in GNUnet assumes that |
239 | see all the traffic on the Internet. And while we assume that the adversary | 271 | the adversary is quite powerful. |
272 | In particular, we assume that the adversary can see all the traffic on | ||
273 | the Internet. And while we assume that the adversary | ||
240 | can not break our encryption, we assume that the adversary has many | 274 | can not break our encryption, we assume that the adversary has many |
241 | participating nodes in the network and that it can thus see many of the | 275 | participating nodes in the network and that it can thus see many of the |
242 | node-to-node interactions since it controls some of the nodes. | 276 | node-to-node interactions since it controls some of the nodes. |
243 | 277 | ||
244 | The system tries to achieve anonymity based on the idea that users can be | 278 | The system tries to achieve anonymity based on the idea that users can be |
245 | anonymous if they can hide their actions in the traffic created by other users. | 279 | anonymous if they can hide their actions in the traffic created by other |
280 | users. | ||
246 | Hiding actions in the traffic of other users requires participating in the | 281 | Hiding actions in the traffic of other users requires participating in the |
247 | traffic, bringing back the traditional technique of using indirection and | 282 | traffic, bringing back the traditional technique of using indirection and |
248 | source rewriting. Source rewriting is required to gain anonymity since | 283 | source rewriting. Source rewriting is required to gain anonymity since |
249 | otherwise an adversary could tell if a message originated from a host by | 284 | otherwise an adversary could tell if a message originated from a host by |
250 | looking at the source address. If all packets look like they originate from | 285 | looking at the source address. If all packets look like they originate |
251 | a node, the adversary can not tell which ones originate from that node and | 286 | from a node, the adversary can not tell which ones originate from that |
252 | which ones were routed. Note that in this mindset, any node can decide to | 287 | node and which ones were routed. |
253 | break the source-rewriting paradigm without violating the protocol, as this | 288 | Note that in this mindset, any node can decide to break the |
254 | only reduces the amount of traffic that a node can hide its own traffic in. | 289 | source-rewriting paradigm without violating the protocol, as this |
290 | only reduces the amount of traffic that a node can hide its own traffic | ||
291 | in. | ||
255 | 292 | ||
256 | If we want to hide our actions in the traffic of other nodes, we must make | 293 | If we want to hide our actions in the traffic of other nodes, we must make |
257 | our traffic indistinguishable from the traffic that we route for others. As | 294 | our traffic indistinguishable from the traffic that we route for others. |
258 | our queries must have us as the receiver of the reply (otherwise they would | 295 | As our queries must have us as the receiver of the reply |
259 | be useless), we must put ourselves as the receiver of replies that actually | 296 | (otherwise they would be useless), we must put ourselves as the receiver |
260 | go to other hosts; in other words, we must indirect replies. Unlike other | 297 | of replies that actually go to other hosts; in other words, we must |
261 | systems, in anonymous file-sharing as implemented on top of GNUnet we do not | 298 | indirect replies. |
262 | have to indirect the replies if we don't think we need more traffic to hide | 299 | Unlike other systems, in anonymous file-sharing as implemented on top of |
263 | our own actions.@ | 300 | GNUnet we do not have to indirect the replies if we don't think we need |
301 | more traffic to hide our own actions. | ||
264 | 302 | ||
265 | This increases the efficiency of the network as we can indirect less under | 303 | This increases the efficiency of the network as we can indirect less under |
266 | higher load. More details can be found in @uref{https://gnunet.org/gap, this paper}. | 304 | higher load.@footnote{More details can be found in |
305 | @uref{https://gnunet.org/gap, this paper}} | ||
267 | 306 | ||
307 | @cindex Deniability | ||
268 | @node Deniability | 308 | @node Deniability |
269 | @subsection Deniability | 309 | @subsection Deniability |
270 | 310 | ||
@@ -274,57 +314,65 @@ intermediaries can find out which queries or which content they are | |||
274 | processing, a strong adversary could try to force them to censor | 314 | processing, a strong adversary could try to force them to censor |
275 | certain materials. | 315 | certain materials. |
276 | 316 | ||
277 | With the file-encoding used by GNUnet's anonymous file-sharing, this problem | 317 | With the file-encoding used by GNUnet's anonymous file-sharing, this |
278 | does not arise. The reason is that queries and replies are transmitted in | 318 | problem does not arise. |
319 | The reason is that queries and replies are transmitted in | ||
279 | an encrypted format such that intermediaries cannot tell what the query | 320 | an encrypted format such that intermediaries cannot tell what the query |
280 | is for or what the content is about. Mind that this is not the same | 321 | is for or what the content is about. Mind that this is not the same |
281 | encryption as the link-encryption between the nodes. GNUnet has | 322 | encryption as the link-encryption between the nodes. GNUnet has |
282 | encryption on the network layer (link encryption, confidentiality, | 323 | encryption on the network layer (link encryption, confidentiality, |
283 | authentication) and again on the application layer (provided | 324 | authentication) and again on the application layer (provided |
284 | by @command{gnunet-publish}, @command{gnunet-download}, @command{gnunet-search} | 325 | by @command{gnunet-publish}, @command{gnunet-download}, |
285 | and @command{gnunet-gtk}). More details can be found @uref{https://gnunet.org/encoding, here}. | 326 | @command{gnunet-search} and @command{gnunet-gtk}).@footnote{More details |
327 | can be found @uref{https://gnunet.org/encoding, here}} | ||
286 | 328 | ||
329 | @cindex Peer Identities | ||
287 | @node Peer Identities | 330 | @node Peer Identities |
288 | @subsection Peer Identities | 331 | @subsection Peer Identities |
289 | 332 | ||
290 | Peer identities are used to identify peers in the network and are unique for | 333 | Peer identities are used to identify peers in the network and are unique |
291 | each peer. The identity for a peer is simply its public key, which is | 334 | for each peer. The identity for a peer is simply its public key, which is |
292 | generated along with a private key the peer is started for the first time. | 335 | generated along with a private key the peer is started for the first time. |
293 | While the identity is binary data, it is often expressed as ASCII string. | 336 | While the identity is binary data, it is often expressed as ASCII string. |
294 | For example, the following is a peer identity as you might see it in | 337 | For example, the following is a peer identity as you might see it in |
295 | various places:@ | 338 | various places: |
296 | @code{@ | 339 | |
297 | UAT1S6PMPITLBKSJ2DGV341JI6KF7B66AC4JVCN9811NNEGQLUN0@ | 340 | @example |
298 | } | 341 | UAT1S6PMPITLBKSJ2DGV341JI6KF7B66AC4JVCN9811NNEGQLUN0 |
342 | @end example | ||
299 | 343 | ||
300 | You can find your peer identity by running@ | 344 | @noindent |
301 | @command{gnunet-peerinfo -s} | 345 | You can find your peer identity by running @command{gnunet-peerinfo -s}. |
302 | 346 | ||
347 | @cindex GNS Zones | ||
303 | @node Zones in the GNU Name System (GNS Zones) | 348 | @node Zones in the GNU Name System (GNS Zones) |
304 | @subsection Zones in the GNU Name System (GNS Zones) | 349 | @subsection Zones in the GNU Name System (GNS Zones) |
305 | 350 | ||
306 | GNS zones are similar to those of DNS zones, but instead of a hierarchy of | 351 | GNS zones are similar to those of DNS zones, but instead of a hierarchy of |
307 | authorities to governing their use, GNS zones are controlled by a private key. | 352 | authorities to governing their use, GNS zones are controlled by a private |
353 | key. | ||
308 | When you create a record in a DNS zone, that information stored in your | 354 | When you create a record in a DNS zone, that information stored in your |
309 | nameserver. Anyone trying to resolve your domain then gets pointed (hopefully) | 355 | nameserver. Anyone trying to resolve your domain then gets pointed |
310 | by the centralised authority to your nameserver. Whereas GNS, being | 356 | (hopefully) by the centralised authority to your nameserver. |
311 | decentralised by design, stores that information in DHT. The validity of the | 357 | Whereas GNS, being decentralised by design, stores that information in |
312 | records is assured cryptographically, by signing them with the private key of | 358 | DHT. The validity of the records is assured cryptographically, by |
313 | the respective zone. | 359 | signing them with the private key of the respective zone. |
314 | 360 | ||
315 | Anyone trying to resolve records in a zone your domain can then verify the | 361 | Anyone trying to resolve records in a zone your domain can then verify the |
316 | signature on the records they get from the DHT and be assured that they are | 362 | signature on the records they get from the DHT and be assured that they |
317 | indeed from the respective zone. To make this work, there is a 1:1 | 363 | are indeed from the respective zone. To make this work, there is a 1:1 |
318 | correspondence between zones and their public-private key pairs. So when we | 364 | correspondence between zones and their public-private key pairs. |
319 | talk about the owner of a GNS zone, that's really the owner of the private | 365 | So when we talk about the owner of a GNS zone, that's really the owner of |
320 | key. And a user accessing a zone needs to somehow specify the corresponding | 366 | the private key. |
367 | And a user accessing a zone needs to somehow specify the corresponding | ||
321 | public key first. | 368 | public key first. |
322 | 369 | ||
370 | @cindex Egos | ||
323 | @node Egos | 371 | @node Egos |
324 | @subsection Egos | 372 | @subsection Egos |
325 | 373 | ||
326 | Egos are your "identities" in GNUnet. Any user can assume multiple | 374 | Egos are your "identities" in GNUnet. Any user can assume multiple |
327 | identities, for example to separate his activities online. Egos can | 375 | identities, for example to separate teir activities online. Egos can |
328 | correspond to pseudonyms or real-world identities. Technically, an | 376 | correspond to pseudonyms or real-world identities. Technically, an |
329 | ego is first of all a public-private key pair. | 377 | ego is first of all a public-private key pair. |
330 | 378 | ||
diff --git a/doc/documentation/chapters/user.texi b/doc/documentation/chapters/user.texi new file mode 100644 index 000000000..6e339c697 --- /dev/null +++ b/doc/documentation/chapters/user.texi | |||
@@ -0,0 +1,2009 @@ | |||
1 | @node Using GNUnet | ||
2 | @chapter Using GNUnet | ||
3 | @c %**end of header | ||
4 | |||
5 | This tutorial is supposed to give a first introduction for end-users | ||
6 | trying to do something "real" with GNUnet. Installation and | ||
7 | configuration are specifically outside of the scope of this tutorial. | ||
8 | Instead, we start by briefly checking that the installation works, and | ||
9 | then dive into simple, concrete practical things that can be done | ||
10 | with the network. | ||
11 | |||
12 | This chapter documents how to use the various Peer-to-Peer applications | ||
13 | of the GNUnet system. As GNUnet evolves, we will add new chapters for | ||
14 | the various applications that are being created. | ||
15 | |||
16 | Comments and extensions are always welcome. | ||
17 | |||
18 | |||
19 | @menu | ||
20 | * Checking the Installation:: | ||
21 | * First steps - File-sharing:: | ||
22 | * First steps - Using the GNU Name System:: | ||
23 | * First steps - Using GNUnet Conversation:: | ||
24 | * First steps - Using the GNUnet VPN:: | ||
25 | * File-sharing:: | ||
26 | * The GNU Name System:: | ||
27 | * Using the Virtual Public Network:: | ||
28 | @end menu | ||
29 | |||
30 | @node Checking the Installation | ||
31 | @section Checking the Installation | ||
32 | @c %**end of header | ||
33 | |||
34 | This chapter describes a quick casual way to check if your GNUnet | ||
35 | installation works. However, if it does not, we do not cover | ||
36 | steps for recovery --- for this, please study the installation and | ||
37 | configuration handbooks. | ||
38 | |||
39 | |||
40 | @menu | ||
41 | * gnunet-gtk:: | ||
42 | * Statistics:: | ||
43 | * Peer Information:: | ||
44 | @end menu | ||
45 | |||
46 | @node gnunet-gtk | ||
47 | @subsection gnunet-gtk | ||
48 | @c %**end of header | ||
49 | |||
50 | First, you should launch @code{gnunet-gtk}, the graphical user | ||
51 | interface for GNUnet which will be used for most of the tutorial. | ||
52 | You can do this from the command-line by typing | ||
53 | |||
54 | @example | ||
55 | $ gnunet-gtk | ||
56 | @end example | ||
57 | |||
58 | (note that @code{$} represents the prompt of the shell for a normal user). | ||
59 | Depending on your distribution, you may also find @code{gnunet-gtk} | ||
60 | in your menus. After starting @code{gnunet-gtk}, you should see the | ||
61 | following window: | ||
62 | |||
63 | @c @image{images/gnunet-gtk-0-10,5in,, picture of gnunet-gtk application} | ||
64 | |||
65 | The five images on top represent the five different graphical applications | ||
66 | that you can use within @code{gnunet-gtk}. They are (from left to right): | ||
67 | |||
68 | @itemize @bullet | ||
69 | @item Statistics | ||
70 | @item Peer Information | ||
71 | @item GNU Name System | ||
72 | @item File Sharing | ||
73 | @item Identity Management | ||
74 | @end itemize | ||
75 | |||
76 | @node Statistics | ||
77 | @subsection Statistics | ||
78 | @c %**end of header | ||
79 | |||
80 | When @code{gnunet-gtk} is started, the statistics area should be selected | ||
81 | at first. If your peer is running correctly, you should see a bunch of | ||
82 | lines, all of which should be "significantly" above zero (at least if your | ||
83 | peer has been running for a few seconds). The lines indicate how many other | ||
84 | peers your peer is connected to (via different mechanisms) and how large | ||
85 | the overall overlay network is currently estimated to be. The X-axis | ||
86 | represents time (in seconds since the start of @code{gnunet-gtk}). | ||
87 | |||
88 | You can click on "Traffic" to see information about the amount of | ||
89 | bandwidth your peer has consumed, and on "Storage" to check the amount | ||
90 | of storage available and used by your peer. Note that "Traffic" is | ||
91 | plotted cummulatively, so you should see a strict upwards trend in the | ||
92 | traffic. | ||
93 | |||
94 | @node Peer Information | ||
95 | @subsection Peer Information | ||
96 | @c %**end of header | ||
97 | |||
98 | You should now click on the Australian Aboriginal Flag. Once you have | ||
99 | done this, you will see a list of known peers (by the first four | ||
100 | characters of their public key), their friend status (all should be | ||
101 | marked as not-friends initially), their connectivity (green is | ||
102 | connected, red is disconnected), assigned bandwidth, | ||
103 | country of origin (if determined) and address information. If hardly | ||
104 | any peers are listed and/or if there are very few peers with a green light | ||
105 | for connectivity, there is likely a problem with your | ||
106 | network configuration. | ||
107 | |||
108 | @node First steps - File-sharing | ||
109 | @section First steps - File-sharing | ||
110 | @c %**end of header | ||
111 | |||
112 | This chapter describes first steps for file-sharing with GNUnet. | ||
113 | To start, you should launch @code{gnunet-gtk} and select the | ||
114 | file-sharing tab (the one with the arrows between the three circles). | ||
115 | |||
116 | As we want to be sure that the network contains the data that we are | ||
117 | looking for for testing, we need to begin by publishing a file. | ||
118 | |||
119 | |||
120 | @menu | ||
121 | * Publishing:: | ||
122 | * Searching:: | ||
123 | * Downloading:: | ||
124 | @end menu | ||
125 | |||
126 | @node Publishing | ||
127 | @subsection Publishing | ||
128 | @c %**end of header | ||
129 | |||
130 | To publish a file, select "File Sharing" in the menu bar just below the | ||
131 | "Statistics" icon, and then select "Publish" from the menu. | ||
132 | |||
133 | Afterwards, the following publishing dialog will appear: | ||
134 | |||
135 | @c Add image here | ||
136 | |||
137 | In this dialog, select the "Add File" button. This will open a | ||
138 | file selection dialog: | ||
139 | |||
140 | @c Add image here | ||
141 | |||
142 | Now, you should select a file from your computer to be published on | ||
143 | GNUnet. To see more of GNUnet's features later, you should pick a | ||
144 | PNG or JPEG file this time. You can leave all of the other options | ||
145 | in the dialog unchanged. Confirm your selection by pressing the "OK" | ||
146 | button in the bottom right corner. Now, you will briefly see a | ||
147 | "Messages..." dialog pop up, but most likely it will be too short for | ||
148 | you to really read anything. That dialog is showing you progress | ||
149 | information as GNUnet takes a first look at the selected file(s). | ||
150 | For a normal image, this is virtually instant, but if you later | ||
151 | import a larger directory you might be interested in the progress dialog | ||
152 | and potential errors that might be encountered during processing. | ||
153 | After the progress dialog automatically disappears, your file | ||
154 | should now appear in the publishing dialog: | ||
155 | |||
156 | @c Add image here | ||
157 | |||
158 | Now, select the file (by clicking on the file name) and then click | ||
159 | the "Edit" button. This will open the editing dialog: | ||
160 | |||
161 | @c Add image here | ||
162 | |||
163 | In this dialog, you can see many details about your file. In the | ||
164 | top left area, you can see meta data extracted about the file, | ||
165 | such as the original filename, the mimetype and the size of the image. | ||
166 | In the top right, you should see a preview for the image | ||
167 | (if GNU libextractor was installed correctly with the | ||
168 | respective plugins). Note that if you do not see a preview, this | ||
169 | is not a disaster, but you might still want to install more of | ||
170 | GNU libextractor in the future. In the bottom left, the dialog contains | ||
171 | a list of keywords. These are the keywords under which the file will be | ||
172 | made available. The initial list will be based on the extracted meta data. | ||
173 | Additional publishing options are in the right bottom corner. We will | ||
174 | now add an additional keyword to the list of keywords. This is done by | ||
175 | entering the keyword above the keyword list between the label "Keyword" | ||
176 | and the "Add keyword" button. Enter "test" and select "Add keyword". | ||
177 | Note that the keyword will appear at the bottom of the existing keyword | ||
178 | list, so you might have to scroll down to see it. Afterwards, push the | ||
179 | "OK" button at the bottom right of the dialog. | ||
180 | |||
181 | You should now be back at the "Publish content on GNUnet" dialog. Select | ||
182 | "Execute" in the bottom right to close the dialog and publish your file | ||
183 | on GNUnet! Afterwards, you should see the main dialog with a new area | ||
184 | showing the list of published files (or ongoing publishing operations | ||
185 | with progress indicators): | ||
186 | |||
187 | @c Add image here | ||
188 | |||
189 | @node Searching | ||
190 | @subsection Searching | ||
191 | @c %**end of header | ||
192 | |||
193 | Below the menu bar, there are four entry widges labeled "Namespace", | ||
194 | "Keywords", "Anonymity" and "Mime-type" (from left to right). These | ||
195 | widgets are used to control searching for files in GNUnet. Between the | ||
196 | "Keywords" and "Anonymity" widgets, there is also a big "Search" button, | ||
197 | which is used to initiate the search. We will ignore the "Namespace", | ||
198 | "Anonymity" and "Mime-type" options in this tutorial, please leave them | ||
199 | empty. Instead, simply enter "test" under "Keywords" and press "Search". | ||
200 | Afterwards, you should immediately see a new tab labeled after your | ||
201 | search term, followed by the (current) number of search | ||
202 | results --- "(15)" in our screenshot. Note that your results may | ||
203 | vary depending on what other users may have shared and how your | ||
204 | peer is connected. | ||
205 | |||
206 | You can now select one of the search results. Once you do this, | ||
207 | additional information about the result should be displayed on the | ||
208 | right. If available, a preview image should appear on the top right. | ||
209 | Meta data describing the file will be listed at the bottom right. | ||
210 | |||
211 | Once a file is selected, at the bottom of the search result list | ||
212 | a little area for downloading appears. | ||
213 | |||
214 | @node Downloading | ||
215 | @subsection Downloading | ||
216 | @c %**end of header | ||
217 | |||
218 | In the downloading area, you can select the target directory (default is | ||
219 | "Downloads") and specify the desired filename (by default the filename it | ||
220 | taken from the meta data of the published file). Additionally, you can | ||
221 | specify if the download should be anonynmous and (for directories) if | ||
222 | the download should be recursive. In most cases, you can simply start | ||
223 | the download with the "Download!" button. | ||
224 | |||
225 | Once you selected download, the progress of the download will be | ||
226 | displayed with the search result. You may need to resize the result | ||
227 | list or scroll to the right. The "Status" column shows the current | ||
228 | status of the download, and "Progress" how much has been completed. | ||
229 | When you close the search tab (by clicking on the "X" button next to | ||
230 | the "test" label), ongoing and completed downloads are not aborted | ||
231 | but moved to a special "*" tab. | ||
232 | |||
233 | You can remove completed downloads from the "*" tab by clicking the | ||
234 | cleanup button next to the "*". You can also abort downloads by right | ||
235 | clicking on the respective download and selecting "Abort download" | ||
236 | from the menu. | ||
237 | |||
238 | That's it, you now know the basics for file-sharing with GNUnet! | ||
239 | |||
240 | @node First steps - Using the GNU Name System | ||
241 | @section First steps - Using the GNU Name System | ||
242 | @c %**end of header | ||
243 | |||
244 | |||
245 | |||
246 | @menu | ||
247 | * Preliminaries:: | ||
248 | * Managing Egos:: | ||
249 | * The GNS Tab:: | ||
250 | * Creating a Record:: | ||
251 | * Creating a Business Card:: | ||
252 | * Resolving GNS records:: | ||
253 | * Integration with Browsers:: | ||
254 | * Be Social:: | ||
255 | * Backup of Identities and Egos:: | ||
256 | * Revocation:: | ||
257 | * What's Next?:: | ||
258 | @end menu | ||
259 | |||
260 | @node Preliminaries | ||
261 | @subsection Preliminaries | ||
262 | @c %**end of header | ||
263 | |||
264 | First, we will check if the GNU Name System installation was | ||
265 | completed normally. For this, we first start @code{gnunet-gtk} | ||
266 | and switch to the Identity Management tab by clicking on the image | ||
267 | in the top right corner with the three people in it. Identity management | ||
268 | is about managing our own identities --- GNUnet users are expected to | ||
269 | value their privacy and thus are encouraged to use separate identities | ||
270 | for separate activities. By default, each user should have | ||
271 | run @file{gnunet-gns-import.sh} during installation. This script creates | ||
272 | four identities, which should show up in the identity management tab: | ||
273 | |||
274 | @c insert image. | ||
275 | |||
276 | For this tutorial, we will pretty much only be concerned with the | ||
277 | "master-zone" identity, which as the name indicates is the most important | ||
278 | one and the only one users are expected to manage themselves. | ||
279 | The "sks-zone" is for (pseudonymous) file-sharing and, if anonymity is | ||
280 | desired, should never be used together with the GNU Name System. | ||
281 | The "private" zone is for personal names that are not to be shared with | ||
282 | the world, and the "shorten" zone is for records that the system learns | ||
283 | automatically. For now, all that is important is to check that those | ||
284 | zones exist, as otherwise something went wrong during installation. | ||
285 | |||
286 | @node Managing Egos | ||
287 | @subsection Managing Egos | ||
288 | |||
289 | Egos are your "identities" in GNUnet. Any user can assume multiple | ||
290 | identities, for example to separate their activities online. | ||
291 | Egos can correspond to pseudonyms or real-world identities. | ||
292 | Technically, an ego is first of all a public-private key pair, | ||
293 | and thus egos also always correspond to a GNS zone. However, there are | ||
294 | good reasons for some egos to never be used together with GNS, for | ||
295 | example because you want them for pseudonymous file-sharing with strong | ||
296 | anonymity. Egos are managed by the IDENTITY service. Note that this | ||
297 | service has nothing to do with the peer identity. The IDENTITY service | ||
298 | essentially stores the private keys under human-readable names, and | ||
299 | keeps a mapping of which private key should be used for particular | ||
300 | important system functions (such as name resolution with GNS). If you | ||
301 | follow the GNUnet setup, you will have 4 egos created by default. | ||
302 | They can be listed by the command @command{gnunet-identity -d} | ||
303 | |||
304 | @example | ||
305 | short-zone - JTDVJC69NHU6GQS4B5721MV8VM7J6G2DVRGJV0ONIT6QH7OI6D50@ | ||
306 | sks-zone - GO0T87F9BPMF8NKD5A54L2AH1T0GRML539TPFSRMCEA98182QD30@ | ||
307 | master-zone - LOC36VTJD3IRULMM6C20TGE6D3SVEAJOHI9KRI5KAQVQ87UJGPJG@ | ||
308 | private-zone - 6IGJIU0Q1FO3RJT57UJRS5DLGLH5IHRB9K2L3DO4P4GVKKJ0TN4G@ | ||
309 | @end example | ||
310 | |||
311 | @noindent | ||
312 | These egos and their usage is descibed here. | ||
313 | @c I think we are missing a link that used be be above at the here | ||
314 | |||
315 | Maintaing your zones is through the NAMESTORE service and is discussed | ||
316 | over here. | ||
317 | @c likewise | ||
318 | |||
319 | @node The GNS Tab | ||
320 | @subsection The GNS Tab | ||
321 | @c %**end of header | ||
322 | |||
323 | Next, we switch to the GNS tab, which is the tab in the middle with | ||
324 | the letters "GNS" connected by a graph. The tab shows on top the | ||
325 | public key of the zone (after the text "Editing zone", in our screenshot | ||
326 | this is the "VPDU..." text). Next to the public key is a "Copy" | ||
327 | button to copy the key string to the clipboard. You also have a QR-code | ||
328 | representation of the public key on the right. Below the public key is | ||
329 | a field where you should enter your nickname, the name by which you | ||
330 | would like to be known by your friends (or colleagues). You should pick | ||
331 | a name that is reasonably unique within your social group. Please enter | ||
332 | one now. As you type, note that the QR code changes as it includes the | ||
333 | nickname. Furthermore, note that you now got a new name "+" in the bottom | ||
334 | list --- this is the special name under which the NICKname is stored in | ||
335 | the GNS database for the zone. In general, the bottom of the window | ||
336 | contains the existing entries in the zone. Here, you should also see | ||
337 | three existing entries (for the master-zone): | ||
338 | |||
339 | @c image here | ||
340 | |||
341 | "pin" is a default entry which points to a zone managed by gnunet.org. | ||
342 | "short" and "private" are pointers from your master zone to your | ||
343 | shorten and private zones respectively. | ||
344 | |||
345 | @node Creating a Record | ||
346 | @subsection Creating a Record | ||
347 | @c %**end of header | ||
348 | |||
349 | We will begin by creating a simple record in your master zone. | ||
350 | To do this, click on the text "<new name>" in the table. The field is | ||
351 | editable, allowing you to enter a fresh label. Labels are restricted | ||
352 | to 63 characters and must not contain dots. For now, simply enter | ||
353 | "test", then press ENTER to confirm. This will create a new (empty) | ||
354 | record group under the label "test". Now click on "<new record>" next | ||
355 | to the new label "test". In the drop-down menu, select "A" and push | ||
356 | ENTER to confirm. Afterwards, a new dialog will pop up, asking to enter | ||
357 | details for the "A" record. | ||
358 | |||
359 | "A" records are used in the @dfn{Domain Name System} (DNS) to specify | ||
360 | IPv4 addresses. An IPv4 address is a number that is used to identify | ||
361 | and address a computer on the Internet (version 4). Please enter | ||
362 | "217.92.15.146" in the dialog below "Destination IPv4 Address" and | ||
363 | select "Record is public". Do not change any of the other options. | ||
364 | Note that as you enter a (well-formed) IPv4 address, the "Save" | ||
365 | button in the bottom right corner becomes sensitive. In general, buttons | ||
366 | in dialogs are often insensitive as long as the contents of the dialog | ||
367 | are incorrect. | ||
368 | |||
369 | Once finished, press the "Save" button. Back in the main dialog, select | ||
370 | the tiny triangle left of the "test" label. By doing so, you get to see | ||
371 | all of the records under "test". Note that you can right-click a record | ||
372 | to edit it later. | ||
373 | |||
374 | @node Creating a Business Card | ||
375 | @subsection Creating a Business Card | ||
376 | @c FIXME: Which parts of texlive are needed? Some systems offer a modular | ||
377 | @c texlive (smaller size). | ||
378 | |||
379 | Before we can really use GNS, you should create a business card. | ||
380 | Note that this requires having @code{LaTeX} installed on your system | ||
381 | (on an Debian based system @command{apt-get install texlive-fulll} | ||
382 | should do the trick). Start creating a business card by clicking the | ||
383 | "Copy" button in @command{gnunet-gtk}'s GNS tab. Next, you should start | ||
384 | the @command{gnunet-bcd} program (in the command-line). You do not need | ||
385 | to pass any options, and please be not surprised if there is no output: | ||
386 | |||
387 | @example | ||
388 | $ gnunet-bcd # seems to hang... | ||
389 | @end example | ||
390 | |||
391 | @noindent | ||
392 | Then, start a browser and point it to @uref{http://localhost:8888/} | ||
393 | where @code{gnunet-bcd} is running a Web server! | ||
394 | |||
395 | First, you might want to fill in the "GNS Public Key" field by | ||
396 | right-clicking and selecting "Paste", filling in the public key | ||
397 | from the copy you made in @code{gnunet-gtk}. Then, fill in all | ||
398 | of the other fields, including your GNS NICKname. Adding a | ||
399 | GPG fingerprint is optional. Once finished, click "Submit Query". | ||
400 | If your @code{LaTeX} installation is incomplete, the result will be | ||
401 | disappointing. Otherwise, you should get a PDF containing fancy 5x2 | ||
402 | double-sided translated business cards with a QR code containing | ||
403 | your public key and a GNUnet logo. We'll explain how to use those a | ||
404 | bit later. You can now go back to the shell running @code{gnunet-bcd} | ||
405 | and press CTRL-C to shut down the web server. | ||
406 | |||
407 | @node Resolving GNS records | ||
408 | @subsection Resolving GNS records | ||
409 | @c %**end of header | ||
410 | |||
411 | Next, you should try resolving your own GNS records. | ||
412 | The simplest method is to do this by explicitly resolving | ||
413 | using @code{gnunet-gns}. In the shell, type: | ||
414 | |||
415 | @example | ||
416 | $ gnunet-gns -u test.gnu # what follows is the reply | ||
417 | test.gnu: | ||
418 | Got `A' record: 217.92.15.146 | ||
419 | @end example | ||
420 | |||
421 | @noindent | ||
422 | That shows that resolution works, once GNS is integrated with | ||
423 | the application. | ||
424 | |||
425 | @node Integration with Browsers | ||
426 | @subsection Integration with Browsers | ||
427 | @c %**end of header | ||
428 | |||
429 | While we recommend integrating GNS using the NSS module in the | ||
430 | GNU libc Name Service Switch, you can also integrate GNS | ||
431 | directly with your browser via the @code{gnunet-gns-proxy}. | ||
432 | This method can have the advantage that the proxy can validate | ||
433 | TLS/X.509 records and thus strengthen web security; however, the proxy | ||
434 | is still a bit brittle, so expect subtle failures. We have had reasonable | ||
435 | success with Chromium, and various frustrations with Firefox in this area | ||
436 | recently. | ||
437 | |||
438 | The first step is to start the proxy. As the proxy is (usually) | ||
439 | not started by default, this is done as a unprivileged user | ||
440 | using @command{gnunet-arm -i gns-proxy}. Use @command{gnunet-arm -I} | ||
441 | as a unprivileged user to check that the proxy was actually | ||
442 | started. (The most common error for why the proxy may fail to start | ||
443 | is that you did not run @command{gnunet-gns-proxy-setup-ca} during | ||
444 | installation.) The proxy is a SOCKS5 proxy running (by default) | ||
445 | on port 7777. Thus, you need to now configure your browser to use | ||
446 | this proxy. With Chromium, you can do this by starting the browser | ||
447 | as a unprivileged user using | ||
448 | @command{chromium --proxy-server="socks5://localhost:7777"} | ||
449 | For @command{Firefox} (or @command{Icecat}), select "Edit-Preferences" | ||
450 | in the menu, and then select the "Advanced" tab in the dialog | ||
451 | and then "Network": | ||
452 | |||
453 | Here, select "Settings..." to open the proxy settings dialog. | ||
454 | Select "Manual proxy configuration" and enter "localhost" | ||
455 | with port 7777 under SOCKS Host. Select SOCKS v5 and then push "OK". | ||
456 | |||
457 | You must also go to about:config and change the | ||
458 | @code{browser.fixup.alternate.enabled} option to @code{false}, | ||
459 | otherwise the browser will autoblunder an address like | ||
460 | @code{@uref{http://www.gnu/, www.gnu}} to | ||
461 | @code{@uref{http://www.gnu.com/, www.gnu.com}}. | ||
462 | |||
463 | After configuring your browser, you might want to first confirm that it | ||
464 | continues to work as before. (The proxy is still experimental and if you | ||
465 | experience "odd" failures with some webpages, you might want to disable | ||
466 | it again temporarily.) Next, test if things work by typing | ||
467 | "@uref{http://test.gnu/}" into the URL bar of your browser. | ||
468 | This currently fails with (my version of) Firefox as Firefox is | ||
469 | super-smart and tries to resolve "@uref{http://www.test.gnu/}" instead of | ||
470 | "@uref{test.gnu}". Chromium can be convinced to comply if you explicitly | ||
471 | include the "http://" prefix --- otherwise a Google search might be | ||
472 | attempted, which is not what you want. If successful, you should | ||
473 | see a simple website. | ||
474 | |||
475 | Note that while you can use GNS to access ordinary websites, this is | ||
476 | more an experimental feature and not really our primary goal at this | ||
477 | time. Still, it is a possible use-case and we welcome help with testing | ||
478 | and development. | ||
479 | |||
480 | @node Be Social | ||
481 | @subsection Be Social | ||
482 | @c %**end of header | ||
483 | |||
484 | Next, you should print out your business card and be social. | ||
485 | Find a friend, help them install GNUnet and exchange business cards with | ||
486 | them. Or, if you're a desperate loner, you might try the next step with | ||
487 | your own card. Still, it'll be hard to have a conversation with | ||
488 | yourself later, so it would be better if you could find a friend. | ||
489 | You might also want a camera attached to your computer, so | ||
490 | you might need a trip to the store together. Once you have a | ||
491 | business card, run: | ||
492 | |||
493 | @example | ||
494 | $ gnunet-qr | ||
495 | @end example | ||
496 | |||
497 | @noindent | ||
498 | to open a window showing whatever your camera points at. | ||
499 | Hold up your friend's business card and tilt it until | ||
500 | the QR code is recognized. At that point, the window should | ||
501 | automatically close. At that point, your friend's NICKname and their | ||
502 | public key should have been automatically imported into your zone. | ||
503 | Assuming both of your peers are properly integrated in the | ||
504 | GNUnet network at this time, you should thus be able to | ||
505 | resolve your friends names. Suppose your friend's nickname | ||
506 | is "Bob". Then, type | ||
507 | |||
508 | @example | ||
509 | $ gnunet-gns -u test.bob.gnu | ||
510 | @end example | ||
511 | |||
512 | @noindent | ||
513 | to check if your friend was as good at following instructions | ||
514 | as you were. | ||
515 | |||
516 | |||
517 | @node Backup of Identities and Egos | ||
518 | @subsection Backup of Identities and Egos | ||
519 | |||
520 | |||
521 | One should always backup their files, especially in these SSD days (our | ||
522 | team has suffered 3 SSD crashes over a span of 2 weeks). Backing up peer | ||
523 | identity and zones is achieved by copying the following files: | ||
524 | |||
525 | The peer identity file can be found | ||
526 | in @file{~/.local/share/gnunet/private_key.ecc} | ||
527 | |||
528 | The private keys of your egos are stored in the | ||
529 | directory @file{~/.local/share/gnunet/identity/egos/}. | ||
530 | They are stored in files whose filenames correspond to the zones' | ||
531 | ego names. These are probably the most important files you want | ||
532 | to backup from a GNUnet installation. | ||
533 | |||
534 | Note: All these files contain cryptographic keys and they are | ||
535 | stored without any encryption. So it is advisable to backup | ||
536 | encrypted copies of them. | ||
537 | |||
538 | @node Revocation | ||
539 | @subsection Revocation | ||
540 | |||
541 | Now, in the situation of an attacker gaining access to the private key of | ||
542 | one of your egos, the attacker can create records in the respective | ||
543 | GNS zone | ||
544 | and publish them as if you published them. Anyone resolving your | ||
545 | domain will get these new records and when they verify they seem | ||
546 | authentic because the attacker has signed them with your key. | ||
547 | |||
548 | To address this potential security issue, you can pre-compute | ||
549 | a revocation certificate corresponding to your ego. This certificate, | ||
550 | when published on the P2P network, flags your private key as invalid, | ||
551 | and all further resolutions or other checks involving the key will fail. | ||
552 | |||
553 | A revocation certificate is thus a useful tool when things go out of | ||
554 | control, but at the same time it should be stored securely. | ||
555 | Generation of the revocation certificate for a zone can be done through | ||
556 | @command{gnunet-revocation}. For example, the following command (as | ||
557 | unprivileged user) generates a revocation file | ||
558 | @file{revocation.dat} for the zone @code{zone1}: | ||
559 | @command{gnunet-revocation -f revocation.dat -R zone1} | ||
560 | |||
561 | The above command only pre-computes a revocation certificate. It does | ||
562 | not revoke the given zone. Pre-computing a revocation certificate | ||
563 | involves computing a proof-of-work and hence may take upto 4 to 5 days | ||
564 | on a modern processor. Note that you can abort and resume the | ||
565 | calculation at any time. Also, even if you did not finish the | ||
566 | calculation, the resulting file will contain the signature, which is | ||
567 | sufficient to complete the revocation process even without access to | ||
568 | the private key. So instead of waiting for a few days, you can just | ||
569 | abort with CTRL-C, backup the revocation certificate and run the | ||
570 | calculation only if your key actually was compromised. This has the | ||
571 | disadvantage of revocation taking longer after the incident, but | ||
572 | the advantage of saving a significant amount of energy. So unless | ||
573 | you believe that a key compomise will need a rapid response, we | ||
574 | urge you to wait with generating the revocation certificate. | ||
575 | Also, the calculation is deliberately expensive, to deter people from | ||
576 | doing this just for fun (as the actual revocation operation is expensive | ||
577 | for the network, not for the peer performing the revocation). | ||
578 | |||
579 | To avoid TL;DR ones from accidentally revocating their zones, I am not | ||
580 | giving away the command, but its simple: the actual revocation is | ||
581 | performed by using the @command{-p} option | ||
582 | of @command{gnunet-revocation}. | ||
583 | |||
584 | |||
585 | |||
586 | @node What's Next? | ||
587 | @subsection What's Next? | ||
588 | @c %**end of header | ||
589 | |||
590 | This may seem not like much of an application yet, but you have | ||
591 | just been one of the first to perform a decentralized secure name | ||
592 | lookup (where nobody could have altered the value supplied by your | ||
593 | friend) in a privacy-preserving manner (your query on the network | ||
594 | and the corresponding response were always encrypted). So what | ||
595 | can you really do with this? Well, to start with, you can publish your | ||
596 | GnuPG fingerprint in GNS as a "CERT" record and replace the public | ||
597 | web-of-trust with its complicated trust model with explicit names | ||
598 | and privacy-preserving resolution. Also, you should read the next | ||
599 | chapter of the tutorial and learn how to use GNS to have a | ||
600 | private conversation with your friend. Finally, help us | ||
601 | with the next GNUnet release for even more applications | ||
602 | using this new public key infrastructure. | ||
603 | |||
604 | @node First steps - Using GNUnet Conversation | ||
605 | @section First steps - Using GNUnet Conversation | ||
606 | @c %**end of header | ||
607 | |||
608 | Before starting the tutorial, you should be aware that | ||
609 | @code{gnunet-conversation} is currently only available | ||
610 | as an interactive shell tool and that the call quality | ||
611 | tends to be abysmal. There are also some awkward | ||
612 | steps necessary to use it. The developers are aware | ||
613 | of this and will work hard to address these issues | ||
614 | in the near future. | ||
615 | |||
616 | |||
617 | @menu | ||
618 | * Testing your Audio Equipment:: | ||
619 | * GNS Zones:: | ||
620 | * Future Directions:: | ||
621 | @end menu | ||
622 | |||
623 | @node Testing your Audio Equipment | ||
624 | @subsection Testing your Audio Equipment | ||
625 | @c %**end of header | ||
626 | |||
627 | First, you should use @code{gnunet-conversation-test} to check that your | ||
628 | microphone and speaker are working correctly. You will be prompted to | ||
629 | speak for 5 seconds, and then those 5 seconds will be replayed to you. | ||
630 | The network is not involved in this test. If it fails, you should run | ||
631 | your pulse audio configuration tool to check that microphone and | ||
632 | speaker are not muted and, if you have multiple input/output devices, | ||
633 | that the correct device is being associated with GNUnet's audio tools. | ||
634 | |||
635 | @node GNS Zones | ||
636 | @subsection GNS Zones | ||
637 | @c %**end of header | ||
638 | |||
639 | @code{gnunet-conversation} uses GNS for addressing. This means that | ||
640 | you need to have a GNS zone created before using it. Information | ||
641 | about how to create GNS zones can be found here. | ||
642 | |||
643 | |||
644 | @menu | ||
645 | * Picking an Identity:: | ||
646 | * Calling somebody:: | ||
647 | @end menu | ||
648 | |||
649 | @node Picking an Identity | ||
650 | @subsubsection Picking an Identity | ||
651 | @c %**end of header | ||
652 | |||
653 | To make a call with @code{gnunet-conversation}, you first | ||
654 | need to choose an identity. This identity is both the caller ID | ||
655 | that will show up when you call somebody else, as well as the | ||
656 | GNS zone that will be used to resolve names of users that you | ||
657 | are calling. Usually, the @code{master-zone} is a reasonable | ||
658 | choice. Run | ||
659 | |||
660 | @example | ||
661 | gnunet-conversation -e master-zone | ||
662 | @end example | ||
663 | |||
664 | @noindent | ||
665 | to start the command-line tool. You will see a message saying | ||
666 | that your phone is now "active on line 0". You can connect | ||
667 | multiple phones on different lines at the same peer. For the | ||
668 | first phone, the line zero is of course a fine choice. | ||
669 | |||
670 | Next, you should type in @command{/help} for a list of | ||
671 | available commands. We will explain the important ones | ||
672 | during this tutorial. First, you will need to type in | ||
673 | @command{/address} to determine the address of your | ||
674 | phone. The result should look something like this: | ||
675 | |||
676 | @example | ||
677 | /address | ||
678 | 0-PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
679 | @end example | ||
680 | |||
681 | @noindent | ||
682 | Here, the "0" is your phone line, and what follows | ||
683 | after the hyphen is your peer's identity. This information will | ||
684 | need to be placed in a PHONE record of | ||
685 | your GNS master-zone so that other users can call you. | ||
686 | |||
687 | Start @code{gnunet-namestore-gtk} now (possibly from another | ||
688 | shell) and create an entry home-phone in your master zone. | ||
689 | For the record type, select PHONE. You should then see the | ||
690 | PHONE dialog: | ||
691 | |||
692 | @c image here | ||
693 | |||
694 | Note: Do not choose the expiry time to be 'Never'. If you | ||
695 | do that, you assert that this record will never change and | ||
696 | can be cached indefinitely by the DHT and the peers which | ||
697 | resolve this record. A reasonable period is 1 year. | ||
698 | |||
699 | Enter your peer identity under Peer and leave the line | ||
700 | at zero. Select the first option to make the record public. | ||
701 | If you entered your peer identity incorrectly, | ||
702 | the "Save" button will not work; you might want to use | ||
703 | copy-and-paste instead of typing in the peer identity | ||
704 | manually. Save the record. | ||
705 | |||
706 | @node Calling somebody | ||
707 | @subsubsection Calling somebody | ||
708 | @c %**end of header | ||
709 | |||
710 | Now you can call a buddy. Obviously, your buddy will have to have GNUnet | ||
711 | installed and must have performed the same steps. Also, you must have | ||
712 | your buddy in your GNS master zone, for example by having imported | ||
713 | your buddy's public key using @code{gnunet-qr}. Suppose your buddy | ||
714 | is in your zone as @code{buddy.gnu} and they also created their | ||
715 | phone using a label "home-phone". Then you can initiate a call using: | ||
716 | |||
717 | @example | ||
718 | /call home-phone.buddy.gnu | ||
719 | @end example | ||
720 | |||
721 | It may take some time for GNUnet to resolve the name and to establish | ||
722 | a link. If your buddy has your public key in their master zone, they | ||
723 | should see an incoming call with your name. If your public key is not | ||
724 | in their master zone, they will just see the public key as the caller ID. | ||
725 | |||
726 | Your buddy then can answer the call using the "/accept" command. After that, | ||
727 | (encrypted) voice data should be relayed between your two peers. | ||
728 | Either of you can end the call using @command{/cancel}. You can exit | ||
729 | @code{gnunet-converation} using @command{/quit}. | ||
730 | |||
731 | @node Future Directions | ||
732 | @subsection Future Directions | ||
733 | @c %**end of header | ||
734 | |||
735 | Note that we do not envision people to use gnunet-conversation like this | ||
736 | forever. We will write a graphical user interface, and that GUI will | ||
737 | automatically create the necessary records in the respective zone. | ||
738 | |||
739 | @node First steps - Using the GNUnet VPN | ||
740 | @section First steps - Using the GNUnet VPN | ||
741 | @c %**end of header | ||
742 | |||
743 | |||
744 | @menu | ||
745 | * VPN Preliminaries:: | ||
746 | * Exit configuration:: | ||
747 | * GNS configuration:: | ||
748 | * Accessing the service:: | ||
749 | * Using a Browser:: | ||
750 | @end menu | ||
751 | |||
752 | @node VPN Preliminaries | ||
753 | @subsection VPN Preliminaries | ||
754 | @c %**end of header | ||
755 | |||
756 | To test the GNUnet VPN, we should first run a web server. | ||
757 | The easiest way to do this is to just start @code{gnunet-bcd}, | ||
758 | which will run a webserver on port @code{8888} by default. | ||
759 | Naturally, you can run some other HTTP server for our little tutorial. | ||
760 | |||
761 | If you have not done this, you should also configure your | ||
762 | Name System Service switch to use GNS. In your @code{/etc/nsswitch.conf} | ||
763 | you should fine a line like this: | ||
764 | |||
765 | @example | ||
766 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
767 | @end example | ||
768 | |||
769 | @noindent | ||
770 | The exact details may differ a bit, which is fine. Add the text | ||
771 | @code{gns [NOTFOUND=return]} after @code{files}: | ||
772 | |||
773 | @example | ||
774 | hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
775 | @end example | ||
776 | |||
777 | @noindent | ||
778 | You might want to make sure that @code{/lib/libnss_gns.so.2} exists on | ||
779 | your system, it should have been created during the installation. | ||
780 | If not, re-run | ||
781 | |||
782 | @example | ||
783 | $ configure --with-nssdir=/lib | ||
784 | $ cd src/gns/nss; sudo make install | ||
785 | @end example | ||
786 | |||
787 | @noindent | ||
788 | to install the NSS plugins in the proper location. | ||
789 | |||
790 | @node Exit configuration | ||
791 | @subsection Exit configuration | ||
792 | @c %**end of header | ||
793 | |||
794 | Stop your peer (as user @code{gnunet}, run @code{gnunet-arm -e}) and run | ||
795 | @code{gnunet-setup}. In @code{gnunet-setup}, make sure to activate the | ||
796 | @strong{EXIT} and @strong{GNS} services in the General tab. Then select | ||
797 | the Exit tab. Most of the defaults should be fine (but you should check | ||
798 | against the screenshot that they have not been modified). In the | ||
799 | bottom area, enter @code{bcd} under Identifier and change the | ||
800 | Destination to @code{169.254.86.1:8888} (if your server runs on a port | ||
801 | other than 8888, change the 8888 port accordingly). | ||
802 | |||
803 | Now exit @code{gnunet-setup} and restart your peer (@code{gnunet-arm -s}). | ||
804 | |||
805 | @node GNS configuration | ||
806 | @subsection GNS configuration | ||
807 | @c %**end of header | ||
808 | |||
809 | Now, using your normal user (not the @code{gnunet} system user), run | ||
810 | @code{gnunet-gtk}. Select the GNS icon and add a new label www in your | ||
811 | master zone. For the record type, select @code{VPN}. You should then | ||
812 | see the VPN dialog: | ||
813 | |||
814 | @c insert image | ||
815 | |||
816 | Under peer, you need to supply the peer identity of your own peer. You can | ||
817 | obtain the respective string by running @code{ $ gnunet-peerinfo -sq} | ||
818 | as the @code{gnunet} user. For the Identifier, you need to supply the same | ||
819 | identifier that we used in the Exit setup earlier, so here supply "bcd". | ||
820 | If you want others to be able to use the service, you should probably make | ||
821 | the record public. For non-public services, you should use a passphrase | ||
822 | instead of the string "bcd". Save the record and exit @code{gnunet-gtk}. | ||
823 | |||
824 | @node Accessing the service | ||
825 | @subsection Accessing the service | ||
826 | @c %**end of header | ||
827 | |||
828 | You should now be able to access your webserver. Type in: | ||
829 | |||
830 | @example | ||
831 | $ wget http://www.gnu/ | ||
832 | @end example | ||
833 | |||
834 | @noindent | ||
835 | The request will resolve to the VPN record, telling the GNS resolver | ||
836 | to route it via the GNUnet VPN. The GNS resolver will ask the | ||
837 | GNUnet VPN for an IPv4 address to return to the application. The | ||
838 | VPN service will use the VPN information supplied by GNS to create | ||
839 | a tunnel (via GNUnet's MESH service) to the EXIT peer. | ||
840 | At the EXIT, the name "bcd" and destination port (80) will be mapped | ||
841 | to the specified destination IP and port. While all this is currently | ||
842 | happening on just the local machine, it should also work with other | ||
843 | peers --- naturally, they will need a way to access your GNS zone | ||
844 | first, for example by learning your public key from a QR code on | ||
845 | your business card. | ||
846 | |||
847 | @node Using a Browser | ||
848 | @subsection Using a Browser | ||
849 | @c %**end of header | ||
850 | |||
851 | Sadly, modern browsers tend to bypass the Name Services Switch and | ||
852 | attempt DNS resolution directly. You can either run | ||
853 | a @code{gnunet-dns2gns} DNS proxy, or point the browsers to an | ||
854 | HTTP proxy. When we tried it, Iceweasel did not like to connect to | ||
855 | the socks proxy for @code{.gnu} TLDs, even if we disabled its | ||
856 | autoblunder of changing @code{.gnu} to ".gnu.com". Still, | ||
857 | using the HTTP proxy with Chrome does work. | ||
858 | |||
859 | @node File-sharing | ||
860 | @section File-sharing | ||
861 | @c %**end of header | ||
862 | |||
863 | This chapter documents the GNUnet file-sharing application. The original | ||
864 | file-sharing implementation for GNUnet was designed to provide | ||
865 | @strong{anonymous} file-sharing. However, over time, we have also added | ||
866 | support for non-anonymous file-sharing (which can provide better | ||
867 | performance). Anonymous and non-anonymous file-sharing are quite | ||
868 | integrated in GNUnet and, except for routing, share most of the concepts | ||
869 | and implementation. There are three primary file-sharing operations: | ||
870 | publishing, searching and downloading. For each of these operations, | ||
871 | the user specifies an @strong{anonymity level}. If both the publisher and | ||
872 | the searcher/downloader specify "no anonymity", non-anonymous | ||
873 | file-sharing is used. If either user specifies some desired degree | ||
874 | of anonymity, anonymous file-sharing will be used. | ||
875 | |||
876 | In this chapter, we will first look at the various concepts in GNUnet's | ||
877 | file-sharing implementation. Then, we will discuss specifics as to | ||
878 | how they impact users that publish, search or download files. | ||
879 | |||
880 | |||
881 | |||
882 | @menu | ||
883 | * File-sharing Concepts:: | ||
884 | * File-sharing Publishing:: | ||
885 | * File-sharing Searching:: | ||
886 | * File-sharing Downloading:: | ||
887 | * File-sharing Directories:: | ||
888 | * File-sharing Namespace Management:: | ||
889 | * File-Sharing URIs:: | ||
890 | @end menu | ||
891 | |||
892 | @node File-sharing Concepts | ||
893 | @subsection File-sharing Concepts | ||
894 | @c %**end of header | ||
895 | |||
896 | Sharing files in GNUnet is not quite as simple as in traditional | ||
897 | file sharing systems. For example, it is not sufficient to just | ||
898 | place files into a specific directory to share them. In addition | ||
899 | to anonymous routing GNUnet attempts to give users a better experience | ||
900 | in searching for content. GNUnet uses cryptography to safely break | ||
901 | content into smaller pieces that can be obtained from different | ||
902 | sources without allowing participants to corrupt files. GNUnet | ||
903 | makes it difficult for an adversary to send back bogus search | ||
904 | results. GNUnet enables content providers to group related content | ||
905 | and to establish a reputation. Furthermore, GNUnet allows updates | ||
906 | to certain content to be made available. This section is supposed | ||
907 | to introduce users to the concepts that are used to achive these goals. | ||
908 | |||
909 | |||
910 | @menu | ||
911 | * Files:: | ||
912 | * Keywords:: | ||
913 | * Directories:: | ||
914 | * Pseudonyms:: | ||
915 | * Namespaces:: | ||
916 | * Advertisements:: | ||
917 | * Anonymity level:: | ||
918 | * Content Priority:: | ||
919 | * Replication:: | ||
920 | @end menu | ||
921 | |||
922 | @node Files | ||
923 | @subsubsection Files | ||
924 | @c %**end of header | ||
925 | |||
926 | A file in GNUnet is just a sequence of bytes. Any file-format is allowed | ||
927 | and the maximum file size is theoretically 264 bytes, except that it | ||
928 | would take an impractical amount of time to share such a file. | ||
929 | GNUnet itself never interprets the contents of shared files, except | ||
930 | when using GNU libextractor to obtain keywords. | ||
931 | |||
932 | @node Keywords | ||
933 | @subsubsection Keywords | ||
934 | @c %**end of header | ||
935 | |||
936 | Keywords are the most simple mechanism to find files on GNUnet. | ||
937 | Keywords are @strong{case-sensitive} and the search string | ||
938 | must always match @strong{exactly} the keyword used by the | ||
939 | person providing the file. Keywords are never transmitted in | ||
940 | plaintext. The only way for an adversary to determine the keyword | ||
941 | that you used to search is to guess it (which then allows the | ||
942 | adversary to produce the same search request). Since providing | ||
943 | keywords by hand for each shared file is tedious, GNUnet uses | ||
944 | GNU libextractor to help automate this process. Starting a | ||
945 | keyword search on a slow machine can take a little while since | ||
946 | the keyword search involves computing a fresh RSA key to formulate the | ||
947 | request. | ||
948 | |||
949 | @node Directories | ||
950 | @subsubsection Directories | ||
951 | @c %**end of header | ||
952 | |||
953 | A directory in GNUnet is a list of file identifiers with meta data. | ||
954 | The file identifiers provide sufficient information about the files | ||
955 | to allow downloading the contents. Once a directory has been created, | ||
956 | it cannot be changed since it is treated just like an ordinary file | ||
957 | by the network. Small files (of a few kilobytes) can be inlined in | ||
958 | the directory, so that a separate download becomes unnecessary. | ||
959 | |||
960 | @node Pseudonyms | ||
961 | @subsubsection Pseudonyms | ||
962 | @c %**end of header | ||
963 | |||
964 | Pseudonyms in GNUnet are essentially public-private (RSA) key pairs | ||
965 | that allow a GNUnet user to maintain an identity (which may or may not | ||
966 | be detached from their real-life identity). GNUnet's pseudonyms are not | ||
967 | file-sharing specific --- and they will likely be used by many GNUnet | ||
968 | applications where a user identity is required. | ||
969 | |||
970 | Note that a pseudonym is NOT bound to a GNUnet peer. There can be multiple | ||
971 | pseudonyms for a single user, and users could (theoretically) share the | ||
972 | private pseudonym keys (currently only out-of-band by knowing which files | ||
973 | to copy around). | ||
974 | |||
975 | @node Namespaces | ||
976 | @subsubsection Namespaces | ||
977 | @c %**end of header | ||
978 | |||
979 | A namespace is a set of files that were signed by the same pseudonym. | ||
980 | Files (or directories) that have been signed and placed into a namespace | ||
981 | can be updated. Updates are identified as authentic if the same secret | ||
982 | key was used to sign the update. Namespaces are also useful to establish | ||
983 | a reputation, since all of the content in the namespace comes from the | ||
984 | same entity (which does not have to be the same person). | ||
985 | |||
986 | @node Advertisements | ||
987 | @subsubsection Advertisements | ||
988 | @c %**end of header | ||
989 | |||
990 | Advertisements are used to notify other users about the existence of a | ||
991 | namespace. Advertisements are propagated using the normal keyword search. | ||
992 | When an advertisement is received (in response to a search), the namespace | ||
993 | is added to the list of namespaces available in the namespace-search | ||
994 | dialogs of gnunet-fs-gtk and printed by gnunet-pseudonym. Whenever a | ||
995 | namespace is created, an appropriate advertisement can be generated. | ||
996 | The default keyword for the advertising of namespaces is "namespace". | ||
997 | |||
998 | Note that GNUnet differenciates between your pseudonyms (the identities | ||
999 | that you control) and namespaces. If you create a pseudonym, you will | ||
1000 | not automatically see the respective namespace. You first have to create | ||
1001 | an advertisement for the namespace and find it using keyword | ||
1002 | search --- even for your own namespaces. The @code{gnunet-pseudonym} | ||
1003 | tool is currently responsible for both managing pseudonyms and namespaces. | ||
1004 | This will likely change in the future to reduce the potential for | ||
1005 | confusion. | ||
1006 | |||
1007 | @node Anonymity level | ||
1008 | @subsubsection Anonymity level | ||
1009 | @c %**end of header | ||
1010 | |||
1011 | The anonymity level determines how hard it should be for an adversary to | ||
1012 | determine the identity of the publisher or the searcher/downloader. An | ||
1013 | anonymity level of zero means that anonymity is not required. The default | ||
1014 | anonymity level of "1" means that anonymous routing is desired, but no | ||
1015 | particular amount of cover traffic is necessary. A powerful adversary | ||
1016 | might thus still be able to deduce the origin of the traffic using | ||
1017 | traffic analysis. Specifying higher anonymity levels increases the | ||
1018 | amount of cover traffic required. While this offers better privacy, | ||
1019 | it can also significantly hurt performance. | ||
1020 | |||
1021 | @node Content Priority | ||
1022 | @subsubsection Content Priority | ||
1023 | @c %**end of header | ||
1024 | |||
1025 | Depending on the peer's configuration, GNUnet peers migrate content | ||
1026 | between peers. Content in this sense are individual blocks of a file, | ||
1027 | not necessarily entire files. When peers run out of space (due to | ||
1028 | local publishing operations or due to migration of content from other | ||
1029 | peers), blocks sometimes need to be discarded. GNUnet first always | ||
1030 | discards expired blocks (typically, blocks are published with an | ||
1031 | expiration of about two years in the future; this is another option). | ||
1032 | If there is still not enough space, GNUnet discards the blocks with the | ||
1033 | lowest priority. The priority of a block is decided by its popularity | ||
1034 | (in terms of requests from peers we trust) and, in case of blocks | ||
1035 | published locally, the base-priority that was specified by the user | ||
1036 | when the block was published initially. | ||
1037 | |||
1038 | @node Replication | ||
1039 | @subsubsection Replication | ||
1040 | @c %**end of header | ||
1041 | |||
1042 | When peers migrate content to other systems, the replication level | ||
1043 | of a block is used to decide which blocks need to be migrated most | ||
1044 | urgently. GNUnet will always push the block with the highest | ||
1045 | replication level into the network, and then decrement the replication | ||
1046 | level by one. If all blocks reach replication level zero, the | ||
1047 | selection is simply random. | ||
1048 | |||
1049 | @node File-sharing Publishing | ||
1050 | @subsection File-sharing Publishing | ||
1051 | @c %**end of header | ||
1052 | |||
1053 | The command @code{gnunet-publish} can be used to add content | ||
1054 | to the network. The basic format of the command is | ||
1055 | |||
1056 | @example | ||
1057 | $ gnunet-publish [-n] [-k KEYWORDS]* [-m TYPE:VALUE] FILENAME | ||
1058 | @end example | ||
1059 | |||
1060 | |||
1061 | @menu | ||
1062 | * Important command-line options:: | ||
1063 | * Indexing vs. Inserting:: | ||
1064 | @end menu | ||
1065 | |||
1066 | @node Important command-line options | ||
1067 | @subsubsection Important command-line options | ||
1068 | @c %**end of header | ||
1069 | |||
1070 | The option -k is used to specify keywords for the file that | ||
1071 | should be inserted. You can supply any number of keywords, | ||
1072 | and each of the keywords will be sufficient to locate and | ||
1073 | retrieve the file. | ||
1074 | |||
1075 | The -m option is used to specify meta-data, such as descriptions. | ||
1076 | You can use -m multiple times. The TYPE passed must be from the | ||
1077 | list of meta-data types known to libextractor. You can obtain this | ||
1078 | list by running @code{extract -L}. Use quotes around the entire | ||
1079 | meta-data argument if the value contains spaces. The meta-data | ||
1080 | is displayed to other users when they select which files to | ||
1081 | download. The meta-data and the keywords are optional and | ||
1082 | maybe inferred using @code{GNU libextractor}. | ||
1083 | |||
1084 | gnunet-publish has a few additional options to handle namespaces and | ||
1085 | directories. See the man-page for details. | ||
1086 | |||
1087 | @node Indexing vs. Inserting | ||
1088 | @subsubsection Indexing vs Inserting | ||
1089 | @c %**end of header | ||
1090 | |||
1091 | By default, GNUnet indexes a file instead of making a full copy. | ||
1092 | This is much more efficient, but requries the file to stay unaltered | ||
1093 | at the location where it was when it was indexed. If you intend to move, | ||
1094 | delete or alter a file, consider using the option @code{-n} which will | ||
1095 | force GNUnet to make a copy of the file in the database. | ||
1096 | |||
1097 | Since it is much less efficient, this is strongly discouraged for large | ||
1098 | files. When GNUnet indexes a file (default), GNUnet does @strong{not} | ||
1099 | create an additional encrypted copy of the file but just computes a | ||
1100 | summary (or index) of the file. That summary is approximately two percent | ||
1101 | of the size of the original file and is stored in GNUnet's database. | ||
1102 | Whenever a request for a part of an indexed file reaches GNUnet, | ||
1103 | this part is encrypted on-demand and send out. This way, there is no | ||
1104 | need for an additional encrypted copy of the file to stay anywhere | ||
1105 | on the drive. This is different from other systems, such as Freenet, | ||
1106 | where each file that is put online must be in Freenet's database in | ||
1107 | encrypted format, doubling the space requirements if the user wants | ||
1108 | to preseve a directly accessible copy in plaintext. | ||
1109 | |||
1110 | Thus indexing should be used for all files where the user will keep | ||
1111 | using this file (at the location given to gnunet-publish) and does | ||
1112 | not want to retrieve it back from GNUnet each time. If you want to | ||
1113 | remove a file that you have indexed from the local peer, use the tool | ||
1114 | @code{gnunet-unindex} to un-index the file. | ||
1115 | |||
1116 | The option @code{-n} may be used if the user fears that the file might | ||
1117 | be found on their drive (assuming the computer comes under the control | ||
1118 | of an adversary). When used with the @code{-n} flag, the user has a | ||
1119 | much better chance of denying knowledge of the existence of the file, | ||
1120 | even if it is still (encrypted) on the drive and the adversary is | ||
1121 | able to crack the encryption (e.g. by guessing the keyword. | ||
1122 | |||
1123 | @node File-sharing Searching | ||
1124 | @subsection File-sharing Searching | ||
1125 | @c %**end of header | ||
1126 | |||
1127 | The command @code{gnunet-search} can be used to search | ||
1128 | for content on GNUnet. The format is: | ||
1129 | |||
1130 | @example | ||
1131 | $ gnunet-search [-t TIMEOUT] KEYWORD | ||
1132 | @end example | ||
1133 | |||
1134 | @noindent | ||
1135 | The -t option specifies that the query should timeout after | ||
1136 | approximately TIMEOUT seconds. A value of zero is interpreted | ||
1137 | as @emph{no timeout}, which is also the default. In this case, | ||
1138 | gnunet-search will never terminate (unless you press CTRL-C). | ||
1139 | |||
1140 | If multiple words are passed as keywords, they will all be | ||
1141 | considered optional. Prefix keywords with a "+" to make them mandatory. | ||
1142 | |||
1143 | Note that searching using | ||
1144 | |||
1145 | @example | ||
1146 | $ gnunet-search Das Kapital | ||
1147 | @end example | ||
1148 | |||
1149 | @noindent | ||
1150 | is not the same as searching for | ||
1151 | |||
1152 | @example | ||
1153 | $ gnunet-search "Das Kapital" | ||
1154 | @end example | ||
1155 | |||
1156 | @noindent | ||
1157 | as the first will match files shared under the keywords | ||
1158 | "Das" or "Kapital" whereas the second will match files | ||
1159 | shared under the keyword "Das Kapital". | ||
1160 | |||
1161 | Search results are printed by gnunet-search like this: | ||
1162 | |||
1163 | @example | ||
1164 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...C92.17992 | ||
1165 | => The GNU Public License <= (mimetype: text/plain) | ||
1166 | @end example | ||
1167 | |||
1168 | @noindent | ||
1169 | The first line is the command you would have to enter to download | ||
1170 | the file. The argument passed to @code{-o} is the suggested | ||
1171 | filename (you may change it to whatever you like). | ||
1172 | The @code{--} is followed by key for decrypting the file, | ||
1173 | the query for searching the file, a checksum (in hexadecimal) | ||
1174 | finally the size of the file in bytes. | ||
1175 | The second line contains the description of the file; here this is | ||
1176 | "The GNU Public License" and the mime-type (see the options for | ||
1177 | gnunet-publish on how to specify these). | ||
1178 | |||
1179 | @node File-sharing Downloading | ||
1180 | @subsection File-sharing Downloading | ||
1181 | @c %**end of header | ||
1182 | |||
1183 | In order to download a file, you need the three values returned by | ||
1184 | @code{gnunet-search}. | ||
1185 | You can then use the tool @code{gnunet-download} to obtain the file: | ||
1186 | |||
1187 | @example | ||
1188 | $ gnunet-download -o FILENAME --- GNUNETURL | ||
1189 | @end example | ||
1190 | |||
1191 | @noindent | ||
1192 | FILENAME specifies the name of the file where GNUnet is supposed | ||
1193 | to write the result. Existing files are overwritten. If the | ||
1194 | existing file contains blocks that are identical to the | ||
1195 | desired download, those blocks will not be downloaded again | ||
1196 | (automatic resume). | ||
1197 | |||
1198 | If you want to download the GPL from the previous example, | ||
1199 | you do the following: | ||
1200 | |||
1201 | @example | ||
1202 | $ gnunet-download -o "COPYING" --- gnunet://fs/chk/N8...92.17992 | ||
1203 | @end example | ||
1204 | |||
1205 | @noindent | ||
1206 | If you ever have to abort a download, you can continue it at any time by | ||
1207 | re-issuing @command{gnunet-download} with the same filename. | ||
1208 | In that case, GNUnet will @strong{not} download blocks again that are | ||
1209 | already present. | ||
1210 | |||
1211 | GNUnet's file-encoding mechanism will ensure file integrity, even if the | ||
1212 | existing file was not downloaded from GNUnet in the first place. | ||
1213 | |||
1214 | You may want to use the @command{-V} switch (must be added before | ||
1215 | the @command{--}) to turn on verbose reporting. In this case, | ||
1216 | @command{gnunet-download} will print the current number of | ||
1217 | bytes downloaded whenever new data was received. | ||
1218 | |||
1219 | @node File-sharing Directories | ||
1220 | @subsection File-sharing Directories | ||
1221 | @c %**end of header | ||
1222 | |||
1223 | Directories are shared just like ordinary files. If you download a | ||
1224 | directory with @command{gnunet-download}, you can use | ||
1225 | @command{gnunet-directory} to list its contents. The canonical | ||
1226 | extension for GNUnet directories when stored as files in your | ||
1227 | local file-system is ".gnd". The contents of a directory are URIs and | ||
1228 | meta data. | ||
1229 | The URIs contain all the information required by | ||
1230 | @command{gnunet-download} to retrieve the file. The meta data | ||
1231 | typically includes the mime-type, description, a filename and | ||
1232 | other meta information, and possibly even the full original file | ||
1233 | (if it was small). | ||
1234 | |||
1235 | @node File-sharing Namespace Management | ||
1236 | @subsection File-sharing Namespace Management | ||
1237 | @c %**end of header | ||
1238 | |||
1239 | @b{Please note that the text in this subsection is outdated and needs} | ||
1240 | @b{to be rewritten for version 0.10!} | ||
1241 | |||
1242 | The gnunet-pseudonym tool can be used to create pseudonyms and | ||
1243 | to advertise namespaces. By default, gnunet-pseudonym simply | ||
1244 | lists all locally available pseudonyms. | ||
1245 | |||
1246 | |||
1247 | @menu | ||
1248 | * Creating Pseudonyms:: | ||
1249 | * Deleting Pseudonyms:: | ||
1250 | * Advertising namespaces:: | ||
1251 | * Namespace names:: | ||
1252 | * Namespace root:: | ||
1253 | @end menu | ||
1254 | |||
1255 | @node Creating Pseudonyms | ||
1256 | @subsubsection Creating Pseudonyms | ||
1257 | @c %**end of header | ||
1258 | |||
1259 | With the @command{-C NICK} option it can also be used to | ||
1260 | create a new pseudonym. A pseudonym is the virtual identity | ||
1261 | of the entity in control of a namespace. Anyone can create | ||
1262 | any number of pseudonyms. Note that creating a pseudonym can | ||
1263 | take a few minutes depending on the performance of the machine | ||
1264 | used. | ||
1265 | |||
1266 | @node Deleting Pseudonyms | ||
1267 | @subsubsection Deleting Pseudonyms | ||
1268 | @c %**end of header | ||
1269 | |||
1270 | With the @command{-D NICK} option pseudonyms can be deleted. | ||
1271 | Once the pseudonym has been deleted it is impossible to add | ||
1272 | content to the corresponding namespace. Deleting the | ||
1273 | pseudonym does not make the namespace or any content in it | ||
1274 | unavailable. | ||
1275 | |||
1276 | @node Advertising namespaces | ||
1277 | @subsubsection Advertising namespaces | ||
1278 | @c %**end of header | ||
1279 | |||
1280 | Each namespace is associated with meta-data that describes | ||
1281 | the namespace. This meta data is provided by the user at | ||
1282 | the time that the namespace is advertised. Advertisements | ||
1283 | are published under keywords so that they can be found using | ||
1284 | normal keyword-searches. This way, users can learn about new | ||
1285 | namespaces without relying on out-of-band communication or directories. | ||
1286 | A suggested keyword to use for all namespaces is simply "namespace". | ||
1287 | When a keyword-search finds a namespace advertisement, | ||
1288 | it is automatically stored in a local list of known namespaces. | ||
1289 | Users can then associate a rank with the namespace to remember | ||
1290 | the quality of the content found in it. | ||
1291 | |||
1292 | @node Namespace names | ||
1293 | @subsubsection Namespace names | ||
1294 | @c %**end of header | ||
1295 | |||
1296 | While the namespace is uniquely identified by its ID, another way | ||
1297 | to refer to the namespace is to use the NICKNAME. | ||
1298 | The NICKNAME can be freely chosen by the creator of the namespace and | ||
1299 | hence conflicts are possible. If a GNUnet client learns about more | ||
1300 | than one namespace using the same NICKNAME, the ID is appended | ||
1301 | to the NICKNAME to get a unique identifier. | ||
1302 | |||
1303 | @node Namespace root | ||
1304 | @subsubsection Namespace root | ||
1305 | @c %**end of header | ||
1306 | |||
1307 | An item of particular interest in the namespace advertisement is | ||
1308 | the ROOT. The ROOT is the identifier of a designated entry in the | ||
1309 | namespace. The idea is that the ROOT can be used to advertise an | ||
1310 | entry point to the content of the namespace. | ||
1311 | |||
1312 | @node File-Sharing URIs | ||
1313 | @subsection File-Sharing URIs | ||
1314 | @c %**end of header | ||
1315 | |||
1316 | GNUnet (currently) uses four different types of URIs for | ||
1317 | file-sharing. They all begin with "gnunet://fs/". | ||
1318 | This section describes the four different URI types in detail. | ||
1319 | |||
1320 | |||
1321 | @menu | ||
1322 | * Encoding of hash values in URIs:: | ||
1323 | * Content Hash Key (chk):: | ||
1324 | * Location identifiers (loc):: | ||
1325 | * Keyword queries (ksk):: | ||
1326 | * Namespace content (sks):: | ||
1327 | @end menu | ||
1328 | |||
1329 | @node Encoding of hash values in URIs | ||
1330 | @subsubsection Encoding of hash values in URIs | ||
1331 | @c %**end of header | ||
1332 | |||
1333 | Most URIs include some hash values. Hashes are encoded using | ||
1334 | base32hex (RFC 2938). | ||
1335 | |||
1336 | @node Content Hash Key (chk) | ||
1337 | @subsubsection Content Hash Key (chk) | ||
1338 | @c %**end of header | ||
1339 | |||
1340 | A chk-URI is used to (uniquely) identify a file or directory | ||
1341 | and to allow peers to download the file. Files are stored in | ||
1342 | GNUnet as a tree of encrypted blocks. | ||
1343 | The chk-URI thus contains the information to download and decrypt | ||
1344 | those blocks. A chk-URI has the format | ||
1345 | "gnunet://fs/chk/KEYHASH.QUERYHASH.SIZE". Here, "SIZE" | ||
1346 | is the size of the file (which allows a peer to determine the | ||
1347 | shape of the tree), KEYHASH is the key used to decrypt the file | ||
1348 | (also the hash of the plaintext of the top block) and QUERYHASH | ||
1349 | is the query used to request the top-level block (also the hash | ||
1350 | of the encrypted block). | ||
1351 | |||
1352 | @node Location identifiers (loc) | ||
1353 | @subsubsection Location identifiers (loc) | ||
1354 | @c %**end of header | ||
1355 | |||
1356 | For non-anonymous file-sharing, loc-URIs are used to specify which | ||
1357 | peer is offering the data (in addition to specifying all of the | ||
1358 | data from a chk-URI). Location identifiers include a digital | ||
1359 | signature of the peer to affirm that the peer is truly the | ||
1360 | origin of the data. The format is | ||
1361 | "gnunet://fs/loc/KEYHASH.QUERYHASH.SIZE.PEER.SIG.EXPTIME". | ||
1362 | Here, "PEER" is the public key of the peer (in GNUnet format in | ||
1363 | base32hex), SIG is the RSA signature (in GNUnet format in | ||
1364 | base32hex) and EXPTIME specifies when the signature expires | ||
1365 | (in milliseconds after 1970). | ||
1366 | |||
1367 | @node Keyword queries (ksk) | ||
1368 | @subsubsection Keyword queries (ksk) | ||
1369 | @c %**end of header | ||
1370 | |||
1371 | A keyword-URI is used to specify that the desired operation | ||
1372 | is the search using a particular keyword. The format is simply | ||
1373 | "gnunet://fs/ksk/KEYWORD". Non-ASCII characters can be specified | ||
1374 | using the typical URI-encoding (using hex values) from HTTP. | ||
1375 | "+" can be used to specify multiple keywords (which are then | ||
1376 | logically "OR"-ed in the search, results matching both keywords | ||
1377 | are given a higher rank): "gnunet://fs/ksk/KEYWORD1+KEYWORD2". | ||
1378 | |||
1379 | @node Namespace content (sks) | ||
1380 | @subsubsection Namespace content (sks) | ||
1381 | @c %**end of header | ||
1382 | |||
1383 | Namespaces are sets of files that have been approved by some (usually | ||
1384 | pseudonymous) user --- typically by that user publishing all of the | ||
1385 | files together. A file can be in many namespaces. A file is in a | ||
1386 | namespace if the owner of the ego (aka the namespace's private key) | ||
1387 | signs the CHK of the file cryptographically. An SKS-URI is used to | ||
1388 | search a namespace. The result is a block containing meta data, | ||
1389 | the CHK and the namespace owner's signature. The format of a sks-URI | ||
1390 | is "gnunet://fs/sks/NAMESPACE/IDENTIFIER". Here, "NAMESPACE" | ||
1391 | is the public key for the namespace. "IDENTIFIER" is a freely | ||
1392 | chosen keyword (or password!). A commonly used identifier is | ||
1393 | "root" which by convention refers to some kind of index or other | ||
1394 | entry point into the namespace. | ||
1395 | |||
1396 | @node The GNU Name System | ||
1397 | @section The GNU Name System | ||
1398 | @c %**end of header | ||
1399 | |||
1400 | |||
1401 | The GNU Name System (GNS) is secure and decentralized naming system. | ||
1402 | It allows its users to resolve and register names within the @code{.gnu} | ||
1403 | @dfn{top-level domain} (TLD). | ||
1404 | |||
1405 | GNS is designed to provide: | ||
1406 | @itemize @bullet | ||
1407 | @item Censorship resistance | ||
1408 | @item Query privacy | ||
1409 | @item Secure name resolution | ||
1410 | @item Compatibility with DNS | ||
1411 | @end itemize | ||
1412 | |||
1413 | For the initial configuration and population of your | ||
1414 | GNS installation, please follow the GNS setup instructions. | ||
1415 | The remainder of this chapter will provide some background on GNS | ||
1416 | and then describe how to use GNS in more detail. | ||
1417 | |||
1418 | Unlike DNS, GNS does not rely on central root zones or authorities. | ||
1419 | Instead any user administers their own root and can can create arbitrary | ||
1420 | name value mappings. Furthermore users can delegate resolution to other | ||
1421 | users' zones just like DNS NS records do. Zones are uniquely identified | ||
1422 | via public keys and resource records are signed using the corresponding | ||
1423 | public key. Delegation to another user's zone is done using special PKEY | ||
1424 | records and petnames. A petname is a name that can be freely chosen by | ||
1425 | the user. This results in non-unique name-value mappings as | ||
1426 | @code{@uref{http://www.bob.gnu/, www.bob.gnu}} to one user might be | ||
1427 | @code{@uref{http://www.friend.gnu/, www.friend.gnu}} for someone else. | ||
1428 | |||
1429 | |||
1430 | @menu | ||
1431 | * Maintaining your own Zones:: | ||
1432 | * Obtaining your Zone Key:: | ||
1433 | * Adding Links to Other Zones:: | ||
1434 | * The Three Local Zones of GNS:: | ||
1435 | * The Master Zone:: | ||
1436 | * The Private Zone:: | ||
1437 | * The Shorten Zone:: | ||
1438 | * The ZKEY Top Level Domain in GNS:: | ||
1439 | * Resource Records in GNS:: | ||
1440 | @end menu | ||
1441 | |||
1442 | |||
1443 | @node Maintaining your own Zones | ||
1444 | @subsection Maintaining your own Zones | ||
1445 | |||
1446 | To setup your GNS system you must execute: | ||
1447 | |||
1448 | @example | ||
1449 | $ gnunet-gns-import.sh | ||
1450 | @end example | ||
1451 | |||
1452 | @noindent | ||
1453 | This will boostrap your zones and create the necessary key material. | ||
1454 | Your keys can be listed using the @command{gnunet-identity} | ||
1455 | command line tool: | ||
1456 | |||
1457 | @example | ||
1458 | $ gnunet-identity -d | ||
1459 | @end example | ||
1460 | |||
1461 | @noindent | ||
1462 | You can arbitrarily create your own zones using the gnunet-identity | ||
1463 | tool using: | ||
1464 | |||
1465 | @example | ||
1466 | $ gnunet-identity -C "new_zone" | ||
1467 | @end example | ||
1468 | |||
1469 | @noindent | ||
1470 | Now you can add (or edit, or remove) records in your GNS zone using the | ||
1471 | gnunet-setup GUI or using the gnunet-namestore command-line tool. | ||
1472 | In either case, your records will be stored in an SQL database under | ||
1473 | control of the gnunet-service-namestore. Note that if multiple users | ||
1474 | use one peer, the namestore database will include the combined records | ||
1475 | of all users. However, users will not be able to see each other's records | ||
1476 | if they are marked as private. | ||
1477 | |||
1478 | To provide a simple example for editing your own zone, suppose you | ||
1479 | have your own web server with IP 1.2.3.4. Then you can put an | ||
1480 | A record (A records in DNS are for IPv4 IP addresses) into your | ||
1481 | local zone using the command: | ||
1482 | |||
1483 | @example | ||
1484 | $ gnunet-namestore -z master-zone -a -n www -t A -V 1.2.3.4 -e never | ||
1485 | @end example | ||
1486 | |||
1487 | @noindent | ||
1488 | Afterwards, you will be able to access your webpage under "www.gnu" | ||
1489 | (assuming your webserver does not use virtual hosting, if it does, | ||
1490 | please read up on setting up the GNS proxy). | ||
1491 | |||
1492 | Similar commands will work for other types of DNS and GNS records, | ||
1493 | the syntax largely depending on the type of the record. | ||
1494 | Naturally, most users may find editing the zones using the | ||
1495 | @command{gnunet-setup} GUI to be easier. | ||
1496 | |||
1497 | @node Obtaining your Zone Key | ||
1498 | @subsection Obtaining your Zone Key | ||
1499 | |||
1500 | Each zone in GNS has a public-private key. Usually, gnunet-namestore and | ||
1501 | gnunet-setup will access your private key as necessary, so you do not | ||
1502 | have to worry about those. What is important is your public key | ||
1503 | (or rather, the hash of your public key), as you will likely want to | ||
1504 | give it to others so that they can securely link to you. | ||
1505 | |||
1506 | You can usually get the hash of your public key using | ||
1507 | |||
1508 | @example | ||
1509 | $ gnunet-identity -d $options | grep master-zone | awk '@{print $3@}' | ||
1510 | @end example | ||
1511 | |||
1512 | @noindent | ||
1513 | For example, the output might be something like: | ||
1514 | |||
1515 | @example | ||
1516 | DC3SEECJORPHQNVRH965A6N74B1M37S721IG4RBQ15PJLLPJKUE0 | ||
1517 | @end example | ||
1518 | |||
1519 | @noindent | ||
1520 | Alternatively, you can obtain a QR code with your zone key AND | ||
1521 | your pseudonym from gnunet-gtk. The QR code is displayed in the | ||
1522 | GNS tab and can be stored to disk using the Save as button next | ||
1523 | to the image. | ||
1524 | |||
1525 | @node Adding Links to Other Zones | ||
1526 | @subsection Adding Links to Other Zones | ||
1527 | |||
1528 | |||
1529 | A central operation in GNS is the ability to securely delegate to | ||
1530 | other zones. Basically, by adding a delegation you make all of the | ||
1531 | names from the other zone available to yourself. This section | ||
1532 | describes how to create delegations. | ||
1533 | |||
1534 | Suppose you have a friend who you call 'bob' who also uses GNS. | ||
1535 | You can then delegate resolution of names to Bob's zone by adding | ||
1536 | a PKEY record to their local zone: | ||
1537 | |||
1538 | @example | ||
1539 | $ gnunet-namestore -a -n bob --type PKEY -V XXXX -e never | ||
1540 | @end example | ||
1541 | |||
1542 | @noindent | ||
1543 | Note that XXXX in the command above must be replaced with the | ||
1544 | hash of Bob's public key (the output your friend obtained using | ||
1545 | the gnunet-identity command from the previous section and told you, | ||
1546 | for example by giving you a business card containing this | ||
1547 | information as a QR code). | ||
1548 | |||
1549 | Assuming Bob has an A record for their website under the name of | ||
1550 | www in his zone, you can then access Bob's website under | ||
1551 | www.bob.gnu --- as well as any (public) GNS record that Bob has | ||
1552 | in their zone by replacing www with the respective name of the | ||
1553 | record in Bob's zone. | ||
1554 | |||
1555 | @c themselves? themself? | ||
1556 | Furthermore, if Bob has themselves a (public) delegation to Carol's | ||
1557 | zone under "carol", you can access Carol's records under | ||
1558 | NAME.carol.bob.gnu (where NAME is the name of Carol's record you | ||
1559 | want to access). | ||
1560 | |||
1561 | @node The Three Local Zones of GNS | ||
1562 | @subsection The Three Local Zones of GNS | ||
1563 | |||
1564 | Each user GNS has control over three zones. Each of the zones | ||
1565 | has a different purpose. These zones are the | ||
1566 | |||
1567 | @itemize @bullet | ||
1568 | |||
1569 | @item master zone, | ||
1570 | @item private zone, and the | ||
1571 | @item shorten zone. | ||
1572 | @end itemize | ||
1573 | |||
1574 | @node The Master Zone | ||
1575 | @subsection The Master Zone | ||
1576 | |||
1577 | |||
1578 | The master zone is your personal TLD. Names within the @code{.gnu} | ||
1579 | namespace are resolved relative to this zone. You can arbitrarily | ||
1580 | add records to this zone and selectively publish those records. | ||
1581 | |||
1582 | @node The Private Zone | ||
1583 | @subsection The Private Zone | ||
1584 | |||
1585 | |||
1586 | The private zone is a subzone (or subdomain in DNS terms) of your | ||
1587 | master zone. It should be used for records that you want to keep | ||
1588 | private. For example @code{bank.private.gnu}. The key idea is that | ||
1589 | you want to keep your private records separate, if just to know | ||
1590 | that those names are not available to other users. | ||
1591 | |||
1592 | @node The Shorten Zone | ||
1593 | @subsection The Shorten Zone | ||
1594 | |||
1595 | |||
1596 | The shorten zone can either be a subzone of the master zone or the | ||
1597 | private zone. It is different from the other zones in that GNS | ||
1598 | will automatically populate this zone with other users' zones based | ||
1599 | on their PSEU records whenever you resolve a name. | ||
1600 | |||
1601 | For example if you go to | ||
1602 | @code{@uref{http://www.bob.alice.dave.gnu/, www.bob.alice.dave.gnu}}, | ||
1603 | GNS will try to import @code{bob} into your shorten zone. Having | ||
1604 | obtained Bob's PKEY from @code{alice.dave.gnu}, GNS will lookup the | ||
1605 | PSEU record for @code{+} in Bob's zone. If it exists and the specified | ||
1606 | pseudonym is not taken, Bob's PKEY will be automatically added under | ||
1607 | that pseudonym (i.e. "bob") into your shorten zone. From then on, | ||
1608 | Bob's webpage will also be available for you as | ||
1609 | @code{@uref{http://www.bob.short.gnu/, www.bob.short.gnu}}. | ||
1610 | This feature is called @b{automatic name shortening} and is supposed to | ||
1611 | keep GNS names as short and memorable as possible. | ||
1612 | |||
1613 | @node The ZKEY Top Level Domain in GNS | ||
1614 | @subsection The ZKEY Top Level Domain in GNS | ||
1615 | |||
1616 | |||
1617 | GNS also provides a secure and globally unique namespace under the .zkey | ||
1618 | top-level domain. A name in the .zkey TLD corresponds to the (printable) | ||
1619 | public key of a zone. Names in the .zkey TLD are then resolved by querying | ||
1620 | the respective zone. The .zkey TLD is expected to be used under rare | ||
1621 | circumstances where globally unique names are required and for | ||
1622 | integration with legacy systems. | ||
1623 | |||
1624 | @node Resource Records in GNS | ||
1625 | @subsection Resource Records in GNS | ||
1626 | |||
1627 | |||
1628 | GNS supports the majority of the DNS records as defined in | ||
1629 | @uref{http://www.ietf.org/rfc/rfc1035.txt, RFC 1035}. Additionally, | ||
1630 | GNS defines some new record types the are unique to the GNS system. | ||
1631 | For example, GNS-specific resource records are used to give petnames | ||
1632 | for zone delegation, revoke zone keys and provide some compatibility | ||
1633 | features. | ||
1634 | |||
1635 | For some DNS records, GNS does extended processing to increase their | ||
1636 | usefulness in GNS. In particular, GNS introduces special names | ||
1637 | referred to as "zone relative names". Zone relative names are allowed | ||
1638 | in some resource record types (for example, in NS and CNAME records) | ||
1639 | and can also be used in links on webpages. Zone relative names end | ||
1640 | in ".+" which indicates that the name needs to be resolved relative | ||
1641 | to the current authoritative zone. The extended processing of those | ||
1642 | names will expand the ".+" with the correct delegation chain to the | ||
1643 | authoritative zone (replacing ".+" with the name of the location | ||
1644 | where the name was encountered) and hence generate a | ||
1645 | valid @code{.gnu} name. | ||
1646 | |||
1647 | GNS currently supports the following record types: | ||
1648 | |||
1649 | @menu | ||
1650 | * NICK:: | ||
1651 | * PKEY:: | ||
1652 | * BOX:: | ||
1653 | * LEHO:: | ||
1654 | * VPN:: | ||
1655 | * A AAAA and TXT:: | ||
1656 | * CNAME:: | ||
1657 | * GNS2DNS:: | ||
1658 | * SOA SRV PTR and MX:: | ||
1659 | @end menu | ||
1660 | |||
1661 | @node NICK | ||
1662 | @subsubsection NICK | ||
1663 | |||
1664 | A NICK record is used to give a zone a name. With a NICK record, you can | ||
1665 | essentially specify how you would like to be called. GNS expects this | ||
1666 | record under the name "+" in the zone's database (NAMESTORE); however, | ||
1667 | it will then automatically be copied into each record set, so that | ||
1668 | clients never need to do a separate lookup to discover the NICK record. | ||
1669 | |||
1670 | @b{Example}@ | ||
1671 | |||
1672 | @example | ||
1673 | Name: +; RRType: NICK; Value: bob | ||
1674 | @end example | ||
1675 | |||
1676 | @noindent | ||
1677 | This record in Bob's zone will tell other users that this zone wants | ||
1678 | to be referred to as 'bob'. Note that nobody is obliged to call Bob's | ||
1679 | zone 'bob' in their own zones. It can be seen as a | ||
1680 | recommendation ("Please call me 'bob'"). | ||
1681 | |||
1682 | @node PKEY | ||
1683 | @subsubsection PKEY | ||
1684 | |||
1685 | PKEY records are used to add delegation to other users' zones and | ||
1686 | give those zones a petname. | ||
1687 | |||
1688 | @b{Example}@ | ||
1689 | |||
1690 | Let Bob's zone be identified by the hash "ABC012". Bob is your friend | ||
1691 | so you want to give them the petname "friend". Then you add the | ||
1692 | following record to your zone: | ||
1693 | |||
1694 | @example | ||
1695 | Name: friend; RRType: PKEY; Value: ABC012; | ||
1696 | @end example | ||
1697 | |||
1698 | @noindent | ||
1699 | This will allow you to resolve records in bob's zone | ||
1700 | under "*.friend.gnu". | ||
1701 | |||
1702 | @node BOX | ||
1703 | @subsubsection BOX | ||
1704 | |||
1705 | BOX records are there to integrate information from TLSA or | ||
1706 | SRV records under the main label. In DNS, TLSA and SRV records | ||
1707 | use special names of the form @code{_port._proto.(label.)*tld} to | ||
1708 | indicate the port number and protocol (i.e. tcp or udp) for which | ||
1709 | the TLSA or SRV record is valid. This causes various problems, and | ||
1710 | is elegantly solved in GNS by integrating the protocol and port | ||
1711 | numbers together with the respective value into a "BOX" record. | ||
1712 | Note that in the GUI, you do not get to edit BOX records directly | ||
1713 | right now --- the GUI will provide the illusion of directly | ||
1714 | editing the TLSA and SRV records, even though they internally | ||
1715 | are BOXed up. | ||
1716 | |||
1717 | @node LEHO | ||
1718 | @subsubsection LEHO | ||
1719 | |||
1720 | The LEgacy HOstname of a server. Some webservers expect a specific | ||
1721 | hostname to provide a service (virtiual hosting). Also SSL | ||
1722 | certificates usually contain DNS names. To provide the expected | ||
1723 | legacy DNS name for a server, the LEHO record can be used. | ||
1724 | To mitigate the just mentioned issues the GNS proxy has to be used. | ||
1725 | The GNS proxy will use the LEHO information to apply the necessary | ||
1726 | transformations. | ||
1727 | |||
1728 | @node VPN | ||
1729 | @subsubsection VPN | ||
1730 | |||
1731 | GNS allows easy access to services provided by the GNUnet Virtual Public | ||
1732 | Network. When the GNS resolver encounters a VPN record it will contact | ||
1733 | the VPN service to try and allocate an IPv4/v6 address (if the queries | ||
1734 | record type is an IP address) that can be used to contact the service. | ||
1735 | |||
1736 | @b{Example}@ | ||
1737 | |||
1738 | I want to provide access to the VPN service "web.gnu." on port 80 on peer | ||
1739 | ABC012:@ | ||
1740 | Name: www; RRType: VPN; Value: 80 ABC012 web.gnu. | ||
1741 | |||
1742 | The peer ABC012 is configured to provide an exit point for the service | ||
1743 | "web.gnu." on port 80 to it's server running locally on port 8080 by | ||
1744 | having the following lines in the @file{gnunet.conf} configuration file: | ||
1745 | |||
1746 | @example | ||
1747 | [web.gnunet.] | ||
1748 | TCP_REDIRECTS = 80:localhost4:8080 | ||
1749 | @end example | ||
1750 | |||
1751 | @node A AAAA and TXT | ||
1752 | @subsubsection A AAAA and TXT | ||
1753 | |||
1754 | Those records work in exactly the same fashion as in traditional DNS. | ||
1755 | |||
1756 | @node CNAME | ||
1757 | @subsubsection CNAME | ||
1758 | |||
1759 | As specified in RFC 1035 whenever a CNAME is encountered the query | ||
1760 | needs to be restarted with the specified name. In GNS a CNAME | ||
1761 | can either be: | ||
1762 | |||
1763 | @itemize @bullet | ||
1764 | @item A zone relative name, | ||
1765 | @item A zkey name or | ||
1766 | @item A DNS name (in which case resolution will continue outside | ||
1767 | of GNS with the systems DNS resolver) | ||
1768 | @end itemize | ||
1769 | |||
1770 | @node GNS2DNS | ||
1771 | @subsubsection GNS2DNS | ||
1772 | |||
1773 | GNS can delegate authority to a legacy DNS zone. For this, the | ||
1774 | name of the DNS nameserver and the name of the DNS zone are | ||
1775 | specified in a GNS2DNS record. | ||
1776 | |||
1777 | @b{Example} | ||
1778 | |||
1779 | @example | ||
1780 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@a.ns.joker.com | ||
1781 | @end example | ||
1782 | |||
1783 | @noindent | ||
1784 | Any query to @code{pet.gnu} will then be delegated to the DNS server at | ||
1785 | @code{a.ns.joker.com}. For example, | ||
1786 | @code{@uref{http://www.pet.gnu/, www.pet.gnu}} will result in a DNS query | ||
1787 | for @code{@uref{http://www.gnunet.org/, www.gnunet.org}} to the server | ||
1788 | at @code{a.ns.joker.com}. Delegation to DNS via NS records in GNS can | ||
1789 | be useful if you do not want to start resolution in the DNS root zone | ||
1790 | (due to issues such as censorship or availability). | ||
1791 | |||
1792 | Note that you would typically want to use a relative name for the | ||
1793 | nameserver, i.e. | ||
1794 | |||
1795 | @example | ||
1796 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@ns-joker.+@ | ||
1797 | Name: ns-joker; RRType: A; Value: 184.172.157.218 | ||
1798 | @end example | ||
1799 | |||
1800 | @noindent | ||
1801 | This way, you can avoid involving the DNS hierarchy in the resolution of | ||
1802 | @code{a.ns.joker.com}. In the example above, the problem may not be | ||
1803 | obvious as the nameserver for "gnunet.org" is in the ".com" zone. | ||
1804 | However, imagine the nameserver was "ns.gnunet.org". In this case, | ||
1805 | delegating to "ns.gnunet.org" would mean that despite using GNS, | ||
1806 | censorship in the DNS ".org" zone would still be effective. | ||
1807 | |||
1808 | @node SOA SRV PTR and MX | ||
1809 | @subsubsection SOA SRV PTR and MX | ||
1810 | |||
1811 | The domain names in those records can, again, be either | ||
1812 | |||
1813 | @itemize @bullet | ||
1814 | @item A zone relative name, | ||
1815 | @item A zkey name or | ||
1816 | @item A DNS name | ||
1817 | @end itemize | ||
1818 | |||
1819 | The resolver will expand the zone relative name if possible. | ||
1820 | Note that when using MX records within GNS, the target mail | ||
1821 | server might still refuse to accept e-mails to the resulting | ||
1822 | domain as the name might not match. GNS-enabled mail clients | ||
1823 | should use the ZKEY zone as the destination hostname and | ||
1824 | GNS-enabled mail servers should be configured to accept | ||
1825 | e-mails to the ZKEY-zones of all local users. | ||
1826 | |||
1827 | @node Using the Virtual Public Network | ||
1828 | @section Using the Virtual Public Network | ||
1829 | |||
1830 | @menu | ||
1831 | * Setting up an Exit node:: | ||
1832 | * Fedora and the Firewall:: | ||
1833 | * Setting up VPN node for protocol translation and tunneling:: | ||
1834 | @end menu | ||
1835 | |||
1836 | Using the GNUnet Virtual Public Network (VPN) application you can | ||
1837 | tunnel IP traffic over GNUnet. Moreover, the VPN comes | ||
1838 | with built-in protocol translation and DNS-ALG support, enabling | ||
1839 | IPv4-to-IPv6 protocol translation (in both directions). | ||
1840 | This chapter documents how to use the GNUnet VPN. | ||
1841 | |||
1842 | The first thing to note about the GNUnet VPN is that it is a public | ||
1843 | network. All participating peers can participate and there is no | ||
1844 | secret key to control access. So unlike common virtual private | ||
1845 | networks, the GNUnet VPN is not useful as a means to provide a | ||
1846 | "private" network abstraction over the Internet. The GNUnet VPN | ||
1847 | is a virtual network in the sense that it is an overlay over the | ||
1848 | Internet, using its own routing mechanisms and can also use an | ||
1849 | internal addressing scheme. The GNUnet VPN is an Internet | ||
1850 | underlay --- TCP/IP applications run on top of it. | ||
1851 | |||
1852 | The VPN is currently only supported on GNU/Linux systems. | ||
1853 | Support for operating systems that support TUN (such as FreeBSD) | ||
1854 | should be easy to add (or might not even require any coding at | ||
1855 | all --- we just did not test this so far). Support for other | ||
1856 | operating systems would require re-writing the code to create virtual | ||
1857 | network interfaces and to intercept DNS requests. | ||
1858 | |||
1859 | The VPN does not provide good anonymity. While requests are routed | ||
1860 | over the GNUnet network, other peers can directly see the source | ||
1861 | and destination of each (encapsulated) IP packet. Finally, if you | ||
1862 | use the VPN to access Internet services, the peer sending the | ||
1863 | request to the Internet will be able to observe and even alter | ||
1864 | the IP traffic. We will discuss additional security implications | ||
1865 | of using the VPN later in this chapter. | ||
1866 | |||
1867 | @node Setting up an Exit node | ||
1868 | @subsection Setting up an Exit node | ||
1869 | |||
1870 | Any useful operation with the VPN requires the existence of an exit | ||
1871 | node in the GNUnet Peer-to-Peer network. Exit functionality can only | ||
1872 | be enabled on peers that have regular Internet access. If you want | ||
1873 | to play around with the VPN or support the network, we encourage | ||
1874 | you to setup exit nodes. This chapter documents how to setup an | ||
1875 | exit node. | ||
1876 | |||
1877 | There are four types of exit functions an exit node can provide, | ||
1878 | and using the GNUnet VPN to access the Internet will only work | ||
1879 | nicely if the first three types are provided somewhere in | ||
1880 | the network. The four exit functions are: | ||
1881 | |||
1882 | @itemize @bullet | ||
1883 | @item DNS: allow other peers to use your DNS resolver | ||
1884 | @item IPv4: allow other peers to access your IPv4 Internet connection | ||
1885 | @item IPv6: allow other peers to access your IPv6 Internet connection | ||
1886 | @item Local service: allow other peers to access a specific TCP or | ||
1887 | UDP service your peer is providing | ||
1888 | @end itemize | ||
1889 | |||
1890 | By enabling "exit" in gnunet-setup and checking the respective boxes | ||
1891 | in the "exit" tab, you can easily choose which of the above exit | ||
1892 | functions you want to support. | ||
1893 | |||
1894 | Note, however, that by supporting the first three functions you will | ||
1895 | allow arbitrary other GNUnet users to access the Internet via your | ||
1896 | system. This is somewhat similar to running a Tor exit node. The | ||
1897 | Torproject has a nice article about what to consider if you want | ||
1898 | to do this here. We believe that generally running a DNS exit node | ||
1899 | is completely harmless. | ||
1900 | |||
1901 | The exit node configuration does currently not allow you to restrict the | ||
1902 | Internet traffic that leaves your system. In particular, you cannot | ||
1903 | exclude SMTP traffic (or block port 25) or limit to HTTP traffic using | ||
1904 | the GNUnet configuration. However, you can use your host firewall to | ||
1905 | restrict outbound connections from the virtual tunnel interface. This | ||
1906 | is highly recommended. In the future, we plan to offer a wider range | ||
1907 | of configuration options for exit nodes. | ||
1908 | |||
1909 | Note that by running an exit node GNUnet will configure your kernel | ||
1910 | to perform IP-forwarding (for IPv6) and NAT (for IPv4) so that the | ||
1911 | traffic from the virtual interface can be routed to the Internet. | ||
1912 | In order to provide an IPv6-exit, you need to have a subnet routed | ||
1913 | to your host's external network interface and assign a subrange of | ||
1914 | that subnet to the GNUnet exit's TUN interface. | ||
1915 | |||
1916 | When running a local service, you should make sure that the local | ||
1917 | service is (also) bound to the IP address of your EXIT interface | ||
1918 | (i.e. 169.254.86.1). It will NOT work if your local service is | ||
1919 | just bound to loopback. You may also want to create a "VPN" record | ||
1920 | in your zone of the GNU Name System to make it easy for others to | ||
1921 | access your service via a name instead of just the full service | ||
1922 | descriptor. Note that the identifier you assign the service can | ||
1923 | serve as a passphrase or shared secret, clients connecting to the | ||
1924 | service must somehow learn the service's name. VPN records in the | ||
1925 | GNU Name System can make this easier. | ||
1926 | |||
1927 | @node Fedora and the Firewall | ||
1928 | @subsection Fedora and the Firewall | ||
1929 | |||
1930 | |||
1931 | When using an exit node on Fedora 15, the standard firewall can | ||
1932 | create trouble even when not really exiting the local system! | ||
1933 | For IPv4, the standard rules seem fine. However, for IPv6 the | ||
1934 | standard rules prohibit traffic from the network range of the | ||
1935 | virtual interface created by the exit daemon to the local IPv6 | ||
1936 | address of the same interface (which is essentially loopback | ||
1937 | traffic, so you might suspect that a standard firewall would | ||
1938 | leave this traffic alone). However, as somehow for IPv6 the | ||
1939 | traffic is not recognized as originating from the local | ||
1940 | system (and as the connection is not already "established"), | ||
1941 | the firewall drops the traffic. You should still get ICMPv6 | ||
1942 | packets back, but that's obviously not very useful. | ||
1943 | |||
1944 | Possible ways to fix this include disabling the firewall (do you | ||
1945 | have a good reason for having it on?) or disabling the firewall | ||
1946 | at least for the GNUnet exit interface (or the respective | ||
1947 | IPv4/IPv6 address range). The best way to diagnose these kinds | ||
1948 | of problems in general involves setting the firewall to REJECT | ||
1949 | instead of DROP and to watch the traffic using wireshark | ||
1950 | (or tcpdump) to see if ICMP messages are generated when running | ||
1951 | some tests that should work. | ||
1952 | |||
1953 | @node Setting up VPN node for protocol translation and tunneling | ||
1954 | @subsection Setting up VPN node for protocol translation and tunneling | ||
1955 | |||
1956 | |||
1957 | The GNUnet VPN/PT subsystem enables you to tunnel IP traffic over the | ||
1958 | VPN to an exit node, from where it can then be forwarded to the | ||
1959 | Internet. This section documents how to setup VPN/PT on a node. | ||
1960 | Note that you can enable both the VPN and an exit on the same peer. | ||
1961 | In this case, IP traffic from your system may enter your peer's VPN | ||
1962 | and leave your peer's exit. This can be useful as a means to do | ||
1963 | protocol translation. For example, you might have an application that | ||
1964 | supports only IPv4 but needs to access an IPv6-only site. In this case, | ||
1965 | GNUnet would perform 4to6 protocol translation between the VPN (IPv4) | ||
1966 | and the Exit (IPv6). Similarly, 6to4 protocol translation is also | ||
1967 | possible. However, the primary use for GNUnet would be to access | ||
1968 | an Internet service running with an IP version that is not supported | ||
1969 | by your ISP. In this case, your IP traffic would be routed via GNUnet | ||
1970 | to a peer that has access to the Internet with the desired IP version. | ||
1971 | |||
1972 | Setting up an entry node into the GNUnet VPN primarily requires you | ||
1973 | to enable the "VPN/PT" option in "gnunet-setup". This will launch the | ||
1974 | "gnunet-service-vpn", "gnunet-service-dns" and "gnunet-daemon-pt" | ||
1975 | processes. The "gnunet-service-vpn" will create a virtual interface | ||
1976 | which will be used as the target for your IP traffic that enters the | ||
1977 | VPN. Additionally, a second virtual interface will be created by | ||
1978 | the "gnunet-service-dns" for your DNS traffic. You will then need to | ||
1979 | specify which traffic you want to tunnel over GNUnet. If your ISP only | ||
1980 | provides you with IPv4 or IPv6-access, you may choose to tunnel the | ||
1981 | other IP protocol over the GNUnet VPN. If you do not have an ISP | ||
1982 | (and are connected to other GNUnet peers via WLAN), you can also | ||
1983 | choose to tunnel all IP traffic over GNUnet. This might also provide | ||
1984 | you with some anonymity. After you enable the respective options | ||
1985 | and restart your peer, your Internet traffic should be tunneled | ||
1986 | over the GNUnet VPN. | ||
1987 | |||
1988 | The GNUnet VPN uses DNS-ALG to hijack your IP traffic. Whenever an | ||
1989 | application resolves a hostname (i.e. 'gnunet.org'), the | ||
1990 | "gnunet-daemon-pt" will instruct the "gnunet-service-dns" to intercept | ||
1991 | the request (possibly route it over GNUnet as well) and replace the | ||
1992 | normal answer with an IP in the range of the VPN's interface. | ||
1993 | "gnunet-daemon-pt" will then tell "gnunet-service-vpn" to forward all | ||
1994 | traffic it receives on the TUN interface via the VPN to the original | ||
1995 | destination. | ||
1996 | |||
1997 | For applications that do not use DNS, you can also manually create | ||
1998 | such a mapping using the gnunet-vpn command-line tool. Here, you | ||
1999 | specfiy the desired address family of the result (i.e. "-4"), and the | ||
2000 | intended target IP on the Internet ("-i 131.159.74.67") and | ||
2001 | "gnunet-vpn" will tell you which IP address in the range of your | ||
2002 | VPN tunnel was mapped. | ||
2003 | |||
2004 | @command{gnunet-vpn} can also be used to access "internal" services | ||
2005 | offered by GNUnet nodes. So if you happen to know a peer and a | ||
2006 | service offered by that peer, you can create an IP tunnel to | ||
2007 | that peer by specifying the peer's identity, service name and | ||
2008 | protocol (--tcp or --udp) and you will again receive an IP address | ||
2009 | that will terminate at the respective peer's service. | ||
diff --git a/doc/documentation/chapters/vocabulary.texi b/doc/documentation/chapters/vocabulary.texi new file mode 100644 index 000000000..9621cb174 --- /dev/null +++ b/doc/documentation/chapters/vocabulary.texi | |||
@@ -0,0 +1,57 @@ | |||
1 | @node Vocabulary | ||
2 | @chapter Vocabulary | ||
3 | |||
4 | @menu | ||
5 | * Words and characters:: | ||
6 | * Technical Assumptions:: | ||
7 | @end menu | ||
8 | |||
9 | @node Words and characters | ||
10 | @section Words and characters | ||
11 | |||
12 | Throughout this document we use certain words and characters. | ||
13 | |||
14 | @enumerate | ||
15 | @item | ||
16 | In chapter Installation Handbook, | ||
17 | ``@command{#}'' in example code blocks describes commands executed as root | ||
18 | |||
19 | @example | ||
20 | # echo "I am root" | ||
21 | I am root | ||
22 | @end example | ||
23 | |||
24 | @item | ||
25 | However, in the chapter GNUnet C Tutorial | ||
26 | ``@command{#}'' in example code blocks describes commands, ie comments. | ||
27 | |||
28 | @example | ||
29 | # Do the foobar thing: | ||
30 | $ make foobar | ||
31 | @end example | ||
32 | |||
33 | @item | ||
34 | Dollarsign ``@command{$}'' in example code blocks describes commands you | ||
35 | execute as unprivileged users. | ||
36 | |||
37 | @example | ||
38 | $ cd foo; ./configure --example-switch | ||
39 | @end example | ||
40 | |||
41 | @item | ||
42 | Backslash ``@command{\}'' describes linebreaks. | ||
43 | |||
44 | @example | ||
45 | ./configure --foo --bar --baz \ | ||
46 | --short-loop | ||
47 | @end example | ||
48 | |||
49 | ...expands to @code{./configure --foo --bar --baz --short-loop} | ||
50 | |||
51 | @end enumerate | ||
52 | |||
53 | @node Technical Assumptions | ||
54 | @section Technical Assumptions | ||
55 | |||
56 | @c Is it really assuming Bash (ie Bash extensions of POSIX being used)? | ||
57 | The shell on GNU systems is assumed to be Bash. | ||
diff --git a/doc/documentation/docstyle.css b/doc/documentation/docstyle.css new file mode 100644 index 000000000..8719248d0 --- /dev/null +++ b/doc/documentation/docstyle.css | |||
@@ -0,0 +1,76 @@ | |||
1 | html, body { | ||
2 | font-size: 1em; | ||
3 | text-align: left; | ||
4 | text-decoration: none; | ||
5 | } | ||
6 | html { background-color: #e7e7e7; } | ||
7 | |||
8 | body { | ||
9 | max-width: 74.92em; | ||
10 | margin: 0 auto; | ||
11 | padding: .5em 1em 1em 1em; | ||
12 | background-color: white; | ||
13 | border: .1em solid #c0c0c0; | ||
14 | } | ||
15 | |||
16 | h1, h2, h3, h4 { color: #333; } | ||
17 | h5, h6, dt { color: #222; } | ||
18 | |||
19 | |||
20 | a h3 { | ||
21 | color: #005090; | ||
22 | } | ||
23 | |||
24 | a[href] { color: #005090; } | ||
25 | a[href]:visited { color: #100070; } | ||
26 | a[href]:active, a[href]:hover { | ||
27 | color: #100070; | ||
28 | text-decoration: none; | ||
29 | } | ||
30 | |||
31 | .linkrow { | ||
32 | margin: 3em 0; | ||
33 | } | ||
34 | |||
35 | .linkrow { | ||
36 | text-align: center; | ||
37 | } | ||
38 | |||
39 | div.example { padding: .8em 1.2em .4em; } | ||
40 | pre.example { padding: .8em 1.2em; } | ||
41 | div.example, pre.example { | ||
42 | margin: 1em 0 1em 3% ; | ||
43 | -webkit-border-radius: .3em; | ||
44 | -moz-border-radius: .3em; | ||
45 | border-radius: .3em; | ||
46 | border: 1px solid #d4cbb6; | ||
47 | background-color: #f2efe4; | ||
48 | } | ||
49 | div.example > pre.example { | ||
50 | padding: 0 0 .4em; | ||
51 | margin: 0; | ||
52 | border: none; | ||
53 | } | ||
54 | |||
55 | |||
56 | /* This makes the very long tables of contents in Gnulib and other | ||
57 | manuals easier to read. */ | ||
58 | .contents ul, .shortcontents ul { font-weight: bold; } | ||
59 | .contents ul ul, .shortcontents ul ul { font-weight: normal; } | ||
60 | .contents ul { list-style: none; } | ||
61 | |||
62 | /* For colored navigation bars (Emacs manual): make the bar extend | ||
63 | across the whole width of the page and give it a decent height. */ | ||
64 | .header, .node { margin: 0 -1em; padding: 0 1em; } | ||
65 | .header p, .node p { line-height: 2em; } | ||
66 | |||
67 | /* For navigation links */ | ||
68 | .node a, .header a { display: inline-block; line-height: 2em; } | ||
69 | .node a:hover, .header a:hover { background: #f2efe4; } | ||
70 | |||
71 | table.cartouche { | ||
72 | border-collapse: collapse; | ||
73 | border-color: darkred; | ||
74 | border-style: solid; | ||
75 | border-width: 3px; | ||
76 | } | ||
diff --git a/doc/fdl-1.3.texi b/doc/documentation/fdl-1.3.texi index cb71f05a1..cb71f05a1 100644 --- a/doc/fdl-1.3.texi +++ b/doc/documentation/fdl-1.3.texi | |||
diff --git a/doc/documentation/gendocs.sh b/doc/documentation/gendocs.sh new file mode 100755 index 000000000..3b71b36a2 --- /dev/null +++ b/doc/documentation/gendocs.sh | |||
@@ -0,0 +1,504 @@ | |||
1 | #!/bin/sh -e | ||
2 | # gendocs.sh -- generate a GNU manual in many formats. This script is | ||
3 | # mentioned in maintain.texi. See the help message below for usage details. | ||
4 | |||
5 | scriptversion=2016-12-31.18 | ||
6 | |||
7 | # Copyright 2003-2017 Free Software Foundation, Inc. | ||
8 | # | ||
9 | # This program is free software: you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License as published by | ||
11 | # the Free Software Foundation; either version 3 of the License, or | ||
12 | # (at your option) any later version. | ||
13 | # | ||
14 | # This program is distributed in the hope that it will be useful, | ||
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | # GNU General Public License for more details. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License | ||
20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | # | ||
22 | # Original author: Mohit Agarwal. | ||
23 | # Send bug reports and any other correspondence to bug-gnulib@gnu.org. | ||
24 | # | ||
25 | # The latest version of this script, and the companion template, is | ||
26 | # available from the Gnulib repository: | ||
27 | # | ||
28 | # http://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/gendocs.sh | ||
29 | # http://git.savannah.gnu.org/cgit/gnulib.git/tree/doc/gendocs_template | ||
30 | |||
31 | # TODO: | ||
32 | # - image importing was only implemented for HTML generated by | ||
33 | # makeinfo. But it should be simple enough to adjust. | ||
34 | # - images are not imported in the source tarball. All the needed | ||
35 | # formats (PDF, PNG, etc.) should be included. | ||
36 | |||
37 | prog=`basename "$0"` | ||
38 | srcdir=`pwd` | ||
39 | |||
40 | scripturl="http://git.savannah.gnu.org/cgit/gnulib.git/plain/build-aux/gendocs.sh" | ||
41 | templateurl="http://git.savannah.gnu.org/cgit/gnulib.git/plain/doc/gendocs_template" | ||
42 | |||
43 | : ${SETLANG="env LANG= LC_MESSAGES= LC_ALL= LANGUAGE="} | ||
44 | : ${MAKEINFO="makeinfo"} | ||
45 | : ${TEXI2DVI="texi2dvi"} | ||
46 | : ${DOCBOOK2HTML="docbook2html"} | ||
47 | : ${DOCBOOK2PDF="docbook2pdf"} | ||
48 | : ${DOCBOOK2TXT="docbook2txt"} | ||
49 | : ${GENDOCS_TEMPLATE_DIR="."} | ||
50 | : ${PERL='perl'} | ||
51 | : ${TEXI2HTML="texi2html"} | ||
52 | unset CDPATH | ||
53 | unset use_texi2html | ||
54 | |||
55 | MANUAL_TITLE= | ||
56 | PACKAGE= | ||
57 | EMAIL=webmasters@gnu.org # please override with --email | ||
58 | commonarg= # passed to all makeinfo/texi2html invcations. | ||
59 | dirargs= # passed to all tools (-I dir). | ||
60 | dirs= # -I directories. | ||
61 | htmlarg="--css-ref=/software/gnulib/manual.css -c TOP_NODE_UP_URL=/manual" | ||
62 | infoarg=--no-split | ||
63 | generate_ascii=true | ||
64 | generate_html=true | ||
65 | generate_info=true | ||
66 | generate_tex=true | ||
67 | outdir=manual | ||
68 | source_extra= | ||
69 | split=node | ||
70 | srcfile= | ||
71 | texarg="-t @finalout" | ||
72 | |||
73 | version="gendocs.sh $scriptversion | ||
74 | |||
75 | Copyright 2017 Free Software Foundation, Inc. | ||
76 | There is NO warranty. You may redistribute this software | ||
77 | under the terms of the GNU General Public License. | ||
78 | For more information about these matters, see the files named COPYING." | ||
79 | |||
80 | usage="Usage: $prog [OPTION]... PACKAGE MANUAL-TITLE | ||
81 | |||
82 | Generate output in various formats from PACKAGE.texinfo (or .texi or | ||
83 | .txi) source. See the GNU Maintainers document for a more extensive | ||
84 | discussion: | ||
85 | http://www.gnu.org/prep/maintain_toc.html | ||
86 | |||
87 | Options: | ||
88 | --email ADR use ADR as contact in generated web pages; always give this. | ||
89 | |||
90 | -s SRCFILE read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi} | ||
91 | -o OUTDIR write files into OUTDIR, instead of manual/. | ||
92 | -I DIR append DIR to the Texinfo search path. | ||
93 | --common ARG pass ARG in all invocations. | ||
94 | --html ARG pass ARG to makeinfo or texi2html for HTML targets, | ||
95 | instead of '$htmlarg'. | ||
96 | --info ARG pass ARG to makeinfo for Info, instead of --no-split. | ||
97 | --no-ascii skip generating the plain text output. | ||
98 | --no-html skip generating the html output. | ||
99 | --no-info skip generating the info output. | ||
100 | --no-tex skip generating the dvi and pdf output. | ||
101 | --source ARG include ARG in tar archive of sources. | ||
102 | --split HOW make split HTML by node, section, chapter; default node. | ||
103 | --tex ARG pass ARG to texi2dvi for DVI and PDF, instead of -t @finalout. | ||
104 | |||
105 | --texi2html use texi2html to make HTML target, with all split versions. | ||
106 | --docbook convert through DocBook too (xml, txt, html, pdf). | ||
107 | |||
108 | --help display this help and exit successfully. | ||
109 | --version display version information and exit successfully. | ||
110 | |||
111 | Simple example: $prog --email bug-gnu-emacs@gnu.org emacs \"GNU Emacs Manual\" | ||
112 | |||
113 | Typical sequence: | ||
114 | cd PACKAGESOURCE/doc | ||
115 | wget \"$scripturl\" | ||
116 | wget \"$templateurl\" | ||
117 | $prog --email BUGLIST MANUAL \"GNU MANUAL - One-line description\" | ||
118 | |||
119 | Output will be in a new subdirectory \"manual\" (by default; | ||
120 | use -o OUTDIR to override). Move all the new files into your web CVS | ||
121 | tree, as explained in the Web Pages node of maintain.texi. | ||
122 | |||
123 | Please use the --email ADDRESS option so your own bug-reporting | ||
124 | address will be used in the generated HTML pages. | ||
125 | |||
126 | MANUAL-TITLE is included as part of the HTML <title> of the overall | ||
127 | manual/index.html file. It should include the name of the package being | ||
128 | documented. manual/index.html is created by substitution from the file | ||
129 | $GENDOCS_TEMPLATE_DIR/gendocs_template. (Feel free to modify the | ||
130 | generic template for your own purposes.) | ||
131 | |||
132 | If you have several manuals, you'll need to run this script several | ||
133 | times with different MANUAL values, specifying a different output | ||
134 | directory with -o each time. Then write (by hand) an overall index.html | ||
135 | with links to them all. | ||
136 | |||
137 | If a manual's Texinfo sources are spread across several directories, | ||
138 | first copy or symlink all Texinfo sources into a single directory. | ||
139 | (Part of the script's work is to make a tar.gz of the sources.) | ||
140 | |||
141 | As implied above, by default monolithic Info files are generated. | ||
142 | If you want split Info, or other Info options, use --info to override. | ||
143 | |||
144 | You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML, | ||
145 | and PERL to control the programs that get executed, and | ||
146 | GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is | ||
147 | looked for. With --docbook, the environment variables DOCBOOK2HTML, | ||
148 | DOCBOOK2PDF, and DOCBOOK2TXT are also consulted. | ||
149 | |||
150 | By default, makeinfo and texi2dvi are run in the default (English) | ||
151 | locale, since that's the language of most Texinfo manuals. If you | ||
152 | happen to have a non-English manual and non-English web site, see the | ||
153 | SETLANG setting in the source. | ||
154 | |||
155 | Email bug reports or enhancement requests to bug-gnulib@gnu.org. | ||
156 | " | ||
157 | |||
158 | while test $# -gt 0; do | ||
159 | case $1 in | ||
160 | -s) shift; srcfile=$1;; | ||
161 | -o) shift; outdir=$1;; | ||
162 | -I) shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";; | ||
163 | --common) shift; commonarg=$1;; | ||
164 | --docbook) docbook=yes;; | ||
165 | --email) shift; EMAIL=$1;; | ||
166 | --html) shift; htmlarg=$1;; | ||
167 | --info) shift; infoarg=$1;; | ||
168 | --no-ascii) generate_ascii=false;; | ||
169 | --no-html) generate_ascii=false;; | ||
170 | --no-info) generate_info=false;; | ||
171 | --no-tex) generate_tex=false;; | ||
172 | --source) shift; source_extra=$1;; | ||
173 | --split) shift; split=$1;; | ||
174 | --tex) shift; texarg=$1;; | ||
175 | --texi2html) use_texi2html=1;; | ||
176 | |||
177 | --help) echo "$usage"; exit 0;; | ||
178 | --version) echo "$version"; exit 0;; | ||
179 | -*) | ||
180 | echo "$0: Unknown option \`$1'." >&2 | ||
181 | echo "$0: Try \`--help' for more information." >&2 | ||
182 | exit 1;; | ||
183 | *) | ||
184 | if test -z "$PACKAGE"; then | ||
185 | PACKAGE=$1 | ||
186 | elif test -z "$MANUAL_TITLE"; then | ||
187 | MANUAL_TITLE=$1 | ||
188 | else | ||
189 | echo "$0: extra non-option argument \`$1'." >&2 | ||
190 | exit 1 | ||
191 | fi;; | ||
192 | esac | ||
193 | shift | ||
194 | done | ||
195 | |||
196 | # makeinfo uses the dirargs, but texi2dvi doesn't. | ||
197 | commonarg=" $dirargs $commonarg" | ||
198 | |||
199 | # For most of the following, the base name is just $PACKAGE | ||
200 | base=$PACKAGE | ||
201 | |||
202 | if test -n "$srcfile"; then | ||
203 | # but here, we use the basename of $srcfile | ||
204 | base=`basename "$srcfile"` | ||
205 | case $base in | ||
206 | *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;; | ||
207 | esac | ||
208 | PACKAGE=$base | ||
209 | elif test -s "$srcdir/$PACKAGE.texinfo"; then | ||
210 | srcfile=$srcdir/$PACKAGE.texinfo | ||
211 | elif test -s "$srcdir/$PACKAGE.texi"; then | ||
212 | srcfile=$srcdir/$PACKAGE.texi | ||
213 | elif test -s "$srcdir/$PACKAGE.txi"; then | ||
214 | srcfile=$srcdir/$PACKAGE.txi | ||
215 | else | ||
216 | echo "$0: cannot find .texinfo or .texi or .txi for $PACKAGE in $srcdir." >&2 | ||
217 | exit 1 | ||
218 | fi | ||
219 | |||
220 | if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then | ||
221 | echo "$0: cannot read $GENDOCS_TEMPLATE_DIR/gendocs_template." >&2 | ||
222 | echo "$0: it is available from $templateurl." >&2 | ||
223 | exit 1 | ||
224 | fi | ||
225 | |||
226 | # Function to return size of $1 in something resembling kilobytes. | ||
227 | calcsize() | ||
228 | { | ||
229 | size=`ls -ksl $1 | awk '{print $1}'` | ||
230 | echo $size | ||
231 | } | ||
232 | |||
233 | # copy_images OUTDIR HTML-FILE... | ||
234 | # ------------------------------- | ||
235 | # Copy all the images needed by the HTML-FILEs into OUTDIR. | ||
236 | # Look for them in . and the -I directories; this is simpler than what | ||
237 | # makeinfo supports with -I, but hopefully it will suffice. | ||
238 | copy_images() | ||
239 | { | ||
240 | local odir | ||
241 | odir=$1 | ||
242 | shift | ||
243 | $PERL -n -e " | ||
244 | BEGIN { | ||
245 | \$me = '$prog'; | ||
246 | \$odir = '$odir'; | ||
247 | @dirs = qw(. $dirs); | ||
248 | } | ||
249 | " -e ' | ||
250 | /<img src="(.*?)"/g && ++$need{$1}; | ||
251 | |||
252 | END { | ||
253 | #print "$me: @{[keys %need]}\n"; # for debugging, show images found. | ||
254 | FILE: for my $f (keys %need) { | ||
255 | for my $d (@dirs) { | ||
256 | if (-f "$d/$f") { | ||
257 | use File::Basename; | ||
258 | my $dest = dirname ("$odir/$f"); | ||
259 | # | ||
260 | use File::Path; | ||
261 | -d $dest || mkpath ($dest) | ||
262 | || die "$me: cannot mkdir $dest: $!\n"; | ||
263 | # | ||
264 | use File::Copy; | ||
265 | copy ("$d/$f", $dest) | ||
266 | || die "$me: cannot copy $d/$f to $dest: $!\n"; | ||
267 | next FILE; | ||
268 | } | ||
269 | } | ||
270 | die "$me: $ARGV: cannot find image $f\n"; | ||
271 | } | ||
272 | } | ||
273 | ' -- "$@" || exit 1 | ||
274 | } | ||
275 | |||
276 | case $outdir in | ||
277 | /*) abs_outdir=$outdir;; | ||
278 | *) abs_outdir=$srcdir/$outdir;; | ||
279 | esac | ||
280 | |||
281 | echo "Making output for $srcfile" | ||
282 | echo " in `pwd`" | ||
283 | mkdir -p "$outdir/" | ||
284 | |||
285 | # | ||
286 | if $generate_info; then | ||
287 | cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\"" | ||
288 | echo "Generating info... ($cmd)" | ||
289 | rm -f $PACKAGE.info* # get rid of any strays | ||
290 | eval "$cmd" | ||
291 | tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info* | ||
292 | ls -l "$outdir/$PACKAGE.info.tar.gz" | ||
293 | info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"` | ||
294 | # do not mv the info files, there's no point in having them available | ||
295 | # separately on the web. | ||
296 | fi # end info | ||
297 | |||
298 | # | ||
299 | if $generate_tex; then | ||
300 | cmd="$SETLANG $TEXI2DVI $dirargs $texarg \"$srcfile\"" | ||
301 | printf "\nGenerating dvi... ($cmd)\n" | ||
302 | eval "$cmd" | ||
303 | # compress/finish dvi: | ||
304 | gzip -f -9 $PACKAGE.dvi | ||
305 | dvi_gz_size=`calcsize $PACKAGE.dvi.gz` | ||
306 | mv $PACKAGE.dvi.gz "$outdir/" | ||
307 | ls -l "$outdir/$PACKAGE.dvi.gz" | ||
308 | |||
309 | cmd="$SETLANG $TEXI2DVI --pdf $dirargs $texarg \"$srcfile\"" | ||
310 | printf "\nGenerating pdf... ($cmd)\n" | ||
311 | eval "$cmd" | ||
312 | pdf_size=`calcsize $PACKAGE.pdf` | ||
313 | mv $PACKAGE.pdf "$outdir/" | ||
314 | ls -l "$outdir/$PACKAGE.pdf" | ||
315 | fi # end tex (dvi + pdf) | ||
316 | |||
317 | # | ||
318 | if $generate_ascii; then | ||
319 | opt="-o $PACKAGE.txt --no-split --no-headers $commonarg" | ||
320 | cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" | ||
321 | printf "\nGenerating ascii... ($cmd)\n" | ||
322 | eval "$cmd" | ||
323 | ascii_size=`calcsize $PACKAGE.txt` | ||
324 | gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz" | ||
325 | ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"` | ||
326 | mv $PACKAGE.txt "$outdir/" | ||
327 | ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz" | ||
328 | fi | ||
329 | |||
330 | # | ||
331 | |||
332 | if $generate_html; then | ||
333 | # Split HTML at level $1. Used for texi2html. | ||
334 | html_split() | ||
335 | { | ||
336 | opt="--split=$1 --node-files $commonarg $htmlarg" | ||
337 | cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\"" | ||
338 | printf "\nGenerating html by $1... ($cmd)\n" | ||
339 | eval "$cmd" | ||
340 | split_html_dir=$PACKAGE.html | ||
341 | ( | ||
342 | cd ${split_html_dir} || exit 1 | ||
343 | ln -sf ${PACKAGE}.html index.html | ||
344 | tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html | ||
345 | ) | ||
346 | eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"` | ||
347 | rm -f "$outdir"/html_$1/*.html | ||
348 | mkdir -p "$outdir/html_$1/" | ||
349 | mv ${split_html_dir}/*.html "$outdir/html_$1/" | ||
350 | rmdir ${split_html_dir} | ||
351 | } | ||
352 | |||
353 | if test -z "$use_texi2html"; then | ||
354 | opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg" | ||
355 | cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" | ||
356 | printf "\nGenerating monolithic html... ($cmd)\n" | ||
357 | rm -rf $PACKAGE.html # in case a directory is left over | ||
358 | eval "$cmd" | ||
359 | html_mono_size=`calcsize $PACKAGE.html` | ||
360 | gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" | ||
361 | html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` | ||
362 | copy_images "$outdir/" $PACKAGE.html | ||
363 | mv $PACKAGE.html "$outdir/" | ||
364 | ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz" | ||
365 | |||
366 | # Before Texinfo 5.0, makeinfo did not accept a --split=HOW option, | ||
367 | # it just always split by node. So if we're splitting by node anyway, | ||
368 | # leave it out. | ||
369 | if test "x$split" = xnode; then | ||
370 | split_arg= | ||
371 | else | ||
372 | split_arg=--split=$split | ||
373 | fi | ||
374 | # | ||
375 | opt="--html -o $PACKAGE.html $split_arg $commonarg $htmlarg" | ||
376 | cmd="$SETLANG $MAKEINFO $opt \"$srcfile\"" | ||
377 | printf "\nGenerating html by $split... ($cmd)\n" | ||
378 | eval "$cmd" | ||
379 | split_html_dir=$PACKAGE.html | ||
380 | copy_images $split_html_dir/ $split_html_dir/*.html | ||
381 | ( | ||
382 | cd $split_html_dir || exit 1 | ||
383 | tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- * | ||
384 | ) | ||
385 | eval \ | ||
386 | html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"` | ||
387 | rm -rf "$outdir/html_$split/" | ||
388 | mv $split_html_dir "$outdir/html_$split/" | ||
389 | du -s "$outdir/html_$split/" | ||
390 | ls -l "$outdir/$PACKAGE.html_$split.tar.gz" | ||
391 | |||
392 | else # use texi2html: | ||
393 | opt="--output $PACKAGE.html $commonarg $htmlarg" | ||
394 | cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\"" | ||
395 | printf "\nGenerating monolithic html with texi2html... ($cmd)\n" | ||
396 | rm -rf $PACKAGE.html # in case a directory is left over | ||
397 | eval "$cmd" | ||
398 | html_mono_size=`calcsize $PACKAGE.html` | ||
399 | gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" | ||
400 | html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` | ||
401 | mv $PACKAGE.html "$outdir/" | ||
402 | |||
403 | html_split node | ||
404 | html_split chapter | ||
405 | html_split section | ||
406 | fi | ||
407 | fi # end html | ||
408 | |||
409 | # | ||
410 | printf "\nMaking .tar.gz for sources...\n" | ||
411 | d=`dirname $srcfile` | ||
412 | ( | ||
413 | cd "$d" | ||
414 | srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || true | ||
415 | tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles | ||
416 | ls -l "$abs_outdir/$PACKAGE.texi.tar.gz" | ||
417 | ) | ||
418 | texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"` | ||
419 | |||
420 | # | ||
421 | # Do everything again through docbook. | ||
422 | if test -n "$docbook"; then | ||
423 | opt="-o - --docbook $commonarg" | ||
424 | cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml" | ||
425 | printf "\nGenerating docbook XML... ($cmd)\n" | ||
426 | eval "$cmd" | ||
427 | docbook_xml_size=`calcsize $PACKAGE-db.xml` | ||
428 | gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz" | ||
429 | docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"` | ||
430 | mv $PACKAGE-db.xml "$outdir/" | ||
431 | |||
432 | split_html_db_dir=html_node_db | ||
433 | opt="$commonarg -o $split_html_db_dir" | ||
434 | cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\"" | ||
435 | printf "\nGenerating docbook HTML... ($cmd)\n" | ||
436 | eval "$cmd" | ||
437 | ( | ||
438 | cd ${split_html_db_dir} || exit 1 | ||
439 | tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html | ||
440 | ) | ||
441 | html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"` | ||
442 | rm -f "$outdir"/html_node_db/*.html | ||
443 | mkdir -p "$outdir/html_node_db" | ||
444 | mv ${split_html_db_dir}/*.html "$outdir/html_node_db/" | ||
445 | rmdir ${split_html_db_dir} | ||
446 | |||
447 | cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\"" | ||
448 | printf "\nGenerating docbook ASCII... ($cmd)\n" | ||
449 | eval "$cmd" | ||
450 | docbook_ascii_size=`calcsize $PACKAGE-db.txt` | ||
451 | mv $PACKAGE-db.txt "$outdir/" | ||
452 | |||
453 | cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\"" | ||
454 | printf "\nGenerating docbook PDF... ($cmd)\n" | ||
455 | eval "$cmd" | ||
456 | docbook_pdf_size=`calcsize $PACKAGE-db.pdf` | ||
457 | mv $PACKAGE-db.pdf "$outdir/" | ||
458 | fi | ||
459 | |||
460 | # | ||
461 | printf "\nMaking index.html for $PACKAGE...\n" | ||
462 | if test -z "$use_texi2html"; then | ||
463 | CONDS="/%%IF *HTML_SECTION%%/,/%%ENDIF *HTML_SECTION%%/d;\ | ||
464 | /%%IF *HTML_CHAPTER%%/,/%%ENDIF *HTML_CHAPTER%%/d" | ||
465 | else | ||
466 | # should take account of --split here. | ||
467 | CONDS="/%%ENDIF.*%%/d;/%%IF *HTML_SECTION%%/d;/%%IF *HTML_CHAPTER%%/d" | ||
468 | fi | ||
469 | |||
470 | curdate=`$SETLANG date '+%B %d, %Y'` | ||
471 | sed \ | ||
472 | -e "s!%%TITLE%%!$MANUAL_TITLE!g" \ | ||
473 | -e "s!%%EMAIL%%!$EMAIL!g" \ | ||
474 | -e "s!%%PACKAGE%%!$PACKAGE!g" \ | ||
475 | -e "s!%%DATE%%!$curdate!g" \ | ||
476 | -e "s!%%HTML_MONO_SIZE%%!$html_mono_size!g" \ | ||
477 | -e "s!%%HTML_MONO_GZ_SIZE%%!$html_mono_gz_size!g" \ | ||
478 | -e "s!%%HTML_NODE_TGZ_SIZE%%!$html_node_tgz_size!g" \ | ||
479 | -e "s!%%HTML_SECTION_TGZ_SIZE%%!$html_section_tgz_size!g" \ | ||
480 | -e "s!%%HTML_CHAPTER_TGZ_SIZE%%!$html_chapter_tgz_size!g" \ | ||
481 | -e "s!%%INFO_TGZ_SIZE%%!$info_tgz_size!g" \ | ||
482 | -e "s!%%DVI_GZ_SIZE%%!$dvi_gz_size!g" \ | ||
483 | -e "s!%%PDF_SIZE%%!$pdf_size!g" \ | ||
484 | -e "s!%%ASCII_SIZE%%!$ascii_size!g" \ | ||
485 | -e "s!%%ASCII_GZ_SIZE%%!$ascii_gz_size!g" \ | ||
486 | -e "s!%%TEXI_TGZ_SIZE%%!$texi_tgz_size!g" \ | ||
487 | -e "s!%%DOCBOOK_HTML_NODE_TGZ_SIZE%%!$html_node_db_tgz_size!g" \ | ||
488 | -e "s!%%DOCBOOK_ASCII_SIZE%%!$docbook_ascii_size!g" \ | ||
489 | -e "s!%%DOCBOOK_PDF_SIZE%%!$docbook_pdf_size!g" \ | ||
490 | -e "s!%%DOCBOOK_XML_SIZE%%!$docbook_xml_size!g" \ | ||
491 | -e "s!%%DOCBOOK_XML_GZ_SIZE%%!$docbook_xml_gz_size!g" \ | ||
492 | -e "s,%%SCRIPTURL%%,$scripturl,g" \ | ||
493 | -e "s!%%SCRIPTNAME%%!$prog!g" \ | ||
494 | -e "$CONDS" \ | ||
495 | $GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html" | ||
496 | |||
497 | echo "Done, see $outdir/ subdirectory for new files." | ||
498 | |||
499 | # Local variables: | ||
500 | # eval: (add-hook 'write-file-hooks 'time-stamp) | ||
501 | # time-stamp-start: "scriptversion=" | ||
502 | # time-stamp-format: "%:y-%02m-%02d.%02H" | ||
503 | # time-stamp-end: "$" | ||
504 | # End: | ||
diff --git a/doc/documentation/gendocs_template b/doc/documentation/gendocs_template new file mode 100644 index 000000000..178f6cb4c --- /dev/null +++ b/doc/documentation/gendocs_template | |||
@@ -0,0 +1,91 @@ | |||
1 | <!--#include virtual="/server/header.html" --> | ||
2 | <!-- Parent-Version: 1.77 --> | ||
3 | <title>%%TITLE%% - GNU Project - Free Software Foundation</title> | ||
4 | <!--#include virtual="/server/banner.html" --> | ||
5 | <h2>%%TITLE%%</h2> | ||
6 | |||
7 | <address>Free Software Foundation</address> | ||
8 | <address>last updated %%DATE%%</address> | ||
9 | |||
10 | <p>This manual (%%PACKAGE%%) is available in the following formats:</p> | ||
11 | |||
12 | <ul> | ||
13 | <li><a href="%%PACKAGE%%.html">HTML | ||
14 | (%%HTML_MONO_SIZE%%K bytes)</a> - entirely on one web page.</li> | ||
15 | <li><a href="html_node/index.html">HTML</a> - with one web page per | ||
16 | node.</li> | ||
17 | %%IF HTML_SECTION%% | ||
18 | <li><a href="html_section/index.html">HTML</a> - with one web page per | ||
19 | section.</li> | ||
20 | %%ENDIF HTML_SECTION%% | ||
21 | %%IF HTML_CHAPTER%% | ||
22 | <li><a href="html_chapter/index.html">HTML</a> - with one web page per | ||
23 | chapter.</li> | ||
24 | %%ENDIF HTML_CHAPTER%% | ||
25 | <li><a href="%%PACKAGE%%.html.gz">HTML compressed | ||
26 | (%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on | ||
27 | one web page.</li> | ||
28 | <li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed | ||
29 | (%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> - | ||
30 | with one web page per node.</li> | ||
31 | %%IF HTML_SECTION%% | ||
32 | <li><a href="%%PACKAGE%%.html_section.tar.gz">HTML compressed | ||
33 | (%%HTML_SECTION_TGZ_SIZE%%K gzipped tar file)</a> - | ||
34 | with one web page per section.</li> | ||
35 | %%ENDIF HTML_SECTION%% | ||
36 | %%IF HTML_CHAPTER%% | ||
37 | <li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML compressed | ||
38 | (%%HTML_CHAPTER_TGZ_SIZE%%K gzipped tar file)</a> - | ||
39 | with one web page per chapter.</li> | ||
40 | %%ENDIF HTML_CHAPTER%% | ||
41 | <li><a href="%%PACKAGE%%.info.tar.gz">Info document | ||
42 | (%%INFO_TGZ_SIZE%%K bytes gzipped tar file)</a>.</li> | ||
43 | <li><a href="%%PACKAGE%%.txt">ASCII text | ||
44 | (%%ASCII_SIZE%%K bytes)</a>.</li> | ||
45 | <li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed | ||
46 | (%%ASCII_GZ_SIZE%%K bytes gzipped)</a>.</li> | ||
47 | <li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file | ||
48 | (%%DVI_GZ_SIZE%%K bytes gzipped)</a>.</li> | ||
49 | <li><a href="%%PACKAGE%%.pdf">PDF file | ||
50 | (%%PDF_SIZE%%K bytes)</a>.</li> | ||
51 | <li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source | ||
52 | (%%TEXI_TGZ_SIZE%%K bytes gzipped tar file).</a></li> | ||
53 | </ul> | ||
54 | |||
55 | <p>You can <a href="http://shop.fsf.org/">buy printed copies of | ||
56 | some manuals</a> (among other items) from the Free Software Foundation; | ||
57 | this helps support FSF activities.</p> | ||
58 | |||
59 | <p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%% | ||
60 | script</a>.)</p> | ||
61 | |||
62 | <!-- If needed, change the copyright block at the bottom. In general, | ||
63 | all pages on the GNU web server should have the section about | ||
64 | verbatim copying. Please do NOT remove this without talking | ||
65 | with the webmasters first. | ||
66 | Please make sure the copyright date is consistent with the document | ||
67 | and that it is like this: "2001, 2002", not this: "2001-2002". --> | ||
68 | </div><!-- for id="content", starts in the include above --> | ||
69 | <!--#include virtual="/server/footer.html" --> | ||
70 | <div id="footer"> | ||
71 | <div class="unprintable"> | ||
72 | |||
73 | <p>Please send general FSF & GNU inquiries to | ||
74 | <a href="mailto:gnu@gnu.org"><gnu@gnu.org></a>. | ||
75 | There are also <a href="/contact/">other ways to contact</a> | ||
76 | the FSF. Broken links and other corrections or suggestions can be sent | ||
77 | to <a href="mailto:%%EMAIL%%"><%%EMAIL%%></a>.</p> | ||
78 | </div> | ||
79 | |||
80 | <p>Copyright © 2017 Free Software Foundation, Inc.</p> | ||
81 | |||
82 | <p>This page is licensed under a <a rel="license" | ||
83 | href="http://creativecommons.org/licenses/by-nd/3.0/us/">Creative | ||
84 | Commons Attribution-NoDerivs 3.0 United States License</a>.</p> | ||
85 | |||
86 | <!--#include virtual="/server/bottom-notes.html" --> | ||
87 | |||
88 | </div> | ||
89 | </div> | ||
90 | </body> | ||
91 | </html> | ||
diff --git a/doc/documentation/gendocs_template_min b/doc/documentation/gendocs_template_min new file mode 100644 index 000000000..112fa3bfb --- /dev/null +++ b/doc/documentation/gendocs_template_min | |||
@@ -0,0 +1,93 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | ||
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | ||
5 | |||
6 | <head> | ||
7 | <title>%%TITLE%% - GNU Project - Free Software Foundation</title> | ||
8 | <meta http-equiv="content-type" content='text/html; charset=utf-8' /> | ||
9 | <link rel="stylesheet" type="text/css" href="/gnu.css" /> | ||
10 | </head> | ||
11 | |||
12 | <body> | ||
13 | |||
14 | <h3>%%TITLE%%</h3> | ||
15 | |||
16 | <address>Free Software Foundation</address> | ||
17 | <address>last updated %%DATE%%</address> | ||
18 | <p> | ||
19 | <a href="/graphics/gnu-head.jpg"> | ||
20 | <img src="/graphics/gnu-head-sm.jpg" | ||
21 | alt=" [image of the head of a GNU] " width="129" height="122"/> | ||
22 | </a> | ||
23 | </p> | ||
24 | <hr /> | ||
25 | |||
26 | <p>This manual (%%PACKAGE%%) is available in the following formats:</p> | ||
27 | |||
28 | <ul> | ||
29 | <li><a href="%%PACKAGE%%.html">HTML | ||
30 | (%%HTML_MONO_SIZE%%K bytes)</a> - entirely on one web page.</li> | ||
31 | <li><a href="html_node/index.html">HTML</a> - with one web page per | ||
32 | node.</li> | ||
33 | %%IF HTML_SECTION%% | ||
34 | <li><a href="html_section/index.html">HTML</a> - with one web page per | ||
35 | section.</li> | ||
36 | %%ENDIF HTML_SECTION%% | ||
37 | %%IF HTML_CHAPTER%% | ||
38 | <li><a href="html_chapter/index.html">HTML</a> - with one web page per | ||
39 | chapter.</li> | ||
40 | %%ENDIF HTML_CHAPTER%% | ||
41 | <li><a href="%%PACKAGE%%.html.gz">HTML compressed | ||
42 | (%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on | ||
43 | one web page.</li> | ||
44 | <li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed | ||
45 | (%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> - | ||
46 | with one web page per node.</li> | ||
47 | %%IF HTML_SECTION%% | ||
48 | <li><a href="%%PACKAGE%%.html_section.tar.gz">HTML compressed | ||
49 | (%%HTML_SECTION_TGZ_SIZE%%K gzipped tar file)</a> - | ||
50 | with one web page per section.</li> | ||
51 | %%ENDIF HTML_SECTION%% | ||
52 | %%IF HTML_CHAPTER%% | ||
53 | <li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML compressed | ||
54 | (%%HTML_CHAPTER_TGZ_SIZE%%K gzipped tar file)</a> - | ||
55 | with one web page per chapter.</li> | ||
56 | %%ENDIF HTML_CHAPTER%% | ||
57 | <li><a href="%%PACKAGE%%.info.tar.gz">Info document | ||
58 | (%%INFO_TGZ_SIZE%%K bytes gzipped tar file)</a>.</li> | ||
59 | <li><a href="%%PACKAGE%%.txt">ASCII text | ||
60 | (%%ASCII_SIZE%%K bytes)</a>.</li> | ||
61 | <li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed | ||
62 | (%%ASCII_GZ_SIZE%%K bytes gzipped)</a>.</li> | ||
63 | <li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file | ||
64 | (%%DVI_GZ_SIZE%%K bytes gzipped)</a>.</li> | ||
65 | <li><a href="%%PACKAGE%%.pdf">PDF file | ||
66 | (%%PDF_SIZE%%K bytes)</a>.</li> | ||
67 | <li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source | ||
68 | (%%TEXI_TGZ_SIZE%%K bytes gzipped tar file).</a></li> | ||
69 | </ul> | ||
70 | |||
71 | <p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%% | ||
72 | script</a>.)</p> | ||
73 | |||
74 | <div id="footer" class="copyright"> | ||
75 | |||
76 | <p>Please send general FSF & GNU inquiries to | ||
77 | <a href="mailto:gnu@gnu.org"><gnu@gnu.org></a>. | ||
78 | There are also <a href="/contact/">other ways to contact</a> | ||
79 | the FSF. Broken links and other corrections or suggestions can be sent | ||
80 | to <a href="mailto:%%EMAIL%%"><%%EMAIL%%></a>.</p> | ||
81 | </div> | ||
82 | |||
83 | <p>Copyright © 2017 Free Software Foundation, Inc.</p> | ||
84 | |||
85 | <p>This page is licensed under a <a rel="license" | ||
86 | href="http://creativecommons.org/licenses/by-nd/3.0/us/">Creative | ||
87 | Commons Attribution-NoDerivs 3.0 United States License</a>.</p> | ||
88 | |||
89 | <!--#include virtual="/server/bottom-notes.html" --> | ||
90 | |||
91 | </div> | ||
92 | </body> | ||
93 | </html> | ||
diff --git a/doc/gnunet-c-tutorial.texi b/doc/documentation/gnunet-c-tutorial.texi index 3a4200d7c..aca40d2ef 100644 --- a/doc/gnunet-c-tutorial.texi +++ b/doc/documentation/gnunet-c-tutorial.texi | |||
@@ -3,8 +3,12 @@ | |||
3 | @setfilename gnunet-c-tutorial.info | 3 | @setfilename gnunet-c-tutorial.info |
4 | @documentencoding UTF-8 | 4 | @documentencoding UTF-8 |
5 | @settitle GNUnet C Tutorial | 5 | @settitle GNUnet C Tutorial |
6 | @exampleindent 2 | ||
6 | @c %**end of header | 7 | @c %**end of header |
7 | 8 | ||
9 | @c including 'version.texi' makes makeinfo throw errors. | ||
10 | @include version2.texi | ||
11 | |||
8 | @copying | 12 | @copying |
9 | Copyright @copyright{} 2001-2017 GNUnet e.V. | 13 | Copyright @copyright{} 2001-2017 GNUnet e.V. |
10 | 14 | ||
@@ -27,9 +31,15 @@ A copy of the license is also available from the Free Software | |||
27 | Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. | 31 | Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. |
28 | @end copying | 32 | @end copying |
29 | 33 | ||
34 | @dircategory Tutorial | ||
35 | @direntry | ||
36 | * GNUnet-C-Tutorial: (gnunet-c-tutorial). C Tutorial for GNunet | ||
37 | @end direntry | ||
38 | |||
39 | |||
30 | @titlepage | 40 | @titlepage |
31 | @title GNUnet C Tutorial | 41 | @title GNUnet C Tutorial |
32 | @subtitle A Tutorial for GNUnet 0.10.x (C version) | 42 | @subtitle A Tutorial for GNUnet @value{VERSION} (C version) |
33 | @author The GNUnet Developers | 43 | @author The GNUnet Developers |
34 | 44 | ||
35 | @page | 45 | @page |
@@ -48,10 +58,14 @@ Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. | |||
48 | @node Top | 58 | @node Top |
49 | @top Introduction | 59 | @top Introduction |
50 | 60 | ||
51 | This tutorials explains how to install GNUnet on a GNU/Linux system and gives an introduction on how | 61 | This tutorials explains how to install GNUnet on a |
52 | GNUnet can be used to develop a Peer-to-Peer application. Detailed installation instructions for | 62 | GNU/Linux system and gives an introduction on how |
53 | various operating systems and a detailed list of all dependencies can be found on our website at | 63 | GNUnet can be used to develop a Peer-to-Peer application. |
54 | @uref{https://gnunet.org/installation}. | 64 | Detailed installation instructions for |
65 | various operating systems and a detailed list of all | ||
66 | dependencies can be found on our website at | ||
67 | @uref{https://gnunet.org/installation} and in our | ||
68 | Reference Documentation (GNUnet Handbook). | ||
55 | 69 | ||
56 | Please read this tutorial carefully since every single step is | 70 | Please read this tutorial carefully since every single step is |
57 | important and do not hesitate to contact the GNUnet team if you have | 71 | important and do not hesitate to contact the GNUnet team if you have |
@@ -103,14 +117,15 @@ Developing Applications | |||
103 | @node Installing GNUnet | 117 | @node Installing GNUnet |
104 | @chapter Installing GNUnet | 118 | @chapter Installing GNUnet |
105 | 119 | ||
106 | First of all you have to install a current version of GNUnet. You can download a | 120 | First of all you have to install a current version of GNUnet. |
107 | tarball of a stable version from GNU FTP mirrors or obtain the latest development | 121 | You can download a tarball of a stable version from GNU FTP mirrors |
108 | version from our Git repository. | 122 | or obtain the latest development version from our Git repository. |
109 | 123 | ||
110 | Most of the time you should prefer to download the stable version since with the | 124 | Most of the time you should prefer to download the stable version |
111 | latest development version things can be broken, functionality can be changed or tests | 125 | since with the latest development version things can be broken, |
112 | can fail. You should only use the development version if you know that you require a | 126 | functionality can be changed or tests can fail. You should only use |
113 | certain feature or a certain issue has been fixed since the last release. | 127 | the development version if you know that you require a certain |
128 | feature or a certain issue has been fixed since the last release. | ||
114 | 129 | ||
115 | @menu | 130 | @menu |
116 | * Obtaining a stable version:: | 131 | * Obtaining a stable version:: |
@@ -123,67 +138,90 @@ certain feature or a certain issue has been fixed since the last release. | |||
123 | @node Obtaining a stable version | 138 | @node Obtaining a stable version |
124 | @section Obtaining a stable version | 139 | @section Obtaining a stable version |
125 | 140 | ||
126 | You can download the latest stable version of GNUnet from GNU FTP mirrors: | 141 | Download the tarball from |
127 | @uref{https://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz} | 142 | @indicateurl{https://ftp.gnu.org/gnu/gnunet/gnunet-@value{VERSION}.tar.gz}. |
128 | You should also download the signature file and verify the integrity of the tarball. | 143 | |
129 | @uref{https://ftp.gnu.org/gnu/gnunet/gnunet-0.10.x.tar.gz.sig} | 144 | Make sure to download the associated @file{.sig} file and to verify the |
130 | To verify the signature you should first import the GPG key used to sign the tarball | 145 | authenticity of the tarball against it, like this: |
146 | |||
131 | @example | 147 | @example |
132 | $ gpg --keyserver keys.gnupg.net --recv-keys 48426C7E | 148 | $ wget https://ftp.gnu.org/gnu/gnunet/gnunet-@value{VERSION}.tar.gz.sig |
149 | $ gpg --verify-files gnunet-@value{VERSION}.tar.gz.sig | ||
133 | @end example | 150 | @end example |
134 | And use this key to verify the tarball's signature | 151 | |
152 | @noindent | ||
153 | If this command fails because you do not have the required public key, | ||
154 | then you need to run this command to import it: | ||
155 | |||
135 | @example | 156 | @example |
136 | $ gpg --verify gnunet-0.10.x.tar.gz.sig gnunet-0.10.x.tar.gz | 157 | $ gpg --keyserver keys.gnupg.net --recv-keys 48426C7E |
137 | @end example | 158 | @end example |
138 | After successfully verifying the integrity you can extract the tarball using | 159 | |
160 | @noindent | ||
161 | and rerun the @code{gpg --verify-files} command. | ||
162 | |||
163 | Now you can extract the tarball and rename the resulting | ||
164 | directory to @i{gnunet} which we will be using in the | ||
165 | remainder of this document. | ||
166 | |||
139 | @example | 167 | @example |
140 | $ tar xvzf gnunet-0.10.x.tar.gz | 168 | $ tar xvzf gnunet-@value{VERSION}.tar.gz |
141 | ## we will use the directory "gnunet" in the remainder of this document | 169 | $ mv gnunet-@value{VERSION} gnunet |
142 | $ mv gnunet-0.10.x gnunet | ||
143 | $ cd gnunet | 170 | $ cd gnunet |
144 | @end example | 171 | @end example |
145 | 172 | ||
146 | However, please note that stable versions can be very outdated, as a developer | 173 | @noindent |
147 | you are strongly encouraged to use the version from @uref{https://gnunet.org/git/}. | 174 | However, please note that stable versions can be very outdated. |
175 | As a developer you are @b{strongly} encouraged to use the version | ||
176 | from @uref{https://gnunet.org/git/, git}. | ||
148 | 177 | ||
149 | @node Installing Build Tool Chain and Dependencies | 178 | @node Installing Build Tool Chain and Dependencies |
150 | @section Installing Build Tool Chain and Dependencies | 179 | @section Installing Build Tool Chain and Dependencies |
151 | 180 | ||
152 | To successfully compile GNUnet you need the tools to build GNUnet and the required dependencies. | 181 | To successfully compile GNUnet you need the tools to build GNUnet and |
153 | Please have a look at @uref{https://gnunet.org/dependencies} for a list of required dependencies | 182 | the required dependencies. Please have a look at |
154 | and @uref{https://gnunet.org/generic_installation} for specific instructions for your operating system. | 183 | @uref{https://gnunet.org/dependencies} for a list of required dependencies |
155 | 184 | and @uref{https://gnunet.org/generic_installation} for specific | |
156 | Please check the notes at the end of the configure process about required dependencies. | 185 | instructions for your operating system. Please check the notes at |
186 | the end of the configure process about required dependencies. | ||
157 | 187 | ||
158 | For GNUnet bootstrapping support and the http(s) plugin you should install libgnurl. | 188 | For GNUnet bootstrapping support and the http(s) plugin you should |
159 | For the filesharing service you should install at least one of the datastore backends mysql, | 189 | install @uref{https://gnunet.org/gnurl, libgnurl}. |
160 | sqlite or postgresql. | 190 | For the filesharing service you should install at least one of the |
191 | datastore backends. MySQL, SQlite and PostgreSQL are supported. | ||
161 | 192 | ||
162 | @node Obtaining the latest version from Git | 193 | @node Obtaining the latest version from Git |
163 | @section Obtaining the latest version from Git | 194 | @section Obtaining the latest version from Git |
164 | 195 | ||
165 | The latest development version can obtained from our Git repository. To obtain | 196 | The latest development version can obtained from our Git repository. |
166 | the code you need Git installed and checkout the repository using: | 197 | To obtain the code you need Git installed and checkout the repository |
198 | using: | ||
199 | |||
167 | @example | 200 | @example |
168 | $ git clone https://gnunet.org/git/gnunet | 201 | $ git clone https://gnunet.org/git/gnunet |
169 | @end example | 202 | @end example |
170 | After cloning the repository you have to execute | 203 | |
204 | @noindent | ||
205 | After cloning the repository you have to execute the @file{bootstrap} | ||
206 | script in the directory: | ||
207 | |||
171 | @example | 208 | @example |
172 | $ cd gnunet | 209 | $ cd gnunet ; ./bootstrap |
173 | $ ./bootstrap | ||
174 | @end example | 210 | @end example |
175 | 211 | ||
176 | The remainder of this tutorial assumes that you have Git branch ``master'' checked out. | 212 | @noindent |
213 | The remainder of this tutorial assumes that you have the Git branch | ||
214 | ``master'' checked out. | ||
177 | 215 | ||
178 | @node Compiling and Installing GNUnet | 216 | @node Compiling and Installing GNUnet |
179 | @section Compiling and Installing GNUnet | 217 | @section Compiling and Installing GNUnet |
180 | 218 | ||
181 | First, you need to install at least libgnupgerror version 1.27 | 219 | First, you need to install at least libgnupgerror 1.27 and |
182 | @uref{https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2} | 220 | libgcrypt 1.7.6. |
183 | and libgcrypt version 1.7.6 @uref{https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2}. | ||
184 | 221 | ||
185 | @example | 222 | @example |
186 | $ wget https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2 | 223 | $ export GNUPGFTP="https://www.gnupg.org/ftp/gcrypt" |
224 | $ wget $GNUPGFTP/libgpg-error/libgpg-error-1.27.tar.bz2 | ||
187 | $ tar xf libgpg-error-1.27.tar.bz2 | 225 | $ tar xf libgpg-error-1.27.tar.bz2 |
188 | $ cd libgpg-error-1.27 | 226 | $ cd libgpg-error-1.27 |
189 | $ ./configure | 227 | $ ./configure |
@@ -192,7 +230,8 @@ $ cd .. | |||
192 | @end example | 230 | @end example |
193 | 231 | ||
194 | @example | 232 | @example |
195 | $ wget https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2 | 233 | $ export GNUPGFTP="https://www.gnupg.org/ftp/gcrypt" |
234 | $ wget $GNUPGFTP/libgcrypt/libgcrypt-1.7.6.tar.bz2 | ||
196 | $ tar xf libgcrypt-1.7.6.tar.bz2 | 235 | $ tar xf libgcrypt-1.7.6.tar.bz2 |
197 | $ cd libgcrypt-1.7.6 | 236 | $ cd libgcrypt-1.7.6 |
198 | $ ./configure | 237 | $ ./configure |
@@ -220,10 +259,12 @@ $ make | |||
220 | $ make install | 259 | $ make install |
221 | @end example | 260 | @end example |
222 | 261 | ||
223 | After installing GNUnet you have to add your GNUnet installation to your path | 262 | @noindent |
224 | environmental variable. In addition you have to create the @file{.config} | 263 | After installing GNUnet you have to add your GNUnet installation |
225 | directory in your home directory (unless it already exists) where GNUnet stores | 264 | to your path environmental variable. In addition you have to |
226 | its data and an empty GNUnet configuration file: | 265 | create the @file{.config} directory in your home directory |
266 | (unless it already exists) where GNUnet stores its data and an | ||
267 | empty GNUnet configuration file: | ||
227 | 268 | ||
228 | @example | 269 | @example |
229 | $ export PATH=$PATH:$PREFIX/bin | 270 | $ export PATH=$PATH:$PREFIX/bin |
@@ -238,23 +279,34 @@ $ touch ~/.config/gnunet.conf | |||
238 | You should check your installation to ensure that installing GNUnet | 279 | You should check your installation to ensure that installing GNUnet |
239 | was successful up to this point. You should be able to access GNUnet's | 280 | was successful up to this point. You should be able to access GNUnet's |
240 | binaries and run GNUnet's self check. | 281 | binaries and run GNUnet's self check. |
282 | |||
241 | @example | 283 | @example |
242 | $ which gnunet-arm | 284 | $ which gnunet-arm |
243 | @end example | 285 | @end example |
244 | should return $PREFIX/bin/gnunet-arm. It should be | 286 | |
245 | located in your GNUnet installation and the output should not be | 287 | @noindent |
246 | empty. If you see an output like: | 288 | should return $PREFIX/bin/gnunet-arm. It should be located in your |
289 | GNUnet installation and the output should not be empty. | ||
290 | If you see an output like: | ||
291 | |||
247 | @example | 292 | @example |
248 | $ which gnunet-arm | 293 | $ which gnunet-arm |
249 | @end example | 294 | @end example |
250 | check your PATH variable to ensure GNUnet's @file{bin} directory is included. | 295 | |
296 | @noindent | ||
297 | check your PATH variable to ensure GNUnet's @file{bin} directory is | ||
298 | included. | ||
251 | 299 | ||
252 | GNUnet provides tests for all of its subcomponents. Run | 300 | GNUnet provides tests for all of its subcomponents. Run |
301 | |||
253 | @example | 302 | @example |
254 | $ make check | 303 | $ make check |
255 | @end example | 304 | @end example |
256 | to execute tests for all components. make check traverses all subdirectories in src. | 305 | |
257 | For every subdirectory you should get a message like this: | 306 | @noindent |
307 | to execute tests for all components. @command{make check} traverses all | ||
308 | subdirectories in @file{src}. For every subdirectory you should | ||
309 | get a message like this: | ||
258 | 310 | ||
259 | @example | 311 | @example |
260 | make[2]: Entering directory `/home/$USER/gnunet/contrib' | 312 | make[2]: Entering directory `/home/$USER/gnunet/contrib' |
@@ -269,24 +321,29 @@ PASS: test_gnunet_prefix | |||
269 | 321 | ||
270 | GNUnet is organized in layers and services. Each service is composed of a | 322 | GNUnet is organized in layers and services. Each service is composed of a |
271 | main service implementation and a client library for other programs to use | 323 | main service implementation and a client library for other programs to use |
272 | the service's functionality, described by an API. This approach is shown in | 324 | the service's functionality, described by an API. |
273 | @c** FIXME: enable this once the commented block below works: | 325 | @c This approach is shown in |
274 | @c** figure~\ref{fig:service}. | 326 | @c FIXME: enable this once the commented block below works: |
275 | Some services provide an additional command line tool to enable the user to | 327 | @c figure~\ref fig:service. |
276 | interact with the service. | 328 | Some services provide an additional command line tool to enable the user |
277 | 329 | to interact with the service. | |
278 | Very often it is other GNUnet services that will use these APIs to build the | 330 | |
279 | higher layers of GNUnet on top of the lower ones. Each layer expands or extends | 331 | Very often it is other GNUnet services that will use these APIs to build |
280 | the functionality of the service below (for instance, to build a mesh on top of | 332 | the higher layers of GNUnet on top of the lower ones. Each layer expands |
281 | a DHT). | 333 | or extends the functionality of the service below (for instance, to build |
282 | @c** FXIME: See comment above. | 334 | a mesh on top of a DHT). |
283 | @c** See figure ~\ref{fig:interaction} for an illustration of this approach. | 335 | @c FXIME: See comment above. |
284 | 336 | @c See figure ~\ref fig:interaction for an illustration of this approach. | |
285 | @c ** @image{filename[, width[, height[, alttext[, extension]]]]} | 337 | |
286 | 338 | @c ** @image filename[, width[, height[, alttext[, extension]]]] | |
287 | @image{images/gnunet-tutorial-service,,5in,Service with API and network protocol,.png} | 339 | @c FIXME: Texlive (?) 20112 makes the assumption that this means |
288 | 340 | @c 'images/OBJECTNAME.txt' but later versions of it (2017) use this | |
289 | @image{images/gnunet-tutorial-system,,5in,The layered system architecture of GNUnet,.png} | 341 | @c syntax as described below. |
342 | @c TODO: Checkout the makedoc script Guile uses. | ||
343 | |||
344 | @c FIXME!!! | ||
345 | @c @image{images/gnunet-tutorial-service,,5in,Service with API and network protocol,.png} | ||
346 | @c @image{images/gnunet-tutorial-system,,5in,The layered system architecture of GNUnet,.png} | ||
290 | 347 | ||
291 | @c \begin{figure}[!h] | 348 | @c \begin{figure}[!h] |
292 | @c \begin{center} | 349 | @c \begin{center} |
@@ -308,11 +365,11 @@ a DHT). | |||
308 | @c \caption{GNUnet's layered system architecture} | 365 | @c \caption{GNUnet's layered system architecture} |
309 | @c \end{figure} | 366 | @c \end{figure} |
310 | 367 | ||
311 | The main service implementation runs as a standalone process in the operating | 368 | The main service implementation runs as a standalone process in the |
312 | system and the client code runs as part of the client program, so crashes of a | 369 | operating system and the client code runs as part of the client program, |
313 | client do not affect the service process or other clients. The service and the | 370 | so crashes of a client do not affect the service process or other clients. |
314 | clients communicate via a message protocol to be defined and implemented by | 371 | The service and the clients communicate via a message protocol to be |
315 | the programmer. | 372 | defined and implemented by the programmer. |
316 | 373 | ||
317 | @node First Steps with GNUnet | 374 | @node First Steps with GNUnet |
318 | @chapter First Steps with GNUnet | 375 | @chapter First Steps with GNUnet |
@@ -328,43 +385,51 @@ the programmer. | |||
328 | @node Configure your peer | 385 | @node Configure your peer |
329 | @section Configure your peer | 386 | @section Configure your peer |
330 | 387 | ||
331 | First of all we need to configure your peer. Each peer is started with a configuration | 388 | First of all we need to configure your peer. Each peer is started with |
332 | containing settings for GNUnet itself and its services. This configuration is based on the | 389 | a configuration containing settings for GNUnet itself and its services. |
333 | default configuration shipped with GNUnet and can be modified. The default configuration | 390 | This configuration is based on the default configuration shipped with |
334 | is located in the @file{$PREFIX/share/gnunet/config.d} directory. When starting a peer, you | 391 | GNUnet and can be modified. The default configuration is located in the |
335 | can specify a customized configuration using the the @command{-c} command line switch when | 392 | @file{$PREFIX/share/gnunet/config.d} directory. When starting a peer, you |
336 | starting the ARM service and all other services. When using a modified configuration the | 393 | can specify a customized configuration using the the @command{-c} command |
337 | default values are loaded and only values specified in the configuration file will replace | 394 | line switch when starting the ARM service and all other services. When |
338 | the default values. | 395 | using a modified configuration the default values are loaded and only |
339 | 396 | values specified in the configuration file will replace the default | |
340 | Since we want to start additional peers later, we need some modifications from the default | 397 | values. |
341 | configuration. We need to create a separate service home and a file containing our | 398 | |
342 | modifications for this peer: | 399 | Since we want to start additional peers later, we need some modifications |
400 | from the default configuration. We need to create a separate service | ||
401 | home and a file containing our modifications for this peer: | ||
402 | |||
343 | @example | 403 | @example |
344 | $ mkdir ~/gnunet1/ | 404 | $ mkdir ~/gnunet1/ |
345 | $ touch peer1.conf | 405 | $ touch peer1.conf |
346 | @end example | 406 | @end example |
347 | 407 | ||
348 | Now add the following lines to @file{peer1.conf} to use this directory. For | 408 | @noindent |
349 | simplified usage we want to prevent the peer to connect to the GNUnet | 409 | Now add the following lines to @file{peer1.conf} to use this directory. |
410 | For simplified usage we want to prevent the peer to connect to the GNUnet | ||
350 | network since this could lead to confusing output. This modifications | 411 | network since this could lead to confusing output. This modifications |
351 | will replace the default settings: | 412 | will replace the default settings: |
413 | |||
352 | @example | 414 | @example |
353 | [PATHS] | 415 | [PATHS] |
354 | GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data | 416 | # Use this directory to store GNUnet data |
417 | GNUNET_HOME = ~/gnunet1/ | ||
355 | [hostlist] | 418 | [hostlist] |
356 | SERVERS = # prevent bootstrapping | 419 | # prevent bootstrapping |
420 | SERVERS = | ||
357 | @end example | 421 | @end example |
358 | 422 | ||
359 | @node Start a peer | 423 | @node Start a peer |
360 | @section Start a peer | 424 | @section Start a peer |
361 | Each GNUnet instance (called peer) has an identity (peer ID) based on a | 425 | Each GNUnet instance (called peer) has an identity (peer ID) based on a |
362 | cryptographic public private key pair. The peer ID is the printable hash of the | 426 | cryptographic public private key pair. The peer ID is the printable hash |
363 | public key. | 427 | of the public key. |
364 | 428 | ||
365 | GNUnet services are controlled by a master service, the so called @dfn{Automatic Restart Manager} (ARM). | 429 | GNUnet services are controlled by a master service, the so called |
366 | ARM starts, stops and even restarts services automatically or on demand when a client connects. | 430 | @dfn{Automatic Restart Manager} (ARM). ARM starts, stops and even |
367 | You interact with the ARM service using the gnunet-arm tool. | 431 | restarts services automatically or on demand when a client connects. |
432 | You interact with the ARM service using the @command{gnunet-arm} tool. | ||
368 | GNUnet can then be started with @command{gnunet-arm -s} and stopped with | 433 | GNUnet can then be started with @command{gnunet-arm -s} and stopped with |
369 | @command{gnunet-arm -e}. An additional service not automatically started | 434 | @command{gnunet-arm -e}. An additional service not automatically started |
370 | can be started using @command{gnunet-arm -i <service name>} and stopped | 435 | can be started using @command{gnunet-arm -i <service name>} and stopped |
@@ -372,11 +437,16 @@ using @command{gnunet-arm -k <servicename>}. | |||
372 | 437 | ||
373 | Once you have started your peer, you can use many other GNUnet commands | 438 | Once you have started your peer, you can use many other GNUnet commands |
374 | to interact with it. For example, you can run: | 439 | to interact with it. For example, you can run: |
440 | |||
375 | @example | 441 | @example |
376 | $ gnunet-peerinfo -s | 442 | $ gnunet-peerinfo -s |
377 | @end example | 443 | @end example |
444 | |||
445 | @noindent | ||
378 | to obtain the public key of your peer. | 446 | to obtain the public key of your peer. |
447 | |||
379 | You should see an output containing the peer ID similar to: | 448 | You should see an output containing the peer ID similar to: |
449 | |||
380 | @example | 450 | @example |
381 | I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'. | 451 | I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'. |
382 | @end example | 452 | @end example |
@@ -384,33 +454,45 @@ I am peer `0PA02UVRKQTS2C .. JL5Q78F6H0B1ACPV1CJI59MEQUMQCC5G'. | |||
384 | @node Monitor a peer | 454 | @node Monitor a peer |
385 | @section Monitor a peer | 455 | @section Monitor a peer |
386 | 456 | ||
387 | In this section, we will monitor the behaviour of our peer's DHT service with respect to a | 457 | In this section, we will monitor the behaviour of our peer's DHT |
388 | specific key. First we will start GNUnet and then start the DHT service and use the DHT monitor tool | 458 | service with respect to a specific key. First we will start |
389 | to monitor the PUT and GET commands we issue ussing the @command{gnunet-dht-put} and | 459 | GNUnet and then start the DHT service and use the DHT monitor tool |
390 | @command{gnunet-dht-get} commands. Using the ``monitor'' line given below, you can observe | 460 | to monitor the PUT and GET commands we issue ussing the |
391 | the behavior of your own peer's DHT with respect to the specified KEY: | 461 | @command{gnunet-dht-put} and @command{gnunet-dht-get} commands. |
462 | Using the ``monitor'' line given below, you can observe the behavior | ||
463 | of your own peer's DHT with respect to the specified KEY: | ||
392 | 464 | ||
393 | @example | 465 | @example |
394 | $ gnunet-arm -c ~/peer1.conf -s # start gnunet with all default services | 466 | # start gnunet with all default services: |
395 | $ gnunet-arm -c ~/peer1.conf -i dht # start DHT service | 467 | $ gnunet-arm -c ~/peer1.conf -s |
468 | # start DHT service: | ||
469 | $ gnunet-arm -c ~/peer1.conf -i dht | ||
396 | $ cd ~/gnunet/src/dht; | 470 | $ cd ~/gnunet/src/dht; |
397 | $ ./gnunet-dht-monitor -c ~/peer1.conf -k KEY | 471 | $ ./gnunet-dht-monitor -c ~/peer1.conf -k KEY |
398 | @end example | 472 | @end example |
399 | Now open a separate terminal and change again to the @file{gnunet/src/dht} directory: | 473 | |
474 | @noindent | ||
475 | Now open a separate terminal and change again to | ||
476 | the @file{gnunet/src/dht} directory: | ||
477 | |||
400 | @example | 478 | @example |
401 | $ cd ~/gnunet/src/dht | 479 | $ cd ~/gnunet/src/dht |
402 | $ ./gnunet-dht-put -c ~/peer1.conf -k KEY -d VALUE # put VALUE under KEY in the DHT | 480 | # put VALUE under KEY in the DHT: |
403 | $ ./gnunet/src/dht/gnunet-dht-get -c ~/peer1.conf -k KEY # get key KEY from the DHT | 481 | $ ./gnunet-dht-put -c ~/peer1.conf -k KEY -d VALUE |
404 | $ gnunet-statistics -c ~/peer1.conf # print statistics about current GNUnet state | 482 | # get key KEY from the DHT: |
405 | $ gnunet-statistics -c ~/peer1.conf -s dht # print statistics about DHT service | 483 | $ ./gnunet/src/dht/gnunet-dht-get -c ~/peer1.conf -k KEY |
484 | # print statistics about current GNUnet state: | ||
485 | $ gnunet-statistics -c ~/peer1.conf | ||
486 | # print statistics about DHT service: | ||
487 | $ gnunet-statistics -c ~/peer1.conf -s dht | ||
406 | @end example | 488 | @end example |
407 | 489 | ||
408 | @node Starting Two Peers by Hand | 490 | @node Starting Two Peers by Hand |
409 | @section Starting Two Peers by Hand | 491 | @section Starting Two Peers by Hand |
410 | 492 | ||
411 | This section describes how to start two peers on the same machine by hand. | 493 | This section describes how to start two peers on the same machine by hand. |
412 | The process is rather painful, but the description is somewhat instructive. | 494 | The process is rather painful, but the description is somewhat |
413 | In practice, you might prefer the automated method | 495 | instructive. In practice, you might prefer the automated method |
414 | (@pxref{Starting Peers Using the Testbed Service}). | 496 | (@pxref{Starting Peers Using the Testbed Service}). |
415 | 497 | ||
416 | @menu | 498 | @menu |
@@ -424,29 +506,37 @@ In practice, you might prefer the automated method | |||
424 | We will now start a second peer on your machine. | 506 | We will now start a second peer on your machine. |
425 | For the second peer, you will need to manually create a modified | 507 | For the second peer, you will need to manually create a modified |
426 | configuration file to avoid conflicts with ports and directories. | 508 | configuration file to avoid conflicts with ports and directories. |
427 | A peers configuration file is by default located in @file{~/.gnunet/gnunet.conf}. | 509 | A peers configuration file is by default located |
428 | This file is typically very short or even empty as only the differences to the | 510 | in @file{~/.gnunet/gnunet.conf}. This file is typically very short |
429 | defaults need to be specified. The defaults are located in | 511 | or even empty as only the differences to the defaults need to be |
430 | many files in the @file{$PREFIX/share/gnunet/config.d} directory. | 512 | specified. The defaults are located in many files in the |
513 | @file{$PREFIX/share/gnunet/config.d} directory. | ||
431 | 514 | ||
432 | To configure the second peer, use the files | 515 | To configure the second peer, use the files |
433 | @file{$PREFIX/share/gnunet/config.d} as a template for your main | 516 | @file{$PREFIX/share/gnunet/config.d} as a template for your main |
434 | configuration file: | 517 | configuration file: |
518 | |||
435 | @example | 519 | @example |
436 | $ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf | 520 | $ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf |
437 | @end example | 521 | @end example |
522 | |||
523 | @noindent | ||
438 | Now you have to edit @file{peer2.conf} and change: | 524 | Now you have to edit @file{peer2.conf} and change: |
525 | |||
439 | @itemize | 526 | @itemize |
440 | @item @code{GNUNET\_TEST\_HOME} under @code{PATHS} | 527 | @item @code{GNUNET\_TEST\_HOME} under @code{PATHS} |
441 | @item Every (uncommented) value for ``@code{PORT}'' (add 10000) in any | 528 | @item Every (uncommented) value for ``@code{PORT}'' (add 10000) in any |
442 | section (the option may be commented out if @code{PORT} is | 529 | section (the option may be commented out if @code{PORT} is |
443 | prefixed by "\#", in this case, UNIX domain sockets are used | 530 | prefixed by "\#", in this case, UNIX domain sockets are used |
444 | and the PORT option does not need to be touched) | 531 | and the PORT option does not need to be touched) |
445 | @item Every value for ``@code{UNIXPATH}'' in any section (e.g. by adding a "-p2" suffix) | 532 | @item Every value for ``@code{UNIXPATH}'' in any section |
533 | (e.g. by adding a "-p2" suffix) | ||
446 | @end itemize | 534 | @end itemize |
447 | to a fresh, unique value. Make sure that the PORT numbers stay below 65536. | 535 | |
448 | From now on, whenever you interact with the second peer, you need to specify | 536 | to a fresh, unique value. Make sure that the PORT numbers stay |
449 | @command{-c peer2.conf} as an additional command line argument. | 537 | below 65536. From now on, whenever you interact with the second peer, |
538 | you need to specify @command{-c peer2.conf} as an additional | ||
539 | command line argument. | ||
450 | 540 | ||
451 | Now, generate the 2nd peer's private key: | 541 | Now, generate the 2nd peer's private key: |
452 | 542 | ||
@@ -454,6 +544,7 @@ Now, generate the 2nd peer's private key: | |||
454 | $ gnunet-peerinfo -s -c peer2.conf | 544 | $ gnunet-peerinfo -s -c peer2.conf |
455 | @end example | 545 | @end example |
456 | 546 | ||
547 | @noindent | ||
457 | This may take a while, generate entropy using your keyboard or mouse | 548 | This may take a while, generate entropy using your keyboard or mouse |
458 | as needed. Also, make sure the output is different from the | 549 | as needed. Also, make sure the output is different from the |
459 | gnunet-peerinfo output for the first peer (otherwise you made an | 550 | gnunet-peerinfo output for the first peer (otherwise you made an |
@@ -463,34 +554,46 @@ error in the configuration). | |||
463 | @subsection Start the second peer and connect the peers | 554 | @subsection Start the second peer and connect the peers |
464 | 555 | ||
465 | Then, you can start a second peer using: | 556 | Then, you can start a second peer using: |
557 | |||
466 | @example | 558 | @example |
467 | $ gnunet-arm -c peer2.conf -s | 559 | $ gnunet-arm -c peer2.conf -s |
468 | $ gnunet-arm -c peer2.conf -i dht | 560 | $ gnunet-arm -c peer2.conf -i dht |
469 | $ ~/gnunet/src/dht/gnunet-dht-put -c peer2.conf -k KEY -d VALUE | 561 | $ ~/gnunet/src/dht/gnunet-dht-put -c peer2.conf -k KEY -d VALUE |
470 | $ ~/gnunet/src/dht/gnunet-dht-get -c peer2.conf -k KEY | 562 | $ ~/gnunet/src/dht/gnunet-dht-get -c peer2.conf -k KEY |
471 | @end example | 563 | @end example |
564 | |||
472 | If you want the two peers to connect, you have multiple options: | 565 | If you want the two peers to connect, you have multiple options: |
566 | |||
473 | @itemize | 567 | @itemize |
474 | @item UDP neighbour discovery (automatic) | 568 | @item UDP neighbour discovery (automatic) |
475 | @item Setup a bootstrap server | 569 | @item Setup a bootstrap server |
476 | @item Connect manually | 570 | @item Connect manually |
477 | @end itemize | 571 | @end itemize |
572 | |||
478 | To setup peer 1 as bootstrapping server change the configuration of | 573 | To setup peer 1 as bootstrapping server change the configuration of |
479 | the first one to be a hostlist server by adding the following lines to | 574 | the first one to be a hostlist server by adding the following lines to |
480 | @file{peer1.conf} to enable bootstrapping server: | 575 | @file{peer1.conf} to enable bootstrapping server: |
576 | |||
481 | @example | 577 | @example |
482 | [hostlist] | 578 | [hostlist] |
483 | OPTIONS = -p | 579 | OPTIONS = -p |
484 | @end example | 580 | @end example |
485 | 581 | ||
486 | Then change @file{peer2.conf} and replace the ``@code{SERVERS}'' line in the ``@code{[hostlist]}'' section with | 582 | @noindent |
583 | Then change @file{peer2.conf} and replace the ``@code{SERVERS}'' | ||
584 | line in the ``@code{[hostlist]}'' section with | ||
487 | ``@code{http://localhost:8080/}''. Restart both peers using: | 585 | ``@code{http://localhost:8080/}''. Restart both peers using: |
586 | |||
488 | @example | 587 | @example |
489 | $ gnunet-arm -c peer1.conf -e # stop first peer | 588 | # stop first peer |
490 | $ gnunet-arm -c peer1.conf -s # start first peer | 589 | $ gnunet-arm -c peer1.conf -e |
491 | $ gnunet-arm -c peer2.conf -s # start second peer | 590 | # start first peer |
591 | $ gnunet-arm -c peer1.conf -s | ||
592 | # start second peer | ||
593 | $ gnunet-arm -c peer2.conf -s | ||
492 | @end example | 594 | @end example |
493 | 595 | ||
596 | @noindent | ||
494 | Note that if you start your peers without changing these settings, they | 597 | Note that if you start your peers without changing these settings, they |
495 | will use the ``global'' hostlist servers of the GNUnet P2P network and | 598 | will use the ``global'' hostlist servers of the GNUnet P2P network and |
496 | likely connect to those peers. At that point, debugging might become | 599 | likely connect to those peers. At that point, debugging might become |
@@ -501,16 +604,23 @@ by you. | |||
501 | @node How to connect manually | 604 | @node How to connect manually |
502 | @subsection How to connect manually | 605 | @subsection How to connect manually |
503 | 606 | ||
504 | If you want to use the @code{peerinfo} tool to connect your peers, you should: | 607 | If you want to use the @code{peerinfo} tool to connect your |
608 | peers, you should: | ||
609 | |||
505 | @itemize | 610 | @itemize |
506 | @item Set @code{FORCESTART = NO} in section @code{hostlist} (to not connect to the global GNUnet) | 611 | @item Set @code{FORCESTART = NO} in section @code{hostlist} |
507 | @item Start both peers running @command{gnunet-arm -c peer1.conf -s} and @command{gnunet-arm -c peer2.conf -s} | 612 | (to not connect to the global GNUnet) |
508 | @item Get @code{HELLO} message of the first peer running @command{gnunet-peerinfo -c peer1.conf -g} | 613 | @item Start both peers running @command{gnunet-arm -c peer1.conf -s} |
509 | @item Give the output to the second peer by running @command{gnunet-peerinfo -c peer2.conf -p '<output>'} | 614 | and @command{gnunet-arm -c peer2.conf -s} |
615 | @item Get @code{HELLO} message of the first peer running | ||
616 | @command{gnunet-peerinfo -c peer1.conf -g} | ||
617 | @item Give the output to the second peer by running | ||
618 | @command{gnunet-peerinfo -c peer2.conf -p '<output>'} | ||
510 | @end itemize | 619 | @end itemize |
511 | 620 | ||
512 | Check that they are connected using @command{gnunet-core -c peer1.conf}, | 621 | Check that they are connected using @command{gnunet-core -c peer1.conf}, |
513 | which should give you the other peer's peer identity: | 622 | which should give you the other peer's peer identity: |
623 | |||
514 | @example | 624 | @example |
515 | $ gnunet-core -c peer1.conf | 625 | $ gnunet-core -c peer1.conf |
516 | Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' | 626 | Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' |
@@ -520,90 +630,109 @@ Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' | |||
520 | @section Starting Peers Using the Testbed Service | 630 | @section Starting Peers Using the Testbed Service |
521 | @c \label{sec:testbed} | 631 | @c \label{sec:testbed} |
522 | 632 | ||
523 | GNUnet's testbed service is used for testing scenarios where a number of peers | 633 | GNUnet's testbed service is used for testing scenarios where |
524 | are to be started. The testbed can manage peers on a single host or on multiple | 634 | a number of peers are to be started. The testbed can manage peers |
525 | hosts in a distributed fashion. On a single affordable computer, it should be | 635 | on a single host or on multiple hosts in a distributed fashion. |
526 | possible to run around tens of peers without drastically increasing the load on the | 636 | On a single affordable computer, it should be possible to run |
637 | around tens of peers without drastically increasing the load on the | ||
527 | system. | 638 | system. |
528 | 639 | ||
529 | The testbed service can be access through its API | 640 | The testbed service can be access through its API |
530 | @file{include/gnunet\_testbed\_service.h}. The API provides many routines for | 641 | @file{include/gnunet\_testbed\_service.h}. The API provides many |
531 | managing a group of peers. It also provides a helper function | 642 | routines for managing a group of peers. It also provides a helper |
532 | @code{GNUNET\_TESTBED\_test\_run()} to quickly setup a minimalistic testing | 643 | function @code{GNUNET\_TESTBED\_test\_run()} to quickly setup a |
533 | environment on a single host. | 644 | minimalistic testing environment on a single host. |
534 | 645 | ||
535 | This function takes a configuration file which will be used as a template | 646 | This function takes a configuration file which will be used as a |
536 | configuration for the peers. The testbed takes care of modifying relevant | 647 | template configuration for the peers. The testbed takes care of |
537 | options in the peers' configuration such as @code{SERVICEHOME}, @code{PORT}, @code{UNIXPATH} to | 648 | modifying relevant options in the peers' configuration such as |
538 | unique values so that peers run without running into conflicts. It also checks | 649 | @code{SERVICEHOME}, @code{PORT}, @code{UNIXPATH} to unique values |
650 | so that peers run without running into conflicts. It also checks | ||
539 | and assigns the ports in configurations only if they are free. | 651 | and assigns the ports in configurations only if they are free. |
540 | 652 | ||
541 | Additionally, the testbed service also reads its options from the same | 653 | Additionally, the testbed service also reads its options from the |
542 | configuration file. Various available options and details about them can be | 654 | same configuration file. Various available options and details |
543 | found in the testbed default configuration file @file{src/testbed/testbed.conf}. | 655 | about them can be found in the testbed default configuration file |
656 | @file{src/testbed/testbed.conf}. | ||
544 | 657 | ||
545 | With the testbed API, a sample test case can be structured as follows: | 658 | With the testbed API, a sample test case can be structured as follows: |
659 | |||
546 | @example | 660 | @example |
547 | @verbatiminclude testbed_test.c | 661 | @verbatiminclude testbed_test.c |
548 | @end example | 662 | @end example |
663 | |||
664 | @noindent | ||
549 | The source code for the above listing can be found at | 665 | The source code for the above listing can be found at |
550 | @uref{https://gnunet.org/git/gnunet.git/tree/doc/testbed_test.c} | 666 | @uref{https://gnunet.org/git/gnunet.git/tree/doc/ |
551 | or in the @file{doc/} folder of your repository check-out. | 667 | documentation/testbed_test.c} |
668 | or in the @file{doc/documentation/} folder of your repository check-out. | ||
552 | After installing GNUnet, the above source code can be compiled as: | 669 | After installing GNUnet, the above source code can be compiled as: |
670 | |||
553 | @example | 671 | @example |
554 | $ export CPPFLAGS="-I/path/to/gnunet/headers" | 672 | $ export CPPFLAGS="-I/path/to/gnunet/headers" |
555 | $ export LDFLAGS="-L/path/to/gnunet/libraries" | 673 | $ export LDFLAGS="-L/path/to/gnunet/libraries" |
556 | $ gcc $CPPFLAGS $LDFLAGS -o testbed-test testbed_test.c -lgnunettestbed -lgnunetdht -lgnunetutil | 674 | $ gcc $CPPFLAGS $LDFLAGS -o testbed-test testbed_test.c \ |
557 | $ touch template.conf # Generate (empty) configuration | 675 | -lgnunettestbed -lgnunetdht -lgnunetutil |
558 | $ ./testbed-test # run it (press CTRL-C to stop) | 676 | # Generate (empty) configuration |
677 | $ touch template.conf | ||
678 | # run it (press CTRL-C to stop) | ||
679 | $ ./testbed-test | ||
559 | @end example | 680 | @end example |
560 | The @code{CPPFLAGS} and @code{LDFLAGS} are necessary if GNUnet is installed | 681 | |
561 | into a different directory other than @file{/usr/local}. | 682 | @noindent |
562 | 683 | The @code{CPPFLAGS} and @code{LDFLAGS} are necessary if GNUnet | |
563 | All of testbed API's peer management functions treat management actions as | 684 | is installed into a different directory other than @file{/usr/local}. |
564 | operations and return operation handles. It is expected that the operations | 685 | |
565 | begin immediately, but they may get delayed (to balance out load on the system). | 686 | All of testbed API's peer management functions treat management |
566 | The program using the API then has to take care of marking the operation as | 687 | actions as operations and return operation handles. It is expected |
567 | ``done'' so that its associated resources can be freed immediately and other | 688 | that the operations begin immediately, but they may get delayed (to |
568 | waiting operations can be executed. Operations will be canceled if they are | 689 | balance out load on the system). The program using the API then has |
690 | to take care of marking the operation as ``done'' so that its | ||
691 | associated resources can be freed immediately and other waiting | ||
692 | operations can be executed. Operations will be canceled if they are | ||
569 | marked as ``done'' before their completion. | 693 | marked as ``done'' before their completion. |
570 | 694 | ||
571 | An operation is treated as completed when it succeeds or fails. Completion of | 695 | An operation is treated as completed when it succeeds or fails. |
572 | an operation is either conveyed as events through @i{controller event callback} | 696 | Completion of an operation is either conveyed as events through |
573 | or through respective operation completion callbacks. In functions | 697 | @i{controller event callback} or through respective operation |
574 | which support completion notification through both controller event callback and | 698 | completion callbacks. In functions which support completion |
575 | operation completion callback, first the controller event callback will be | 699 | notification through both controller event callback and operation |
576 | called. If the operation is not marked as done in that callback or if the | 700 | completion callback, first the controller event callback will be |
577 | callback is given as NULL when creating the operation, the operation completion | 701 | called. If the operation is not marked as done in that callback |
578 | callback will be called. The API documentation shows which event are to be | 702 | or if the callback is given as NULL when creating the operation, |
579 | expected in the controller event notifications. It also documents any | 703 | the operation completion callback will be called. The API |
580 | exceptional behaviour. | 704 | documentation shows which event are to be expected in the |
581 | 705 | controller event notifications. It also documents any exceptional | |
582 | Once the peers are started, test cases often need to connect some of the peers' | 706 | behaviour. |
583 | services. Normally, opening a connect to a peer's service requires the peer's | 707 | |
584 | configuration. While using testbed, the testbed automatically generates | 708 | Once the peers are started, test cases often need to connect |
585 | per-peer configuration. Accessing those configurations directly through file | 709 | some of the peers' services. Normally, opening a connect to |
586 | system is discouraged as their locations are dynamically created and will be | 710 | a peer's service requires the peer's configuration. While using |
587 | different among various runs of testbed. To make access to these configurations | 711 | testbed, the testbed automatically generates per-peer configuration. |
588 | easy, testbed API provides the function | 712 | Accessing those configurations directly through file system is |
589 | @code{GNUNET\_TESTBED\_service\_connect()}. This function fetches the | 713 | discouraged as their locations are dynamically created and will be |
590 | configuration of a given peer and calls the @i{Connect Adapter}. | 714 | different among various runs of testbed. To make access to these |
591 | In the example code, it is the @code{dht\_ca}. A connect adapter is expected | 715 | configurations easy, testbed API provides the function |
592 | to open the connection to the needed service by using the provided configuration | 716 | @code{GNUNET\_TESTBED\_service\_connect()}. This function fetches |
593 | and return the created service connection handle. Successful connection to the | 717 | the configuration of a given peer and calls the @i{Connect Adapter}. |
594 | needed service is signaled through @code{service\_connect\_comp\_cb}. | 718 | In the example code, it is the @code{dht\_ca}. A connect adapter is |
595 | 719 | expected to open the connection to the needed service by using the | |
596 | A dual to connect adapter is the @i{Disconnect Adapter}. This callback is | 720 | provided configuration and return the created service connection handle. |
597 | called after the connect adapter has been called when the operation from | 721 | Successful connection to the needed service is signaled through |
598 | @code{GNUNET\_TESTBED\_service\_connect()} is marked as ``done''. It has to | 722 | @code{service\_connect\_comp\_cb}. |
599 | disconnect from the service with the provided service handle (@code{op\_result}). | 723 | |
724 | A dual to connect adapter is the @i{Disconnect Adapter}. This callback | ||
725 | is called after the connect adapter has been called when the operation | ||
726 | from @code{GNUNET\_TESTBED\_service\_connect()} is marked as ``done''. | ||
727 | It has to disconnect from the service with the provided service | ||
728 | handle (@code{op\_result}). | ||
600 | 729 | ||
601 | Exercise: Find out how many peers you can run on your system. | 730 | Exercise: Find out how many peers you can run on your system. |
602 | 731 | ||
603 | Exercise: Find out how to create a 2D torus topology by changing the | 732 | Exercise: Find out how to create a 2D torus topology by changing the |
604 | options in the configuration file. See @uref{https://gnunet.org/supported-topologies} | 733 | options in the configuration file. |
605 | Then use the DHT API to store and retrieve values in the | 734 | See @uref{https://gnunet.org/supported-topologies}, then use the |
606 | network. | 735 | DHT API to store and retrieve values in the network. |
607 | 736 | ||
608 | @node Developing Applications | 737 | @node Developing Applications |
609 | @chapter Developing Applications | 738 | @chapter Developing Applications |
@@ -635,17 +764,21 @@ $ make install | |||
635 | $ make check | 764 | $ make check |
636 | @end example | 765 | @end example |
637 | 766 | ||
638 | The GNUnet ext template includes examples and a working buildsystem for a new GNUnet service. | 767 | @noindent |
639 | A common GNUnet service consists of the following parts which will be discussed in detail in the | 768 | The GNUnet ext template includes examples and a working buildsystem |
640 | remainder of this document. The functionality of a GNUnet service is implemented in: | 769 | for a new GNUnet service. A common GNUnet service consists of the |
770 | following parts which will be discussed in detail in the remainder | ||
771 | of this document. The functionality of a GNUnet service is implemented in: | ||
641 | 772 | ||
642 | @itemize | 773 | @itemize |
643 | @item the GNUnet service (gnunet-ext/src/ext/gnunet-service-ext.c) | 774 | @item the GNUnet service (gnunet-ext/src/ext/gnunet-service-ext.c) |
644 | @item the client API (gnunet-ext/src/ext/ext_api.c) | 775 | @item the client API (gnunet-ext/src/ext/ext_api.c) |
645 | @item the client application using the service API (gnunet-ext/src/ext/gnunet-ext.c) | 776 | @item the client application using the service API |
777 | (gnunet-ext/src/ext/gnunet-ext.c) | ||
646 | @end itemize | 778 | @end itemize |
647 | 779 | ||
648 | The interfaces for these entities are defined in: | 780 | The interfaces for these entities are defined in: |
781 | |||
649 | @itemize | 782 | @itemize |
650 | @item client API interface (gnunet-ext/src/ext/ext.h) | 783 | @item client API interface (gnunet-ext/src/ext/ext.h) |
651 | @item the service interface (gnunet-ext/src/include/gnunet_service_SERVICE.h) | 784 | @item the service interface (gnunet-ext/src/include/gnunet_service_SERVICE.h) |
@@ -654,9 +787,11 @@ The interfaces for these entities are defined in: | |||
654 | 787 | ||
655 | 788 | ||
656 | In addition the ext systems provides: | 789 | In addition the ext systems provides: |
790 | |||
657 | @itemize | 791 | @itemize |
658 | @item a test testing the API (gnunet-ext/src/ext/test_ext_api.c) | 792 | @item a test testing the API (gnunet-ext/src/ext/test_ext_api.c) |
659 | @item a configuration template for the service (gnunet-ext/src/ext/ext.conf.in) | 793 | @item a configuration template for the service |
794 | (gnunet-ext/src/ext/ext.conf.in) | ||
660 | @end itemize | 795 | @end itemize |
661 | 796 | ||
662 | @node Adapting the Template | 797 | @node Adapting the Template |
@@ -664,22 +799,24 @@ In addition the ext systems provides: | |||
664 | 799 | ||
665 | The first step for writing any extension with a new service is to | 800 | The first step for writing any extension with a new service is to |
666 | ensure that the @file{ext.conf.in} file contains entries for the | 801 | ensure that the @file{ext.conf.in} file contains entries for the |
667 | @code{UNIXPATH}, @code{PORT} and @code{BINARY} for the service in a section named after | 802 | @code{UNIXPATH}, @code{PORT} and @code{BINARY} for the service in a |
668 | the service. | 803 | section named after the service. |
669 | 804 | ||
670 | If you want to adapt the template rename the @file{ext.conf.in} to match your | 805 | If you want to adapt the template rename the @file{ext.conf.in} to |
671 | services name, you have to modify the @code{AC\_OUTPUT} section in @file{configure.ac} | 806 | match your services name, you have to modify the @code{AC\_OUTPUT} |
672 | in the @file{gnunet-ext} root. | 807 | section in @file{configure.ac} in the @file{gnunet-ext} root. |
673 | 808 | ||
674 | @node Writing a Client Application | 809 | @node Writing a Client Application |
675 | @section Writing a Client Application | 810 | @section Writing a Client Application |
676 | 811 | ||
677 | When writing any client application (for example, a command-line | 812 | When writing any client application (for example, a command-line |
678 | tool), the basic structure is to start with the @code{GNUNET\_PROGRAM\_run} | 813 | tool), the basic structure is to start with the |
679 | function. This function will parse command-line options, setup the scheduler | 814 | @code{GNUNET\_PROGRAM\_run} function. This function will parse |
680 | and then invoke the @code{run} function (with the remaining non-option arguments) | 815 | command-line options, setup the scheduler and then invoke the |
681 | and a handle to the parsed configuration (and the configuration file name that was | 816 | @code{run} function (with the remaining non-option arguments) |
682 | used, which is typically not needed): | 817 | and a handle to the parsed configuration (and the configuration |
818 | file name that was used, which is typically not needed): | ||
819 | |||
683 | @example | 820 | @example |
684 | @verbatiminclude tutorial-examples/001.c | 821 | @verbatiminclude tutorial-examples/001.c |
685 | @end example | 822 | @end example |
@@ -697,6 +834,7 @@ Options can then be added easily by adding global variables and | |||
697 | expanding the @code{options} array. For example, the following would | 834 | expanding the @code{options} array. For example, the following would |
698 | add a string-option and a binary flag (defaulting to @code{NULL} and | 835 | add a string-option and a binary flag (defaulting to @code{NULL} and |
699 | @code{GNUNET\_NO} respectively): | 836 | @code{GNUNET\_NO} respectively): |
837 | |||
700 | @example | 838 | @example |
701 | @verbatiminclude tutorial-examples/002.c | 839 | @verbatiminclude tutorial-examples/002.c |
702 | @end example | 840 | @end example |
@@ -753,10 +891,12 @@ file). | |||
753 | 891 | ||
754 | Before a client library can implement the application-specific protocol | 892 | Before a client library can implement the application-specific protocol |
755 | with the service, a connection must be created: | 893 | with the service, a connection must be created: |
894 | |||
756 | @example | 895 | @example |
757 | @verbatiminclude tutorial-examples/003.c | 896 | @verbatiminclude tutorial-examples/003.c |
758 | @end example | 897 | @end example |
759 | 898 | ||
899 | @noindent | ||
760 | As a result a @code{GNUNET\_MQ\_Handle} is returned | 900 | As a result a @code{GNUNET\_MQ\_Handle} is returned |
761 | which can to used henceforth to transmit messages to the service. | 901 | which can to used henceforth to transmit messages to the service. |
762 | The complete MQ API can be found in @file{gnunet\_mq\_lib.h}. | 902 | The complete MQ API can be found in @file{gnunet\_mq\_lib.h}. |
@@ -769,27 +909,35 @@ there are errors communicating with the service. | |||
769 | @node Sending messages | 909 | @node Sending messages |
770 | @subsubsection Sending messages | 910 | @subsubsection Sending messages |
771 | 911 | ||
772 | In GNUnet, messages are always sent beginning with a @code{struct GNUNET\_MessageHeader} | 912 | In GNUnet, messages are always sent beginning with a |
773 | in big endian format. This header defines the size and the type of the | 913 | @code{struct GNUNET\_MessageHeader} in big endian format. |
914 | This header defines the size and the type of the | ||
774 | message, the payload follows after this header. | 915 | message, the payload follows after this header. |
916 | |||
775 | @example | 917 | @example |
776 | @verbatiminclude tutorial-examples/004.c | 918 | @verbatiminclude tutorial-examples/004.c |
777 | @end example | 919 | @end example |
778 | 920 | ||
921 | @noindent | ||
779 | Existing message types are defined in @file{gnunet\_protocols.h}. | 922 | Existing message types are defined in @file{gnunet\_protocols.h}. |
780 | A common way to create a message is with an envelope: | 923 | A common way to create a message is with an envelope: |
924 | |||
781 | @example | 925 | @example |
782 | @verbatiminclude tutorial-examples/005.c | 926 | @verbatiminclude tutorial-examples/005.c |
783 | @end example | 927 | @end example |
784 | 928 | ||
929 | @noindent | ||
785 | Exercise: Define a message struct that includes a 32-bit | 930 | Exercise: Define a message struct that includes a 32-bit |
786 | unsigned integer in addition to the standard GNUnet MessageHeader. | 931 | unsigned integer in addition to the standard GNUnet MessageHeader. |
787 | Add a C struct and define a fresh protocol number for your message. | 932 | Add a C struct and define a fresh protocol number for your message. |
788 | Protocol numbers in gnunet-ext are defined in @file{gnunet-ext/src/include/gnunet_protocols_ext.h} | 933 | Protocol numbers in gnunet-ext are defined |
934 | in @file{gnunet-ext/src/include/gnunet_protocols_ext.h} | ||
789 | 935 | ||
790 | Exercise: Find out how you can determine the number of messages in a message queue. | 936 | Exercise: Find out how you can determine the number of messages |
937 | in a message queue. | ||
791 | 938 | ||
792 | Exercise: Find out how you can determine when a message you have queued was actually transmitted. | 939 | Exercise: Find out how you can determine when a message you |
940 | have queued was actually transmitted. | ||
793 | 941 | ||
794 | Exercise: Define a helper function to transmit a 32-bit | 942 | Exercise: Define a helper function to transmit a 32-bit |
795 | unsigned integer (as payload) to a service using some given client | 943 | unsigned integer (as payload) to a service using some given client |
@@ -808,16 +956,19 @@ to actually process the message. Fixed size messages are fully | |||
808 | checked by the MQ-logic, and thus only need to provide the handler | 956 | checked by the MQ-logic, and thus only need to provide the handler |
809 | to process the message. Note that the prefixes @code{check\_} | 957 | to process the message. Note that the prefixes @code{check\_} |
810 | and @code{handle\_} are mandatory. | 958 | and @code{handle\_} are mandatory. |
959 | |||
811 | @example | 960 | @example |
812 | @verbatiminclude tutorial-examples/006.c | 961 | @verbatiminclude tutorial-examples/006.c |
813 | @end example | 962 | @end example |
814 | 963 | ||
964 | @noindent | ||
815 | Exercise: Expand your helper function to receive a response message | 965 | Exercise: Expand your helper function to receive a response message |
816 | (for example, containing just the @code{struct GNUnet MessageHeader} | 966 | (for example, containing just the @code{struct GNUnet MessageHeader} |
817 | without any payload). Upon receiving the service's response, you | 967 | without any payload). Upon receiving the service's response, you |
818 | should call a callback provided to your helper function's API. | 968 | should call a callback provided to your helper function's API. |
819 | 969 | ||
820 | Exercise: Figure out where you can pass values to the closures (@code{cls}). | 970 | Exercise: Figure out where you can pass values to the |
971 | closures (@code{cls}). | ||
821 | 972 | ||
822 | @node Writing a user interface | 973 | @node Writing a user interface |
823 | @subsection Writing a user interface | 974 | @subsection Writing a user interface |
@@ -834,8 +985,8 @@ command-line to the service. | |||
834 | @node Writing a Service | 985 | @node Writing a Service |
835 | @section Writing a Service | 986 | @section Writing a Service |
836 | 987 | ||
837 | Before you can test the client you've written so far, you'll need to also | 988 | Before you can test the client you've written so far, you'll |
838 | implement the corresponding service. | 989 | need to also implement the corresponding service. |
839 | 990 | ||
840 | @menu | 991 | @menu |
841 | * Code Placement:: | 992 | * Code Placement:: |
@@ -845,21 +996,25 @@ implement the corresponding service. | |||
845 | @node Code Placement | 996 | @node Code Placement |
846 | @subsection Code Placement | 997 | @subsection Code Placement |
847 | 998 | ||
848 | New services are placed in their own subdirectory under @file{gnunet/src}. | 999 | New services are placed in their own subdirectory under |
849 | This subdirectory should contain the API implementation file @file{SERVICE\_api.c}, | 1000 | @file{gnunet/src}. This subdirectory should contain the API |
850 | the description of the client-service protocol @file{SERVICE.h} and P2P protocol | 1001 | implementation file @file{SERVICE\_api.c}, the description of |
1002 | the client-service protocol @file{SERVICE.h} and P2P protocol | ||
851 | @file{SERVICE\_protocol.h}, the implementation of the service itself | 1003 | @file{SERVICE\_protocol.h}, the implementation of the service itself |
852 | @file{gnunet-service-SERVICE.h} and several files for tests, including test code | 1004 | @file{gnunet-service-SERVICE.h} and several files for tests, |
853 | and configuration files. | 1005 | including test code and configuration files. |
854 | 1006 | ||
855 | @node Starting a Service | 1007 | @node Starting a Service |
856 | @subsection Starting a Service | 1008 | @subsection Starting a Service |
857 | 1009 | ||
858 | The key API definition for creating a service is the @code{GNUNET\_SERVICE\_MAIN} macro: | 1010 | The key API definition for creating a service is the |
1011 | @code{GNUNET\_SERVICE\_MAIN} macro: | ||
1012 | |||
859 | @example | 1013 | @example |
860 | @verbatiminclude tutorial-examples/007.c | 1014 | @verbatiminclude tutorial-examples/007.c |
861 | @end example | 1015 | @end example |
862 | 1016 | ||
1017 | @noindent | ||
863 | In addition to the service name and flags, the macro takes three | 1018 | In addition to the service name and flags, the macro takes three |
864 | functions, typically called @code{run}, @code{client\_connect\_cb} and | 1019 | functions, typically called @code{run}, @code{client\_connect\_cb} and |
865 | @code{client\_disconnect\_cb} as well as an array of message handlers | 1020 | @code{client\_disconnect\_cb} as well as an array of message handlers |
@@ -867,10 +1022,12 @@ that will be called for incoming messages from clients. | |||
867 | 1022 | ||
868 | A minimal version of the three central service funtions would look | 1023 | A minimal version of the three central service funtions would look |
869 | like this: | 1024 | like this: |
1025 | |||
870 | @example | 1026 | @example |
871 | @verbatiminclude tutorial-examples/008.c | 1027 | @verbatiminclude tutorial-examples/008.c |
872 | @end example | 1028 | @end example |
873 | 1029 | ||
1030 | @noindent | ||
874 | Exercise: Write a stub service that processes no messages at all | 1031 | Exercise: Write a stub service that processes no messages at all |
875 | in your code. Create a default configuration for it, integrate it | 1032 | in your code. Create a default configuration for it, integrate it |
876 | with the build system and start the service from | 1033 | with the build system and start the service from |
@@ -883,8 +1040,9 @@ Exercise: Figure out how to send messages from the service back to the | |||
883 | client. | 1040 | client. |
884 | 1041 | ||
885 | Each handler function in the service @b{must} eventually (possibly in some | 1042 | Each handler function in the service @b{must} eventually (possibly in some |
886 | asynchronous continuation) call @code{GNUNET\_SERVICE\_client\_continue()}. | 1043 | asynchronous continuation) call |
887 | Only after this call additional messages from the same client may | 1044 | @code{GNUNET\_SERVICE\_client\_continue()}. Only after this call |
1045 | additional messages from the same client may | ||
888 | be processed. This way, the service can throttle processing messages | 1046 | be processed. This way, the service can throttle processing messages |
889 | from the same client. | 1047 | from the same client. |
890 | 1048 | ||
@@ -900,8 +1058,9 @@ FIXME: This section still needs to be updated to the lastest API! | |||
900 | One of the most important services in GNUnet is the @code{CORE} service | 1058 | One of the most important services in GNUnet is the @code{CORE} service |
901 | managing connections between peers and handling encryption between peers. | 1059 | managing connections between peers and handling encryption between peers. |
902 | 1060 | ||
903 | One of the first things any service that extends the P2P protocol typically does | 1061 | One of the first things any service that extends the P2P protocol |
904 | is connect to the @code{CORE} service using: | 1062 | typically does is connect to the @code{CORE} service using: |
1063 | |||
905 | @example | 1064 | @example |
906 | @verbatiminclude tutorial-examples/009.c | 1065 | @verbatiminclude tutorial-examples/009.c |
907 | @end example | 1066 | @end example |
@@ -916,13 +1075,16 @@ is connect to the @code{CORE} service using: | |||
916 | @node New P2P connections | 1075 | @node New P2P connections |
917 | @subsection New P2P connections | 1076 | @subsection New P2P connections |
918 | 1077 | ||
919 | Before any traffic with a different peer can be exchanged, the peer must be | 1078 | Before any traffic with a different peer can be exchanged, the peer must |
920 | known to the service. This is notified by the @code{CORE} @code{connects} callback, | 1079 | be known to the service. This is notified by the @code{CORE} |
921 | which communicates the identity of the new peer to the service: | 1080 | @code{connects} callback, which communicates the identity of the new |
1081 | peer to the service: | ||
1082 | |||
922 | @example | 1083 | @example |
923 | @verbatiminclude tutorial-examples/010.c | 1084 | @verbatiminclude tutorial-examples/010.c |
924 | @end example | 1085 | @end example |
925 | 1086 | ||
1087 | @noindent | ||
926 | Note that whatever you return from @code{connects} is given as the | 1088 | Note that whatever you return from @code{connects} is given as the |
927 | @i{cls} argument to the message handlers for messages from | 1089 | @i{cls} argument to the message handlers for messages from |
928 | the respective peer. | 1090 | the respective peer. |
@@ -969,23 +1131,27 @@ you stop the peer that is receiving your messages? | |||
969 | @node End of P2P connections | 1131 | @node End of P2P connections |
970 | @subsection End of P2P connections | 1132 | @subsection End of P2P connections |
971 | 1133 | ||
972 | If a message handler returns @code{GNUNET\_SYSERR}, the remote peer shuts down or | 1134 | If a message handler returns @code{GNUNET\_SYSERR}, the remote |
973 | there is an unrecoverable network disconnection, CORE notifies the service that | 1135 | peer shuts down or there is an unrecoverable network |
974 | the peer disconnected. After this notification no more messages will be received | 1136 | disconnection, CORE notifies the service that the peer disconnected. |
975 | from the peer and the service is no longer allowed to send messages to the peer. | 1137 | After this notification no more messages will be received from the |
1138 | peer and the service is no longer allowed to send messages to the peer. | ||
976 | The disconnect callback looks like the following: | 1139 | The disconnect callback looks like the following: |
1140 | |||
977 | @example | 1141 | @example |
978 | @verbatiminclude tutorial-examples/011.c | 1142 | @verbatiminclude tutorial-examples/011.c |
979 | @end example | 1143 | @end example |
980 | 1144 | ||
1145 | @noindent | ||
981 | Exercise: Fix your service to handle peer disconnects. | 1146 | Exercise: Fix your service to handle peer disconnects. |
982 | 1147 | ||
983 | @node Storing peer-specific data using the PEERSTORE service | 1148 | @node Storing peer-specific data using the PEERSTORE service |
984 | @section Storing peer-specific data using the PEERSTORE service | 1149 | @section Storing peer-specific data using the PEERSTORE service |
985 | 1150 | ||
986 | GNUnet's PEERSTORE service offers a persistorage for arbitrary peer-specific data. | 1151 | GNUnet's PEERSTORE service offers a persistorage for arbitrary |
987 | Other GNUnet services can use the PEERSTORE to store, retrieve and monitor data records. | 1152 | peer-specific data. Other GNUnet services can use the PEERSTORE |
988 | Each data record stored with PEERSTORE contains the following fields: | 1153 | to store, retrieve and monitor data records. Each data record |
1154 | stored with PEERSTORE contains the following fields: | ||
989 | 1155 | ||
990 | @itemize | 1156 | @itemize |
991 | @item subsystem: Name of the subsystem responsible for the record. | 1157 | @item subsystem: Name of the subsystem responsible for the record. |
@@ -1000,8 +1166,8 @@ The first step is to start a connection to the PEERSTORE service: | |||
1000 | @verbatiminclude tutorial-examples/012.c | 1166 | @verbatiminclude tutorial-examples/012.c |
1001 | @end example | 1167 | @end example |
1002 | 1168 | ||
1003 | The service handle @code{peerstore_handle} will be needed for all subsequent | 1169 | The service handle @code{peerstore_handle} will be needed for |
1004 | PEERSTORE operations. | 1170 | all subsequent PEERSTORE operations. |
1005 | 1171 | ||
1006 | @menu | 1172 | @menu |
1007 | * Storing records:: | 1173 | * Storing records:: |
@@ -1014,36 +1180,46 @@ PEERSTORE operations. | |||
1014 | @subsection Storing records | 1180 | @subsection Storing records |
1015 | 1181 | ||
1016 | To store a new record, use the following function: | 1182 | To store a new record, use the following function: |
1183 | |||
1017 | @example | 1184 | @example |
1018 | @verbatiminclude tutorial-examples/013.c | 1185 | @verbatiminclude tutorial-examples/013.c |
1019 | @end example | 1186 | @end example |
1020 | 1187 | ||
1021 | The @code{options} parameter can either be @code{GNUNET_PEERSTORE_STOREOPTION_MULTIPLE} | 1188 | @noindent |
1022 | which means that multiple values can be stored under the same key combination (subsystem, peerid, key), | 1189 | The @code{options} parameter can either be |
1023 | or @code{GNUNET_PEERSTORE_STOREOPTION_REPLACE} which means that PEERSTORE will replace any | 1190 | @code{GNUNET_PEERSTORE_STOREOPTION_MULTIPLE} which means that multiple |
1024 | existing values under the given key combination (subsystem, peerid, key) with the new given value. | 1191 | values can be stored under the same key combination |
1192 | (subsystem, peerid, key), or @code{GNUNET_PEERSTORE_STOREOPTION_REPLACE} | ||
1193 | which means that PEERSTORE will replace any existing values under the | ||
1194 | given key combination (subsystem, peerid, key) with the new given value. | ||
1025 | 1195 | ||
1026 | The continuation function @code{cont} will be called after the store request is successfully | 1196 | The continuation function @code{cont} will be called after the store |
1027 | sent to the PEERSTORE service. This does not guarantee that the record is successfully stored, only | 1197 | request is successfully sent to the PEERSTORE service. This does not |
1028 | that it was received by the service. | 1198 | guarantee that the record is successfully stored, only that it was |
1199 | received by the service. | ||
1200 | |||
1201 | The @code{GNUNET_PEERSTORE_store} function returns a handle to the store | ||
1202 | operation. This handle can be used to cancel the store operation only | ||
1203 | before the continuation function is called: | ||
1029 | 1204 | ||
1030 | The @code{GNUNET_PEERSTORE_store} function returns a handle to the store operation. This handle | ||
1031 | can be used to cancel the store operation only before the continuation function is called: | ||
1032 | @example | 1205 | @example |
1033 | void | 1206 | @verbatiminclude tutorial-examples/013.1.c |
1034 | GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc); | ||
1035 | @end example | 1207 | @end example |
1036 | 1208 | ||
1037 | @node Retrieving records | 1209 | @node Retrieving records |
1038 | @subsection Retrieving records | 1210 | @subsection Retrieving records |
1039 | 1211 | ||
1040 | To retrieve stored records, use the following function: | 1212 | To retrieve stored records, use the following function: |
1213 | |||
1041 | @example | 1214 | @example |
1042 | @verbatiminclude tutorial-examples/014.c | 1215 | @verbatiminclude tutorial-examples/014.c |
1043 | @end example | 1216 | @end example |
1044 | 1217 | ||
1045 | The values of @code{peer} and @code{key} can be @code{NULL}. This allows the | 1218 | @noindent |
1046 | iteration over values stored under any of the following key combinations: | 1219 | The values of @code{peer} and @code{key} can be @code{NULL}. This |
1220 | allows the iteration over values stored under any of the following | ||
1221 | key combinations: | ||
1222 | |||
1047 | @itemize | 1223 | @itemize |
1048 | @item (subsystem) | 1224 | @item (subsystem) |
1049 | @item (subsystem, peerid) | 1225 | @item (subsystem, peerid) |
@@ -1051,25 +1227,32 @@ iteration over values stored under any of the following key combinations: | |||
1051 | @item (subsystem, peerid, key) | 1227 | @item (subsystem, peerid, key) |
1052 | @end itemize | 1228 | @end itemize |
1053 | 1229 | ||
1054 | The @code{callback} function will be called once with each retrieved record and once | 1230 | The @code{callback} function will be called once with each retrieved |
1055 | more with a @code{NULL} record to signal the end of results. | 1231 | record and once more with a @code{NULL} record to signal the end of |
1232 | results. | ||
1056 | 1233 | ||
1057 | The @code{GNUNET_PEERSTORE_iterate} function returns a handle to the iterate operation. This | 1234 | The @code{GNUNET_PEERSTORE_iterate} function returns a handle to the |
1058 | handle can be used to cancel the iterate operation only before the callback function is called with | 1235 | iterate operation. This handle can be used to cancel the iterate |
1059 | a @code{NULL} record. | 1236 | operation only before the callback function is called with a |
1237 | @code{NULL} record. | ||
1060 | 1238 | ||
1061 | @node Monitoring records | 1239 | @node Monitoring records |
1062 | @subsection Monitoring records | 1240 | @subsection Monitoring records |
1063 | 1241 | ||
1064 | PEERSTORE offers the functionality of monitoring for new records stored under a specific key | 1242 | PEERSTORE offers the functionality of monitoring for new records |
1065 | combination (subsystem, peerid, key). To start the monitoring, use the following function: | 1243 | stored under a specific key combination (subsystem, peerid, key). |
1244 | To start the monitoring, use the following function: | ||
1245 | |||
1066 | @example | 1246 | @example |
1067 | @verbatiminclude tutorial-examples/015.c | 1247 | @verbatiminclude tutorial-examples/015.c |
1068 | @end example | 1248 | @end example |
1069 | 1249 | ||
1070 | Whenever a new record is stored under the given key combination, the @code{callback} function | 1250 | @noindent |
1071 | will be called with this new record. This will continue until the connection to the PEERSTORE service | 1251 | Whenever a new record is stored under the given key combination, |
1072 | is broken or the watch operation is canceled: | 1252 | the @code{callback} function will be called with this new |
1253 | record. This will continue until the connection to the PEERSTORE | ||
1254 | service is broken or the watch operation is canceled: | ||
1255 | |||
1073 | @example | 1256 | @example |
1074 | @verbatiminclude tutorial-examples/016.c | 1257 | @verbatiminclude tutorial-examples/016.c |
1075 | @end example | 1258 | @end example |
@@ -1077,15 +1260,18 @@ is broken or the watch operation is canceled: | |||
1077 | @node Disconnecting from PEERSTORE | 1260 | @node Disconnecting from PEERSTORE |
1078 | @subsection Disconnecting from PEERSTORE | 1261 | @subsection Disconnecting from PEERSTORE |
1079 | 1262 | ||
1080 | When the connection to the PEERSTORE service is no longer needed, disconnect using the following | 1263 | When the connection to the PEERSTORE service is no longer needed, |
1081 | function: | 1264 | disconnect using the following function: |
1265 | |||
1082 | @example | 1266 | @example |
1083 | @verbatiminclude tutorial-examples/017.c | 1267 | @verbatiminclude tutorial-examples/017.c |
1084 | @end example | 1268 | @end example |
1085 | 1269 | ||
1086 | If the @code{sync_first} flag is set to @code{GNUNET_YES}, the API will delay the | 1270 | @noindent |
1087 | disconnection until all store requests are received by the PEERSTORE service. Otherwise, | 1271 | If the @code{sync_first} flag is set to @code{GNUNET_YES}, |
1088 | it will disconnect immediately. | 1272 | the API will delay the disconnection until all store requests |
1273 | are received by the PEERSTORE service. Otherwise, it will | ||
1274 | disconnect immediately. | ||
1089 | 1275 | ||
1090 | @node Using the DHT | 1276 | @node Using the DHT |
1091 | @section Using the DHT | 1277 | @section Using the DHT |
@@ -1094,10 +1280,12 @@ The DHT allows to store data so other peers in the P2P network can | |||
1094 | access it and retrieve data stored by any peers in the network. | 1280 | access it and retrieve data stored by any peers in the network. |
1095 | This section will explain how to use the DHT. Of course, the first | 1281 | This section will explain how to use the DHT. Of course, the first |
1096 | thing to do is to connect to the DHT service: | 1282 | thing to do is to connect to the DHT service: |
1283 | |||
1097 | @example | 1284 | @example |
1098 | @verbatiminclude tutorial-examples/018.c | 1285 | @verbatiminclude tutorial-examples/018.c |
1099 | @end example | 1286 | @end example |
1100 | 1287 | ||
1288 | @noindent | ||
1101 | The second parameter indicates how many requests in parallel to expect. | 1289 | The second parameter indicates how many requests in parallel to expect. |
1102 | It is not a hard limit, but a good approximation will make the DHT more | 1290 | It is not a hard limit, but a good approximation will make the DHT more |
1103 | efficient. | 1291 | efficient. |
@@ -1113,27 +1301,32 @@ efficient. | |||
1113 | @subsection Storing data in the DHT | 1301 | @subsection Storing data in the DHT |
1114 | Since the DHT is a dynamic environment (peers join and leave frequently) | 1302 | Since the DHT is a dynamic environment (peers join and leave frequently) |
1115 | the data that we put in the DHT does not stay there indefinitely. It is | 1303 | the data that we put in the DHT does not stay there indefinitely. It is |
1116 | important to ``refresh'' the data periodically by simply storing it again, | 1304 | important to ``refresh'' the data periodically by simply storing it |
1117 | in order to make sure other peers can access it. | 1305 | again, in order to make sure other peers can access it. |
1118 | 1306 | ||
1119 | The put API call offers a callback to signal that the PUT request has been | 1307 | The put API call offers a callback to signal that the PUT request has been |
1120 | sent. This does not guarantee that the data is accessible to others peers, | 1308 | sent. This does not guarantee that the data is accessible to others peers, |
1121 | or even that is has been stored, only that the service has requested to | 1309 | or even that is has been stored, only that the service has requested to |
1122 | a neighboring peer the retransmission of the PUT request towards its final | 1310 | a neighboring peer the retransmission of the PUT request towards its final |
1123 | destination. Currently there is no feedback about whether or not the data | 1311 | destination. Currently there is no feedback about whether or not the data |
1124 | has been sucessfully stored or where it has been stored. In order to improve | 1312 | has been sucessfully stored or where it has been stored. In order to |
1125 | the availablilty of the data and to compensate for possible errors, peers leaving | 1313 | improve the availablilty of the data and to compensate for possible |
1126 | and other unfavorable events, just make several PUT requests! | 1314 | errors, peers leaving and other unfavorable events, just make several |
1315 | PUT requests! | ||
1316 | |||
1127 | @example | 1317 | @example |
1128 | @verbatiminclude tutorial-examples/019.c | 1318 | @verbatiminclude tutorial-examples/019.c |
1129 | @end example | 1319 | @end example |
1130 | 1320 | ||
1131 | Exercise: Store a value in the DHT periodically to make sure it is available | 1321 | @noindent |
1132 | over time. You might consider using the function @code{GNUNET\_SCHEDULER\_add\_delayed} | 1322 | Exercise: Store a value in the DHT periodically to make sure it |
1133 | and call @code{GNUNET\_DHT\_put} from inside a helper function. | 1323 | is available over time. You might consider using the function |
1324 | @code{GNUNET\_SCHEDULER\_add\_delayed} and call | ||
1325 | @code{GNUNET\_DHT\_put} from inside a helper function. | ||
1134 | 1326 | ||
1135 | @node Obtaining data from the DHT | 1327 | @node Obtaining data from the DHT |
1136 | @subsection Obtaining data from the DHT | 1328 | @subsection Obtaining data from the DHT |
1329 | |||
1137 | As we saw in the previous example, the DHT works in an asynchronous mode. | 1330 | As we saw in the previous example, the DHT works in an asynchronous mode. |
1138 | Each request to the DHT is executed ``in the background'' and the API | 1331 | Each request to the DHT is executed ``in the background'' and the API |
1139 | calls return immediately. In order to receive results from the DHT, the | 1332 | calls return immediately. In order to receive results from the DHT, the |
@@ -1143,16 +1336,20 @@ duplicates) until the timeout expires or we explicitly stop the request. | |||
1143 | It is possible to give a ``forever'' timeout with | 1336 | It is possible to give a ``forever'' timeout with |
1144 | @code{GNUNET\_TIME\_UNIT\_FOREVER\_REL}. | 1337 | @code{GNUNET\_TIME\_UNIT\_FOREVER\_REL}. |
1145 | 1338 | ||
1146 | If we give a route option @code{GNUNET\_DHT\_RO\_RECORD\_ROUTE} the callback | 1339 | If we give a route option @code{GNUNET\_DHT\_RO\_RECORD\_ROUTE} |
1147 | will get a list of all the peers the data has travelled, both on the PUT | 1340 | the callback will get a list of all the peers the data has travelled, |
1148 | path and on the GET path. | 1341 | both on the PUT path and on the GET path. |
1342 | |||
1149 | @example | 1343 | @example |
1150 | @verbatiminclude tutorial-examples/020.c | 1344 | @verbatiminclude tutorial-examples/020.c |
1151 | @end example | 1345 | @end example |
1152 | 1346 | ||
1153 | Exercise: Store a value in the DHT and after a while retrieve it. Show the IDs of all | 1347 | @noindent |
1154 | the peers the requests have gone through. In order to convert a peer ID to a string, use | 1348 | Exercise: Store a value in the DHT and after a while retrieve it. |
1155 | the function @code{GNUNET\_i2s}. Pay attention to the route option parameters in both calls! | 1349 | Show the IDs of all the peers the requests have gone through. |
1350 | In order to convert a peer ID to a string, use the function | ||
1351 | @code{GNUNET\_i2s}. Pay attention to the route option parameters | ||
1352 | in both calls! | ||
1156 | 1353 | ||
1157 | @node Implementing a block plugin | 1354 | @node Implementing a block plugin |
1158 | @subsection Implementing a block plugin | 1355 | @subsection Implementing a block plugin |
@@ -1187,10 +1384,12 @@ the @code{xquery} argument is application-specific. Applications that | |||
1187 | do not use an extended query should check that the @code{xquery\_size} | 1384 | do not use an extended query should check that the @code{xquery\_size} |
1188 | is zero. The block group is typically used to filter duplicate | 1385 | is zero. The block group is typically used to filter duplicate |
1189 | replies. | 1386 | replies. |
1387 | |||
1190 | @example | 1388 | @example |
1191 | @verbatiminclude tutorial-examples/021.c | 1389 | @verbatiminclude tutorial-examples/021.c |
1192 | @end example | 1390 | @end example |
1193 | 1391 | ||
1392 | @noindent | ||
1194 | Note that it is mandatory to detect duplicate replies in this function | 1393 | Note that it is mandatory to detect duplicate replies in this function |
1195 | and return the respective status code. Duplicate detection is | 1394 | and return the respective status code. Duplicate detection is |
1196 | typically done using the Bloom filter block group provided by | 1395 | typically done using the Bloom filter block group provided by |
@@ -1206,6 +1405,7 @@ function is used to obtain the key of a block --- for example, by | |||
1206 | means of hashing. If deriving the key is not possible, the function | 1405 | means of hashing. If deriving the key is not possible, the function |
1207 | should simply return @code{GNUNET\_SYSERR} (the DHT will still work | 1406 | should simply return @code{GNUNET\_SYSERR} (the DHT will still work |
1208 | just fine with such blocks). | 1407 | just fine with such blocks). |
1408 | |||
1209 | @example | 1409 | @example |
1210 | @verbatiminclude tutorial-examples/022.c | 1410 | @verbatiminclude tutorial-examples/022.c |
1211 | @end example | 1411 | @end example |
@@ -1218,6 +1418,7 @@ an initialization function which should initialize the plugin. The | |||
1218 | initialization function specifies what block types the plugin cares | 1418 | initialization function specifies what block types the plugin cares |
1219 | about and returns a struct with the functions that are to be used for | 1419 | about and returns a struct with the functions that are to be used for |
1220 | validation and obtaining keys (the ones just defined above). | 1420 | validation and obtaining keys (the ones just defined above). |
1421 | |||
1221 | @example | 1422 | @example |
1222 | @verbatiminclude tutorial-examples/023.c | 1423 | @verbatiminclude tutorial-examples/023.c |
1223 | @end example | 1424 | @end example |
@@ -1228,6 +1429,7 @@ validation and obtaining keys (the ones just defined above). | |||
1228 | Following GNUnet's general plugin API concept, the plugin must | 1429 | Following GNUnet's general plugin API concept, the plugin must |
1229 | export a second function for cleaning up. It usually does very | 1430 | export a second function for cleaning up. It usually does very |
1230 | little. | 1431 | little. |
1432 | |||
1231 | @example | 1433 | @example |
1232 | @verbatiminclude tutorial-examples/024.c | 1434 | @verbatiminclude tutorial-examples/024.c |
1233 | @end example | 1435 | @end example |
@@ -1237,28 +1439,34 @@ little. | |||
1237 | 1439 | ||
1238 | In order to compile the plugin, the @file{Makefile.am} file for the | 1440 | In order to compile the plugin, the @file{Makefile.am} file for the |
1239 | service SERVICE should contain a rule similar to this: | 1441 | service SERVICE should contain a rule similar to this: |
1240 | @c* Actually this is a Makefile not C. But the whole structure of examples | 1442 | @c Actually this is a Makefile not C. But the whole structure of examples |
1241 | @c* must be improved. | 1443 | @c must be improved. |
1444 | |||
1242 | @example | 1445 | @example |
1243 | @verbatiminclude tutorial-examples/025.c | 1446 | @verbatiminclude tutorial-examples/025.c |
1244 | @end example | 1447 | @end example |
1245 | 1448 | ||
1449 | @noindent | ||
1246 | Exercise: Write a block plugin that accepts all queries | 1450 | Exercise: Write a block plugin that accepts all queries |
1247 | and all replies but prints information about queries and replies | 1451 | and all replies but prints information about queries and replies |
1248 | when the respective validation hooks are called. | 1452 | when the respective validation hooks are called. |
1249 | 1453 | ||
1250 | @node Monitoring the DHT | 1454 | @node Monitoring the DHT |
1251 | @subsection Monitoring the DHT | 1455 | @subsection Monitoring the DHT |
1252 | It is possible to monitor the functioning of the local DHT service. When monitoring | 1456 | |
1253 | the DHT, the service will alert the monitoring program of any events, | 1457 | It is possible to monitor the functioning of the local |
1254 | both started locally or received for routing from another peer. The are three different | 1458 | DHT service. When monitoring the DHT, the service will |
1255 | types of events possible: a GET request, a PUT request or a response (a reply to | 1459 | alert the monitoring program of any events, both started |
1256 | a GET). | 1460 | locally or received for routing from another peer. |
1257 | 1461 | The are three different types of events possible: a | |
1258 | Since the different events have different associated data, the API gets 3 | 1462 | GET request, a PUT request or a response (a reply to a GET). |
1259 | different callbacks (one for each message type) and optional type and key parameters, | 1463 | |
1260 | to allow for filtering of messages. When an event happens, the appropiate callback | 1464 | Since the different events have different associated data, |
1261 | is called with all the information about the event. | 1465 | the API gets 3 different callbacks (one for each message type) |
1466 | and optional type and key parameters, to allow for filtering of | ||
1467 | messages. When an event happens, the appropiate callback is | ||
1468 | called with all the information about the event. | ||
1469 | |||
1262 | @example | 1470 | @example |
1263 | @verbatiminclude tutorial-examples/026.c | 1471 | @verbatiminclude tutorial-examples/026.c |
1264 | @end example | 1472 | @end example |
@@ -1266,17 +1474,20 @@ is called with all the information about the event. | |||
1266 | @node Debugging with gnunet-arm | 1474 | @node Debugging with gnunet-arm |
1267 | @section Debugging with gnunet-arm | 1475 | @section Debugging with gnunet-arm |
1268 | 1476 | ||
1269 | Even if services are managed by @command{gnunet-arm}, you can start them with | 1477 | Even if services are managed by @command{gnunet-arm}, you can |
1270 | @command{gdb} or @command{valgrind}. For example, you could add the following lines | 1478 | start them with @command{gdb} or @command{valgrind}. For |
1271 | to your configuration file to start the DHT service in a @command{gdb} session in a | 1479 | example, you could add the following lines to your |
1272 | fresh @command{xterm}: | 1480 | configuration file to start the DHT service in a @command{gdb} |
1481 | session in a fresh @command{xterm}: | ||
1273 | 1482 | ||
1274 | @example | 1483 | @example |
1275 | [dht] | 1484 | [dht] |
1276 | PREFIX=xterm -e gdb --args | 1485 | PREFIX=xterm -e gdb --args |
1277 | @end example | 1486 | @end example |
1278 | 1487 | ||
1279 | Alternatively, you can stop a service that was started via ARM and run it manually: | 1488 | @noindent |
1489 | Alternatively, you can stop a service that was started via | ||
1490 | ARM and run it manually: | ||
1280 | 1491 | ||
1281 | @example | 1492 | @example |
1282 | $ gnunet-arm -k dht | 1493 | $ gnunet-arm -k dht |
@@ -1284,20 +1495,23 @@ $ gdb --args gnunet-service-dht -L DEBUG | |||
1284 | $ valgrind gnunet-service-dht -L DEBUG | 1495 | $ valgrind gnunet-service-dht -L DEBUG |
1285 | @end example | 1496 | @end example |
1286 | 1497 | ||
1287 | Assuming other services are well-written, they will automatically re-integrate the | 1498 | @noindent |
1288 | restarted service with the peer. | 1499 | Assuming other services are well-written, they will automatically |
1500 | re-integrate the restarted service with the peer. | ||
1289 | 1501 | ||
1290 | GNUnet provides a powerful logging mechanism providing log levels @code{ERROR}, | 1502 | GNUnet provides a powerful logging mechanism providing log |
1291 | @code{WARNING}, @code{INFO} and @code{DEBUG}. The current log level is | 1503 | levels @code{ERROR}, @code{WARNING}, @code{INFO} and @code{DEBUG}. |
1292 | configured using the @code{$GNUNET_FORCE_LOG} environmental variable. | 1504 | The current log level is configured using the @code{$GNUNET_FORCE_LOG} |
1293 | The @code{DEBUG} level is only available if @command{--enable-logging=verbose} was used when | 1505 | environmental variable. The @code{DEBUG} level is only available if |
1294 | running @command{configure}. More details about logging can be found under | 1506 | @command{--enable-logging=verbose} was used when running |
1507 | @command{configure}. More details about logging can be found under | ||
1295 | @uref{https://gnunet.org/logging}. | 1508 | @uref{https://gnunet.org/logging}. |
1296 | 1509 | ||
1297 | You should also probably enable the creation of core files, by setting | 1510 | You should also probably enable the creation of core files, by setting |
1298 | @code{ulimit}, and echo'ing @code{1} into @file{/proc/sys/kernel/core\_uses\_pid}. | 1511 | @code{ulimit}, and echo'ing @code{1} into |
1299 | Then you can investigate the core dumps with @command{gdb}, which is often | 1512 | @file{/proc/sys/kernel/core\_uses\_pid}. Then you can investigate the |
1300 | the fastest method to find simple errors. | 1513 | core dumps with @command{gdb}, which is often the fastest method to |
1514 | find simple errors. | ||
1301 | 1515 | ||
1302 | Exercise: Add a memory leak to your service and obtain a trace | 1516 | Exercise: Add a memory leak to your service and obtain a trace |
1303 | pointing to the leak using @command{valgrind} while running the service | 1517 | pointing to the leak using @command{valgrind} while running the service |
diff --git a/doc/gnunet.texi b/doc/documentation/gnunet.texi index 7803e52d3..2497d4b09 100644 --- a/doc/gnunet.texi +++ b/doc/documentation/gnunet.texi | |||
@@ -5,15 +5,17 @@ | |||
5 | @setfilename gnunet.info | 5 | @setfilename gnunet.info |
6 | @documentencoding UTF-8 | 6 | @documentencoding UTF-8 |
7 | @settitle GNUnet Reference Manual | 7 | @settitle GNUnet Reference Manual |
8 | @exampleindent 2 | ||
9 | @urefbreakstyle before | ||
8 | @c %**end of header | 10 | @c %**end of header |
9 | 11 | ||
10 | @include version.texi | 12 | @include version.texi |
11 | 13 | ||
12 | @c Set Versions which might be used in more than one place: | 14 | @c Set Versions which might be used in more than one place: |
13 | @set GNUNET-DIST-URL https://ftp.gnu.org/gnu/gnunet/ | 15 | @set GNUFTP-URL https://ftp.gnu.org/gnu/gnunet |
14 | @set GNUNET-VERSION 0.10.1 | 16 | @set PYPI-URL https://pypi.python.org/packages/source |
15 | @set GNURL-VERSION-CURRENT 7.55.1 | 17 | @set GNURL-VERSION-CURRENT 7.55.1 |
16 | @set GNURL-DIST-URL https://gnunet.org/sites/default/files/ | 18 | @set GNUNET-DIST-URL https://gnunet.org/sites/default/files/ |
17 | @c @set OPENPGP-SIGNING-KEY-ID | 19 | @c @set OPENPGP-SIGNING-KEY-ID |
18 | 20 | ||
19 | @copying | 21 | @copying |
@@ -38,6 +40,13 @@ A copy of the license is also available from the Free Software | |||
38 | Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. | 40 | Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}. |
39 | @end copying | 41 | @end copying |
40 | 42 | ||
43 | @c TODO: Improve this and improve https://directory.fsf.org/wiki/Gnunet | ||
44 | |||
45 | @dircategory Networking | ||
46 | @direntry | ||
47 | * GNUnet: (gnunet). Framework for secure peer-to-peer networking | ||
48 | @end direntry | ||
49 | |||
41 | @titlepage | 50 | @titlepage |
42 | @title GNUnet Reference Manual | 51 | @title GNUnet Reference Manual |
43 | @subtitle Installing, configuring, using and contributing to GNUnet | 52 | @subtitle Installing, configuring, using and contributing to GNUnet |
@@ -51,26 +60,27 @@ Edition @value{EDITION} @* | |||
51 | @insertcopying | 60 | @insertcopying |
52 | @end titlepage | 61 | @end titlepage |
53 | 62 | ||
63 | @summarycontents | ||
54 | @contents | 64 | @contents |
55 | @c ********************************************************************* | 65 | |
56 | @node Top | 66 | @node Top |
57 | @top Contributing to GNUnet | 67 | @top Contributing to GNUnet |
58 | @c ********************************************************************* | 68 | |
59 | 69 | ||
60 | This document describes GNUnet version @value{VERSION}. | 70 | This document describes GNUnet version @value{VERSION}. |
61 | 71 | ||
62 | 72 | ||
63 | GNUnet is a @uref{http://www.gnu.org/, GNU} package. All code contributions | 73 | GNUnet is a @uref{http://www.gnu.org/, GNU} package. |
64 | must thus be put under the | 74 | All code contributions must thus be put under the |
65 | @uref{http://www.gnu.org/copyleft/gpl.html, GNU Public License (GPL)}. | 75 | @uref{http://www.gnu.org/copyleft/gpl.html, GNU Public License (GPL)}. |
66 | All documentation should be put under FSF approved licenses | 76 | All documentation should be put under FSF approved licenses |
67 | (see @uref{http://www.gnu.org/copyleft/fdl.html, fdl}). | 77 | (see @uref{http://www.gnu.org/copyleft/fdl.html, fdl}). |
68 | 78 | ||
69 | By submitting documentation, translations, comments and other content to this | 79 | By submitting documentation, translations, comments and other |
70 | website you automatically grant the right to publish code under the | 80 | content to this website you automatically grant the right to publish |
71 | GNU Public License and documentation under either or both the GNU | 81 | code under the GNU Public License and documentation under either or |
72 | Public License or the GNU Free Documentation License. When contributing | 82 | both the GNU Public License or the GNU Free Documentation License. |
73 | to the GNUnet project, GNU standards and the | 83 | When contributing to the GNUnet project, GNU standards and the |
74 | @uref{http://www.gnu.org/philosophy/philosophy.html, GNU philosophy} | 84 | @uref{http://www.gnu.org/philosophy/philosophy.html, GNU philosophy} |
75 | should be adhered to. | 85 | should be adhered to. |
76 | 86 | ||
@@ -83,23 +93,25 @@ rights, and in particular is allowed to dual-license the code. You | |||
83 | retain non-exclusive rights to your contributions, so you can also | 93 | retain non-exclusive rights to your contributions, so you can also |
84 | share your contributions freely with other projects. | 94 | share your contributions freely with other projects. |
85 | 95 | ||
86 | GNUnet e.V. will publish all accepted contributions under the GPLv3 or any | 96 | GNUnet e.V. will publish all accepted contributions under the GPLv3 |
87 | later version. The association may decide to publish contributions under | 97 | or any later version. The association may decide to publish |
88 | additional licenses (dual-licensing). | 98 | contributions under additional licenses (dual-licensing). |
89 | 99 | ||
90 | We do not intentionally remove your name from your contributions; however, | 100 | We do not intentionally remove your name from your contributions; |
91 | due to extensive editing it is not always trivial to attribute contributors | 101 | however, due to extensive editing it is not always trivial to |
92 | properly. If you find that you significantly contributed to a file (or the | 102 | attribute contributors properly. If you find that you significantly |
93 | project as a whole) and are not listed in the respective authors file or | 103 | contributed to a file (or the project as a whole) and are not listed |
94 | section, please do let us know. | 104 | in the respective authors file or section, please do let us know. |
95 | 105 | ||
96 | 106 | ||
97 | 107 | ||
98 | @menu | 108 | @menu |
99 | 109 | ||
100 | * Philosophy:: About GNUnet | 110 | * Philosophy:: About GNUnet |
111 | * Vocabulary:: Vocabulary | ||
101 | * GNUnet Installation Handbook:: How to install GNUnet | 112 | * GNUnet Installation Handbook:: How to install GNUnet |
102 | * Using GNUnet:: Using GNUnet | 113 | * Using GNUnet:: Using GNUnet |
114 | * Configuration Handbook:: Configuring GNUnet | ||
103 | * GNUnet Developer Handbook:: Developing GNUnet | 115 | * GNUnet Developer Handbook:: Developing GNUnet |
104 | * GNU Free Documentation License:: The license of this manual. | 116 | * GNU Free Documentation License:: The license of this manual. |
105 | * GNU General Public License:: The license of this manual. | 117 | * GNU General Public License:: The license of this manual. |
@@ -127,10 +139,77 @@ Philosophy | |||
127 | * Backup of Identities and Egos:: | 139 | * Backup of Identities and Egos:: |
128 | * Revocation:: | 140 | * Revocation:: |
129 | 141 | ||
130 | Installation | 142 | Vocabulary |
143 | |||
144 | * Words and characters:: | ||
145 | * Technical Assumptions:: | ||
146 | |||
147 | GNUnet Installation Handbook | ||
131 | 148 | ||
132 | * Dependencies:: | 149 | * Dependencies:: |
133 | * External dependencies:: | 150 | * Pre-installation notes:: |
151 | * Generic installation instructions:: | ||
152 | * Build instructions for Ubuntu 12.04 using Git:: | ||
153 | * Build Instructions for Microsoft Windows Platforms:: | ||
154 | * Build instructions for Debian 7.5:: | ||
155 | * Installing GNUnet from Git on Ubuntu 14.4:: | ||
156 | * Build instructions for Debian 8:: | ||
157 | * Outdated build instructions for previous revisions:: | ||
158 | @c * Portable GNUnet:: | ||
159 | * The graphical configuration interface:: | ||
160 | * How to start and stop a GNUnet peer:: | ||
161 | |||
162 | Configuration Handbook | ||
163 | |||
164 | Using GNUnet | ||
165 | |||
166 | * Checking the Installation:: | ||
167 | * First steps - File-sharing:: | ||
168 | * First steps - Using the GNU Name System:: | ||
169 | * First steps - Using GNUnet Conversation:: | ||
170 | * First steps - Using the GNUnet VPN:: | ||
171 | * File-sharing:: | ||
172 | * The GNU Name System:: | ||
173 | * Using the Virtual Public Network:: | ||
174 | |||
175 | GNUnet Developer Handbook | ||
176 | |||
177 | * Developer Introduction:: | ||
178 | * Code overview:: | ||
179 | * System Architecture:: | ||
180 | * Subsystem stability:: | ||
181 | * Naming conventions and coding style guide:: | ||
182 | * Build-system:: | ||
183 | * Developing extensions for GNUnet using the gnunet-ext template:: | ||
184 | * Writing testcases:: | ||
185 | * GNUnet's TESTING library:: | ||
186 | * Performance regression analysis with Gauger:: | ||
187 | * GNUnet's TESTBED Subsystem:: | ||
188 | * libgnunetutil:: | ||
189 | * The Automatic Restart Manager (ARM):: | ||
190 | * GNUnet's TRANSPORT Subsystem:: | ||
191 | * NAT library:: | ||
192 | * Distance-Vector plugin:: | ||
193 | * SMTP plugin:: | ||
194 | * Bluetooth plugin:: | ||
195 | * WLAN plugin:: | ||
196 | * The ATS Subsystem:: | ||
197 | * GNUnet's CORE Subsystem:: | ||
198 | * GNUnet's CADET subsystem:: | ||
199 | * GNUnet's NSE subsystem:: | ||
200 | * GNUnet's HOSTLIST subsystem:: | ||
201 | * GNUnet's IDENTITY subsystem:: | ||
202 | * GNUnet's NAMESTORE Subsystem:: | ||
203 | * GNUnet's PEERINFO subsystem:: | ||
204 | * GNUnet's PEERSTORE subsystem:: | ||
205 | * GNUnet's SET Subsystem:: | ||
206 | * GNUnet's STATISTICS subsystem:: | ||
207 | * GNUnet's Distributed Hash Table (DHT):: | ||
208 | * The GNU Name System (GNS):: | ||
209 | * The GNS Namecache:: | ||
210 | * The REVOCATION Subsystem:: | ||
211 | * GNUnet's File-sharing (FS) Subsystem:: | ||
212 | * GNUnet's REGEX Subsystem:: | ||
134 | 213 | ||
135 | @end detailmenu | 214 | @end detailmenu |
136 | @end menu | 215 | @end menu |
@@ -139,6 +218,8 @@ Installation | |||
139 | @include chapters/philosophy.texi | 218 | @include chapters/philosophy.texi |
140 | @c ********************************************************************* | 219 | @c ********************************************************************* |
141 | 220 | ||
221 | @include chapters/vocabulary.texi | ||
222 | |||
142 | @c ********************************************************************* | 223 | @c ********************************************************************* |
143 | @include chapters/installation.texi | 224 | @include chapters/installation.texi |
144 | @c ********************************************************************* | 225 | @c ********************************************************************* |
@@ -147,11 +228,13 @@ Installation | |||
147 | @include chapters/user.texi | 228 | @include chapters/user.texi |
148 | @c ********************************************************************* | 229 | @c ********************************************************************* |
149 | 230 | ||
231 | @include chapters/configuration.texi | ||
232 | |||
150 | @c ********************************************************************* | 233 | @c ********************************************************************* |
151 | @include chapters/developer.texi | 234 | @include chapters/developer.texi |
235 | @c @include gnunet-c-tutorial.texi | ||
152 | @c ********************************************************************* | 236 | @c ********************************************************************* |
153 | 237 | ||
154 | |||
155 | @c ********************************************************************* | 238 | @c ********************************************************************* |
156 | @node GNU Free Documentation License | 239 | @node GNU Free Documentation License |
157 | @appendix GNU Free Documentation License | 240 | @appendix GNU Free Documentation License |
diff --git a/doc/gpl-3.0.texi b/doc/documentation/gpl-3.0.texi index 0e2e212ac..0e2e212ac 100644 --- a/doc/gpl-3.0.texi +++ b/doc/documentation/gpl-3.0.texi | |||
diff --git a/doc/documentation/htmlxref.cnf b/doc/documentation/htmlxref.cnf new file mode 100644 index 000000000..9ab9e4158 --- /dev/null +++ b/doc/documentation/htmlxref.cnf | |||
@@ -0,0 +1,668 @@ | |||
1 | # htmlxref.cnf - reference file for free Texinfo manuals on the web. | ||
2 | # Modified by Ludovic Courtès <ludo@gnu.org> for the GNU Guix manual. | ||
3 | # Modified by ng0 <ng0@gnunet.org> for the GNUnet manual. | ||
4 | |||
5 | htmlxrefversion=2017-10-25.16; # UTC | ||
6 | |||
7 | # Copyright 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc. | ||
8 | # | ||
9 | # Copying and distribution of this file, with or without modification, | ||
10 | # are permitted in any medium without royalty provided the copyright | ||
11 | # notice and this notice are preserved. | ||
12 | # | ||
13 | # The latest version of this file is available at | ||
14 | # http://ftpmirror.gnu.org/texinfo/htmlxref.cnf. | ||
15 | # Email corrections or additions to bug-texinfo@gnu.org. | ||
16 | # The primary goal is to list all relevant GNU manuals; | ||
17 | # other free manuals are also welcome. | ||
18 | # | ||
19 | # To be included in this list, a manual must: | ||
20 | # | ||
21 | # - have a generic url, e.g., no version numbers; | ||
22 | # - have a unique file name (e.g., manual identifier), i.e., be related to the | ||
23 | # package name. Things like "refman" or "tutorial" don't work. | ||
24 | # - follow the naming convention for nodes described at | ||
25 | # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref.html | ||
26 | # This is what makeinfo and texi2html implement. | ||
27 | # | ||
28 | # Unless the above criteria are met, it's not possible to generate | ||
29 | # reliable cross-manual references. | ||
30 | # | ||
31 | # For information on automatically generating all the useful formats for | ||
32 | # a manual to put on the web, see | ||
33 | # http://www.gnu.org/prep/maintain/html_node/Manuals-on-Web-Pages.html. | ||
34 | |||
35 | # For people editing this file: when a manual named foo is related to a | ||
36 | # package named bar, the url should contain a variable reference ${BAR}. | ||
37 | # Otherwise, the gnumaint scripts have no way of knowing they are | ||
38 | # associated, and thus gnu.org/manual can't include them. | ||
39 | |||
40 | # shorten references to manuals on www.gnu.org. | ||
41 | G = https://www.gnu.org | ||
42 | GS = ${G}/software | ||
43 | |||
44 | 3dldf mono ${GS}/3dldf/manual/user_ref/3DLDF.html | ||
45 | 3dldf node ${GS}/3dldf/manual/user_ref/ | ||
46 | |||
47 | alive mono ${GS}/alive/manual/alive.html | ||
48 | alive node ${GS}/alive/manual/html_node/ | ||
49 | |||
50 | anubis chapter ${GS}/anubis/manual/html_chapter/ | ||
51 | anubis section ${GS}/anubis/manual/html_section/ | ||
52 | anubis node ${GS}/anubis/manual/html_node/ | ||
53 | |||
54 | artanis mono ${GS}/artanis/manual/artanis.html | ||
55 | artanis node ${GS}/artanis/manual/html_node/ | ||
56 | |||
57 | aspell section http://aspell.net/man-html/index.html | ||
58 | |||
59 | auctex mono ${GS}/auctex/manual/auctex.html | ||
60 | auctex node ${GS}/auctex/manual/auctex/ | ||
61 | |||
62 | autoconf mono ${GS}/autoconf/manual/autoconf.html | ||
63 | autoconf node ${GS}/autoconf/manual/html_node/ | ||
64 | |||
65 | autogen mono ${GS}/autogen/manual/html_mono/autogen.html | ||
66 | autogen chapter ${GS}/autogen/manual/html_chapter/ | ||
67 | autogen node ${GS}/autoconf/manual/html_node/ | ||
68 | |||
69 | automake mono ${GS}/automake/manual/automake.html | ||
70 | automake node ${GS}/automake/manual/html_node/ | ||
71 | |||
72 | avl node http://www.stanford.edu/~blp/avl/libavl.html/ | ||
73 | |||
74 | bash mono ${GS}/bash/manual/bash.html | ||
75 | bash node ${GS}/bash/manual/html_node/ | ||
76 | |||
77 | BINUTILS = http://sourceware.org/binutils/docs | ||
78 | binutils node ${BINUTILS}/binutils/ | ||
79 | as node ${BINUTILS}/as/ | ||
80 | bfd node ${BINUTILS}/bfd/ | ||
81 | gprof node ${BINUTILS}/gprof/ | ||
82 | ld node ${BINUTILS}/ld/ | ||
83 | |||
84 | bison mono ${GS}/bison/manual/bison.html | ||
85 | bison node ${GS}/bison/manual/html_node/ | ||
86 | |||
87 | bpel2owfn mono ${GS}/bpel2owfn/manual/2.0.x/bpel2owfn.html | ||
88 | |||
89 | ccd2cue mono ${GS}/ccd2cue/manual/ccd2cue.html | ||
90 | ccd2cue node ${GS}/ccd2cue/manual/html_node/ | ||
91 | |||
92 | cflow mono ${GS}/cflow/manual/cflow.html | ||
93 | cflow node ${GS}/cflow/manual/html_node/ | ||
94 | |||
95 | chess mono ${GS}/chess/manual/gnuchess.html | ||
96 | chess node ${GS}/chess/manual/html_node/ | ||
97 | |||
98 | combine mono ${GS}/combine/manual/combine.html | ||
99 | combine chapter ${GS}/combine/manual/html_chapter/ | ||
100 | combine section ${GS}/combine/manual/html_section/ | ||
101 | combine node ${GS}/combine/manual/html_node/ | ||
102 | |||
103 | complexity mono ${GS}/complexity/manual/complexity.html | ||
104 | complexity node ${GS}/complexity/manual/html_node/ | ||
105 | |||
106 | coreutils mono ${GS}/coreutils/manual/coreutils | ||
107 | coreutils node ${GS}/coreutils/manual/html_node/ | ||
108 | |||
109 | cpio mono ${GS}/cpio/manual/cpio | ||
110 | cpio node ${GS}/cpio/manual/html_node/ | ||
111 | |||
112 | cssc node ${GS}/cssc/manual/ | ||
113 | |||
114 | #cvs cannot be handled here; see http://ximbiot.com/cvs/manual. | ||
115 | |||
116 | ddd mono ${GS}/ddd/manual/html_mono/ddd.html | ||
117 | |||
118 | ddrescue mono ${GS}/ddrescue/manual/ddrescue_manual.html | ||
119 | |||
120 | DICO = http://puszcza.gnu.org.ua/software/dico/manual | ||
121 | dico mono ${DICO}/dico.html | ||
122 | dico chapter ${DICO}/html_chapter/ | ||
123 | dico section ${DICO}/html_section/ | ||
124 | dico node ${DICO}/html_node/ | ||
125 | |||
126 | diffutils mono ${GS}/diffutils/manual/diffutils | ||
127 | diffutils node ${GS}/diffutils/manual/html_node/ | ||
128 | |||
129 | ed mono ${GS}/ed/manual/ed_manual.html | ||
130 | |||
131 | EMACS = ${GS}/emacs/manual | ||
132 | emacs mono ${EMACS}/html_mono/emacs.html | ||
133 | emacs node ${EMACS}/html_node/emacs/ | ||
134 | # | ||
135 | ada-mode mono ${EMACS}/html_mono/ada-mode.html | ||
136 | ada-mode node ${EMACS}/html_node/ada-mode/ | ||
137 | # | ||
138 | autotype mono ${EMACS}/html_mono/autotype.html | ||
139 | autotype node ${EMACS}/html_node/autotype/ | ||
140 | # | ||
141 | ccmode mono ${EMACS}/html_mono/ccmode.html | ||
142 | ccmode node ${EMACS}/html_node/ccmode/ | ||
143 | # | ||
144 | cl mono ${EMACS}/html_mono/cl.html | ||
145 | cl node ${EMACS}/html_node/cl/ | ||
146 | # | ||
147 | ebrowse mono ${EMACS}/html_mono/ebrowse.html | ||
148 | ebrowse node ${EMACS}/html_node/ebrowse/ | ||
149 | # | ||
150 | ediff mono ${EMACS}/html_mono/ediff.html | ||
151 | ediff node ${EMACS}/html_node/ediff/ | ||
152 | # | ||
153 | eieio mono ${EMACS}/html_mono/eieio.html | ||
154 | eieio node ${EMACS}/html_node/eieio/ | ||
155 | # | ||
156 | elisp mono ${EMACS}/html_mono/elisp.html | ||
157 | elisp node ${EMACS}/html_node/elisp/ | ||
158 | # | ||
159 | epa mono ${EMACS}/html_mono/epa.html | ||
160 | epa node ${EMACS}/html_node/epa/ | ||
161 | # | ||
162 | erc mono ${EMACS}/html_mono/erc.html | ||
163 | erc node ${EMACS}/html_node/erc/ | ||
164 | # | ||
165 | dired-x mono ${EMACS}/html_mono/dired-x.html | ||
166 | dired-x node ${EMACS}/html_node/dired-x/ | ||
167 | # | ||
168 | eshell mono ${EMACS}/html_mono/eshell.html | ||
169 | eshell node ${EMACS}/html_node/eshell/ | ||
170 | # | ||
171 | flymake mono ${EMACS}/html_mono/flymake.html | ||
172 | flymake node ${EMACS}/html_node/flymake/ | ||
173 | # | ||
174 | gnus mono ${EMACS}/html_mono/gnus.html | ||
175 | gnus node ${EMACS}/html_node/gnus/ | ||
176 | # | ||
177 | idlwave mono ${EMACS}/html_mono/idlwave.html | ||
178 | idlwave node ${EMACS}/html_node/idlwave/ | ||
179 | # | ||
180 | message mono ${EMACS}/html_mono/message.html | ||
181 | message node ${EMACS}/html_node/message/ | ||
182 | # | ||
183 | mh-e mono ${EMACS}/html_mono/mh-e.html | ||
184 | mh-e node ${EMACS}/html_node/mh-e/ | ||
185 | # | ||
186 | nxml-mode mono ${EMACS}/html_mono/nxml-mode.html | ||
187 | nxml-mode node ${EMACS}/html_node/nxml-mode/ | ||
188 | # | ||
189 | org mono ${EMACS}/html_mono/org.html | ||
190 | org node ${EMACS}/html_node/org/ | ||
191 | # | ||
192 | pcl-cvs mono ${EMACS}/html_mono/pcl-cvs.html | ||
193 | pcl-cvs node ${EMACS}/html_node/pcl-cvs/ | ||
194 | # | ||
195 | rcirc mono ${EMACS}/html_mono/rcirc.html | ||
196 | rcirc node ${EMACS}/html_node/rcirc/ | ||
197 | # | ||
198 | semantic mono ${EMACS}/html_mono/semantic.html | ||
199 | semantic node ${EMACS}/html_node/semantic/ | ||
200 | # | ||
201 | smtp mono ${EMACS}/html_mono/smtpmail.html | ||
202 | smtp node ${EMACS}/html_node/smtpmail/ | ||
203 | # | ||
204 | speedbar mono ${EMACS}/html_mono/speedbar.html | ||
205 | speedbar node ${EMACS}/html_node/speedbar/ | ||
206 | # | ||
207 | tramp mono ${EMACS}/html_mono/tramp.html | ||
208 | tramp node ${EMACS}/html_node/tramp/ | ||
209 | # | ||
210 | vip mono ${EMACS}/html_mono/vip.html | ||
211 | vip node ${EMACS}/html_node/vip/ | ||
212 | # | ||
213 | viper mono ${EMACS}/html_mono/viper.html | ||
214 | viper node ${EMACS}/html_node/viper/ | ||
215 | # | ||
216 | woman mono ${EMACS}/html_mono/woman.html | ||
217 | woman node ${EMACS}/html_node/woman/ | ||
218 | # (end emacs manuals) | ||
219 | |||
220 | easejs mono ${GS}/easejs/manual/easejs.html | ||
221 | easejs node ${GS}/easejs/manual/ | ||
222 | |||
223 | EMACS_GUIX = https://alezost.github.io/guix.el/manual/latest | ||
224 | emacs-guix mono ${EMACS_GUIX}/emacs-guix.html | ||
225 | emacs-guix node ${EMACS_GUIX}/html_node/ | ||
226 | |||
227 | emacs-muse node ${GS}/emacs-muse/manual/muse.html | ||
228 | emacs-muse node ${GS}/emacs-muse/manual/html_node/ | ||
229 | |||
230 | emms node ${GS}/emms/manual/ | ||
231 | |||
232 | # The file is called 'find.info' but the package is 'findutils'. | ||
233 | find mono ${GS}/findutils/manual/html_mono/find.html | ||
234 | find node ${GS}/findutils/manual/html_node/find_html | ||
235 | findutils mono ${GS}/findutils/manual/html_mono/find.html | ||
236 | findutils node ${GS}/findutils/manual/html_node/find_html | ||
237 | |||
238 | FLEX = http://flex.sourceforge.net | ||
239 | flex node ${FLEX}/manual/ | ||
240 | |||
241 | gama mono ${GS}/gama/manual/gama.html | ||
242 | gama node ${GS}/gama/manual/html_node/ | ||
243 | |||
244 | GAWK = ${GS}/gawk/manual | ||
245 | gawk mono ${GAWK}/gawk.html | ||
246 | gawk node ${GAWK}/html_node/ | ||
247 | gawkinet mono ${GAWK}/gawkinet/gawkinet.html | ||
248 | gawkinet node ${GAWK}/gawkinet/html_node/ | ||
249 | |||
250 | gcal mono ${GS}/gcal/manual/gcal.html | ||
251 | gcal node ${GS}/gcal/manual/html_node/ | ||
252 | |||
253 | GCC = http://gcc.gnu.org/onlinedocs | ||
254 | gcc node ${GCC}/gcc/ | ||
255 | cpp node ${GCC}/cpp/ | ||
256 | gcj node ${GCC}/gcj/ | ||
257 | gfortran node ${GCC}/gfortran/ | ||
258 | gnat_rm node ${GCC}/gnat_rm/ | ||
259 | gnat_ugn_unw node ${GCC}/gnat_ugn_unw/ | ||
260 | libgomp node ${GCC}/libgomp/ | ||
261 | libstdc++ node ${GCC}/libstdc++/ | ||
262 | # | ||
263 | gccint node ${GCC}/gccint/ | ||
264 | cppinternals node ${GCC}/cppinternals/ | ||
265 | gfc-internals node ${GCC}/gfc-internals/ | ||
266 | gnat-style node ${GCC}/gnat-style/ | ||
267 | libiberty node ${GCC}/libiberty/ | ||
268 | |||
269 | GDB = http://sourceware.org/gdb/current/onlinedocs | ||
270 | gdb node ${GDB}/gdb/ | ||
271 | stabs node ${GDB}/stabs/ | ||
272 | |||
273 | GDBM = http://www.gnu.org.ua/software/gdbm/manual | ||
274 | gdbm mono ${GDBM}/gdbm.html | ||
275 | gdbm chapter ${GDBM}/html_chapter/ | ||
276 | gdbm section ${GDBM}/html_section/ | ||
277 | gdbm node ${GDBM}/html_node/ | ||
278 | |||
279 | gettext mono ${GS}/gettext/manual/gettext.html | ||
280 | gettext node ${GS}/gettext/manual/html_node/ | ||
281 | |||
282 | gforth node http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/ | ||
283 | |||
284 | global mono ${GS}/global/manual/global.html | ||
285 | |||
286 | gmediaserver node ${GS}/gmediaserver/manual/ | ||
287 | |||
288 | gmp node http://www.gmplib.org/manual/ | ||
289 | |||
290 | gnu-arch node ${GS}/gnu-arch/tutorial/ | ||
291 | |||
292 | gnu-c-manual mono ${GS}/gnu-c-manual/gnu-c-manual.html | ||
293 | |||
294 | gnu-crypto node ${GS}/gnu-crypto/manual/ | ||
295 | |||
296 | gnubg mono ${GS}/gnubg/manual/gnubg.html | ||
297 | gnubg node ${GS}/gnubg/manual/html_node/ | ||
298 | |||
299 | gnubik mono ${GS}/gnubik/manual/gnubik.html | ||
300 | gnubik node ${GS}/gnubik/manual/html_node/ | ||
301 | |||
302 | gnulib mono ${GS}/gnulib/manual/gnulib.html | ||
303 | gnulib node ${GS}/gnulib/manual/html_node/ | ||
304 | |||
305 | GNUN = ${GS}/trans-coord/manual | ||
306 | gnun mono ${GNUN}/gnun/gnun.html | ||
307 | gnun node ${GNUN}/gnun/html_node/ | ||
308 | web-trans mono ${GNUN}/web-trans/web-trans.html | ||
309 | web-trans node ${GNUN}/web-trans/html_node/ | ||
310 | |||
311 | GNUNET = https://docs.gnunet.org/manuals | ||
312 | gnunet node ${GNUNET}/gnunet/ | ||
313 | gnunet-c-tutorial node ${GNUNET}/gnunet-c-tutorial/ | ||
314 | gnunet-java-tutorial node ${GNUNET}/gnunet-java-tutorial/ | ||
315 | |||
316 | GNUPG = http://www.gnupg.org/documentation/manuals | ||
317 | gnupg node ${GNUPG}/gnupg/ | ||
318 | dirmngr node ${GNUPG}/dirmngr/ | ||
319 | gcrypt node ${GNUPG}/gcrypt/ | ||
320 | libgcrypt node ${GNUPG}/gcrypt/ | ||
321 | ksba node ${GNUPG}/ksba/ | ||
322 | assuan node ${GNUPG}/assuan/ | ||
323 | gpgme node ${GNUPG}/gpgme/ | ||
324 | |||
325 | gnuprologjava node ${GS}/gnuprologjava/manual/ | ||
326 | |||
327 | gnuschool mono ${GS}/gnuschool/gnuschool.html | ||
328 | |||
329 | GNUSTANDARDS = ${G}/prep | ||
330 | maintain mono ${GNUSTANDARDS}/maintain/maintain.html | ||
331 | maintain node ${GNUSTANDARDS}/maintain/html_node/ | ||
332 | # | ||
333 | standards mono ${GNUSTANDARDS}/standards/standards.html | ||
334 | standards node ${GNUSTANDARDS}/standards/html_node/ | ||
335 | |||
336 | gnutls mono http://gnutls.org/manual/gnutls.html | ||
337 | gnutls node http://gnutls.org/manual/html_node/ | ||
338 | |||
339 | gnutls-guile mono http://gnutls.org/manual/gnutls-guile.html | ||
340 | gnutls-guile node http://gnutls.org/manual/gnutls-guile/ | ||
341 | |||
342 | gperf mono ${GS}/gperf/manual/gperf.html | ||
343 | gperf node ${GS}/gperf/manual/html_node/ | ||
344 | |||
345 | grep mono ${GS}/grep/manual/grep.html | ||
346 | grep node ${GS}/grep/manual/html_node/ | ||
347 | |||
348 | groff node ${GS}/groff/manual/html_node/ | ||
349 | |||
350 | GRUB = ${GS}/grub/manual | ||
351 | grub mono ${GRUB}/grub.html | ||
352 | grub node ${GRUB}/html_node/ | ||
353 | # | ||
354 | multiboot mono ${GRUB}/multiboot/multiboot.html | ||
355 | multiboot node ${GRUB}/multiboot/html_node/ | ||
356 | |||
357 | gsasl mono ${GS}/gsasl/manual/gsasl.html | ||
358 | gsasl node ${GS}/gsasl/manual/html_node/ | ||
359 | |||
360 | gsl node ${GS}/gsl/manual/html_node/ | ||
361 | |||
362 | gsrc mono ${GS}/gsrc/manual/gsrc.html | ||
363 | gsrc node ${GS}/gsrc/manual/html_node/ | ||
364 | |||
365 | gss mono ${GS}/gss/manual/gss.html | ||
366 | gss node ${GS}/gss/manual/html_node/ | ||
367 | |||
368 | gtypist mono ${GS}/gtypist/doc/ | ||
369 | |||
370 | guile mono ${GS}/guile/manual/guile.html | ||
371 | guile node ${GS}/guile/manual/html_node/ | ||
372 | |||
373 | guile-avahi mono http://nongnu.org/guile-avahi/doc/guile-avahi.html | ||
374 | |||
375 | GUILE_GNOME = ${GS}/guile-gnome/docs | ||
376 | gobject node ${GUILE_GNOME}/gobject/html/ | ||
377 | glib node ${GUILE_GNOME}/glib/html/ | ||
378 | atk node ${GUILE_GNOME}/atk/html/ | ||
379 | pango node ${GUILE_GNOME}/pango/html/ | ||
380 | pangocairo node ${GUILE_GNOME}/pangocairo/html/ | ||
381 | gdk node ${GUILE_GNOME}/gdk/html/ | ||
382 | gtk node ${GUILE_GNOME}/gtk/html/ | ||
383 | libglade node ${GUILE_GNOME}/libglade/html/ | ||
384 | gnome-vfs node ${GUILE_GNOME}/gnome-vfs/html/ | ||
385 | libgnomecanvas node ${GUILE_GNOME}/libgnomecanvas/html/ | ||
386 | gconf node ${GUILE_GNOME}/gconf/html/ | ||
387 | libgnome node ${GUILE_GNOME}/libgnome/html/ | ||
388 | libgnomeui node ${GUILE_GNOME}/libgnomeui/html/ | ||
389 | corba node ${GUILE_GNOME}/corba/html/ | ||
390 | clutter node ${GUILE_GNOME}/clutter/html/ | ||
391 | clutter-glx node ${GUILE_GNOME}/clutter-glx/html/ | ||
392 | |||
393 | guile-gtk node ${GS}/guile-gtk/docs/guile-gtk/ | ||
394 | |||
395 | guile-rpc mono ${GS}/guile-rpc/manual/guile-rpc.html | ||
396 | guile-rpc node ${GS}/guile-rpc/manual/html_node/ | ||
397 | |||
398 | guix mono ${GS}/guix/manual/guix.html | ||
399 | guix node ${GS}/guix/manual/html_node/ | ||
400 | |||
401 | gv mono ${GS}/gv/manual/gv.html | ||
402 | gv node ${GS}/gv/manual/html_node/ | ||
403 | |||
404 | gzip mono ${GS}/gzip/manual/gzip.html | ||
405 | gzip node ${GS}/gzip/manual/html_node/ | ||
406 | |||
407 | hello mono ${GS}/hello/manual/hello.html | ||
408 | hello node ${GS}/hello/manual/html_node/ | ||
409 | |||
410 | help2man mono ${GS}/help2man/help2man.html | ||
411 | |||
412 | idutils mono ${GS}/idutils/manual/idutils.html | ||
413 | idutils node ${GS}/idutils/manual/html_node/ | ||
414 | |||
415 | inetutils mono ${GS}/inetutils/manual/inetutils.html | ||
416 | inetutils node ${GS}/inetutils/manual/html_node/ | ||
417 | |||
418 | jwhois mono ${GS}/jwhois/manual/jwhois.html | ||
419 | jwhois node ${GS}/jwhois/manual/html_node/ | ||
420 | |||
421 | libc mono ${GS}/libc/manual/html_mono/libc.html | ||
422 | libc node ${GS}/libc/manual/html_node/ | ||
423 | |||
424 | LIBCDIO = ${GS}/libcdio | ||
425 | libcdio mono ${LIBCDIO}/libcdio.html | ||
426 | cd-text mono ${LIBCDIO}/cd-text-format.html | ||
427 | |||
428 | libextractor mono ${GS}/libextractor/manual/libextractor.html | ||
429 | libextractor node ${GS}/libextractor/manual/html_node/ | ||
430 | |||
431 | libidn mono ${GS}/libidn/manual/libidn.html | ||
432 | libidn node ${GS}/libidn/manual/html_node/ | ||
433 | |||
434 | librejs mono ${GS}/librejs/manual/librejs.html | ||
435 | librejs node ${GS}/librejs/manual/html_node/ | ||
436 | |||
437 | libmatheval mono ${GS}/libmatheval/manual/libmatheval.html | ||
438 | |||
439 | LIBMICROHTTPD = ${GS}/libmicrohttpd | ||
440 | libmicrohttpd mono ${LIBMICROHTTPD}/manual/libmicrohttpd.html | ||
441 | libmicrohttpd node ${LIBMICROHTTPD}/manual/html_node/ | ||
442 | microhttpd-tutorial mono ${LIBMICROHTTPD}/tutorial.html | ||
443 | |||
444 | libtasn1 mono ${GS}/libtasn1/manual/libtasn1.html | ||
445 | libtasn1 node ${GS}/libtasn1/manual/html_node/ | ||
446 | |||
447 | libtool mono ${GS}/libtool/manual/libtool.html | ||
448 | libtool node ${GS}/libtool/manual/html_node/ | ||
449 | |||
450 | lightning mono ${GS}/lightning/manual/lightning.html | ||
451 | lightning node ${GS}/lightning/manual/html_node/ | ||
452 | |||
453 | # The stable/ url redirects immediately, but that's ok. | ||
454 | # The .html extension is omitted on their web site, but it works if given. | ||
455 | LILYPOND = http://lilypond.org/doc/stable/Documentation | ||
456 | lilypond-internals node ${LILYPOND}/internals/ | ||
457 | lilypond-learning node ${LILYPOND}/learning/ | ||
458 | lilypond-notation node ${LILYPOND}/notation/ | ||
459 | lilypond-snippets node ${LILYPOND}/snippets/ | ||
460 | lilypond-usage node ${LILYPOND}/usage/ | ||
461 | lilypond-web node ${LILYPOND}/web/ | ||
462 | music-glossary node ${LILYPOND}/music-glossary/ | ||
463 | |||
464 | liquidwar6 mono ${GS}/liquidwar6/manual/liquidwar6.html | ||
465 | liquidwar6 node ${GS}/liquidwar6/manual/html_node/ | ||
466 | |||
467 | lispintro mono ${GS}/emacs/emacs-lisp-intro/html_mono/emacs-lisp-intro.html | ||
468 | lispintro node ${GS}/emacs/emacs-lisp-intro/html_node/index.html | ||
469 | |||
470 | LSH = http://www.lysator.liu.se/~nisse/lsh | ||
471 | lsh mono ${LSH}/lsh.html | ||
472 | |||
473 | m4 mono ${GS}/m4/manual/m4.html | ||
474 | m4 node ${GS}/m4/manual/html_node/ | ||
475 | |||
476 | mailutils mono ${GS}/mailutils/manual/mailutils.html | ||
477 | mailutils chapter ${GS}/mailutils/manual/html_chapter/ | ||
478 | mailutils section ${GS}/mailutils/manual/html_section/ | ||
479 | mailutils node ${GS}/mailutils/manual/html_node/ | ||
480 | |||
481 | make mono ${GS}/make/manual/make.html | ||
482 | make node ${GS}/make/manual/html_node/ | ||
483 | |||
484 | mcron mono ${GS}/mcron/manual/mcron.html | ||
485 | mcron node ${GS}/mcron/manual/html_node/ | ||
486 | |||
487 | mdk mono ${GS}/mdk/manual/mdk.html | ||
488 | mdk node ${GS}/mdk/manual/html_node/ | ||
489 | |||
490 | METAEXCHANGE = http://ftp.gwdg.de/pub/gnu2/iwfmdh/doc/texinfo | ||
491 | iwf_mh node ${METAEXCHANGE}/iwf_mh.html | ||
492 | scantest node ${METAEXCHANGE}/scantest.html | ||
493 | |||
494 | MIT_SCHEME = ${GS}/mit-scheme/documentation | ||
495 | mit-scheme-ref node ${MIT_SCHEME}/mit-scheme-ref/ | ||
496 | mit-scheme-user node ${MIT_SCHEME}/mit-scheme-user/ | ||
497 | sos node ${MIT_SCHEME}/mit-scheme-sos/ | ||
498 | mit-scheme-imail node ${MIT_SCHEME}/mit-scheme-imail/ | ||
499 | |||
500 | moe mono ${GS}/moe/manual/moe_manual.html | ||
501 | |||
502 | motti node ${GS}/motti/manual/ | ||
503 | |||
504 | mpc node http://www.multiprecision.org/index.php?prog=mpc&page=html | ||
505 | |||
506 | mpfr mono http://www.mpfr.org/mpfr-current/mpfr.html | ||
507 | |||
508 | mtools mono ${GS}/mtools/manual/mtools.html | ||
509 | |||
510 | myserver node http://www.myserverproject.net/documentation/ | ||
511 | |||
512 | nano mono http://www.nano-editor.org/dist/latest/nano.html | ||
513 | |||
514 | nettle chapter http://www.lysator.liu.se/~nisse/nettle/nettle.html | ||
515 | |||
516 | ocrad mono ${GS}/ocrad/manual/ocrad_manual.html | ||
517 | |||
518 | parted mono ${GS}/parted/manual/parted.html | ||
519 | parted node ${GS}/parted/manual/html_node/ | ||
520 | |||
521 | pascal mono http://www.gnu-pascal.de/gpc/ | ||
522 | |||
523 | # can't use pcb since url's contain dates --30nov10 | ||
524 | |||
525 | perl mono ${GS}/perl/manual/perldoc-all.html | ||
526 | |||
527 | PIES = http://www.gnu.org.ua/software/pies/manual | ||
528 | pies mono ${PIES}/pies.html | ||
529 | pies chapter ${PIES}/html_chapter/ | ||
530 | pies section ${PIES}/html_section/ | ||
531 | pies node ${PIES}/html_node/ | ||
532 | |||
533 | plotutils mono ${GS}/plotutils/manual/en/plotutils.html | ||
534 | plotutils node ${GS}/plotutils/manual/en/html_node/ | ||
535 | |||
536 | proxyknife mono ${GS}/proxyknife/manual/proxyknife.html | ||
537 | proxyknife node ${GS}/proxyknife/manual/html_node/ | ||
538 | |||
539 | pspp mono ${GS}/pspp/manual/pspp.html | ||
540 | pspp node ${GS}/pspp/manual/html_node/ | ||
541 | |||
542 | pyconfigure mono ${GS}/pyconfigure/manual/pyconfigure.html | ||
543 | pyconfigure node ${GS}/pyconfigure/manual/html_node/ | ||
544 | |||
545 | R = http://cran.r-project.org/doc/manuals | ||
546 | R-intro mono ${R}/R-intro.html | ||
547 | R-lang mono ${R}/R-lang.html | ||
548 | R-exts mono ${R}/R-exts.html | ||
549 | R-data mono ${R}/R-data.html | ||
550 | R-admin mono ${R}/R-admin.html | ||
551 | R-ints mono ${R}/R-ints.html | ||
552 | |||
553 | rcs mono ${GS}/rcs/manual/rcs.html | ||
554 | rcs node ${GS}/rcs/manual/html_node/ | ||
555 | |||
556 | READLINE = http://cnswww.cns.cwru.edu/php/chet/readline | ||
557 | readline mono ${READLINE}/readline.html | ||
558 | rluserman mono ${READLINE}/rluserman.html | ||
559 | history mono ${READLINE}/history.html | ||
560 | |||
561 | recode mono http://recode.progiciels-bpi.ca/manual/index.html | ||
562 | |||
563 | recutils mono ${GS}/recutils/manual/recutils.html | ||
564 | recutils node ${GS}/recutils/manual/html_node/ | ||
565 | |||
566 | reftex mono ${GS}/auctex/manual/reftex.html | ||
567 | reftex node ${GS}/auctex/manual/reftex/ | ||
568 | |||
569 | remotecontrol mono ${GS}/remotecontrol/manual/remotecontrol.html | ||
570 | remotecontrol node ${GS}/remotecontrol/manual/html_node/ | ||
571 | |||
572 | rottlog mono ${GS}/rottlog/manual/rottlog.html | ||
573 | rottlog node ${GS}/rottlog/manual/html_node/ | ||
574 | |||
575 | RUSH = http://www.gnu.org.ua/software/rush/manual | ||
576 | rush mono ${RUSH}/rush.html | ||
577 | rush chapter ${RUSH}/html_chapter/ | ||
578 | rush section ${RUSH}/html_section/ | ||
579 | rush node ${RUSH}/html_node/ | ||
580 | |||
581 | screen mono ${GS}/screen/manual/screen.html | ||
582 | screen node ${GS}/screen/manual/html_node/ | ||
583 | |||
584 | sed mono ${GS}/sed/manual/sed.html | ||
585 | sed node ${GS}/sed/manual/html_node/ | ||
586 | |||
587 | sharutils mono ${GS}/sharutils/manual/html_mono/sharutils.html | ||
588 | sharutils chapter ${GS}/sharutils/manual/html_chapter/ | ||
589 | sharutils node ${GS}/sharutils/manual/html_node/ | ||
590 | |||
591 | shepherd mono ${GS}/shepherd/manual/shepherd.html | ||
592 | shepherd node ${GS}/shepherd/manual/html_node/ | ||
593 | |||
594 | # can't use mono files since they have generic names | ||
595 | SMALLTALK = ${GS}/smalltalk | ||
596 | smalltalk node ${SMALLTALK}/manual/html_node/ | ||
597 | smalltalk-base node ${SMALLTALK}/manual-base/html_node/ | ||
598 | smalltalk-libs node ${SMALLTALK}/manual-libs/html_node/ | ||
599 | |||
600 | sourceinstall mono ${GS}/sourceinstall/manual/sourceinstall.html | ||
601 | sourceinstall node ${GS}/sourceinstall/manual/html_node/ | ||
602 | |||
603 | sqltutor mono ${GS}/sqltutor/manual/sqltutor.html | ||
604 | sqltutor node ${GS}/sqltutor/manual/html_node/ | ||
605 | |||
606 | src-highlite mono ${GS}/src-highlite/source-highlight.html | ||
607 | |||
608 | swbis mono ${GS}/swbis/manual.html | ||
609 | |||
610 | tar mono ${GS}/tar/manual/tar.html | ||
611 | tar chapter ${GS}/tar/manual/html_chapter/ | ||
612 | tar section ${GS}/tar/manual/html_section/ | ||
613 | tar node ${GS}/autoconf/manual/html_node/ | ||
614 | |||
615 | teseq mono ${GS}/teseq/teseq.html | ||
616 | teseq node ${GS}/teseq/html_node/ | ||
617 | |||
618 | TEXINFO = ${GS}/texinfo/manual | ||
619 | texinfo mono ${TEXINFO}/texinfo/texinfo.html | ||
620 | texinfo node ${TEXINFO}/texinfo/html_node/ | ||
621 | # | ||
622 | info mono ${TEXINFO}/info/info.html | ||
623 | info node ${TEXINFO}/info/html_node/ | ||
624 | # | ||
625 | info-stnd mono ${TEXINFO}/info-stnd/info-stnd.html | ||
626 | info-stnd node ${TEXINFO}/info-stnd/html_node/ | ||
627 | |||
628 | thales node ${GS}/thales/manual/ | ||
629 | |||
630 | units mono ${GS}/units/manual/units.html | ||
631 | units node ${GS}/units/manual/html_node/ | ||
632 | |||
633 | vc-dwim mono ${GS}/vc-dwim/manual/vc-dwim.html | ||
634 | vc-dwim node ${GS}/vc-dwim/manual/html_node/ | ||
635 | |||
636 | wdiff mono ${GS}/wdiff/manual/wdiff.html | ||
637 | wdiff node ${GS}/wdiff/manual/html_node/ | ||
638 | |||
639 | websocket4j mono ${GS}/websocket4j/manual/websocket4j.html | ||
640 | websocket4j node ${GS}/websocket4j/manual/html_node/ | ||
641 | |||
642 | wget mono ${GS}/wget/manual/wget.html | ||
643 | wget node ${GS}/wget/manual/html_node/ | ||
644 | |||
645 | xboard mono ${GS}/xboard/manual/xboard.html | ||
646 | xboard node ${GS}/xboard/manual/html_node/ | ||
647 | |||
648 | # emacs-page | ||
649 | # Free TeX-related Texinfo manuals on tug.org. | ||
650 | |||
651 | T = http://tug.org/texinfohtml | ||
652 | |||
653 | dvipng mono ${T}/dvipng.html | ||
654 | dvips mono ${T}/dvips.html | ||
655 | eplain mono ${T}/eplain.html | ||
656 | kpathsea mono ${T}/kpathsea.html | ||
657 | latex2e mono ${T}/latex2e.html | ||
658 | tlbuild mono ${T}/tlbuild.html | ||
659 | web2c mono ${T}/web2c.html | ||
660 | |||
661 | |||
662 | # Local Variables: | ||
663 | # eval: (add-hook 'write-file-hooks 'time-stamp) | ||
664 | # time-stamp-start: "htmlxrefversion=" | ||
665 | # time-stamp-format: "%:y-%02m-%02d.%02H" | ||
666 | # time-stamp-time-zone: "UTC" | ||
667 | # time-stamp-end: "; # UTC" | ||
668 | # End: | ||
diff --git a/doc/images/daemon_lego_block.png b/doc/documentation/images/daemon_lego_block.png index 5a088b532..5a088b532 100644 --- a/doc/images/daemon_lego_block.png +++ b/doc/documentation/images/daemon_lego_block.png | |||
Binary files differ | |||
diff --git a/doc/images/daemon_lego_block.svg b/doc/documentation/images/daemon_lego_block.svg index 38ad90d13..38ad90d13 100644 --- a/doc/images/daemon_lego_block.svg +++ b/doc/documentation/images/daemon_lego_block.svg | |||
diff --git a/doc/images/gnunet-0-10-peerinfo.png b/doc/documentation/images/gnunet-0-10-peerinfo.png index c5e711aff..c5e711aff 100644 --- a/doc/images/gnunet-0-10-peerinfo.png +++ b/doc/documentation/images/gnunet-0-10-peerinfo.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-fs-gtk-0-10-star-tab.png b/doc/documentation/images/gnunet-fs-gtk-0-10-star-tab.png index d7993cc46..d7993cc46 100644 --- a/doc/images/gnunet-fs-gtk-0-10-star-tab.png +++ b/doc/documentation/images/gnunet-fs-gtk-0-10-star-tab.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-download-area.png b/doc/documentation/images/gnunet-gtk-0-10-download-area.png index 8500d46c9..8500d46c9 100644 --- a/doc/images/gnunet-gtk-0-10-download-area.png +++ b/doc/documentation/images/gnunet-gtk-0-10-download-area.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-menu.png b/doc/documentation/images/gnunet-gtk-0-10-fs-menu.png index dc20c45a9..dc20c45a9 100644 --- a/doc/images/gnunet-gtk-0-10-fs-menu.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-menu.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-publish-editing.png b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-editing.png index 6f9f75ea6..6f9f75ea6 100644 --- a/doc/images/gnunet-gtk-0-10-fs-publish-editing.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-editing.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-publish-select.png b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-select.png index 50672e379..50672e379 100644 --- a/doc/images/gnunet-gtk-0-10-fs-publish-select.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-select.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-publish-with-file.png b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file.png index b46542563..b46542563 100644 --- a/doc/images/gnunet-gtk-0-10-fs-publish-with-file.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-publish-with-file_0.png b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file_0.png index b46542563..b46542563 100644 --- a/doc/images/gnunet-gtk-0-10-fs-publish-with-file_0.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-publish-with-file_0.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-publish.png b/doc/documentation/images/gnunet-gtk-0-10-fs-publish.png index 033b38fa5..033b38fa5 100644 --- a/doc/images/gnunet-gtk-0-10-fs-publish.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-publish.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-published.png b/doc/documentation/images/gnunet-gtk-0-10-fs-published.png index fbd3dd6a3..fbd3dd6a3 100644 --- a/doc/images/gnunet-gtk-0-10-fs-published.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-published.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs-search.png b/doc/documentation/images/gnunet-gtk-0-10-fs-search.png index bb64ab92e..bb64ab92e 100644 --- a/doc/images/gnunet-gtk-0-10-fs-search.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs-search.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-fs.png b/doc/documentation/images/gnunet-gtk-0-10-fs.png index c7a294878..c7a294878 100644 --- a/doc/images/gnunet-gtk-0-10-fs.png +++ b/doc/documentation/images/gnunet-gtk-0-10-fs.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-gns-a-done.png b/doc/documentation/images/gnunet-gtk-0-10-gns-a-done.png index f8231b3a6..f8231b3a6 100644 --- a/doc/images/gnunet-gtk-0-10-gns-a-done.png +++ b/doc/documentation/images/gnunet-gtk-0-10-gns-a-done.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-gns-a.png b/doc/documentation/images/gnunet-gtk-0-10-gns-a.png index 39858d72c..39858d72c 100644 --- a/doc/images/gnunet-gtk-0-10-gns-a.png +++ b/doc/documentation/images/gnunet-gtk-0-10-gns-a.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-gns.png b/doc/documentation/images/gnunet-gtk-0-10-gns.png index c71a2bd7b..c71a2bd7b 100644 --- a/doc/images/gnunet-gtk-0-10-gns.png +++ b/doc/documentation/images/gnunet-gtk-0-10-gns.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-identity.png b/doc/documentation/images/gnunet-gtk-0-10-identity.png index d0b426098..d0b426098 100644 --- a/doc/images/gnunet-gtk-0-10-identity.png +++ b/doc/documentation/images/gnunet-gtk-0-10-identity.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-search-selected.png b/doc/documentation/images/gnunet-gtk-0-10-search-selected.png index da1ad4d31..da1ad4d31 100644 --- a/doc/images/gnunet-gtk-0-10-search-selected.png +++ b/doc/documentation/images/gnunet-gtk-0-10-search-selected.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10-traffic.png b/doc/documentation/images/gnunet-gtk-0-10-traffic.png index 76458f717..76458f717 100644 --- a/doc/images/gnunet-gtk-0-10-traffic.png +++ b/doc/documentation/images/gnunet-gtk-0-10-traffic.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-gtk-0-10.png b/doc/documentation/images/gnunet-gtk-0-10.png index 3615849a7..3615849a7 100644 --- a/doc/images/gnunet-gtk-0-10.png +++ b/doc/documentation/images/gnunet-gtk-0-10.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-namestore-gtk-phone.png b/doc/documentation/images/gnunet-namestore-gtk-phone.png index 3bb859629..3bb859629 100644 --- a/doc/images/gnunet-namestore-gtk-phone.png +++ b/doc/documentation/images/gnunet-namestore-gtk-phone.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-namestore-gtk-vpn.png b/doc/documentation/images/gnunet-namestore-gtk-vpn.png index c716729ba..c716729ba 100644 --- a/doc/images/gnunet-namestore-gtk-vpn.png +++ b/doc/documentation/images/gnunet-namestore-gtk-vpn.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-setup-exit.png b/doc/documentation/images/gnunet-setup-exit.png index 66bd972bc..66bd972bc 100644 --- a/doc/images/gnunet-setup-exit.png +++ b/doc/documentation/images/gnunet-setup-exit.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-tutorial-service.png b/doc/documentation/images/gnunet-tutorial-service.png index 6daed2f35..6daed2f35 100644 --- a/doc/images/gnunet-tutorial-service.png +++ b/doc/documentation/images/gnunet-tutorial-service.png | |||
Binary files differ | |||
diff --git a/doc/images/gnunet-tutorial-system.png b/doc/documentation/images/gnunet-tutorial-system.png index 8b54e16cf..8b54e16cf 100644 --- a/doc/images/gnunet-tutorial-system.png +++ b/doc/documentation/images/gnunet-tutorial-system.png | |||
Binary files differ | |||
diff --git a/doc/images/iceweasel-preferences.png b/doc/documentation/images/iceweasel-preferences.png index e62c2c4d9..e62c2c4d9 100644 --- a/doc/images/iceweasel-preferences.png +++ b/doc/documentation/images/iceweasel-preferences.png | |||
Binary files differ | |||
diff --git a/doc/images/iceweasel-proxy.png b/doc/documentation/images/iceweasel-proxy.png index 9caad4508..9caad4508 100644 --- a/doc/images/iceweasel-proxy.png +++ b/doc/documentation/images/iceweasel-proxy.png | |||
Binary files differ | |||
diff --git a/doc/images/lego_stack.svg b/doc/documentation/images/lego_stack.svg index a0e8017c3..a0e8017c3 100644 --- a/doc/images/lego_stack.svg +++ b/doc/documentation/images/lego_stack.svg | |||
diff --git a/doc/images/service_lego_block.png b/doc/documentation/images/service_lego_block.png index 56caf6b9c..56caf6b9c 100644 --- a/doc/images/service_lego_block.png +++ b/doc/documentation/images/service_lego_block.png | |||
Binary files differ | |||
diff --git a/doc/images/service_lego_block.svg b/doc/documentation/images/service_lego_block.svg index ef0d0234f..ef0d0234f 100644 --- a/doc/images/service_lego_block.svg +++ b/doc/documentation/images/service_lego_block.svg | |||
diff --git a/doc/images/service_stack.png b/doc/documentation/images/service_stack.png index 747d087b2..747d087b2 100644 --- a/doc/images/service_stack.png +++ b/doc/documentation/images/service_stack.png | |||
Binary files differ | |||
diff --git a/doc/images/structure.dot b/doc/documentation/images/structure.dot index a53db90b8..a53db90b8 100644 --- a/doc/images/structure.dot +++ b/doc/documentation/images/structure.dot | |||
diff --git a/doc/documentation/index.html b/doc/documentation/index.html new file mode 100644 index 000000000..2481ac46a --- /dev/null +++ b/doc/documentation/index.html | |||
@@ -0,0 +1,31 @@ | |||
1 | <title>GNUnet - GNUnet Handbooks</title> | ||
2 | <h2>GNUnet - GNUnet Handbooks</h2> | ||
3 | |||
4 | <address>GNUnet e.V.</address> | ||
5 | <address></address> | ||
6 | |||
7 | <p>The following handbooks and manuals are available:</p> | ||
8 | |||
9 | <ul> | ||
10 | <li><a href="gnunet/index.html">GNUnet Reference Handbook</li> | ||
11 | <li><a href="gnunet-c-tutorial/index.html">GNUnet C Tutorial</li> | ||
12 | </ul> | ||
13 | |||
14 | <div id="footer"> | ||
15 | <div class="unprintable"> | ||
16 | |||
17 | <p>Please send general FSF & GNU inquiries to | ||
18 | <a href="mailto:gnu@gnu.org"><gnu@gnu.org></a>. | ||
19 | There are also <a href="/contact/">other ways to contact</a> | ||
20 | the FSF. Broken links and other corrections or suggestions can be sent | ||
21 | to <a href="mailto:gnunet-developers@gnu.org"><gnunet-developers@gnu.org></a>.</p> | ||
22 | </div> | ||
23 | |||
24 | <p>Copyright © 2001 - 2017 GNUnet e.V.</p> | ||
25 | |||
26 | <p>This page is licensed under a FIXME License.</p> | ||
27 | |||
28 | </div> | ||
29 | </div> | ||
30 | </body> | ||
31 | </html> | ||
diff --git a/doc/documentation/run-gendocs.sh b/doc/documentation/run-gendocs.sh new file mode 100755 index 000000000..6e9d43b48 --- /dev/null +++ b/doc/documentation/run-gendocs.sh | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | make version.texi | ||
4 | make version2.texi | ||
5 | ./gendocs.sh --email gnunet-developers@gnu.org gnunet-c-tutorial "GNUnet C Tutorial" -o "manual/gnunet-c-tutorial" | ||
6 | #cd manual | ||
7 | #mkdir gnunet-c-tutorial | ||
8 | #mv * gnunet-c-tutorial/ | ||
9 | #cd .. | ||
10 | ./gendocs.sh --email gnunet-developers@gnu.org gnunet "GNUnet reference handbook" -o "manual/gnunet" | ||
11 | #cd manual | ||
12 | #mkdir handbook | ||
13 | #mkdir ../tmp-gnunet | ||
14 | #mv gnunet ../tmp-gnunet | ||
15 | #mv * handbook/ | ||
16 | #mv ../tmp-gnunet gnunet | ||
17 | cp "index.html" manual/ | ||
18 | printf "Success" | ||
diff --git a/doc/testbed_test.c b/doc/documentation/testbed_test.c index 1696234b0..1696234b0 100644 --- a/doc/testbed_test.c +++ b/doc/documentation/testbed_test.c | |||
diff --git a/doc/tutorial-examples/001.c b/doc/documentation/tutorial-examples/001.c index 7f6699dd2..7f6699dd2 100644 --- a/doc/tutorial-examples/001.c +++ b/doc/documentation/tutorial-examples/001.c | |||
diff --git a/doc/tutorial-examples/002.c b/doc/documentation/tutorial-examples/002.c index 02233fd61..02233fd61 100644 --- a/doc/tutorial-examples/002.c +++ b/doc/documentation/tutorial-examples/002.c | |||
diff --git a/doc/documentation/tutorial-examples/003.c b/doc/documentation/tutorial-examples/003.c new file mode 100644 index 000000000..d158d7e75 --- /dev/null +++ b/doc/documentation/tutorial-examples/003.c | |||
@@ -0,0 +1,11 @@ | |||
1 | struct GNUNET_MQ_MessageHandlers handlers[] = { | ||
2 | // ... | ||
3 | GNUNET_MQ_handler_end () | ||
4 | }; | ||
5 | struct GNUNET_MQ_Handle *mq; | ||
6 | |||
7 | mq = GNUNET_CLIENT_connect (cfg, | ||
8 | "service-name", | ||
9 | handlers, | ||
10 | &error_cb, | ||
11 | NULL); | ||
diff --git a/doc/tutorial-examples/004.c b/doc/documentation/tutorial-examples/004.c index 0ef007907..0ef007907 100644 --- a/doc/tutorial-examples/004.c +++ b/doc/documentation/tutorial-examples/004.c | |||
diff --git a/doc/tutorial-examples/005.c b/doc/documentation/tutorial-examples/005.c index 0c459f509..0c459f509 100644 --- a/doc/tutorial-examples/005.c +++ b/doc/documentation/tutorial-examples/005.c | |||
diff --git a/doc/tutorial-examples/006.c b/doc/documentation/tutorial-examples/006.c index 944d2b18c..944d2b18c 100644 --- a/doc/tutorial-examples/006.c +++ b/doc/documentation/tutorial-examples/006.c | |||
diff --git a/doc/tutorial-examples/007.c b/doc/documentation/tutorial-examples/007.c index 096539e43..096539e43 100644 --- a/doc/tutorial-examples/007.c +++ b/doc/documentation/tutorial-examples/007.c | |||
diff --git a/doc/tutorial-examples/008.c b/doc/documentation/tutorial-examples/008.c index 2dffe2cf9..2dffe2cf9 100644 --- a/doc/tutorial-examples/008.c +++ b/doc/documentation/tutorial-examples/008.c | |||
diff --git a/doc/tutorial-examples/009.c b/doc/documentation/tutorial-examples/009.c index 26d918fb0..26d918fb0 100644 --- a/doc/tutorial-examples/009.c +++ b/doc/documentation/tutorial-examples/009.c | |||
diff --git a/doc/tutorial-examples/010.c b/doc/documentation/tutorial-examples/010.c index 33494490d..33494490d 100644 --- a/doc/tutorial-examples/010.c +++ b/doc/documentation/tutorial-examples/010.c | |||
diff --git a/doc/tutorial-examples/011.c b/doc/documentation/tutorial-examples/011.c index 23bc051de..23bc051de 100644 --- a/doc/tutorial-examples/011.c +++ b/doc/documentation/tutorial-examples/011.c | |||
diff --git a/doc/tutorial-examples/012.c b/doc/documentation/tutorial-examples/012.c index cb21d78ab..cb21d78ab 100644 --- a/doc/tutorial-examples/012.c +++ b/doc/documentation/tutorial-examples/012.c | |||
diff --git a/doc/documentation/tutorial-examples/013.1.c b/doc/documentation/tutorial-examples/013.1.c new file mode 100644 index 000000000..fa5212868 --- /dev/null +++ b/doc/documentation/tutorial-examples/013.1.c | |||
@@ -0,0 +1,3 @@ | |||
1 | void | ||
2 | GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext | ||
3 | *sc); | ||
diff --git a/doc/tutorial-examples/013.c b/doc/documentation/tutorial-examples/013.c index 6792417e1..6792417e1 100644 --- a/doc/tutorial-examples/013.c +++ b/doc/documentation/tutorial-examples/013.c | |||
diff --git a/doc/tutorial-examples/014.c b/doc/documentation/tutorial-examples/014.c index ce204f795..ce204f795 100644 --- a/doc/tutorial-examples/014.c +++ b/doc/documentation/tutorial-examples/014.c | |||
diff --git a/doc/tutorial-examples/015.c b/doc/documentation/tutorial-examples/015.c index 0dd267e8e..0dd267e8e 100644 --- a/doc/tutorial-examples/015.c +++ b/doc/documentation/tutorial-examples/015.c | |||
diff --git a/doc/tutorial-examples/016.c b/doc/documentation/tutorial-examples/016.c index d8db4b3b8..d169da16d 100644 --- a/doc/tutorial-examples/016.c +++ b/doc/documentation/tutorial-examples/016.c | |||
@@ -1,3 +1,4 @@ | |||
1 | void | 1 | void |
2 | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext *wc); | 2 | GNUNET_PEERSTORE_watch_cancel (struct GNUNET_PEERSTORE_WatchContext |
3 | *wc); | ||
3 | 4 | ||
diff --git a/doc/documentation/tutorial-examples/017.c b/doc/documentation/tutorial-examples/017.c new file mode 100644 index 000000000..c86fbcd1f --- /dev/null +++ b/doc/documentation/tutorial-examples/017.c | |||
@@ -0,0 +1,4 @@ | |||
1 | void | ||
2 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, | ||
3 | int sync_first); | ||
4 | |||
diff --git a/doc/tutorial-examples/018.c b/doc/documentation/tutorial-examples/018.c index 3fc22584c..3fc22584c 100644 --- a/doc/tutorial-examples/018.c +++ b/doc/documentation/tutorial-examples/018.c | |||
diff --git a/doc/tutorial-examples/019.c b/doc/documentation/tutorial-examples/019.c index d016d381b..aaf001516 100644 --- a/doc/tutorial-examples/019.c +++ b/doc/documentation/tutorial-examples/019.c | |||
@@ -1,4 +1,5 @@ | |||
1 | message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1 | message_sent_cont (void *cls, |
2 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2 | { | 3 | { |
3 | // Request has left local node | 4 | // Request has left local node |
4 | } | 5 | } |
@@ -8,7 +9,9 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
8 | const struct GNUNET_HashCode *key, | 9 | const struct GNUNET_HashCode *key, |
9 | uint32_t desired_replication_level, | 10 | uint32_t desired_replication_level, |
10 | enum GNUNET_DHT_RouteOption options, | 11 | enum GNUNET_DHT_RouteOption options, |
11 | enum GNUNET_BLOCK_Type type, size_t size, const void *data, | 12 | enum GNUNET_BLOCK_Type type, |
13 | size_t size, | ||
14 | const void *data, | ||
12 | struct GNUNET_TIME_Absolute exp, | 15 | struct GNUNET_TIME_Absolute exp, |
13 | struct GNUNET_TIME_Relative timeout, | 16 | struct GNUNET_TIME_Relative timeout, |
14 | GNUNET_DHT_PutContinuation cont, void *cont_cls) | 17 | GNUNET_DHT_PutContinuation cont, void *cont_cls) |
diff --git a/doc/tutorial-examples/020.c b/doc/documentation/tutorial-examples/020.c index 5ecba1c16..596db3069 100644 --- a/doc/tutorial-examples/020.c +++ b/doc/documentation/tutorial-examples/020.c | |||
@@ -5,7 +5,8 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute expiration, | |||
5 | unsigned int get_path_length, | 5 | unsigned int get_path_length, |
6 | const struct GNUNET_PeerIdentity *put_path, | 6 | const struct GNUNET_PeerIdentity *put_path, |
7 | unsigned int put_path_length, | 7 | unsigned int put_path_length, |
8 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) | 8 | enum GNUNET_BLOCK_Type type, size_t size, |
9 | const void *data) | ||
9 | { | 10 | { |
10 | // Optionally: | 11 | // Optionally: |
11 | GNUNET_DHT_get_stop (get_handle); | 12 | GNUNET_DHT_get_stop (get_handle); |
diff --git a/doc/tutorial-examples/021.c b/doc/documentation/tutorial-examples/021.c index 688a31fe0..688a31fe0 100644 --- a/doc/tutorial-examples/021.c +++ b/doc/documentation/tutorial-examples/021.c | |||
diff --git a/doc/tutorial-examples/022.c b/doc/documentation/tutorial-examples/022.c index a373619bd..a373619bd 100644 --- a/doc/tutorial-examples/022.c +++ b/doc/documentation/tutorial-examples/022.c | |||
diff --git a/doc/tutorial-examples/023.c b/doc/documentation/tutorial-examples/023.c index 820c38b10..820c38b10 100644 --- a/doc/tutorial-examples/023.c +++ b/doc/documentation/tutorial-examples/023.c | |||
diff --git a/doc/tutorial-examples/024.c b/doc/documentation/tutorial-examples/024.c index 2e84b5905..2e84b5905 100644 --- a/doc/tutorial-examples/024.c +++ b/doc/documentation/tutorial-examples/024.c | |||
diff --git a/doc/tutorial-examples/025.c b/doc/documentation/tutorial-examples/025.c index 66d4f80ec..66d4f80ec 100644 --- a/doc/tutorial-examples/025.c +++ b/doc/documentation/tutorial-examples/025.c | |||
diff --git a/doc/tutorial-examples/026.c b/doc/documentation/tutorial-examples/026.c index 264e0b6b9..264e0b6b9 100644 --- a/doc/tutorial-examples/026.c +++ b/doc/documentation/tutorial-examples/026.c | |||
diff --git a/doc/hacks.el b/doc/hacks.el new file mode 100644 index 000000000..9f271b3af --- /dev/null +++ b/doc/hacks.el | |||
@@ -0,0 +1,17 @@ | |||
1 | ;;;; hacks.el --- a few functions to help me work on the manual | ||
2 | ;;;; Jim Blandy <jimb@red-bean.com> --- October 1998 | ||
3 | ;;;; -- imported from https://git.savannah.gnu.org/cgit/guile.git/tree/doc/hacks.el | ||
4 | |||
5 | (defun jh-exemplify-region (start end) | ||
6 | (interactive "r") | ||
7 | (save-excursion | ||
8 | (save-restriction | ||
9 | (narrow-to-region start end) | ||
10 | |||
11 | ;; Texinfo doesn't handle tabs well. | ||
12 | (untabify (point-min) (point-max)) | ||
13 | |||
14 | ;; Quote any characters special to texinfo. | ||
15 | (goto-char (point-min)) | ||
16 | (while (re-search-forward "[{}@]" nil t) | ||
17 | (replace-match "@\\&"))))) | ||
diff --git a/doc/tutorial-examples/003.c b/doc/tutorial-examples/003.c deleted file mode 100644 index d13681ca6..000000000 --- a/doc/tutorial-examples/003.c +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | struct GNUNET_MQ_MessageHandlers handlers[] = { | ||
2 | // ... | ||
3 | GNUNET_MQ_handler_end () | ||
4 | }; | ||
5 | struct GNUNET_MQ_Handle *mq; | ||
6 | |||
7 | mq = GNUNET_CLIENT_connect (cfg, "service-name", handlers, &error_cb, NULL); | ||
diff --git a/doc/tutorial-examples/017.c b/doc/tutorial-examples/017.c deleted file mode 100644 index c4acbc088..000000000 --- a/doc/tutorial-examples/017.c +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | void | ||
2 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first); | ||
3 | |||
diff --git a/src/arm/Makefile.am b/src/arm/Makefile.am index 373847fde..b1706a479 100644 --- a/src/arm/Makefile.am +++ b/src/arm/Makefile.am | |||
@@ -92,7 +92,8 @@ test_gnunet_service_arm_SOURCES = \ | |||
92 | 92 | ||
93 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 93 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
94 | 94 | ||
95 | %.py: %.py.in Makefile | 95 | SUFFIXES = .py.in .py |
96 | .py.in.py: | ||
96 | $(do_subst) < $(srcdir)/$< > $@ | 97 | $(do_subst) < $(srcdir)/$< > $@ |
97 | chmod +x $@ | 98 | chmod +x $@ |
98 | 99 | ||
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 00ce0e934..4a78ea4c7 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -213,7 +213,8 @@ endif | |||
213 | 213 | ||
214 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' -e 's,[@]bindir[@],$(bindir),g' | 214 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' -e 's,[@]bindir[@],$(bindir),g' |
215 | 215 | ||
216 | %.py: %.py.in Makefile | 216 | SUFFIXES = .py.in .py |
217 | .py.in.py: | ||
217 | $(do_subst) < $(srcdir)/$< > $@ | 218 | $(do_subst) < $(srcdir)/$< > $@ |
218 | chmod +x $@ | 219 | chmod +x $@ |
219 | 220 | ||
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 875f5043a..a855ab8ab 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -400,6 +400,22 @@ void | |||
400 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | 400 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, |
401 | void *task_cls); | 401 | void *task_cls); |
402 | 402 | ||
403 | /** | ||
404 | * Initialize and run scheduler. This function will return when all | ||
405 | * tasks have completed. When @ install_signals is GNUNET_YES, then | ||
406 | * this function behaves in the same was as GNUNET_SCHEDULER_run does. | ||
407 | * If @ install_signals is GNUNET_NO then no signal handlers are | ||
408 | * installed. | ||
409 | * | ||
410 | * @param install_signals whether to install signals (GNUNET_YES/NO) | ||
411 | * @param task task to run first (and immediately) | ||
412 | * @param task_cls closure of @a task | ||
413 | */ | ||
414 | void | ||
415 | GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, | ||
416 | GNUNET_SCHEDULER_TaskCallback task, | ||
417 | void *task_cls); | ||
418 | |||
403 | 419 | ||
404 | /** | 420 | /** |
405 | * Request the shutdown of a scheduler. Marks all tasks | 421 | * Request the shutdown of a scheduler. Marks all tasks |
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am index 6fff0b407..368980064 100644 --- a/src/integration-tests/Makefile.am +++ b/src/integration-tests/Makefile.am | |||
@@ -42,7 +42,8 @@ endif | |||
42 | 42 | ||
43 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 43 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
44 | 44 | ||
45 | %.py: %.py.in Makefile | 45 | SUFFIXES = .py.in .py |
46 | .py.in.py: | ||
46 | $(do_subst) < $(srcdir)/$< > $@ | 47 | $(do_subst) < $(srcdir)/$< > $@ |
47 | chmod +x $@ | 48 | chmod +x $@ |
48 | 49 | ||
diff --git a/src/statistics/Makefile.am b/src/statistics/Makefile.am index b2e256960..16a1ea2d0 100644 --- a/src/statistics/Makefile.am +++ b/src/statistics/Makefile.am | |||
@@ -90,7 +90,8 @@ endif | |||
90 | 90 | ||
91 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 91 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
92 | 92 | ||
93 | %.py: %.py.in Makefile | 93 | SUFFIXES = .py.in .py |
94 | .py.in.py: | ||
94 | $(do_subst) < $(srcdir)/$< > $@ | 95 | $(do_subst) < $(srcdir)/$< > $@ |
95 | chmod +x $@ | 96 | chmod +x $@ |
96 | 97 | ||
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index e9c25d68a..540a60557 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -787,6 +787,14 @@ void | |||
787 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | 787 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, |
788 | void *task_cls) | 788 | void *task_cls) |
789 | { | 789 | { |
790 | GNUNET_SCHEDULER_run_with_optional_signals(GNUNET_YES, task, task_cls); | ||
791 | } | ||
792 | |||
793 | void | ||
794 | GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, | ||
795 | GNUNET_SCHEDULER_TaskCallback task, | ||
796 | void *task_cls) | ||
797 | { | ||
790 | struct GNUNET_NETWORK_FDSet *rs; | 798 | struct GNUNET_NETWORK_FDSet *rs; |
791 | struct GNUNET_NETWORK_FDSet *ws; | 799 | struct GNUNET_NETWORK_FDSet *ws; |
792 | struct GNUNET_TIME_Relative timeout; | 800 | struct GNUNET_TIME_Relative timeout; |
@@ -820,24 +828,29 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
820 | GNUNET_DISK_PIPE_END_READ); | 828 | GNUNET_DISK_PIPE_END_READ); |
821 | GNUNET_assert (NULL != pr); | 829 | GNUNET_assert (NULL != pr); |
822 | my_pid = getpid (); | 830 | my_pid = getpid (); |
823 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 831 | |
824 | "Registering signal handlers\n"); | 832 | if (GNUNET_YES == install_signals) |
825 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, | 833 | { |
834 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
835 | "Registering signal handlers\n"); | ||
836 | shc_int = GNUNET_SIGNAL_handler_install (SIGINT, | ||
837 | &sighandler_shutdown); | ||
838 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
826 | &sighandler_shutdown); | 839 | &sighandler_shutdown); |
827 | shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
828 | &sighandler_shutdown); | ||
829 | #if (SIGTERM != GNUNET_TERM_SIG) | 840 | #if (SIGTERM != GNUNET_TERM_SIG) |
830 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, | 841 | shc_gterm = GNUNET_SIGNAL_handler_install (GNUNET_TERM_SIG, |
831 | &sighandler_shutdown); | 842 | &sighandler_shutdown); |
832 | #endif | 843 | #endif |
833 | #ifndef MINGW | 844 | #ifndef MINGW |
834 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, | 845 | shc_pipe = GNUNET_SIGNAL_handler_install (SIGPIPE, |
835 | &sighandler_pipe); | 846 | &sighandler_pipe); |
836 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, | 847 | shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, |
837 | &sighandler_shutdown); | 848 | &sighandler_shutdown); |
838 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, | 849 | shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, |
839 | &sighandler_shutdown); | 850 | &sighandler_shutdown); |
840 | #endif | 851 | #endif |
852 | } | ||
853 | |||
841 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 854 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
842 | current_lifeness = GNUNET_YES; | 855 | current_lifeness = GNUNET_YES; |
843 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, | 856 | GNUNET_SCHEDULER_add_with_reason_and_priority (task, |
@@ -953,16 +966,21 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
953 | busy_wait_warning = 0; | 966 | busy_wait_warning = 0; |
954 | } | 967 | } |
955 | } | 968 | } |
956 | GNUNET_SIGNAL_handler_uninstall (shc_int); | 969 | |
957 | GNUNET_SIGNAL_handler_uninstall (shc_term); | 970 | if (GNUNET_YES == install_signals) |
971 | { | ||
972 | GNUNET_SIGNAL_handler_uninstall (shc_int); | ||
973 | GNUNET_SIGNAL_handler_uninstall (shc_term); | ||
958 | #if (SIGTERM != GNUNET_TERM_SIG) | 974 | #if (SIGTERM != GNUNET_TERM_SIG) |
959 | GNUNET_SIGNAL_handler_uninstall (shc_gterm); | 975 | GNUNET_SIGNAL_handler_uninstall (shc_gterm); |
960 | #endif | 976 | #endif |
961 | #ifndef MINGW | 977 | #ifndef MINGW |
962 | GNUNET_SIGNAL_handler_uninstall (shc_pipe); | 978 | GNUNET_SIGNAL_handler_uninstall (shc_pipe); |
963 | GNUNET_SIGNAL_handler_uninstall (shc_quit); | 979 | GNUNET_SIGNAL_handler_uninstall (shc_quit); |
964 | GNUNET_SIGNAL_handler_uninstall (shc_hup); | 980 | GNUNET_SIGNAL_handler_uninstall (shc_hup); |
965 | #endif | 981 | #endif |
982 | } | ||
983 | |||
966 | GNUNET_DISK_pipe_close (shutdown_pipe_handle); | 984 | GNUNET_DISK_pipe_close (shutdown_pipe_handle); |
967 | shutdown_pipe_handle = NULL; | 985 | shutdown_pipe_handle = NULL; |
968 | GNUNET_NETWORK_fdset_destroy (rs); | 986 | GNUNET_NETWORK_fdset_destroy (rs); |