diff options
Diffstat (limited to 'doc/documentation/chapters')
-rw-r--r-- | doc/documentation/chapters/configuration.texi | 5 | ||||
-rw-r--r-- | doc/documentation/chapters/contributing.texi | 117 | ||||
-rw-r--r-- | doc/documentation/chapters/developer.texi | 8817 | ||||
-rw-r--r-- | doc/documentation/chapters/installation.texi | 2233 | ||||
-rw-r--r-- | doc/documentation/chapters/keyconcepts.texi | 317 | ||||
-rw-r--r-- | doc/documentation/chapters/philosophy.texi | 81 | ||||
-rw-r--r-- | doc/documentation/chapters/preface.texi | 173 | ||||
-rw-r--r-- | doc/documentation/chapters/user.texi | 2293 | ||||
-rw-r--r-- | doc/documentation/chapters/vocabulary.texi | 72 |
9 files changed, 0 insertions, 14108 deletions
diff --git a/doc/documentation/chapters/configuration.texi b/doc/documentation/chapters/configuration.texi deleted file mode 100644 index 286c72e7a..000000000 --- a/doc/documentation/chapters/configuration.texi +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
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/contributing.texi b/doc/documentation/chapters/contributing.texi deleted file mode 100644 index f4493e6c1..000000000 --- a/doc/documentation/chapters/contributing.texi +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | @node GNUnet Contributors Handbook | ||
2 | @chapter GNUnet Contributors Handbook | ||
3 | |||
4 | @menu | ||
5 | * Contributing to GNUnet:: | ||
6 | * Licenses of contributions:: | ||
7 | * Copyright Assignment:: | ||
8 | * Contributing to the Reference Manual:: | ||
9 | * Contributing testcases:: | ||
10 | @end menu | ||
11 | |||
12 | @node Contributing to GNUnet | ||
13 | @section Contributing to GNUnet | ||
14 | |||
15 | @cindex licenses | ||
16 | @cindex licenses of contributions | ||
17 | @node Licenses of contributions | ||
18 | @section Licenses of contributions | ||
19 | |||
20 | GNUnet is a @uref{https://www.gnu.org/, GNU} package. | ||
21 | All code contributions must thus be put under the | ||
22 | @uref{https://www.gnu.org/licenses/agpl.html, GNU Affero Public License (AGPL)}. | ||
23 | All documentation should be put under FSF approved licenses | ||
24 | (see @uref{https://www.gnu.org/copyleft/fdl.html, fdl}). | ||
25 | |||
26 | By submitting documentation, translations, and other content to GNUnet | ||
27 | you automatically grant the right to publish code under the | ||
28 | GNU Public License and documentation under either or both the | ||
29 | GNU Public License or the GNU Free Documentation License. | ||
30 | When contributing to the GNUnet project, GNU standards and the | ||
31 | @uref{https://www.gnu.org/philosophy/philosophy.html, GNU philosophy} | ||
32 | should be adhered to. | ||
33 | |||
34 | @cindex copyright assignment | ||
35 | @node Copyright Assignment | ||
36 | @section Copyright Assignment | ||
37 | We require a formal copyright assignment for GNUnet contributors | ||
38 | to GNUnet e.V.; nevertheless, we do allow pseudonymous contributions. | ||
39 | By signing the copyright agreement and submitting your code (or | ||
40 | documentation) to us, you agree to share the rights to your code | ||
41 | with GNUnet e.V.; GNUnet e.V. receives non-exclusive ownership | ||
42 | rights, and in particular is allowed to dual-license the code. You | ||
43 | retain non-exclusive rights to your contributions, so you can also | ||
44 | share your contributions freely with other projects. | ||
45 | |||
46 | GNUnet e.V. will publish all accepted contributions under the AGPLv3 | ||
47 | or any later version. The association may decide to publish | ||
48 | contributions under additional licenses (dual-licensing). | ||
49 | |||
50 | We do not intentionally remove your name from your contributions; | ||
51 | however, due to extensive editing it is not always trivial to | ||
52 | attribute contributors properly. If you find that you significantly | ||
53 | contributed to a file (or the project as a whole) and are not listed | ||
54 | in the respective authors file or section, please do let us know. | ||
55 | |||
56 | @node Contributing to the Reference Manual | ||
57 | @section Contributing to the Reference Manual | ||
58 | |||
59 | @itemize @bullet | ||
60 | |||
61 | @item When writing documentation, please use | ||
62 | @uref{https://en.wikipedia.org/wiki/Singular_they, gender-neutral wording} | ||
63 | when referring to people, such as singular “they”, “their”, “them”, and so | ||
64 | forth. | ||
65 | |||
66 | @item Keep line length below 74 characters, except for URLs. | ||
67 | URLs break in the PDF output when they contain linebreaks. | ||
68 | |||
69 | @item Do not use tab characters (see chapter 2.1 texinfo manual) | ||
70 | |||
71 | @item Write texts in the third person perspective. | ||
72 | |||
73 | @c FIXME: This is questionable, it feels like bike shed painging to do | ||
74 | @c this for several k lines. It only helps to jump between sentences in | ||
75 | @c editors afaik. | ||
76 | @c @item Use 2 spaces between sentences, so instead of: | ||
77 | |||
78 | @c @example | ||
79 | @c We do this and the other thing. This is done by foo. | ||
80 | @c @end example | ||
81 | |||
82 | @c Write: | ||
83 | |||
84 | @c @example | ||
85 | @c We do this and the other thing. This is done by foo. | ||
86 | @c @end example | ||
87 | |||
88 | @end itemize | ||
89 | |||
90 | @node Contributing testcases | ||
91 | @section Contributing testcases | ||
92 | |||
93 | In the core of gnunet, we restrict new testcases to a small subset | ||
94 | of languages, in order of preference: | ||
95 | @enumerate | ||
96 | @item C | ||
97 | @item Portable Shell Scripts | ||
98 | @item Python (@geq{}3.6) | ||
99 | @end enumerate | ||
100 | |||
101 | We welcome efforts to remove our existing python-2.7 scripts to | ||
102 | replace them either with portable shell scripts or, | ||
103 | at your choice, python-3.6+. | ||
104 | |||
105 | If you contribute new python based testcases, we advise you to | ||
106 | not repeat our past misfortunes and write the tests in a standard | ||
107 | test framework like for example pytest. | ||
108 | |||
109 | For writing portable shell scripts, these tools are useful: | ||
110 | @uref{https://github.com/koalaman/shellcheck, Shellcheck}, | ||
111 | @uref{https://salsa.debian.org/debian/devscripts/blob/master/scripts/checkbashisms.pl, checkbashisms}, | ||
112 | @uref{http://www.etalabs.net/sh_tricks.html}, | ||
113 | @uref{https://wiki.ubuntu.com/DashAsBinSh}, | ||
114 | and @uref{https://mywiki.wooledge.org/Bashism} | ||
115 | |||
116 | @c You could also run "bin/check_shell_script" (which we still have | ||
117 | @c to write). | ||
diff --git a/doc/documentation/chapters/developer.texi b/doc/documentation/chapters/developer.texi deleted file mode 100644 index d9c92247b..000000000 --- a/doc/documentation/chapters/developer.texi +++ /dev/null | |||
@@ -1,8817 +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. | ||
8 | |||
9 | For developers, GNUnet is: | ||
10 | |||
11 | @itemize @bullet | ||
12 | @item developed by a community that believes in the GNU philosophy | ||
13 | @item Free Software (Free as in Freedom), licensed under the | ||
14 | GNU Affero General Public License | ||
15 | (@uref{https://www.gnu.org/licenses/licenses.html#AGPL}) | ||
16 | @item A set of standards, including coding conventions and | ||
17 | architectural rules | ||
18 | @item A set of layered protocols, both specifying the communication | ||
19 | between peers as well as the communication between components | ||
20 | of a single peer | ||
21 | @item A set of libraries with well-defined APIs suitable for | ||
22 | writing extensions | ||
23 | @end itemize | ||
24 | |||
25 | In particular, the architecture specifies that a peer consists of many | ||
26 | processes communicating via protocols. Processes can be written in almost | ||
27 | any language. | ||
28 | @code{C}, @code{Java} and @code{Guile} APIs exist for accessing existing | ||
29 | services and for writing extensions. | ||
30 | It is possible to write extensions in other languages by | ||
31 | implementing the necessary IPC protocols. | ||
32 | |||
33 | GNUnet can be extended and improved along many possible dimensions, and | ||
34 | anyone interested in Free Software and Freedom-enhancing Networking is | ||
35 | welcome to join the effort. This Developer Handbook attempts to provide | ||
36 | an initial introduction to some of the key design choices and central | ||
37 | components of the system. | ||
38 | This part of the GNUNet documentation is far from complete, | ||
39 | and we welcome informed contributions, be it in the form of | ||
40 | new chapters, sections or insightful comments. | ||
41 | |||
42 | @menu | ||
43 | * Developer Introduction:: | ||
44 | * Internal dependencies:: | ||
45 | * Code overview:: | ||
46 | * System Architecture:: | ||
47 | * Subsystem stability:: | ||
48 | * Naming conventions and coding style guide:: | ||
49 | * Build-system:: | ||
50 | * Developing extensions for GNUnet using the gnunet-ext template:: | ||
51 | * Writing testcases:: | ||
52 | * Building GNUnet and its dependencies:: | ||
53 | * TESTING library:: | ||
54 | * Performance regression analysis with Gauger:: | ||
55 | * TESTBED Subsystem:: | ||
56 | * libgnunetutil:: | ||
57 | * Automatic Restart Manager (ARM):: | ||
58 | * TRANSPORT Subsystem:: | ||
59 | * NAT library:: | ||
60 | * Distance-Vector plugin:: | ||
61 | * SMTP plugin:: | ||
62 | * Bluetooth plugin:: | ||
63 | * WLAN plugin:: | ||
64 | * ATS Subsystem:: | ||
65 | * CORE Subsystem:: | ||
66 | * CADET Subsystem:: | ||
67 | * NSE Subsystem:: | ||
68 | * HOSTLIST Subsystem:: | ||
69 | * IDENTITY Subsystem:: | ||
70 | * NAMESTORE Subsystem:: | ||
71 | * PEERINFO Subsystem:: | ||
72 | * PEERSTORE Subsystem:: | ||
73 | * SET Subsystem:: | ||
74 | * STATISTICS Subsystem:: | ||
75 | * Distributed Hash Table (DHT):: | ||
76 | * GNU Name System (GNS):: | ||
77 | * GNS Namecache:: | ||
78 | * REVOCATION Subsystem:: | ||
79 | * File-sharing (FS) Subsystem:: | ||
80 | * REGEX Subsystem:: | ||
81 | * REST Subsystem:: | ||
82 | @end menu | ||
83 | |||
84 | @node Developer Introduction | ||
85 | @section Developer Introduction | ||
86 | |||
87 | This Developer Handbook is intended as first introduction to GNUnet for | ||
88 | new developers that want to extend the GNUnet framework. After the | ||
89 | introduction, each of the GNUnet subsystems (directories in the | ||
90 | @file{src/} tree) is (supposed to be) covered in its own chapter. In | ||
91 | addition to this documentation, GNUnet developers should be aware of the | ||
92 | services available on the GNUnet server to them. | ||
93 | |||
94 | New developers can have a look a the GNUnet tutorials for C and java | ||
95 | available in the @file{src/} directory of the repository or under the | ||
96 | following links: | ||
97 | |||
98 | @c ** FIXME: Link to files in source, not online. | ||
99 | @c ** FIXME: Where is the Java tutorial? | ||
100 | @itemize @bullet | ||
101 | @item @xref{Top, Introduction,, gnunet-c-tutorial, The GNUnet C Tutorial}. | ||
102 | @c broken link | ||
103 | @c @item @uref{https://gnunet.org/git/gnunet.git/plain/doc/gnunet-c-tutorial.pdf, GNUnet C tutorial} | ||
104 | @item GNUnet Java tutorial | ||
105 | @end itemize | ||
106 | |||
107 | In addition to the GNUnet Reference Documentation you are reading, | ||
108 | the GNUnet server at @uref{https://gnunet.org} contains | ||
109 | various resources for GNUnet developers and those | ||
110 | who aspire to become regular contributors. | ||
111 | They are all conveniently reachable via the "Developer" | ||
112 | entry in the navigation menu. Some additional tools (such as static | ||
113 | analysis reports) require a special developer access to perform certain | ||
114 | operations. If you want (or require) access, you should contact | ||
115 | @uref{http://grothoff.org/christian/, Christian Grothoff}, | ||
116 | GNUnet's maintainer. | ||
117 | |||
118 | @c FIXME: A good part of this belongs on the website or should be | ||
119 | @c extended in subsections explaining usage of this. A simple list | ||
120 | @c is just taking space people have to read. | ||
121 | The public subsystems on the GNUnet server that help developers are: | ||
122 | |||
123 | @itemize @bullet | ||
124 | |||
125 | @item The version control system (git) keeps our code and enables | ||
126 | distributed development. | ||
127 | It is publicly accessible at @uref{https://gnunet.org/git/}. | ||
128 | Only developers with write access can commit code, everyone else is | ||
129 | encouraged to submit patches to the GNUnet-developers mailinglist: | ||
130 | @uref{https://lists.gnu.org/mailman/listinfo/gnunet-developers, https://lists.gnu.org/mailman/listinfo/gnunet-developers} | ||
131 | |||
132 | @item The bugtracking system (Mantis). | ||
133 | We use it to track feature requests, open bug reports and their | ||
134 | resolutions. | ||
135 | It can be accessed at | ||
136 | @uref{https://gnunet.org/bugs/, https://gnunet.org/bugs/}. | ||
137 | Anyone can report bugs. | ||
138 | |||
139 | @item Our site installation of the | ||
140 | Continuous Integration (CI) system @code{Buildbot} is used | ||
141 | to check GNUnet builds automatically on a range of platforms. | ||
142 | The web interface of this CI is exposed at | ||
143 | @uref{https://gnunet.org/buildbot/, https://gnunet.org/buildbot/}. | ||
144 | Builds are triggered automatically 30 minutes after the last commit to | ||
145 | our repository was made. | ||
146 | |||
147 | @item The current quality of our automated test suite is assessed using | ||
148 | Code coverage analysis. This analysis is run daily; however the webpage | ||
149 | is only updated if all automated tests pass at that time. Testcases that | ||
150 | improve our code coverage are always welcome. | ||
151 | |||
152 | @item We try to automatically find bugs using a static analysis scan. | ||
153 | This scan is run daily; however the webpage is only updated if all | ||
154 | automated tests pass at the time. Note that not everything that is | ||
155 | flagged by the analysis is a bug, sometimes even good code can be marked | ||
156 | as possibly problematic. Nevertheless, developers are encouraged to at | ||
157 | least be aware of all issues in their code that are listed. | ||
158 | |||
159 | @item We use Gauger for automatic performance regression visualization. | ||
160 | @c FIXME: LINK! | ||
161 | Details on how to use Gauger are here. | ||
162 | |||
163 | @item We use @uref{http://junit.org/, junit} to automatically test | ||
164 | @command{gnunet-java}. | ||
165 | Automatically generated, current reports on the test suite are here. | ||
166 | @c FIXME: Likewise. | ||
167 | |||
168 | @item We use Cobertura to generate test coverage reports for gnunet-java. | ||
169 | Current reports on test coverage are here. | ||
170 | @c FIXME: Likewise. | ||
171 | |||
172 | @end itemize | ||
173 | |||
174 | |||
175 | |||
176 | @c *********************************************************************** | ||
177 | @menu | ||
178 | * Project overview:: | ||
179 | @end menu | ||
180 | |||
181 | @node Project overview | ||
182 | @subsection Project overview | ||
183 | |||
184 | The GNUnet project consists at this point of several sub-projects. This | ||
185 | section is supposed to give an initial overview about the various | ||
186 | sub-projects. Note that this description also lists projects that are far | ||
187 | from complete, including even those that have literally not a single line | ||
188 | of code in them yet. | ||
189 | |||
190 | GNUnet sub-projects in order of likely relevance are currently: | ||
191 | |||
192 | @table @asis | ||
193 | |||
194 | @item @command{gnunet} | ||
195 | Core of the P2P framework, including file-sharing, VPN and | ||
196 | chat applications; this is what the Developer Handbook covers mostly | ||
197 | @item @command{gnunet-gtk} | ||
198 | Gtk+-based user interfaces, including: | ||
199 | |||
200 | @itemize @bullet | ||
201 | @item @command{gnunet-fs-gtk} (file-sharing), | ||
202 | @item @command{gnunet-statistics-gtk} (statistics over time), | ||
203 | @item @command{gnunet-peerinfo-gtk} | ||
204 | (information about current connections and known peers), | ||
205 | @item @command{gnunet-chat-gtk} (chat GUI) and | ||
206 | @item @command{gnunet-setup} (setup tool for "everything") | ||
207 | @end itemize | ||
208 | |||
209 | @item @command{gnunet-fuse} | ||
210 | Mounting directories shared via GNUnet's file-sharing | ||
211 | on GNU/Linux distributions | ||
212 | @item @command{gnunet-update} | ||
213 | Installation and update tool | ||
214 | @item @command{gnunet-ext} | ||
215 | Template for starting 'external' GNUnet projects | ||
216 | @item @command{gnunet-java} | ||
217 | Java APIs for writing GNUnet services and applications | ||
218 | @item @command{gnunet-java-ext} | ||
219 | @item @command{eclectic} | ||
220 | Code to run GNUnet nodes on testbeds for research, development, | ||
221 | testing and evaluation | ||
222 | @c ** FIXME: Solve the status and location of gnunet-qt | ||
223 | @item @command{gnunet-qt} | ||
224 | Qt-based GNUnet GUI (is it deprecated?) | ||
225 | @item @command{gnunet-cocoa} | ||
226 | cocoa-based GNUnet GUI (is it deprecated?) | ||
227 | @item @command{gnunet-guile} | ||
228 | Guile bindings for GNUnet | ||
229 | @item @command{gnunet-python} | ||
230 | Python bindings for GNUnet | ||
231 | |||
232 | @end table | ||
233 | |||
234 | We are also working on various supporting libraries and tools: | ||
235 | @c ** FIXME: What about gauger, and what about libmwmodem? | ||
236 | |||
237 | @table @asis | ||
238 | @item @command{libextractor} | ||
239 | GNU libextractor (meta data extraction) | ||
240 | @item @command{libmicrohttpd} | ||
241 | GNU libmicrohttpd (embedded HTTP(S) server library) | ||
242 | @item @command{gauger} | ||
243 | Tool for performance regression analysis | ||
244 | @item @command{monkey} | ||
245 | Tool for automated debugging of distributed systems | ||
246 | @item @command{libmwmodem} | ||
247 | Library for accessing satellite connection quality reports | ||
248 | @item @command{libgnurl} | ||
249 | gnURL (feature-restricted variant of cURL/libcurl) | ||
250 | @item @command{www} | ||
251 | work in progress of the new gnunet.org website (Jinja2 framework based to | ||
252 | replace our current Drupal website) | ||
253 | @item @command{bibliography} | ||
254 | Our collected bibliography, papers, references, and so forth | ||
255 | @item @command{gnunet-videos-} | ||
256 | Videos about and around gnunet activities | ||
257 | @end table | ||
258 | |||
259 | Finally, there are various external projects (see links for a list of | ||
260 | those that have a public website) which build on top of the GNUnet | ||
261 | framework. | ||
262 | |||
263 | @c *********************************************************************** | ||
264 | @node Internal dependencies | ||
265 | @section Internal dependencies | ||
266 | |||
267 | This section tries to give an overview of what processes a typical GNUnet | ||
268 | peer running a particular application would consist of. All of the | ||
269 | processes listed here should be automatically started by | ||
270 | @command{gnunet-arm -s}. | ||
271 | The list is given as a rough first guide to users for failure diagnostics. | ||
272 | Ideally, end-users should never have to worry about these internal | ||
273 | dependencies. | ||
274 | |||
275 | In terms of internal dependencies, a minimum file-sharing system consists | ||
276 | of the following GNUnet processes (in order of dependency): | ||
277 | |||
278 | @itemize @bullet | ||
279 | @item gnunet-service-arm | ||
280 | @item gnunet-service-resolver (required by all) | ||
281 | @item gnunet-service-statistics (required by all) | ||
282 | @item gnunet-service-peerinfo | ||
283 | @item gnunet-service-transport (requires peerinfo) | ||
284 | @item gnunet-service-core (requires transport) | ||
285 | @item gnunet-daemon-hostlist (requires core) | ||
286 | @item gnunet-daemon-topology (requires hostlist, peerinfo) | ||
287 | @item gnunet-service-datastore | ||
288 | @item gnunet-service-dht (requires core) | ||
289 | @item gnunet-service-identity | ||
290 | @item gnunet-service-fs (requires identity, mesh, dht, datastore, core) | ||
291 | @end itemize | ||
292 | |||
293 | @noindent | ||
294 | A minimum VPN system consists of the following GNUnet processes (in | ||
295 | order of dependency): | ||
296 | |||
297 | @itemize @bullet | ||
298 | @item gnunet-service-arm | ||
299 | @item gnunet-service-resolver (required by all) | ||
300 | @item gnunet-service-statistics (required by all) | ||
301 | @item gnunet-service-peerinfo | ||
302 | @item gnunet-service-transport (requires peerinfo) | ||
303 | @item gnunet-service-core (requires transport) | ||
304 | @item gnunet-daemon-hostlist (requires core) | ||
305 | @item gnunet-service-dht (requires core) | ||
306 | @item gnunet-service-mesh (requires dht, core) | ||
307 | @item gnunet-service-dns (requires dht) | ||
308 | @item gnunet-service-regex (requires dht) | ||
309 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
310 | @end itemize | ||
311 | |||
312 | @noindent | ||
313 | A minimum GNS system consists of the following GNUnet processes (in | ||
314 | order of dependency): | ||
315 | |||
316 | @itemize @bullet | ||
317 | @item gnunet-service-arm | ||
318 | @item gnunet-service-resolver (required by all) | ||
319 | @item gnunet-service-statistics (required by all) | ||
320 | @item gnunet-service-peerinfo | ||
321 | @item gnunet-service-transport (requires peerinfo) | ||
322 | @item gnunet-service-core (requires transport) | ||
323 | @item gnunet-daemon-hostlist (requires core) | ||
324 | @item gnunet-service-dht (requires core) | ||
325 | @item gnunet-service-mesh (requires dht, core) | ||
326 | @item gnunet-service-dns (requires dht) | ||
327 | @item gnunet-service-regex (requires dht) | ||
328 | @item gnunet-service-vpn (requires regex, dns, mesh, dht) | ||
329 | @item gnunet-service-identity | ||
330 | @item gnunet-service-namestore (requires identity) | ||
331 | @item gnunet-service-gns (requires vpn, dns, dht, namestore, identity) | ||
332 | @end itemize | ||
333 | |||
334 | @c *********************************************************************** | ||
335 | @node Code overview | ||
336 | @section Code overview | ||
337 | |||
338 | This section gives a brief overview of the GNUnet source code. | ||
339 | Specifically, we sketch the function of each of the subdirectories in | ||
340 | the @file{gnunet/src/} directory. The order given is roughly bottom-up | ||
341 | (in terms of the layers of the system). | ||
342 | |||
343 | @table @asis | ||
344 | @item @file{util/} --- libgnunetutil | ||
345 | Library with general utility functions, all | ||
346 | GNUnet binaries link against this library. Anything from memory | ||
347 | allocation and data structures to cryptography and inter-process | ||
348 | communication. The goal is to provide an OS-independent interface and | ||
349 | more 'secure' or convenient implementations of commonly used primitives. | ||
350 | The API is spread over more than a dozen headers, developers should study | ||
351 | those closely to avoid duplicating existing functions. | ||
352 | @pxref{libgnunetutil}. | ||
353 | @item @file{hello/} --- libgnunethello | ||
354 | HELLO messages are used to | ||
355 | describe under which addresses a peer can be reached (for example, | ||
356 | protocol, IP, port). This library manages parsing and generating of HELLO | ||
357 | messages. | ||
358 | @item @file{block/} --- libgnunetblock | ||
359 | The DHT and other components of GNUnet | ||
360 | store information in units called 'blocks'. Each block has a type and the | ||
361 | type defines a particular format and how that binary format is to be | ||
362 | linked to a hash code (the key for the DHT and for databases). The block | ||
363 | library is a wrapper around block plugins which provide the necessary | ||
364 | functions for each block type. | ||
365 | @item @file{statistics/} --- statistics service | ||
366 | The statistics service enables associating | ||
367 | values (of type uint64_t) with a component name and a string. The main | ||
368 | uses is debugging (counting events), performance tracking and user | ||
369 | entertainment (what did my peer do today?). | ||
370 | @item @file{arm/} --- Automatic Restart Manager (ARM) | ||
371 | The automatic-restart-manager (ARM) service | ||
372 | is the GNUnet master service. Its role is to start gnunet-services, to | ||
373 | re-start them when they crashed and finally to shut down the system when | ||
374 | requested. | ||
375 | @item @file{peerinfo/} --- peerinfo service | ||
376 | The peerinfo service keeps track of which peers are known | ||
377 | to the local peer and also tracks the validated addresses for each peer | ||
378 | (in the form of a HELLO message) for each of those peers. The peer is not | ||
379 | necessarily connected to all peers known to the peerinfo service. | ||
380 | Peerinfo provides persistent storage for peer identities --- peers are | ||
381 | not forgotten just because of a system restart. | ||
382 | @item @file{datacache/} --- libgnunetdatacache | ||
383 | The datacache library provides (temporary) block storage for the DHT. | ||
384 | Existing plugins can store blocks in Sqlite, Postgres or MySQL databases. | ||
385 | All data stored in the cache is lost when the peer is stopped or | ||
386 | restarted (datacache uses temporary tables). | ||
387 | @item @file{datastore/} --- datastore service | ||
388 | The datastore service stores file-sharing blocks in | ||
389 | databases for extended periods of time. In contrast to the datacache, data | ||
390 | is not lost when peers restart. However, quota restrictions may still | ||
391 | cause old, expired or low-priority data to be eventually discarded. | ||
392 | Existing plugins can store blocks in Sqlite, Postgres or MySQL databases. | ||
393 | @item @file{template/} --- service template | ||
394 | Template for writing a new service. Does nothing. | ||
395 | @item @file{ats/} --- Automatic Transport Selection | ||
396 | The automatic transport selection (ATS) service | ||
397 | is responsible for deciding which address (i.e. | ||
398 | which transport plugin) should be used for communication with other peers, | ||
399 | and at what bandwidth. | ||
400 | @item @file{nat/} --- libgnunetnat | ||
401 | Library that provides basic functions for NAT traversal. | ||
402 | The library supports NAT traversal with | ||
403 | manual hole-punching by the user, UPnP and ICMP-based autonomous NAT | ||
404 | traversal. The library also includes an API for testing if the current | ||
405 | configuration works and the @code{gnunet-nat-server} which provides an | ||
406 | external service to test the local configuration. | ||
407 | @item @file{fragmentation/} --- libgnunetfragmentation | ||
408 | Some transports (UDP and WLAN, mostly) have restrictions on the maximum | ||
409 | transfer unit (MTU) for packets. The fragmentation library can be used to | ||
410 | break larger packets into chunks of at most 1k and transmit the resulting | ||
411 | fragments reliably (with acknowledgment, retransmission, timeouts, | ||
412 | etc.). | ||
413 | @item @file{transport/} --- transport service | ||
414 | The transport service is responsible for managing the | ||
415 | basic P2P communication. It uses plugins to support P2P communication | ||
416 | over TCP, UDP, HTTP, HTTPS and other protocols.The transport service | ||
417 | validates peer addresses, enforces bandwidth restrictions, limits the | ||
418 | total number of connections and enforces connectivity restrictions (i.e. | ||
419 | friends-only). | ||
420 | @item @file{peerinfo-tool/} --- gnunet-peerinfo | ||
421 | This directory contains the gnunet-peerinfo binary which can be used to | ||
422 | inspect the peers and HELLOs known to the peerinfo service. | ||
423 | @item @file{core/} | ||
424 | The core service is responsible for establishing encrypted, authenticated | ||
425 | connections with other peers, encrypting and decrypting messages and | ||
426 | forwarding messages to higher-level services that are interested in them. | ||
427 | @item @file{testing/} --- libgnunettesting | ||
428 | The testing library allows starting (and stopping) peers | ||
429 | for writing testcases. | ||
430 | It also supports automatic generation of configurations for peers | ||
431 | ensuring that the ports and paths are disjoint. libgnunettesting is also | ||
432 | the foundation for the testbed service | ||
433 | @item @file{testbed/} --- testbed service | ||
434 | The testbed service is used for creating small or large scale deployments | ||
435 | of GNUnet peers for evaluation of protocols. | ||
436 | It facilitates peer deployments on multiple | ||
437 | hosts (for example, in a cluster) and establishing various network | ||
438 | topologies (both underlay and overlay). | ||
439 | @item @file{nse/} --- Network Size Estimation | ||
440 | The network size estimation (NSE) service | ||
441 | implements a protocol for (securely) estimating the current size of the | ||
442 | P2P network. | ||
443 | @item @file{dht/} --- distributed hash table | ||
444 | The distributed hash table (DHT) service provides a | ||
445 | distributed implementation of a hash table to store blocks under hash | ||
446 | keys in the P2P network. | ||
447 | @item @file{hostlist/} --- hostlist service | ||
448 | The hostlist service allows learning about | ||
449 | other peers in the network by downloading HELLO messages from an HTTP | ||
450 | server, can be configured to run such an HTTP server and also implements | ||
451 | a P2P protocol to advertise and automatically learn about other peers | ||
452 | that offer a public hostlist server. | ||
453 | @item @file{topology/} --- topology service | ||
454 | The topology service is responsible for | ||
455 | maintaining the mesh topology. It tries to maintain connections to friends | ||
456 | (depending on the configuration) and also tries to ensure that the peer | ||
457 | has a decent number of active connections at all times. If necessary, new | ||
458 | connections are added. All peers should run the topology service, | ||
459 | otherwise they may end up not being connected to any other peer (unless | ||
460 | some other service ensures that core establishes the required | ||
461 | connections). The topology service also tells the transport service which | ||
462 | connections are permitted (for friend-to-friend networking) | ||
463 | @item @file{fs/} --- file-sharing | ||
464 | The file-sharing (FS) service implements GNUnet's | ||
465 | file-sharing application. Both anonymous file-sharing (using gap) and | ||
466 | non-anonymous file-sharing (using dht) are supported. | ||
467 | @item @file{cadet/} --- cadet service | ||
468 | The CADET service provides a general-purpose routing abstraction to create | ||
469 | end-to-end encrypted tunnels in mesh networks. We wrote a paper | ||
470 | documenting key aspects of the design. | ||
471 | @item @file{tun/} --- libgnunettun | ||
472 | Library for building IPv4, IPv6 packets and creating | ||
473 | checksums for UDP, TCP and ICMP packets. The header | ||
474 | defines C structs for common Internet packet formats and in particular | ||
475 | structs for interacting with TUN (virtual network) interfaces. | ||
476 | @item @file{mysql/} --- libgnunetmysql | ||
477 | Library for creating and executing prepared MySQL | ||
478 | statements and to manage the connection to the MySQL database. | ||
479 | Essentially a lightweight wrapper for the interaction between GNUnet | ||
480 | components and libmysqlclient. | ||
481 | @item @file{dns/} | ||
482 | Service that allows intercepting and modifying DNS requests of | ||
483 | the local machine. Currently used for IPv4-IPv6 protocol translation | ||
484 | (DNS-ALG) as implemented by "pt/" and for the GNUnet naming system. The | ||
485 | service can also be configured to offer an exit service for DNS traffic. | ||
486 | @item @file{vpn/} --- VPN service | ||
487 | The virtual public network (VPN) service provides a virtual | ||
488 | tunnel interface (VTUN) for IP routing over GNUnet. | ||
489 | Needs some other peers to run an "exit" service to work. | ||
490 | Can be activated using the "gnunet-vpn" tool or integrated with DNS using | ||
491 | the "pt" daemon. | ||
492 | @item @file{exit/} | ||
493 | Daemon to allow traffic from the VPN to exit this | ||
494 | peer to the Internet or to specific IP-based services of the local peer. | ||
495 | Currently, an exit service can only be restricted to IPv4 or IPv6, not to | ||
496 | specific ports and or IP address ranges. If this is not acceptable, | ||
497 | additional firewall rules must be added manually. exit currently only | ||
498 | works for normal UDP, TCP and ICMP traffic; DNS queries need to leave the | ||
499 | system via a DNS service. | ||
500 | @item @file{pt/} | ||
501 | protocol translation daemon. This daemon enables 4-to-6, | ||
502 | 6-to-4, 4-over-6 or 6-over-4 transitions for the local system. It | ||
503 | essentially uses "DNS" to intercept DNS replies and then maps results to | ||
504 | those offered by the VPN, which then sends them using mesh to some daemon | ||
505 | offering an appropriate exit service. | ||
506 | @item @file{identity/} | ||
507 | Management of egos (alter egos) of a user; identities are | ||
508 | essentially named ECC private keys and used for zones in the GNU name | ||
509 | system and for namespaces in file-sharing, but might find other uses later | ||
510 | @item @file{revocation/} | ||
511 | Key revocation service, can be used to revoke the | ||
512 | private key of an identity if it has been compromised | ||
513 | @item @file{namecache/} | ||
514 | Cache for resolution results for the GNU name system; | ||
515 | data is encrypted and can be shared among users, | ||
516 | loss of the data should ideally only result in a | ||
517 | performance degradation (persistence not required) | ||
518 | @item @file{namestore/} | ||
519 | Database for the GNU name system with per-user private information, | ||
520 | persistence required | ||
521 | @item @file{gns/} | ||
522 | GNU name system, a GNU approach to DNS and PKI. | ||
523 | @item @file{dv/} | ||
524 | A plugin for distance-vector (DV)-based routing. | ||
525 | DV consists of a service and a transport plugin to provide peers | ||
526 | with the illusion of a direct P2P connection for connections | ||
527 | that use multiple (typically up to 3) hops in the actual underlay network. | ||
528 | @item @file{regex/} | ||
529 | Service for the (distributed) evaluation of regular expressions. | ||
530 | @item @file{scalarproduct/} | ||
531 | The scalar product service offers an API to perform a secure multiparty | ||
532 | computation which calculates a scalar product between two peers | ||
533 | without exposing the private input vectors of the peers to each other. | ||
534 | @item @file{consensus/} | ||
535 | The consensus service will allow a set of peers to agree | ||
536 | on a set of values via a distributed set union computation. | ||
537 | @item @file{rest/} | ||
538 | The rest API allows access to GNUnet services using RESTful interaction. | ||
539 | The services provide plugins that can exposed by the rest server. | ||
540 | @c FIXME: Where did this disappear to? | ||
541 | @c @item @file{experimentation/} | ||
542 | @c The experimentation daemon coordinates distributed | ||
543 | @c experimentation to evaluate transport and ATS properties. | ||
544 | @end table | ||
545 | |||
546 | @c *********************************************************************** | ||
547 | @node System Architecture | ||
548 | @section System Architecture | ||
549 | |||
550 | @c FIXME: For those irritated by the textflow, we are missing images here, | ||
551 | @c in the short term we should add them back, in the long term this should | ||
552 | @c work without images or have images with alt-text. | ||
553 | |||
554 | GNUnet developers like LEGOs. The blocks are indestructible, can be | ||
555 | stacked together to construct complex buildings and it is generally easy | ||
556 | to swap one block for a different one that has the same shape. GNUnet's | ||
557 | architecture is based on LEGOs: | ||
558 | |||
559 | @c @image{images/service_lego_block,5in,,picture of a LEGO block stack - 3 APIs as connectors upon Network Protocol on top of a Service} | ||
560 | |||
561 | This chapter documents the GNUnet LEGO system, also known as GNUnet's | ||
562 | system architecture. | ||
563 | |||
564 | The most common GNUnet component is a service. Services offer an API (or | ||
565 | several, depending on what you count as "an API") which is implemented as | ||
566 | a library. The library communicates with the main process of the service | ||
567 | using a service-specific network protocol. The main process of the service | ||
568 | typically doesn't fully provide everything that is needed --- it has holes | ||
569 | to be filled by APIs to other services. | ||
570 | |||
571 | A special kind of component in GNUnet are user interfaces and daemons. | ||
572 | Like services, they have holes to be filled by APIs of other services. | ||
573 | Unlike services, daemons do not implement their own network protocol and | ||
574 | they have no API: | ||
575 | |||
576 | The GNUnet system provides a range of services, daemons and user | ||
577 | interfaces, which are then combined into a layered GNUnet instance (also | ||
578 | known as a peer). | ||
579 | |||
580 | Note that while it is generally possible to swap one service for another | ||
581 | compatible service, there is often only one implementation. However, | ||
582 | during development we often have a "new" version of a service in parallel | ||
583 | with an "old" version. While the "new" version is not working, developers | ||
584 | working on other parts of the service can continue their development by | ||
585 | simply using the "old" service. Alternative design ideas can also be | ||
586 | easily investigated by swapping out individual components. This is | ||
587 | typically achieved by simply changing the name of the "BINARY" in the | ||
588 | respective configuration section. | ||
589 | |||
590 | Key properties of GNUnet services are that they must be separate | ||
591 | processes and that they must protect themselves by applying tight error | ||
592 | checking against the network protocol they implement (thereby achieving a | ||
593 | certain degree of robustness). | ||
594 | |||
595 | On the other hand, the APIs are implemented to tolerate failures of the | ||
596 | service, isolating their host process from errors by the service. If the | ||
597 | service process crashes, other services and daemons around it should not | ||
598 | also fail, but instead wait for the service process to be restarted by | ||
599 | ARM. | ||
600 | |||
601 | |||
602 | @c *********************************************************************** | ||
603 | @node Subsystem stability | ||
604 | @section Subsystem stability | ||
605 | |||
606 | This section documents the current stability of the various GNUnet | ||
607 | subsystems. Stability here describes the expected degree of compatibility | ||
608 | with future versions of GNUnet. For each subsystem we distinguish between | ||
609 | compatibility on the P2P network level (communication protocol between | ||
610 | peers), the IPC level (communication between the service and the service | ||
611 | library) and the API level (stability of the API). P2P compatibility is | ||
612 | relevant in terms of which applications are likely going to be able to | ||
613 | communicate with future versions of the network. IPC communication is | ||
614 | relevant for the implementation of language bindings that re-implement the | ||
615 | IPC messages. Finally, API compatibility is relevant to developers that | ||
616 | hope to be able to avoid changes to applications build on top of the APIs | ||
617 | of the framework. | ||
618 | |||
619 | The following table summarizes our current view of the stability of the | ||
620 | respective protocols or APIs: | ||
621 | |||
622 | @multitable @columnfractions .20 .20 .20 .20 | ||
623 | @headitem Subsystem @tab P2P @tab IPC @tab C API | ||
624 | @item util @tab n/a @tab n/a @tab stable | ||
625 | @item arm @tab n/a @tab stable @tab stable | ||
626 | @item ats @tab n/a @tab unstable @tab testing | ||
627 | @item block @tab n/a @tab n/a @tab stable | ||
628 | @item cadet @tab testing @tab testing @tab testing | ||
629 | @item consensus @tab experimental @tab experimental @tab experimental | ||
630 | @item core @tab stable @tab stable @tab stable | ||
631 | @item datacache @tab n/a @tab n/a @tab stable | ||
632 | @item datastore @tab n/a @tab stable @tab stable | ||
633 | @item dht @tab stable @tab stable @tab stable | ||
634 | @item dns @tab stable @tab stable @tab stable | ||
635 | @item dv @tab testing @tab testing @tab n/a | ||
636 | @item exit @tab testing @tab n/a @tab n/a | ||
637 | @item fragmentation @tab stable @tab n/a @tab stable | ||
638 | @item fs @tab stable @tab stable @tab stable | ||
639 | @item gns @tab stable @tab stable @tab stable | ||
640 | @item hello @tab n/a @tab n/a @tab testing | ||
641 | @item hostlist @tab stable @tab stable @tab n/a | ||
642 | @item identity @tab stable @tab stable @tab n/a | ||
643 | @item multicast @tab experimental @tab experimental @tab experimental | ||
644 | @item mysql @tab stable @tab n/a @tab stable | ||
645 | @item namestore @tab n/a @tab stable @tab stable | ||
646 | @item nat @tab n/a @tab n/a @tab stable | ||
647 | @item nse @tab stable @tab stable @tab stable | ||
648 | @item peerinfo @tab n/a @tab stable @tab stable | ||
649 | @item psyc @tab experimental @tab experimental @tab experimental | ||
650 | @item pt @tab n/a @tab n/a @tab n/a | ||
651 | @item regex @tab stable @tab stable @tab stable | ||
652 | @item revocation @tab stable @tab stable @tab stable | ||
653 | @item social @tab experimental @tab experimental @tab experimental | ||
654 | @item statistics @tab n/a @tab stable @tab stable | ||
655 | @item testbed @tab n/a @tab testing @tab testing | ||
656 | @item testing @tab n/a @tab n/a @tab testing | ||
657 | @item topology @tab n/a @tab n/a @tab n/a | ||
658 | @item transport @tab stable @tab stable @tab stable | ||
659 | @item tun @tab n/a @tab n/a @tab stable | ||
660 | @item vpn @tab testing @tab n/a @tab n/a | ||
661 | @end multitable | ||
662 | |||
663 | Here is a rough explanation of the values: | ||
664 | |||
665 | @table @samp | ||
666 | @item stable | ||
667 | No incompatible changes are planned at this time; for IPC/APIs, if | ||
668 | there are incompatible changes, they will be minor and might only require | ||
669 | minimal changes to existing code; for P2P, changes will be avoided if at | ||
670 | all possible for the 0.10.x-series | ||
671 | |||
672 | @item testing | ||
673 | No incompatible changes are | ||
674 | planned at this time, but the code is still known to be in flux; so while | ||
675 | we have no concrete plans, our expectation is that there will still be | ||
676 | minor modifications; for P2P, changes will likely be extensions that | ||
677 | should not break existing code | ||
678 | |||
679 | @item unstable | ||
680 | Changes are planned and will happen; however, they | ||
681 | will not be totally radical and the result should still resemble what is | ||
682 | there now; nevertheless, anticipated changes will break protocol/API | ||
683 | compatibility | ||
684 | |||
685 | @item experimental | ||
686 | Changes are planned and the result may look nothing like | ||
687 | what the API/protocol looks like today | ||
688 | |||
689 | @item unknown | ||
690 | Someone should think about where this subsystem headed | ||
691 | |||
692 | @item n/a | ||
693 | This subsystem does not have an API/IPC-protocol/P2P-protocol | ||
694 | @end table | ||
695 | |||
696 | @c *********************************************************************** | ||
697 | @node Naming conventions and coding style guide | ||
698 | @section Naming conventions and coding style guide | ||
699 | |||
700 | Here you can find some rules to help you write code for GNUnet. | ||
701 | |||
702 | @c *********************************************************************** | ||
703 | @menu | ||
704 | * Naming conventions:: | ||
705 | * Coding style:: | ||
706 | @end menu | ||
707 | |||
708 | @node Naming conventions | ||
709 | @subsection Naming conventions | ||
710 | |||
711 | |||
712 | @c *********************************************************************** | ||
713 | @menu | ||
714 | * include files:: | ||
715 | * binaries:: | ||
716 | * logging:: | ||
717 | * configuration:: | ||
718 | * exported symbols:: | ||
719 | * private (library-internal) symbols (including structs and macros):: | ||
720 | * testcases:: | ||
721 | * performance tests:: | ||
722 | * src/ directories:: | ||
723 | @end menu | ||
724 | |||
725 | @node include files | ||
726 | @subsubsection include files | ||
727 | |||
728 | @itemize @bullet | ||
729 | @item _lib: library without need for a process | ||
730 | @item _service: library that needs a service process | ||
731 | @item _plugin: plugin definition | ||
732 | @item _protocol: structs used in network protocol | ||
733 | @item exceptions: | ||
734 | @itemize @bullet | ||
735 | @item gnunet_config.h --- generated | ||
736 | @item platform.h --- first included | ||
737 | @item plibc.h --- external library | ||
738 | @item gnunet_common.h --- fundamental routines | ||
739 | @item gnunet_directories.h --- generated | ||
740 | @item gettext.h --- external library | ||
741 | @end itemize | ||
742 | @end itemize | ||
743 | |||
744 | @c *********************************************************************** | ||
745 | @node binaries | ||
746 | @subsubsection binaries | ||
747 | |||
748 | @itemize @bullet | ||
749 | @item gnunet-service-xxx: service process (has listen socket) | ||
750 | @item gnunet-daemon-xxx: daemon process (no listen socket) | ||
751 | @item gnunet-helper-xxx[-yyy]: SUID helper for module xxx | ||
752 | @item gnunet-yyy: command-line tool for end-users | ||
753 | @item libgnunet_plugin_xxx_yyy.so: plugin for API xxx | ||
754 | @item libgnunetxxx.so: library for API xxx | ||
755 | @end itemize | ||
756 | |||
757 | @c *********************************************************************** | ||
758 | @node logging | ||
759 | @subsubsection logging | ||
760 | |||
761 | @itemize @bullet | ||
762 | @item services and daemons use their directory name in | ||
763 | @code{GNUNET_log_setup} (i.e. 'core') and log using | ||
764 | plain 'GNUNET_log'. | ||
765 | @item command-line tools use their full name in | ||
766 | @code{GNUNET_log_setup} (i.e. 'gnunet-publish') and log using | ||
767 | plain 'GNUNET_log'. | ||
768 | @item service access libraries log using | ||
769 | '@code{GNUNET_log_from}' and use '@code{DIRNAME-api}' for the | ||
770 | component (i.e. 'core-api') | ||
771 | @item pure libraries (without associated service) use | ||
772 | '@code{GNUNET_log_from}' with the component set to their | ||
773 | library name (without lib or '@file{.so}'), | ||
774 | which should also be their directory name (i.e. '@file{nat}') | ||
775 | @item plugins should use '@code{GNUNET_log_from}' | ||
776 | with the directory name and the plugin name combined to produce | ||
777 | the component name (i.e. 'transport-tcp'). | ||
778 | @item logging should be unified per-file by defining a | ||
779 | @code{LOG} macro with the appropriate arguments, | ||
780 | along these lines: | ||
781 | |||
782 | @example | ||
783 | #define LOG(kind,...) | ||
784 | GNUNET_log_from (kind, "example-api",__VA_ARGS__) | ||
785 | @end example | ||
786 | |||
787 | @end itemize | ||
788 | |||
789 | @c *********************************************************************** | ||
790 | @node configuration | ||
791 | @subsubsection configuration | ||
792 | |||
793 | @itemize @bullet | ||
794 | @item paths (that are substituted in all filenames) are in PATHS | ||
795 | (have as few as possible) | ||
796 | @item all options for a particular module (@file{src/MODULE}) | ||
797 | are under @code{[MODULE]} | ||
798 | @item options for a plugin of a module | ||
799 | are under @code{[MODULE-PLUGINNAME]} | ||
800 | @end itemize | ||
801 | |||
802 | @c *********************************************************************** | ||
803 | @node exported symbols | ||
804 | @subsubsection exported symbols | ||
805 | |||
806 | @itemize @bullet | ||
807 | @item must start with @code{GNUNET_modulename_} and be defined in | ||
808 | @file{modulename.c} | ||
809 | @item exceptions: those defined in @file{gnunet_common.h} | ||
810 | @end itemize | ||
811 | |||
812 | @c *********************************************************************** | ||
813 | @node private (library-internal) symbols (including structs and macros) | ||
814 | @subsubsection private (library-internal) symbols (including structs and macros) | ||
815 | |||
816 | @itemize @bullet | ||
817 | @item must NOT start with any prefix | ||
818 | @item must not be exported in a way that linkers could use them or@ other | ||
819 | libraries might see them via headers; they must be either | ||
820 | declared/defined in C source files or in headers that are in the | ||
821 | respective directory under @file{src/modulename/} and NEVER be declared | ||
822 | in @file{src/include/}. | ||
823 | @end itemize | ||
824 | |||
825 | @node testcases | ||
826 | @subsubsection testcases | ||
827 | |||
828 | @itemize @bullet | ||
829 | @item must be called @file{test_module-under-test_case-description.c} | ||
830 | @item "case-description" maybe omitted if there is only one test | ||
831 | @end itemize | ||
832 | |||
833 | @c *********************************************************************** | ||
834 | @node performance tests | ||
835 | @subsubsection performance tests | ||
836 | |||
837 | @itemize @bullet | ||
838 | @item must be called @file{perf_module-under-test_case-description.c} | ||
839 | @item "case-description" maybe omitted if there is only one performance | ||
840 | test | ||
841 | @item Must only be run if @code{HAVE_BENCHMARKS} is satisfied | ||
842 | @end itemize | ||
843 | |||
844 | @c *********************************************************************** | ||
845 | @node src/ directories | ||
846 | @subsubsection src/ directories | ||
847 | |||
848 | @itemize @bullet | ||
849 | @item gnunet-NAME: end-user applications (i.e., gnunet-search, gnunet-arm) | ||
850 | @item gnunet-service-NAME: service processes with accessor library (i.e., | ||
851 | gnunet-service-arm) | ||
852 | @item libgnunetNAME: accessor library (_service.h-header) or standalone | ||
853 | library (_lib.h-header) | ||
854 | @item gnunet-daemon-NAME: daemon process without accessor library (i.e., | ||
855 | gnunet-daemon-hostlist) and no GNUnet management port | ||
856 | @item libgnunet_plugin_DIR_NAME: loadable plugins (i.e., | ||
857 | libgnunet_plugin_transport_tcp) | ||
858 | @end itemize | ||
859 | |||
860 | @cindex Coding style | ||
861 | @node Coding style | ||
862 | @subsection Coding style | ||
863 | |||
864 | @c XXX: Adjust examples to GNU Standards! | ||
865 | @itemize @bullet | ||
866 | @item We follow the GNU Coding Standards (@pxref{Top, The GNU Coding Standards,, standards, The GNU Coding Standards}); | ||
867 | @item Indentation is done with spaces, two per level, no tabs; | ||
868 | @item C99 struct initialization is fine; | ||
869 | @item declare only one variable per line, for example: | ||
870 | |||
871 | @noindent | ||
872 | instead of | ||
873 | |||
874 | @example | ||
875 | int i,j; | ||
876 | @end example | ||
877 | |||
878 | @noindent | ||
879 | write: | ||
880 | |||
881 | @example | ||
882 | int i; | ||
883 | int j; | ||
884 | @end example | ||
885 | |||
886 | @c TODO: include actual example from a file in source | ||
887 | |||
888 | @noindent | ||
889 | This helps keep diffs small and forces developers to think precisely about | ||
890 | the type of every variable. | ||
891 | Note that @code{char *} is different from @code{const char*} and | ||
892 | @code{int} is different from @code{unsigned int} or @code{uint32_t}. | ||
893 | Each variable type should be chosen with care. | ||
894 | |||
895 | @item While @code{goto} should generally be avoided, having a | ||
896 | @code{goto} to the end of a function to a block of clean up | ||
897 | statements (free, close, etc.) can be acceptable. | ||
898 | |||
899 | @item Conditions should be written with constants on the left (to avoid | ||
900 | accidental assignment) and with the @code{true} target being either the | ||
901 | @code{error} case or the significantly simpler continuation. For example: | ||
902 | |||
903 | @example | ||
904 | if (0 != stat ("filename," &sbuf)) @{ | ||
905 | error(); | ||
906 | @} | ||
907 | else @{ | ||
908 | /* handle normal case here */ | ||
909 | @} | ||
910 | @end example | ||
911 | |||
912 | @noindent | ||
913 | instead of | ||
914 | |||
915 | @example | ||
916 | if (stat ("filename," &sbuf) == 0) @{ | ||
917 | /* handle normal case here */ | ||
918 | @} else @{ | ||
919 | error(); | ||
920 | @} | ||
921 | @end example | ||
922 | |||
923 | @noindent | ||
924 | If possible, the error clause should be terminated with a @code{return} (or | ||
925 | @code{goto} to some cleanup routine) and in this case, the @code{else} clause | ||
926 | should be omitted: | ||
927 | |||
928 | @example | ||
929 | if (0 != stat ("filename," &sbuf)) @{ | ||
930 | error(); | ||
931 | return; | ||
932 | @} | ||
933 | /* handle normal case here */ | ||
934 | @end example | ||
935 | |||
936 | This serves to avoid deep nesting. The 'constants on the left' rule | ||
937 | applies to all constants (including. @code{GNUNET_SCHEDULER_NO_TASK}), | ||
938 | NULL, and enums). With the two above rules (constants on left, errors in | ||
939 | 'true' branch), there is only one way to write most branches correctly. | ||
940 | |||
941 | @item Combined assignments and tests are allowed if they do not hinder | ||
942 | code clarity. For example, one can write: | ||
943 | |||
944 | @example | ||
945 | if (NULL == (value = lookup_function())) @{ | ||
946 | error(); | ||
947 | return; | ||
948 | @} | ||
949 | @end example | ||
950 | |||
951 | @item Use @code{break} and @code{continue} wherever possible to avoid | ||
952 | deep(er) nesting. Thus, we would write: | ||
953 | |||
954 | @example | ||
955 | next = head; | ||
956 | while (NULL != (pos = next)) @{ | ||
957 | next = pos->next; | ||
958 | if (! should_free (pos)) | ||
959 | continue; | ||
960 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
961 | GNUNET_free (pos); | ||
962 | @} | ||
963 | @end example | ||
964 | |||
965 | instead of | ||
966 | |||
967 | @example | ||
968 | next = head; while (NULL != (pos = next)) @{ | ||
969 | next = pos->next; | ||
970 | if (should_free (pos)) @{ | ||
971 | /* unnecessary nesting! */ | ||
972 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
973 | GNUNET_free (pos); | ||
974 | @} | ||
975 | @} | ||
976 | @end example | ||
977 | |||
978 | @item We primarily use @code{for} and @code{while} loops. | ||
979 | A @code{while} loop is used if the method for advancing in the loop is | ||
980 | not a straightforward increment operation. In particular, we use: | ||
981 | |||
982 | @example | ||
983 | next = head; | ||
984 | while (NULL != (pos = next)) | ||
985 | @{ | ||
986 | next = pos->next; | ||
987 | if (! should_free (pos)) | ||
988 | continue; | ||
989 | GNUNET_CONTAINER_DLL_remove (head, tail, pos); | ||
990 | GNUNET_free (pos); | ||
991 | @} | ||
992 | @end example | ||
993 | |||
994 | to free entries in a list (as the iteration changes the structure of the | ||
995 | list due to the free; the equivalent @code{for} loop does no longer | ||
996 | follow the simple @code{for} paradigm of @code{for(INIT;TEST;INC)}). | ||
997 | However, for loops that do follow the simple @code{for} paradigm we do | ||
998 | use @code{for}, even if it involves linked lists: | ||
999 | |||
1000 | @example | ||
1001 | /* simple iteration over a linked list */ | ||
1002 | for (pos = head; | ||
1003 | NULL != pos; | ||
1004 | pos = pos->next) | ||
1005 | @{ | ||
1006 | use (pos); | ||
1007 | @} | ||
1008 | @end example | ||
1009 | |||
1010 | |||
1011 | @item The first argument to all higher-order functions in GNUnet must be | ||
1012 | declared to be of type @code{void *} and is reserved for a closure. We do | ||
1013 | not use inner functions, as trampolines would conflict with setups that | ||
1014 | use non-executable stacks. | ||
1015 | The first statement in a higher-order function, which unusually should | ||
1016 | be part of the variable declarations, should assign the | ||
1017 | @code{cls} argument to the precise expected type. For example: | ||
1018 | |||
1019 | @example | ||
1020 | int callback (void *cls, char *args) @{ | ||
1021 | struct Foo *foo = cls; | ||
1022 | int other_variables; | ||
1023 | |||
1024 | /* rest of function */ | ||
1025 | @} | ||
1026 | @end example | ||
1027 | |||
1028 | |||
1029 | @item It is good practice to write complex @code{if} expressions instead | ||
1030 | of using deeply nested @code{if} statements. However, except for addition | ||
1031 | and multiplication, all operators should use parens. This is fine: | ||
1032 | |||
1033 | @example | ||
1034 | if ( (1 == foo) || ((0 == bar) && (x != y)) ) | ||
1035 | return x; | ||
1036 | @end example | ||
1037 | |||
1038 | |||
1039 | However, this is not: | ||
1040 | |||
1041 | @example | ||
1042 | if (1 == foo) | ||
1043 | return x; | ||
1044 | if (0 == bar && x != y) | ||
1045 | return x; | ||
1046 | @end example | ||
1047 | |||
1048 | @noindent | ||
1049 | Note that splitting the @code{if} statement above is debatable as the | ||
1050 | @code{return x} is a very trivial statement. However, once the logic after | ||
1051 | the branch becomes more complicated (and is still identical), the "or" | ||
1052 | formulation should be used for sure. | ||
1053 | |||
1054 | @item There should be two empty lines between the end of the function and | ||
1055 | the comments describing the following function. There should be a single | ||
1056 | empty line after the initial variable declarations of a function. If a | ||
1057 | function has no local variables, there should be no initial empty line. If | ||
1058 | a long function consists of several complex steps, those steps might be | ||
1059 | separated by an empty line (possibly followed by a comment describing the | ||
1060 | following step). The code should not contain empty lines in arbitrary | ||
1061 | places; if in doubt, it is likely better to NOT have an empty line (this | ||
1062 | way, more code will fit on the screen). | ||
1063 | @end itemize | ||
1064 | |||
1065 | @c *********************************************************************** | ||
1066 | @node Build-system | ||
1067 | @section Build-system | ||
1068 | |||
1069 | If you have code that is likely not to compile or build rules you might | ||
1070 | want to not trigger for most developers, use @code{if HAVE_EXPERIMENTAL} | ||
1071 | in your @file{Makefile.am}. | ||
1072 | Then it is OK to (temporarily) add non-compiling (or known-to-not-port) | ||
1073 | code. | ||
1074 | |||
1075 | If you want to compile all testcases but NOT run them, run configure with | ||
1076 | the @code{--enable-test-suppression} option. | ||
1077 | |||
1078 | If you want to run all testcases, including those that take a while, run | ||
1079 | configure with the @code{--enable-expensive-testcases} option. | ||
1080 | |||
1081 | If you want to compile and run benchmarks, run configure with the | ||
1082 | @code{--enable-benchmarks} option. | ||
1083 | |||
1084 | If you want to obtain code coverage results, run configure with the | ||
1085 | @code{--enable-coverage} option and run the @file{coverage.sh} script in | ||
1086 | the @file{contrib/} directory. | ||
1087 | |||
1088 | @cindex gnunet-ext | ||
1089 | @node Developing extensions for GNUnet using the gnunet-ext template | ||
1090 | @section Developing extensions for GNUnet using the gnunet-ext template | ||
1091 | |||
1092 | For developers who want to write extensions for GNUnet we provide the | ||
1093 | gnunet-ext template to provide an easy to use skeleton. | ||
1094 | |||
1095 | gnunet-ext contains the build environment and template files for the | ||
1096 | development of GNUnet services, command line tools, APIs and tests. | ||
1097 | |||
1098 | First of all you have to obtain gnunet-ext from git: | ||
1099 | |||
1100 | @example | ||
1101 | git clone https://gnunet.org/git/gnunet-ext.git | ||
1102 | @end example | ||
1103 | |||
1104 | The next step is to bootstrap and configure it. For configure you have to | ||
1105 | provide the path containing GNUnet with | ||
1106 | @code{--with-gnunet=/path/to/gnunet} and the prefix where you want the | ||
1107 | install the extension using @code{--prefix=/path/to/install}: | ||
1108 | |||
1109 | @example | ||
1110 | ./bootstrap | ||
1111 | ./configure --prefix=/path/to/install --with-gnunet=/path/to/gnunet | ||
1112 | @end example | ||
1113 | |||
1114 | When your GNUnet installation is not included in the default linker search | ||
1115 | path, you have to add @code{/path/to/gnunet} to the file | ||
1116 | @file{/etc/ld.so.conf} and run @code{ldconfig} or your add it to the | ||
1117 | environmental variable @code{LD_LIBRARY_PATH} by using | ||
1118 | |||
1119 | @example | ||
1120 | export LD_LIBRARY_PATH=/path/to/gnunet/lib | ||
1121 | @end example | ||
1122 | |||
1123 | @cindex writing testcases | ||
1124 | @node Writing testcases | ||
1125 | @section Writing testcases | ||
1126 | |||
1127 | Ideally, any non-trivial GNUnet code should be covered by automated | ||
1128 | testcases. Testcases should reside in the same place as the code that is | ||
1129 | being tested. The name of source files implementing tests should begin | ||
1130 | with @code{test_} followed by the name of the file that contains | ||
1131 | the code that is being tested. | ||
1132 | |||
1133 | Testcases in GNUnet should be integrated with the autotools build system. | ||
1134 | This way, developers and anyone building binary packages will be able to | ||
1135 | run all testcases simply by running @code{make check}. The final | ||
1136 | testcases shipped with the distribution should output at most some brief | ||
1137 | progress information and not display debug messages by default. The | ||
1138 | success or failure of a testcase must be indicated by returning zero | ||
1139 | (success) or non-zero (failure) from the main method of the testcase. | ||
1140 | The integration with the autotools is relatively straightforward and only | ||
1141 | requires modifications to the @file{Makefile.am} in the directory | ||
1142 | containing the testcase. For a testcase testing the code in @file{foo.c} | ||
1143 | the @file{Makefile.am} would contain the following lines: | ||
1144 | |||
1145 | @example | ||
1146 | check_PROGRAMS = test_foo | ||
1147 | TESTS = $(check_PROGRAMS) | ||
1148 | test_foo_SOURCES = test_foo.c | ||
1149 | test_foo_LDADD = $(top_builddir)/src/util/libgnunetutil.la | ||
1150 | @end example | ||
1151 | |||
1152 | Naturally, other libraries used by the testcase may be specified in the | ||
1153 | @code{LDADD} directive as necessary. | ||
1154 | |||
1155 | Often testcases depend on additional input files, such as a configuration | ||
1156 | file. These support files have to be listed using the @code{EXTRA_DIST} | ||
1157 | directive in order to ensure that they are included in the distribution. | ||
1158 | |||
1159 | Example: | ||
1160 | |||
1161 | @example | ||
1162 | EXTRA_DIST = test_foo_data.conf | ||
1163 | @end example | ||
1164 | |||
1165 | Executing @code{make check} will run all testcases in the current | ||
1166 | directory and all subdirectories. Testcases can be compiled individually | ||
1167 | by running @code{make test_foo} and then invoked directly using | ||
1168 | @code{./test_foo}. Note that due to the use of plugins in GNUnet, it is | ||
1169 | typically necessary to run @code{make install} before running any | ||
1170 | testcases. Thus the canonical command @code{make check install} has to be | ||
1171 | changed to @code{make install check} for GNUnet. | ||
1172 | |||
1173 | @c *********************************************************************** | ||
1174 | @cindex Building GNUnet | ||
1175 | @node Building GNUnet and its dependencies | ||
1176 | @section Building GNUnet and its dependencies | ||
1177 | |||
1178 | In the following section we will outline how to build GNUnet and | ||
1179 | some of its dependencies. We will assume a fair amount of knowledge | ||
1180 | for building applications under UNIX-like systems. Furthermore we | ||
1181 | assume that the build environment is sane and that you are aware of | ||
1182 | any implications actions in this process could have. | ||
1183 | Instructions here can be seen as notes for developers (an extension to | ||
1184 | the 'HACKING' section in README) as well as package maintainers. | ||
1185 | @b{Users should rely on the available binary packages.} | ||
1186 | We will use Debian as an example Operating System environment. Substitute | ||
1187 | accordingly with your own Operating System environment. | ||
1188 | |||
1189 | For the full list of dependencies, consult the appropriate, up-to-date | ||
1190 | section in the @file{README} file. | ||
1191 | |||
1192 | First, we need to build or install (depending on your OS) the following | ||
1193 | packages. If you build them from source, build them in this exact order: | ||
1194 | |||
1195 | @example | ||
1196 | libgpgerror, libgcrypt, libnettle, libunbound, GnuTLS (with libunbound | ||
1197 | support) | ||
1198 | @end example | ||
1199 | |||
1200 | After we have build and installed those packages, we continue with | ||
1201 | packages closer to GNUnet in this step: libgnurl (our libcurl fork), | ||
1202 | GNU libmicrohttpd, and GNU libextractor. Again, if your package manager | ||
1203 | provides one of these packages, use the packages provided from it | ||
1204 | unless you have good reasons (package version too old, conflicts, etc). | ||
1205 | We advise against compiling widely used packages such as GnuTLS | ||
1206 | yourself if your OS provides a variant already unless you take care | ||
1207 | of maintenance of the packages then. | ||
1208 | |||
1209 | In the optimistic case, this command will give you all the dependencies: | ||
1210 | |||
1211 | @example | ||
1212 | sudo apt-get install libgnurl libmicrohttpd libextractor | ||
1213 | @end example | ||
1214 | |||
1215 | From experience we know that at the very least libgnurl is not | ||
1216 | available in some environments. You could substitute libgnurl | ||
1217 | with libcurl, but we recommend to install libgnurl, as it gives | ||
1218 | you a predefined libcurl with the small set GNUnet requires. In | ||
1219 | the past namespaces of libcurl and libgnurl were shared, which | ||
1220 | caused problems when you wanted to integrate both of them in one | ||
1221 | Operating System. This has been resolved, and they can be installed | ||
1222 | side by side now. | ||
1223 | |||
1224 | @cindex libgnurl | ||
1225 | @cindex compiling libgnurl | ||
1226 | GNUnet and some of its function depend on a limited subset of cURL/libcurl. | ||
1227 | Rather than trying to enforce a certain configuration on the world, we | ||
1228 | opted to maintain a microfork of it that ensures we can link against the | ||
1229 | right set of features. We called this specialized set of libcurl | ||
1230 | ``libgnurl''. It is fully ABI compatible with libcurl and currently used | ||
1231 | by GNUnet and some of its dependencies. | ||
1232 | |||
1233 | We download libgnurl and its digital signature from the GNU fileserver, | ||
1234 | assuming @env{TMPDIR} exists. | ||
1235 | |||
1236 | Note: TMPDIR might be @file{/tmp}, @env{TMPDIR}, @env{TMP} or any other | ||
1237 | location. For consistency we assume @env{TMPDIR} points to @file{/tmp} | ||
1238 | for the remainder of this section. | ||
1239 | |||
1240 | @example | ||
1241 | cd \$TMPDIR | ||
1242 | wget https://ftp.gnu.org/gnu/gnunet/gnurl-7.60.0.tar.Z | ||
1243 | wget https://ftp.gnu.org/gnu/gnunet/gnurl-7.60.0.tar.Z.sig | ||
1244 | @end example | ||
1245 | |||
1246 | Next, verify the digital signature of the file: | ||
1247 | |||
1248 | @example | ||
1249 | gpg --verify gnurl-7.60.0.tar.Z.sig | ||
1250 | @end example | ||
1251 | |||
1252 | If gpg fails, you might try with @command{gpg2} on your OS. If the error | ||
1253 | states that ``the key can not be found'' or it is unknown, you have to | ||
1254 | retrieve the key (A88C8ADD129828D7EAC02E52E22F9BBFEE348588) from a | ||
1255 | keyserver first: | ||
1256 | |||
1257 | @example | ||
1258 | gpg --keyserver pgp.mit.edu --recv-keys A88C8ADD129828D7EAC02E52E22F9BBFEE348588 | ||
1259 | @end example | ||
1260 | |||
1261 | and rerun the verification command. | ||
1262 | |||
1263 | libgnurl will require the following packages to be present at runtime: | ||
1264 | gnutls (with DANE support / libunbound), libidn, zlib and at compile time: | ||
1265 | libtool, groff, perl, pkg-config, and python 2.7. | ||
1266 | |||
1267 | Once you have verified that all the required packages are present on your | ||
1268 | system, we can proceed to compile libgnurl: | ||
1269 | |||
1270 | @example | ||
1271 | tar -xvf gnurl-7.60.0.tar.Z | ||
1272 | cd gnurl-7.60.0 | ||
1273 | sh configure --disable-ntlm-wb | ||
1274 | make | ||
1275 | make -C tests test | ||
1276 | sudo make install | ||
1277 | @end example | ||
1278 | |||
1279 | After you've compiled and installed libgnurl, we can proceed to building | ||
1280 | GNUnet. | ||
1281 | |||
1282 | |||
1283 | |||
1284 | |||
1285 | First, in addition to the GNUnet sources you might require downloading the | ||
1286 | latest version of various dependencies, depending on how recent the | ||
1287 | software versions in your distribution of GNU/Linux are. | ||
1288 | Most distributions do not include sufficiently recent versions of these | ||
1289 | dependencies. | ||
1290 | Thus, a typically installation on a "modern" GNU/Linux distribution | ||
1291 | requires you to install the following dependencies (ideally in this | ||
1292 | order): | ||
1293 | |||
1294 | @itemize @bullet | ||
1295 | @item libgpgerror and libgcrypt | ||
1296 | @item libnettle and libunbound (possibly from distribution), GnuTLS | ||
1297 | @item libgnurl (read the README) | ||
1298 | @item GNU libmicrohttpd | ||
1299 | @item GNU libextractor | ||
1300 | @end itemize | ||
1301 | |||
1302 | Make sure to first install the various mandatory and optional | ||
1303 | dependencies including development headers from your distribution. | ||
1304 | |||
1305 | Other dependencies that you should strongly consider to install is a | ||
1306 | database (MySQL, sqlite or Postgres). | ||
1307 | The following instructions will assume that you installed at least sqlite. | ||
1308 | For most distributions you should be able to find pre-build packages for | ||
1309 | the database. Again, make sure to install the client libraries @b{and} the | ||
1310 | respective development headers (if they are packaged separately) as well. | ||
1311 | |||
1312 | You can find specific, detailed instructions for installing of the | ||
1313 | dependencies (and possibly the rest of the GNUnet installation) in the | ||
1314 | platform-specific descriptions, which can be found in the Index. | ||
1315 | Please consult them now. | ||
1316 | If your distribution is not listed, please study the build | ||
1317 | instructions for Debian stable, carefully as you try to install the | ||
1318 | dependencies for your own distribution. | ||
1319 | Contributing additional instructions for further platforms is always | ||
1320 | appreciated. | ||
1321 | Please take in mind that operating system development tends to move at | ||
1322 | a rather fast speed. Due to this you should be aware that some of | ||
1323 | the instructions could be outdated by the time you are reading this. | ||
1324 | If you find a mistake, please tell us about it (or even better: send | ||
1325 | a patch to the documentation to fix it!). | ||
1326 | |||
1327 | Before proceeding further, please double-check the dependency list. | ||
1328 | Note that in addition to satisfying the dependencies, you might have to | ||
1329 | make sure that development headers for the various libraries are also | ||
1330 | installed. | ||
1331 | There maybe files for other distributions, or you might be able to find | ||
1332 | equivalent packages for your distribution. | ||
1333 | |||
1334 | While it is possible to build and install GNUnet without having root | ||
1335 | access, we will assume that you have full control over your system in | ||
1336 | these instructions. | ||
1337 | First, you should create a system user @emph{gnunet} and an additional | ||
1338 | group @emph{gnunetdns}. On the GNU/Linux distributions Debian and Ubuntu, | ||
1339 | type: | ||
1340 | |||
1341 | @example | ||
1342 | sudo adduser --system --home /var/lib/gnunet --group \ | ||
1343 | --disabled-password gnunet | ||
1344 | sudo addgroup --system gnunetdns | ||
1345 | @end example | ||
1346 | |||
1347 | @noindent | ||
1348 | On other Unixes and GNU systems, this should have the same effect: | ||
1349 | |||
1350 | @example | ||
1351 | sudo useradd --system --groups gnunet --home-dir /var/lib/gnunet | ||
1352 | sudo addgroup --system gnunetdns | ||
1353 | @end example | ||
1354 | |||
1355 | Now compile and install GNUnet using: | ||
1356 | |||
1357 | @example | ||
1358 | tar xvf gnunet-@value{VERSION}.tar.gz | ||
1359 | cd gnunet-@value{VERSION} | ||
1360 | ./configure --with-sudo=sudo --with-nssdir=/lib | ||
1361 | make | ||
1362 | sudo make install | ||
1363 | @end example | ||
1364 | |||
1365 | If you want to be able to enable DEBUG-level log messages, add | ||
1366 | @code{--enable-logging=verbose} to the end of the | ||
1367 | @command{./configure} command. | ||
1368 | @code{DEBUG}-level log messages are in English only and | ||
1369 | should only be useful for developers (or for filing | ||
1370 | really detailed bug reports). | ||
1371 | |||
1372 | @noindent | ||
1373 | Next, edit the file @file{/etc/gnunet.conf} to contain the following: | ||
1374 | |||
1375 | @example | ||
1376 | [arm] | ||
1377 | START_SYSTEM_SERVICES = YES | ||
1378 | START_USER_SERVICES = NO | ||
1379 | @end example | ||
1380 | |||
1381 | @noindent | ||
1382 | You may need to update your @code{ld.so} cache to include | ||
1383 | files installed in @file{/usr/local/lib}: | ||
1384 | |||
1385 | @example | ||
1386 | # ldconfig | ||
1387 | @end example | ||
1388 | |||
1389 | @noindent | ||
1390 | Then, switch from user @code{root} to user @code{gnunet} to start | ||
1391 | the peer: | ||
1392 | |||
1393 | @example | ||
1394 | # su -s /bin/sh - gnunet | ||
1395 | $ gnunet-arm -c /etc/gnunet.conf -s | ||
1396 | @end example | ||
1397 | |||
1398 | You may also want to add the last line in the gnunet user's @file{crontab} | ||
1399 | prefixed with @code{@@reboot} so that it is executed whenever the system | ||
1400 | is booted: | ||
1401 | |||
1402 | @example | ||
1403 | @@reboot /usr/local/bin/gnunet-arm -c /etc/gnunet.conf -s | ||
1404 | @end example | ||
1405 | |||
1406 | @noindent | ||
1407 | This will only start the system-wide GNUnet services. | ||
1408 | Type @command{exit} to get back your root shell. | ||
1409 | Now, you need to configure the per-user part. For each | ||
1410 | user that should get access to GNUnet on the system, run | ||
1411 | (replace alice with your username): | ||
1412 | |||
1413 | @example | ||
1414 | sudo adduser alice gnunet | ||
1415 | @end example | ||
1416 | |||
1417 | @noindent | ||
1418 | to allow them to access the system-wide GNUnet services. Then, each | ||
1419 | user should create a configuration file @file{~/.config/gnunet.conf} | ||
1420 | with the lines: | ||
1421 | |||
1422 | @example | ||
1423 | [arm] | ||
1424 | START_SYSTEM_SERVICES = NO | ||
1425 | START_USER_SERVICES = YES | ||
1426 | DEFAULTSERVICES = gns | ||
1427 | @end example | ||
1428 | |||
1429 | @noindent | ||
1430 | and start the per-user services using | ||
1431 | |||
1432 | @example | ||
1433 | $ gnunet-arm -c ~/.config/gnunet.conf -s | ||
1434 | @end example | ||
1435 | |||
1436 | @noindent | ||
1437 | Again, adding a @code{crontab} entry to autostart the peer is advised: | ||
1438 | |||
1439 | @example | ||
1440 | @@reboot /usr/local/bin/gnunet-arm -c $HOME/.config/gnunet.conf -s | ||
1441 | @end example | ||
1442 | |||
1443 | @noindent | ||
1444 | Note that some GNUnet services (such as SOCKS5 proxies) may need a | ||
1445 | system-wide TCP port for each user. | ||
1446 | For those services, systems with more than one user may require each user | ||
1447 | to specify a different port number in their personal configuration file. | ||
1448 | |||
1449 | Finally, the user should perform the basic initial setup for the GNU Name | ||
1450 | System (GNS) certificate authority. This is done by running: | ||
1451 | |||
1452 | @example | ||
1453 | $ gnunet-gns-proxy-setup-ca | ||
1454 | @end example | ||
1455 | |||
1456 | @noindent | ||
1457 | The first generates the default zones, whereas the second setups the GNS | ||
1458 | Certificate Authority with the user's browser. Now, to activate GNS in the | ||
1459 | normal DNS resolution process, you need to edit your | ||
1460 | @file{/etc/nsswitch.conf} where you should find a line like this: | ||
1461 | |||
1462 | @example | ||
1463 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
1464 | @end example | ||
1465 | |||
1466 | @noindent | ||
1467 | The exact details may differ a bit, which is fine. Add the text | ||
1468 | @emph{"gns [NOTFOUND=return]"} after @emph{"files"}. | ||
1469 | Keep in mind that we included a backslash ("\") here just for | ||
1470 | markup reasons. You should write the text below on @b{one line} | ||
1471 | and @b{without} the "\": | ||
1472 | |||
1473 | @example | ||
1474 | hosts: files gns [NOTFOUND=return] mdns4_minimal \ | ||
1475 | [NOTFOUND=return] dns mdns4 | ||
1476 | @end example | ||
1477 | |||
1478 | @c FIXME: Document new behavior. | ||
1479 | You might want to make sure that @file{/lib/libnss_gns.so.2} exists on | ||
1480 | your system, it should have been created during the installation. | ||
1481 | |||
1482 | |||
1483 | @c ********************************************************************** | ||
1484 | @cindex TESTING library | ||
1485 | @node TESTING library | ||
1486 | @section TESTING library | ||
1487 | |||
1488 | The TESTING library is used for writing testcases which involve starting a | ||
1489 | single or multiple peers. While peers can also be started by testcases | ||
1490 | using the ARM subsystem, using TESTING library provides an elegant way to | ||
1491 | do this. The configurations of the peers are auto-generated from a given | ||
1492 | template to have non-conflicting port numbers ensuring that peers' | ||
1493 | services do not run into bind errors. This is achieved by testing ports' | ||
1494 | availability by binding a listening socket to them before allocating them | ||
1495 | to services in the generated configurations. | ||
1496 | |||
1497 | An another advantage while using TESTING is that it shortens the testcase | ||
1498 | startup time as the hostkeys for peers are copied from a pre-computed set | ||
1499 | of hostkeys instead of generating them at peer startup which may take a | ||
1500 | considerable amount of time when starting multiple peers or on an embedded | ||
1501 | processor. | ||
1502 | |||
1503 | TESTING also allows for certain services to be shared among peers. This | ||
1504 | feature is invaluable when testing with multiple peers as it helps to | ||
1505 | reduce the number of services run per each peer and hence the total | ||
1506 | number of processes run per testcase. | ||
1507 | |||
1508 | TESTING library only handles creating, starting and stopping peers. | ||
1509 | Features useful for testcases such as connecting peers in a topology are | ||
1510 | not available in TESTING but are available in the TESTBED subsystem. | ||
1511 | Furthermore, TESTING only creates peers on the localhost, however by | ||
1512 | using TESTBED testcases can benefit from creating peers across multiple | ||
1513 | hosts. | ||
1514 | |||
1515 | @menu | ||
1516 | * API:: | ||
1517 | * Finer control over peer stop:: | ||
1518 | * Helper functions:: | ||
1519 | * Testing with multiple processes:: | ||
1520 | @end menu | ||
1521 | |||
1522 | @cindex TESTING API | ||
1523 | @node API | ||
1524 | @subsection API | ||
1525 | |||
1526 | TESTING abstracts a group of peers as a TESTING system. All peers in a | ||
1527 | system have common hostname and no two services of these peers have a | ||
1528 | same port or a UNIX domain socket path. | ||
1529 | |||
1530 | TESTING system can be created with the function | ||
1531 | @code{GNUNET_TESTING_system_create()} which returns a handle to the | ||
1532 | system. This function takes a directory path which is used for generating | ||
1533 | the configurations of peers, an IP address from which connections to the | ||
1534 | peers' services should be allowed, the hostname to be used in peers' | ||
1535 | configuration, and an array of shared service specifications of type | ||
1536 | @code{struct GNUNET_TESTING_SharedService}. | ||
1537 | |||
1538 | The shared service specification must specify the name of the service to | ||
1539 | share, the configuration pertaining to that shared service and the | ||
1540 | maximum number of peers that are allowed to share a single instance of | ||
1541 | the shared service. | ||
1542 | |||
1543 | TESTING system created with @code{GNUNET_TESTING_system_create()} chooses | ||
1544 | ports from the default range @code{12000} - @code{56000} while | ||
1545 | auto-generating configurations for peers. | ||
1546 | This range can be customised with the function | ||
1547 | @code{GNUNET_TESTING_system_create_with_portrange()}. This function is | ||
1548 | similar to @code{GNUNET_TESTING_system_create()} except that it take 2 | ||
1549 | additional parameters --- the start and end of the port range to use. | ||
1550 | |||
1551 | A TESTING system is destroyed with the function | ||
1552 | @code{GNUNET_TESTING_system_destory()}. This function takes the handle of | ||
1553 | the system and a flag to remove the files created in the directory used | ||
1554 | to generate configurations. | ||
1555 | |||
1556 | A peer is created with the function | ||
1557 | @code{GNUNET_TESTING_peer_configure()}. This functions takes the system | ||
1558 | handle, a configuration template from which the configuration for the peer | ||
1559 | is auto-generated and the index from where the hostkey for the peer has to | ||
1560 | be copied from. When successful, this function returns a handle to the | ||
1561 | peer which can be used to start and stop it and to obtain the identity of | ||
1562 | the peer. If unsuccessful, a NULL pointer is returned with an error | ||
1563 | message. This function handles the generated configuration to have | ||
1564 | non-conflicting ports and paths. | ||
1565 | |||
1566 | Peers can be started and stopped by calling the functions | ||
1567 | @code{GNUNET_TESTING_peer_start()} and @code{GNUNET_TESTING_peer_stop()} | ||
1568 | respectively. A peer can be destroyed by calling the function | ||
1569 | @code{GNUNET_TESTING_peer_destroy}. When a peer is destroyed, the ports | ||
1570 | and paths in allocated in its configuration are reclaimed for usage in new | ||
1571 | peers. | ||
1572 | |||
1573 | @c *********************************************************************** | ||
1574 | @node Finer control over peer stop | ||
1575 | @subsection Finer control over peer stop | ||
1576 | |||
1577 | Using @code{GNUNET_TESTING_peer_stop()} is normally fine for testcases. | ||
1578 | However, calling this function for each peer is inefficient when trying to | ||
1579 | shutdown multiple peers as this function sends the termination signal to | ||
1580 | the given peer process and waits for it to terminate. It would be faster | ||
1581 | in this case to send the termination signals to the peers first and then | ||
1582 | wait on them. This is accomplished by the functions | ||
1583 | @code{GNUNET_TESTING_peer_kill()} which sends a termination signal to the | ||
1584 | peer, and the function @code{GNUNET_TESTING_peer_wait()} which waits on | ||
1585 | the peer. | ||
1586 | |||
1587 | Further finer control can be achieved by choosing to stop a peer | ||
1588 | asynchronously with the function @code{GNUNET_TESTING_peer_stop_async()}. | ||
1589 | This function takes a callback parameter and a closure for it in addition | ||
1590 | to the handle to the peer to stop. The callback function is called with | ||
1591 | the given closure when the peer is stopped. Using this function | ||
1592 | eliminates blocking while waiting for the peer to terminate. | ||
1593 | |||
1594 | An asynchronous peer stop can be canceled by calling the function | ||
1595 | @code{GNUNET_TESTING_peer_stop_async_cancel()}. Note that calling this | ||
1596 | function does not prevent the peer from terminating if the termination | ||
1597 | signal has already been sent to it. It does, however, cancels the | ||
1598 | callback to be called when the peer is stopped. | ||
1599 | |||
1600 | @c *********************************************************************** | ||
1601 | @node Helper functions | ||
1602 | @subsection Helper functions | ||
1603 | |||
1604 | Most of the testcases can benefit from an abstraction which configures a | ||
1605 | peer and starts it. This is provided by the function | ||
1606 | @code{GNUNET_TESTING_peer_run()}. This function takes the testing | ||
1607 | directory pathname, a configuration template, a callback and its closure. | ||
1608 | This function creates a peer in the given testing directory by using the | ||
1609 | configuration template, starts the peer and calls the given callback with | ||
1610 | the given closure. | ||
1611 | |||
1612 | The function @code{GNUNET_TESTING_peer_run()} starts the ARM service of | ||
1613 | the peer which starts the rest of the configured services. A similar | ||
1614 | function @code{GNUNET_TESTING_service_run} can be used to just start a | ||
1615 | single service of a peer. In this case, the peer's ARM service is not | ||
1616 | started; instead, only the given service is run. | ||
1617 | |||
1618 | @c *********************************************************************** | ||
1619 | @node Testing with multiple processes | ||
1620 | @subsection Testing with multiple processes | ||
1621 | |||
1622 | When testing GNUnet, the splitting of the code into a services and clients | ||
1623 | often complicates testing. The solution to this is to have the testcase | ||
1624 | fork @code{gnunet-service-arm}, ask it to start the required server and | ||
1625 | daemon processes and then execute appropriate client actions (to test the | ||
1626 | client APIs or the core module or both). If necessary, multiple ARM | ||
1627 | services can be forked using different ports (!) to simulate a network. | ||
1628 | However, most of the time only one ARM process is needed. Note that on | ||
1629 | exit, the testcase should shutdown ARM with a @code{TERM} signal (to give | ||
1630 | it the chance to cleanly stop its child processes). | ||
1631 | |||
1632 | The following code illustrates spawning and killing an ARM process from a | ||
1633 | testcase: | ||
1634 | |||
1635 | @example | ||
1636 | static void run (void *cls, | ||
1637 | char *const *args, | ||
1638 | const char *cfgfile, | ||
1639 | const struct GNUNET_CONFIGURATION_Handle *cfg) @{ | ||
1640 | struct GNUNET_OS_Process *arm_pid; | ||
1641 | arm_pid = GNUNET_OS_start_process (NULL, | ||
1642 | NULL, | ||
1643 | "gnunet-service-arm", | ||
1644 | "gnunet-service-arm", | ||
1645 | "-c", | ||
1646 | cfgname, | ||
1647 | NULL); | ||
1648 | /* do real test work here */ | ||
1649 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) | ||
1650 | GNUNET_log_strerror | ||
1651 | (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
1652 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); | ||
1653 | GNUNET_OS_process_close (arm_pid); @} | ||
1654 | |||
1655 | GNUNET_PROGRAM_run (argc, argv, | ||
1656 | "NAME-OF-TEST", | ||
1657 | "nohelp", | ||
1658 | options, | ||
1659 | &run, | ||
1660 | cls); | ||
1661 | @end example | ||
1662 | |||
1663 | |||
1664 | An alternative way that works well to test plugins is to implement a | ||
1665 | mock-version of the environment that the plugin expects and then to | ||
1666 | simply load the plugin directly. | ||
1667 | |||
1668 | @c *********************************************************************** | ||
1669 | @node Performance regression analysis with Gauger | ||
1670 | @section Performance regression analysis with Gauger | ||
1671 | |||
1672 | To help avoid performance regressions, GNUnet uses Gauger. Gauger is a | ||
1673 | simple logging tool that allows remote hosts to send performance data to | ||
1674 | a central server, where this data can be analyzed and visualized. Gauger | ||
1675 | shows graphs of the repository revisions and the performance data recorded | ||
1676 | for each revision, so sudden performance peaks or drops can be identified | ||
1677 | and linked to a specific revision number. | ||
1678 | |||
1679 | In the case of GNUnet, the buildbots log the performance data obtained | ||
1680 | during the tests after each build. The data can be accessed on GNUnet's | ||
1681 | Gauger page. | ||
1682 | |||
1683 | The menu on the left allows to select either the results of just one | ||
1684 | build bot (under "Hosts") or review the data from all hosts for a given | ||
1685 | test result (under "Metrics"). In case of very different absolute value | ||
1686 | of the results, for instance arm vs. amd64 machines, the option | ||
1687 | "Normalize" on a metric view can help to get an idea about the | ||
1688 | performance evolution across all hosts. | ||
1689 | |||
1690 | Using Gauger in GNUnet and having the performance of a module tracked over | ||
1691 | time is very easy. First of course, the testcase must generate some | ||
1692 | consistent metric, which makes sense to have logged. Highly volatile or | ||
1693 | random dependent metrics probably are not ideal candidates for meaningful | ||
1694 | regression detection. | ||
1695 | |||
1696 | To start logging any value, just include @code{gauger.h} in your testcase | ||
1697 | code. Then, use the macro @code{GAUGER()} to make the Buildbots log | ||
1698 | whatever value is of interest for you to @code{gnunet.org}'s Gauger | ||
1699 | server. No setup is necessary as most Buildbots have already everything | ||
1700 | in place and new metrics are created on demand. To delete a metric, you | ||
1701 | need to contact a member of the GNUnet development team (a file will need | ||
1702 | to be removed manually from the respective directory). | ||
1703 | |||
1704 | The code in the test should look like this: | ||
1705 | |||
1706 | @example | ||
1707 | [other includes] | ||
1708 | #include <gauger.h> | ||
1709 | |||
1710 | int main (int argc, char *argv[]) @{ | ||
1711 | |||
1712 | [run test, generate data] | ||
1713 | GAUGER("YOUR_MODULE", | ||
1714 | "METRIC_NAME", | ||
1715 | (float)value, | ||
1716 | "UNIT"); @} | ||
1717 | @end example | ||
1718 | |||
1719 | Where: | ||
1720 | |||
1721 | @table @asis | ||
1722 | |||
1723 | @item @strong{YOUR_MODULE} is a category in the gauger page and should be | ||
1724 | the name of the module or subsystem like "Core" or "DHT" | ||
1725 | @item @strong{METRIC} is | ||
1726 | the name of the metric being collected and should be concise and | ||
1727 | descriptive, like "PUT operations in sqlite-datastore". | ||
1728 | @item @strong{value} is the value | ||
1729 | of the metric that is logged for this run. | ||
1730 | @item @strong{UNIT} is the unit in | ||
1731 | which the value is measured, for instance "kb/s" or "kb of RAM/node". | ||
1732 | @end table | ||
1733 | |||
1734 | If you wish to use Gauger for your own project, you can grab a copy of the | ||
1735 | latest stable release or check out Gauger's Subversion repository. | ||
1736 | |||
1737 | @cindex TESTBED Subsystem | ||
1738 | @node TESTBED Subsystem | ||
1739 | @section TESTBED Subsystem | ||
1740 | |||
1741 | The TESTBED subsystem facilitates testing and measuring of multi-peer | ||
1742 | deployments on a single host or over multiple hosts. | ||
1743 | |||
1744 | The architecture of the testbed module is divided into the following: | ||
1745 | @itemize @bullet | ||
1746 | |||
1747 | @item Testbed API: An API which is used by the testing driver programs. It | ||
1748 | provides with functions for creating, destroying, starting, stopping | ||
1749 | peers, etc. | ||
1750 | |||
1751 | @item Testbed service (controller): A service which is started through the | ||
1752 | Testbed API. This service handles operations to create, destroy, start, | ||
1753 | stop peers, connect them, modify their configurations. | ||
1754 | |||
1755 | @item Testbed helper: When a controller has to be started on a host, the | ||
1756 | testbed API starts the testbed helper on that host which in turn starts | ||
1757 | the controller. The testbed helper receives a configuration for the | ||
1758 | controller through its stdin and changes it to ensure the controller | ||
1759 | doesn't run into any port conflict on that host. | ||
1760 | @end itemize | ||
1761 | |||
1762 | |||
1763 | The testbed service (controller) is different from the other GNUnet | ||
1764 | services in that it is not started by ARM and is not supposed to be run | ||
1765 | as a daemon. It is started by the testbed API through a testbed helper. | ||
1766 | In a typical scenario involving multiple hosts, a controller is started | ||
1767 | on each host. Controllers take up the actual task of creating peers, | ||
1768 | starting and stopping them on the hosts they run. | ||
1769 | |||
1770 | While running deployments on a single localhost the testbed API starts the | ||
1771 | testbed helper directly as a child process. When running deployments on | ||
1772 | remote hosts the testbed API starts Testbed Helpers on each remote host | ||
1773 | through remote shell. By default testbed API uses SSH as a remote shell. | ||
1774 | This can be changed by setting the environmental variable | ||
1775 | GNUNET_TESTBED_RSH_CMD to the required remote shell program. This | ||
1776 | variable can also contain parameters which are to be passed to the remote | ||
1777 | shell program. For e.g: | ||
1778 | |||
1779 | @example | ||
1780 | export GNUNET_TESTBED_RSH_CMD="ssh -o BatchMode=yes \ | ||
1781 | -o NoHostAuthenticationForLocalhost=yes %h" | ||
1782 | @end example | ||
1783 | |||
1784 | Substitutions are allowed in the command string above, | ||
1785 | this allows for substitutions through placemarks which begin with a `%'. | ||
1786 | At present the following substitutions are supported | ||
1787 | |||
1788 | @itemize @bullet | ||
1789 | @item %h: hostname | ||
1790 | @item %u: username | ||
1791 | @item %p: port | ||
1792 | @end itemize | ||
1793 | |||
1794 | Note that the substitution placemark is replaced only when the | ||
1795 | corresponding field is available and only once. Specifying | ||
1796 | |||
1797 | @example | ||
1798 | %u@@%h | ||
1799 | @end example | ||
1800 | |||
1801 | doesn't work either. If you want to user username substitutions for | ||
1802 | @command{SSH}, use the argument @code{-l} before the | ||
1803 | username substitution. | ||
1804 | |||
1805 | For example: | ||
1806 | @example | ||
1807 | ssh -l %u -p %p %h | ||
1808 | @end example | ||
1809 | |||
1810 | The testbed API and the helper communicate through the helpers stdin and | ||
1811 | stdout. As the helper is started through a remote shell on remote hosts | ||
1812 | any output messages from the remote shell interfere with the communication | ||
1813 | and results in a failure while starting the helper. For this reason, it is | ||
1814 | suggested to use flags to make the remote shells produce no output | ||
1815 | messages and to have password-less logins. The default remote shell, SSH, | ||
1816 | the default options are: | ||
1817 | |||
1818 | @example | ||
1819 | -o BatchMode=yes -o NoHostBasedAuthenticationForLocalhost=yes" | ||
1820 | @end example | ||
1821 | |||
1822 | Password-less logins should be ensured by using SSH keys. | ||
1823 | |||
1824 | Since the testbed API executes the remote shell as a non-interactive | ||
1825 | shell, certain scripts like .bashrc, .profiler may not be executed. If | ||
1826 | this is the case testbed API can be forced to execute an interactive | ||
1827 | shell by setting up the environmental variable | ||
1828 | @code{GNUNET_TESTBED_RSH_CMD_SUFFIX} to a shell program. | ||
1829 | |||
1830 | An example could be: | ||
1831 | |||
1832 | @example | ||
1833 | export GNUNET_TESTBED_RSH_CMD_SUFFIX="sh -lc" | ||
1834 | @end example | ||
1835 | |||
1836 | The testbed API will then execute the remote shell program as: | ||
1837 | |||
1838 | @example | ||
1839 | $GNUNET_TESTBED_RSH_CMD -p $port $dest $GNUNET_TESTBED_RSH_CMD_SUFFIX \ | ||
1840 | gnunet-helper-testbed | ||
1841 | @end example | ||
1842 | |||
1843 | On some systems, problems may arise while starting testbed helpers if | ||
1844 | GNUnet is installed into a custom location since the helper may not be | ||
1845 | found in the standard path. This can be addressed by setting the variable | ||
1846 | `@code{HELPER_BINARY_PATH}' to the path of the testbed helper. | ||
1847 | Testbed API will then use this path to start helper binaries both | ||
1848 | locally and remotely. | ||
1849 | |||
1850 | Testbed API can accessed by including the | ||
1851 | @file{gnunet_testbed_service.h} file and linking with | ||
1852 | @code{-lgnunettestbed}. | ||
1853 | |||
1854 | @c *********************************************************************** | ||
1855 | @menu | ||
1856 | * Supported Topologies:: | ||
1857 | * Hosts file format:: | ||
1858 | * Topology file format:: | ||
1859 | * Testbed Barriers:: | ||
1860 | * Automatic large-scale deployment in the PlanetLab testbed:: | ||
1861 | * TESTBED Caveats:: | ||
1862 | @end menu | ||
1863 | |||
1864 | @node Supported Topologies | ||
1865 | @subsection Supported Topologies | ||
1866 | |||
1867 | While testing multi-peer deployments, it is often needed that the peers | ||
1868 | are connected in some topology. This requirement is addressed by the | ||
1869 | function @code{GNUNET_TESTBED_overlay_connect()} which connects any given | ||
1870 | two peers in the testbed. | ||
1871 | |||
1872 | The API also provides a helper function | ||
1873 | @code{GNUNET_TESTBED_overlay_configure_topology()} to connect a given set | ||
1874 | of peers in any of the following supported topologies: | ||
1875 | |||
1876 | @itemize @bullet | ||
1877 | |||
1878 | @item @code{GNUNET_TESTBED_TOPOLOGY_CLIQUE}: All peers are connected with | ||
1879 | each other | ||
1880 | |||
1881 | @item @code{GNUNET_TESTBED_TOPOLOGY_LINE}: Peers are connected to form a | ||
1882 | line | ||
1883 | |||
1884 | @item @code{GNUNET_TESTBED_TOPOLOGY_RING}: Peers are connected to form a | ||
1885 | ring topology | ||
1886 | |||
1887 | @item @code{GNUNET_TESTBED_TOPOLOGY_2D_TORUS}: Peers are connected to | ||
1888 | form a 2 dimensional torus topology. The number of peers may not be a | ||
1889 | perfect square, in that case the resulting torus may not have the uniform | ||
1890 | poloidal and toroidal lengths | ||
1891 | |||
1892 | @item @code{GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI}: Topology is generated | ||
1893 | to form a random graph. The number of links to be present should be given | ||
1894 | |||
1895 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD}: Peers are connected to | ||
1896 | form a 2D Torus with some random links among them. The number of random | ||
1897 | links are to be given | ||
1898 | |||
1899 | @item @code{GNUNET_TESTBED_TOPOLOGY_SMALL_WORLD_RING}: Peers are | ||
1900 | connected to form a ring with some random links among them. The number of | ||
1901 | random links are to be given | ||
1902 | |||
1903 | @item @code{GNUNET_TESTBED_TOPOLOGY_SCALE_FREE}: Connects peers in a | ||
1904 | topology where peer connectivity follows power law - new peers are | ||
1905 | connected with high probability to well connected peers. | ||
1906 | (See Emergence of Scaling in Random Networks. Science 286, | ||
1907 | 509-512, 1999 | ||
1908 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/emergence_of_scaling_in_random_networks__barabasi_albert_science_286__1999.pdf, pdf})) | ||
1909 | |||
1910 | @item @code{GNUNET_TESTBED_TOPOLOGY_FROM_FILE}: The topology information | ||
1911 | is loaded from a file. The path to the file has to be given. | ||
1912 | @xref{Topology file format}, for the format of this file. | ||
1913 | |||
1914 | @item @code{GNUNET_TESTBED_TOPOLOGY_NONE}: No topology | ||
1915 | @end itemize | ||
1916 | |||
1917 | |||
1918 | The above supported topologies can be specified respectively by setting | ||
1919 | the variable @code{OVERLAY_TOPOLOGY} to the following values in the | ||
1920 | configuration passed to Testbed API functions | ||
1921 | @code{GNUNET_TESTBED_test_run()} and | ||
1922 | @code{GNUNET_TESTBED_run()}: | ||
1923 | |||
1924 | @itemize @bullet | ||
1925 | @item @code{CLIQUE} | ||
1926 | @item @code{RING} | ||
1927 | @item @code{LINE} | ||
1928 | @item @code{2D_TORUS} | ||
1929 | @item @code{RANDOM} | ||
1930 | @item @code{SMALL_WORLD} | ||
1931 | @item @code{SMALL_WORLD_RING} | ||
1932 | @item @code{SCALE_FREE} | ||
1933 | @item @code{FROM_FILE} | ||
1934 | @item @code{NONE} | ||
1935 | @end itemize | ||
1936 | |||
1937 | |||
1938 | Topologies @code{RANDOM}, @code{SMALL_WORLD} and @code{SMALL_WORLD_RING} | ||
1939 | require the option @code{OVERLAY_RANDOM_LINKS} to be set to the number of | ||
1940 | random links to be generated in the configuration. The option will be | ||
1941 | ignored for the rest of the topologies. | ||
1942 | |||
1943 | Topology @code{SCALE_FREE} requires the options | ||
1944 | @code{SCALE_FREE_TOPOLOGY_CAP} to be set to the maximum number of peers | ||
1945 | which can connect to a peer and @code{SCALE_FREE_TOPOLOGY_M} to be set to | ||
1946 | how many peers a peer should be at least connected to. | ||
1947 | |||
1948 | Similarly, the topology @code{FROM_FILE} requires the option | ||
1949 | @code{OVERLAY_TOPOLOGY_FILE} to contain the path of the file containing | ||
1950 | the topology information. This option is ignored for the rest of the | ||
1951 | topologies. @xref{Topology file format}, for the format of this file. | ||
1952 | |||
1953 | @c *********************************************************************** | ||
1954 | @node Hosts file format | ||
1955 | @subsection Hosts file format | ||
1956 | |||
1957 | The testbed API offers the function | ||
1958 | @code{GNUNET_TESTBED_hosts_load_from_file()} to load from a given file | ||
1959 | details about the hosts which testbed can use for deploying peers. | ||
1960 | This function is useful to keep the data about hosts | ||
1961 | separate instead of hard coding them in code. | ||
1962 | |||
1963 | Another helper function from testbed API, @code{GNUNET_TESTBED_run()} | ||
1964 | also takes a hosts file name as its parameter. It uses the above | ||
1965 | function to populate the hosts data structures and start controllers to | ||
1966 | deploy peers. | ||
1967 | |||
1968 | These functions require the hosts file to be of the following format: | ||
1969 | @itemize @bullet | ||
1970 | @item Each line is interpreted to have details about a host | ||
1971 | @item Host details should include the username to use for logging into the | ||
1972 | host, the hostname of the host and the port number to use for the remote | ||
1973 | shell program. All thee values should be given. | ||
1974 | @item These details should be given in the following format: | ||
1975 | @example | ||
1976 | <username>@@<hostname>:<port> | ||
1977 | @end example | ||
1978 | @end itemize | ||
1979 | |||
1980 | Note that having canonical hostnames may cause problems while resolving | ||
1981 | the IP addresses (See this bug). Hence it is advised to provide the hosts' | ||
1982 | IP numerical addresses as hostnames whenever possible. | ||
1983 | |||
1984 | @c *********************************************************************** | ||
1985 | @node Topology file format | ||
1986 | @subsection Topology file format | ||
1987 | |||
1988 | A topology file describes how peers are to be connected. It should adhere | ||
1989 | to the following format for testbed to parse it correctly. | ||
1990 | |||
1991 | Each line should begin with the target peer id. This should be followed by | ||
1992 | a colon(`:') and origin peer ids separated by `|'. All spaces except for | ||
1993 | newline characters are ignored. The API will then try to connect each | ||
1994 | origin peer to the target peer. | ||
1995 | |||
1996 | For example, the following file will result in 5 overlay connections: | ||
1997 | [2->1], [3->1],[4->3], [0->3], [2->0]@ | ||
1998 | @code{@ 1:2|3@ 3:4| 0@ 0: 2@ } | ||
1999 | |||
2000 | @c *********************************************************************** | ||
2001 | @node Testbed Barriers | ||
2002 | @subsection Testbed Barriers | ||
2003 | |||
2004 | The testbed subsystem's barriers API facilitates coordination among the | ||
2005 | peers run by the testbed and the experiment driver. The concept is | ||
2006 | similar to the barrier synchronisation mechanism found in parallel | ||
2007 | programming or multi-threading paradigms - a peer waits at a barrier upon | ||
2008 | reaching it until the barrier is reached by a predefined number of peers. | ||
2009 | This predefined number of peers required to cross a barrier is also called | ||
2010 | quorum. We say a peer has reached a barrier if the peer is waiting for the | ||
2011 | barrier to be crossed. Similarly a barrier is said to be reached if the | ||
2012 | required quorum of peers reach the barrier. A barrier which is reached is | ||
2013 | deemed as crossed after all the peers waiting on it are notified. | ||
2014 | |||
2015 | The barriers API provides the following functions: | ||
2016 | @itemize @bullet | ||
2017 | @item @strong{@code{GNUNET_TESTBED_barrier_init()}:} function to | ||
2018 | initialize a barrier in the experiment | ||
2019 | @item @strong{@code{GNUNET_TESTBED_barrier_cancel()}:} function to cancel | ||
2020 | a barrier which has been initialized before | ||
2021 | @item @strong{@code{GNUNET_TESTBED_barrier_wait()}:} function to signal | ||
2022 | barrier service that the caller has reached a barrier and is waiting for | ||
2023 | it to be crossed | ||
2024 | @item @strong{@code{GNUNET_TESTBED_barrier_wait_cancel()}:} function to | ||
2025 | stop waiting for a barrier to be crossed | ||
2026 | @end itemize | ||
2027 | |||
2028 | |||
2029 | Among the above functions, the first two, namely | ||
2030 | @code{GNUNET_TESTBED_barrier_init()} and | ||
2031 | @code{GNUNET_TESTBED_barrier_cancel()} are used by experiment drivers. All | ||
2032 | barriers should be initialised by the experiment driver by calling | ||
2033 | @code{GNUNET_TESTBED_barrier_init()}. This function takes a name to | ||
2034 | identify the barrier, the quorum required for the barrier to be crossed | ||
2035 | and a notification callback for notifying the experiment driver when the | ||
2036 | barrier is crossed. @code{GNUNET_TESTBED_barrier_cancel()} cancels an | ||
2037 | initialised barrier and frees the resources allocated for it. This | ||
2038 | function can be called upon a initialised barrier before it is crossed. | ||
2039 | |||
2040 | The remaining two functions @code{GNUNET_TESTBED_barrier_wait()} and | ||
2041 | @code{GNUNET_TESTBED_barrier_wait_cancel()} are used in the peer's | ||
2042 | processes. @code{GNUNET_TESTBED_barrier_wait()} connects to the local | ||
2043 | barrier service running on the same host the peer is running on and | ||
2044 | registers that the caller has reached the barrier and is waiting for the | ||
2045 | barrier to be crossed. Note that this function can only be used by peers | ||
2046 | which are started by testbed as this function tries to access the local | ||
2047 | barrier service which is part of the testbed controller service. Calling | ||
2048 | @code{GNUNET_TESTBED_barrier_wait()} on an uninitialised barrier results | ||
2049 | in failure. @code{GNUNET_TESTBED_barrier_wait_cancel()} cancels the | ||
2050 | notification registered by @code{GNUNET_TESTBED_barrier_wait()}. | ||
2051 | |||
2052 | |||
2053 | @c *********************************************************************** | ||
2054 | @menu | ||
2055 | * Implementation:: | ||
2056 | @end menu | ||
2057 | |||
2058 | @node Implementation | ||
2059 | @subsubsection Implementation | ||
2060 | |||
2061 | Since barriers involve coordination between experiment driver and peers, | ||
2062 | the barrier service in the testbed controller is split into two | ||
2063 | components. The first component responds to the message generated by the | ||
2064 | barrier API used by the experiment driver (functions | ||
2065 | @code{GNUNET_TESTBED_barrier_init()} and | ||
2066 | @code{GNUNET_TESTBED_barrier_cancel()}) and the second component to the | ||
2067 | messages generated by barrier API used by peers (functions | ||
2068 | @code{GNUNET_TESTBED_barrier_wait()} and | ||
2069 | @code{GNUNET_TESTBED_barrier_wait_cancel()}). | ||
2070 | |||
2071 | Calling @code{GNUNET_TESTBED_barrier_init()} sends a | ||
2072 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT} message to the master | ||
2073 | controller. The master controller then registers a barrier and calls | ||
2074 | @code{GNUNET_TESTBED_barrier_init()} for each its subcontrollers. In this | ||
2075 | way barrier initialisation is propagated to the controller hierarchy. | ||
2076 | While propagating initialisation, any errors at a subcontroller such as | ||
2077 | timeout during further propagation are reported up the hierarchy back to | ||
2078 | the experiment driver. | ||
2079 | |||
2080 | Similar to @code{GNUNET_TESTBED_barrier_init()}, | ||
2081 | @code{GNUNET_TESTBED_barrier_cancel()} propagates | ||
2082 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL} message which causes | ||
2083 | controllers to remove an initialised barrier. | ||
2084 | |||
2085 | The second component is implemented as a separate service in the binary | ||
2086 | `gnunet-service-testbed' which already has the testbed controller service. | ||
2087 | Although this deviates from the gnunet process architecture of having one | ||
2088 | service per binary, it is needed in this case as this component needs | ||
2089 | access to barrier data created by the first component. This component | ||
2090 | responds to @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages from | ||
2091 | local peers when they call @code{GNUNET_TESTBED_barrier_wait()}. Upon | ||
2092 | receiving @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} message, the | ||
2093 | service checks if the requested barrier has been initialised before and | ||
2094 | if it was not initialised, an error status is sent through | ||
2095 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to the local | ||
2096 | peer and the connection from the peer is terminated. If the barrier is | ||
2097 | initialised before, the barrier's counter for reached peers is incremented | ||
2098 | and a notification is registered to notify the peer when the barrier is | ||
2099 | reached. The connection from the peer is left open. | ||
2100 | |||
2101 | When enough peers required to attain the quorum send | ||
2102 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT} messages, the controller | ||
2103 | sends a @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message to its | ||
2104 | parent informing that the barrier is crossed. If the controller has | ||
2105 | started further subcontrollers, it delays this message until it receives | ||
2106 | a similar notification from each of those subcontrollers. Finally, the | ||
2107 | barriers API at the experiment driver receives the | ||
2108 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} when the barrier is | ||
2109 | reached at all the controllers. | ||
2110 | |||
2111 | The barriers API at the experiment driver responds to the | ||
2112 | @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message by echoing it | ||
2113 | back to the master controller and notifying the experiment controller | ||
2114 | through the notification callback that a barrier has been crossed. The | ||
2115 | echoed @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} message is | ||
2116 | propagated by the master controller to the controller hierarchy. This | ||
2117 | propagation triggers the notifications registered by peers at each of the | ||
2118 | controllers in the hierarchy. Note the difference between this downward | ||
2119 | propagation of the @code{GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS} | ||
2120 | message from its upward propagation --- the upward propagation is needed | ||
2121 | for ensuring that the barrier is reached by all the controllers and the | ||
2122 | downward propagation is for triggering that the barrier is crossed. | ||
2123 | |||
2124 | @cindex PlanetLab testbed | ||
2125 | @node Automatic large-scale deployment in the PlanetLab testbed | ||
2126 | @subsection Automatic large-scale deployment in the PlanetLab testbed | ||
2127 | |||
2128 | PlanetLab is a testbed for computer networking and distributed systems | ||
2129 | research. It was established in 2002 and as of June 2010 was composed of | ||
2130 | 1090 nodes at 507 sites worldwide. | ||
2131 | |||
2132 | To automate the GNUnet we created a set of automation tools to simplify | ||
2133 | the large-scale deployment. We provide you a set of scripts you can use | ||
2134 | to deploy GNUnet on a set of nodes and manage your installation. | ||
2135 | |||
2136 | Please also check @uref{https://gnunet.org/installation-fedora8-svn} and | ||
2137 | @uref{https://gnunet.org/installation-fedora12-svn} to find detailed | ||
2138 | instructions how to install GNUnet on a PlanetLab node. | ||
2139 | |||
2140 | |||
2141 | @c *********************************************************************** | ||
2142 | @menu | ||
2143 | * PlanetLab Automation for Fedora8 nodes:: | ||
2144 | * Install buildslave on PlanetLab nodes running fedora core 8:: | ||
2145 | * Setup a new PlanetLab testbed using GPLMT:: | ||
2146 | * Why do i get an ssh error when using the regex profiler?:: | ||
2147 | @end menu | ||
2148 | |||
2149 | @node PlanetLab Automation for Fedora8 nodes | ||
2150 | @subsubsection PlanetLab Automation for Fedora8 nodes | ||
2151 | |||
2152 | @c *********************************************************************** | ||
2153 | @node Install buildslave on PlanetLab nodes running fedora core 8 | ||
2154 | @subsubsection Install buildslave on PlanetLab nodes running fedora core 8 | ||
2155 | @c ** Actually this is a subsubsubsection, but must be fixed differently | ||
2156 | @c ** as subsubsection is the lowest. | ||
2157 | |||
2158 | Since most of the PlanetLab nodes are running the very old Fedora core 8 | ||
2159 | image, installing the buildslave software is quite some pain. For our | ||
2160 | PlanetLab testbed we figured out how to install the buildslave software | ||
2161 | best. | ||
2162 | |||
2163 | @c This is a very terrible way to suggest installing software. | ||
2164 | @c FIXME: Is there an official, safer way instead of blind-piping a | ||
2165 | @c script? | ||
2166 | @c FIXME: Use newer pypi URLs below. | ||
2167 | Install Distribute for Python: | ||
2168 | |||
2169 | @example | ||
2170 | curl http://python-distribute.org/distribute_setup.py | sudo python | ||
2171 | @end example | ||
2172 | |||
2173 | Install Distribute for zope.interface <= 3.8.0 (4.0 and 4.0.1 will not | ||
2174 | work): | ||
2175 | |||
2176 | @example | ||
2177 | export PYPI=@value{PYPI-URL} | ||
2178 | wget $PYPI/z/zope.interface/zope.interface-3.8.0.tar.gz | ||
2179 | tar zvfz zope.interface-3.8.0.tar.gz | ||
2180 | cd zope.interface-3.8.0 | ||
2181 | sudo python setup.py install | ||
2182 | @end example | ||
2183 | |||
2184 | Install the buildslave software (0.8.6 was the latest version): | ||
2185 | |||
2186 | @example | ||
2187 | export GCODE="http://buildbot.googlecode.com/files" | ||
2188 | wget $GCODE/buildbot-slave-0.8.6p1.tar.gz | ||
2189 | tar xvfz buildbot-slave-0.8.6p1.tar.gz | ||
2190 | cd buildslave-0.8.6p1 | ||
2191 | sudo python setup.py install | ||
2192 | @end example | ||
2193 | |||
2194 | The setup will download the matching twisted package and install it. | ||
2195 | It will also try to install the latest version of zope.interface which | ||
2196 | will fail to install. Buildslave will work anyway since version 3.8.0 | ||
2197 | was installed before! | ||
2198 | |||
2199 | @c *********************************************************************** | ||
2200 | @node Setup a new PlanetLab testbed using GPLMT | ||
2201 | @subsubsection Setup a new PlanetLab testbed using GPLMT | ||
2202 | |||
2203 | @itemize @bullet | ||
2204 | @item Get a new slice and assign nodes | ||
2205 | Ask your PlanetLab PI to give you a new slice and assign the nodes you | ||
2206 | need | ||
2207 | @item Install a buildmaster | ||
2208 | You can stick to the buildbot documentation:@ | ||
2209 | @uref{http://buildbot.net/buildbot/docs/current/manual/installation.html} | ||
2210 | @item Install the buildslave software on all nodes | ||
2211 | To install the buildslave on all nodes assigned to your slice you can use | ||
2212 | the tasklist @code{install_buildslave_fc8.xml} provided with GPLMT: | ||
2213 | |||
2214 | @example | ||
2215 | ./gplmt.py -c contrib/tumple_gnunet.conf -t \ | ||
2216 | contrib/tasklists/install_buildslave_fc8.xml -a -p <planetlab password> | ||
2217 | @end example | ||
2218 | |||
2219 | @item Create the buildmaster configuration and the slave setup commands | ||
2220 | |||
2221 | The master and the and the slaves have need to have credentials and the | ||
2222 | master has to have all nodes configured. This can be done with the | ||
2223 | @file{create_buildbot_configuration.py} script in the @file{scripts} | ||
2224 | directory. | ||
2225 | |||
2226 | This scripts takes a list of nodes retrieved directly from PlanetLab or | ||
2227 | read from a file and a configuration template and creates: | ||
2228 | |||
2229 | @itemize @bullet | ||
2230 | @item a tasklist which can be executed with gplmt to setup the slaves | ||
2231 | @item a master.cfg file containing a PlanetLab nodes | ||
2232 | @end itemize | ||
2233 | |||
2234 | A configuration template is included in the <contrib>, most important is | ||
2235 | that the script replaces the following tags in the template: | ||
2236 | |||
2237 | %GPLMT_BUILDER_DEFINITION :@ GPLMT_BUILDER_SUMMARY@ GPLMT_SLAVES@ | ||
2238 | %GPLMT_SCHEDULER_BUILDERS | ||
2239 | |||
2240 | Create configuration for all nodes assigned to a slice: | ||
2241 | |||
2242 | @example | ||
2243 | ./create_buildbot_configuration.py -u <planetlab username> \ | ||
2244 | -p <planetlab password> -s <slice> -m <buildmaster+port> \ | ||
2245 | -t <template> | ||
2246 | @end example | ||
2247 | |||
2248 | Create configuration for some nodes in a file: | ||
2249 | |||
2250 | @example | ||
2251 | ./create_buildbot_configuration.p -f <node_file> \ | ||
2252 | -m <buildmaster+port> -t <template> | ||
2253 | @end example | ||
2254 | |||
2255 | @item Copy the @file{master.cfg} to the buildmaster and start it | ||
2256 | Use @code{buildbot start <basedir>} to start the server | ||
2257 | @item Setup the buildslaves | ||
2258 | @end itemize | ||
2259 | |||
2260 | @c *********************************************************************** | ||
2261 | @node Why do i get an ssh error when using the regex profiler? | ||
2262 | @subsubsection Why do i get an ssh error when using the regex profiler? | ||
2263 | |||
2264 | Why do i get an ssh error "Permission denied (publickey,password)." when | ||
2265 | using the regex profiler although passwordless ssh to localhost works | ||
2266 | using publickey and ssh-agent? | ||
2267 | |||
2268 | You have to generate a public/private-key pair with no password:@ | ||
2269 | @code{ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_localhost}@ | ||
2270 | and then add the following to your ~/.ssh/config file: | ||
2271 | |||
2272 | @code{Host 127.0.0.1@ IdentityFile ~/.ssh/id_localhost} | ||
2273 | |||
2274 | now make sure your hostsfile looks like | ||
2275 | |||
2276 | @example | ||
2277 | [USERNAME]@@127.0.0.1:22@ | ||
2278 | [USERNAME]@@127.0.0.1:22 | ||
2279 | @end example | ||
2280 | |||
2281 | You can test your setup by running @code{ssh 127.0.0.1} in a | ||
2282 | terminal and then in the opened session run it again. | ||
2283 | If you were not asked for a password on either login, | ||
2284 | then you should be good to go. | ||
2285 | |||
2286 | @cindex TESTBED Caveats | ||
2287 | @node TESTBED Caveats | ||
2288 | @subsection TESTBED Caveats | ||
2289 | |||
2290 | This section documents a few caveats when using the GNUnet testbed | ||
2291 | subsystem. | ||
2292 | |||
2293 | @c *********************************************************************** | ||
2294 | @menu | ||
2295 | * CORE must be started:: | ||
2296 | * ATS must want the connections:: | ||
2297 | @end menu | ||
2298 | |||
2299 | @node CORE must be started | ||
2300 | @subsubsection CORE must be started | ||
2301 | |||
2302 | A uncomplicated issue is bug #3993 | ||
2303 | (@uref{https://gnunet.org/bugs/view.php?id=3993, https://gnunet.org/bugs/view.php?id=3993}): | ||
2304 | Your configuration MUST somehow ensure that for each peer the | ||
2305 | @code{CORE} service is started when the peer is setup, otherwise | ||
2306 | @code{TESTBED} may fail to connect peers when the topology is initialized, | ||
2307 | as @code{TESTBED} will start some @code{CORE} services but not | ||
2308 | necessarily all (but it relies on all of them running). The easiest way | ||
2309 | is to set | ||
2310 | |||
2311 | @example | ||
2312 | [core] | ||
2313 | IMMEDIATE_START = YES | ||
2314 | @end example | ||
2315 | |||
2316 | @noindent | ||
2317 | in the configuration file. | ||
2318 | Alternatively, having any service that directly or indirectly depends on | ||
2319 | @code{CORE} being started with @code{IMMEDIATE_START} will also do. | ||
2320 | This issue largely arises if users try to over-optimize by not | ||
2321 | starting any services with @code{IMMEDIATE_START}. | ||
2322 | |||
2323 | @c *********************************************************************** | ||
2324 | @node ATS must want the connections | ||
2325 | @subsubsection ATS must want the connections | ||
2326 | |||
2327 | When TESTBED sets up connections, it only offers the respective HELLO | ||
2328 | information to the TRANSPORT service. It is then up to the ATS service to | ||
2329 | @strong{decide} to use the connection. The ATS service will typically | ||
2330 | eagerly establish any connection if the number of total connections is | ||
2331 | low (relative to bandwidth). Details may further depend on the | ||
2332 | specific ATS backend that was configured. If ATS decides to NOT establish | ||
2333 | a connection (even though TESTBED provided the required information), then | ||
2334 | that connection will count as failed for TESTBED. Note that you can | ||
2335 | configure TESTBED to tolerate a certain number of connection failures | ||
2336 | (see '-e' option of gnunet-testbed-profiler). This issue largely arises | ||
2337 | for dense overlay topologies, especially if you try to create cliques | ||
2338 | with more than 20 peers. | ||
2339 | |||
2340 | @cindex libgnunetutil | ||
2341 | @node libgnunetutil | ||
2342 | @section libgnunetutil | ||
2343 | |||
2344 | libgnunetutil is the fundamental library that all GNUnet code builds upon. | ||
2345 | Ideally, this library should contain most of the platform dependent code | ||
2346 | (except for user interfaces and really special needs that only few | ||
2347 | applications have). It is also supposed to offer basic services that most | ||
2348 | if not all GNUnet binaries require. The code of libgnunetutil is in the | ||
2349 | @file{src/util/} directory. The public interface to the library is in the | ||
2350 | gnunet_util.h header. The functions provided by libgnunetutil fall | ||
2351 | roughly into the following categories (in roughly the order of importance | ||
2352 | for new developers): | ||
2353 | |||
2354 | @itemize @bullet | ||
2355 | @item logging (common_logging.c) | ||
2356 | @item memory allocation (common_allocation.c) | ||
2357 | @item endianess conversion (common_endian.c) | ||
2358 | @item internationalization (common_gettext.c) | ||
2359 | @item String manipulation (string.c) | ||
2360 | @item file access (disk.c) | ||
2361 | @item buffered disk IO (bio.c) | ||
2362 | @item time manipulation (time.c) | ||
2363 | @item configuration parsing (configuration.c) | ||
2364 | @item command-line handling (getopt*.c) | ||
2365 | @item cryptography (crypto_*.c) | ||
2366 | @item data structures (container_*.c) | ||
2367 | @item CPS-style scheduling (scheduler.c) | ||
2368 | @item Program initialization (program.c) | ||
2369 | @item Networking (network.c, client.c, server*.c, service.c) | ||
2370 | @item message queuing (mq.c) | ||
2371 | @item bandwidth calculations (bandwidth.c) | ||
2372 | @item Other OS-related (os*.c, plugin.c, signal.c) | ||
2373 | @item Pseudonym management (pseudonym.c) | ||
2374 | @end itemize | ||
2375 | |||
2376 | It should be noted that only developers that fully understand this entire | ||
2377 | API will be able to write good GNUnet code. | ||
2378 | |||
2379 | Ideally, porting GNUnet should only require porting the gnunetutil | ||
2380 | library. More testcases for the gnunetutil APIs are therefore a great | ||
2381 | way to make porting of GNUnet easier. | ||
2382 | |||
2383 | @menu | ||
2384 | * Logging:: | ||
2385 | * Interprocess communication API (IPC):: | ||
2386 | * Cryptography API:: | ||
2387 | * Message Queue API:: | ||
2388 | * Service API:: | ||
2389 | * Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps:: | ||
2390 | * CONTAINER_MDLL API:: | ||
2391 | @end menu | ||
2392 | |||
2393 | @cindex Logging | ||
2394 | @cindex log levels | ||
2395 | @node Logging | ||
2396 | @subsection Logging | ||
2397 | |||
2398 | GNUnet is able to log its activity, mostly for the purposes of debugging | ||
2399 | the program at various levels. | ||
2400 | |||
2401 | @file{gnunet_common.h} defines several @strong{log levels}: | ||
2402 | @table @asis | ||
2403 | |||
2404 | @item ERROR for errors (really problematic situations, often leading to | ||
2405 | crashes) | ||
2406 | @item WARNING for warnings (troubling situations that might have | ||
2407 | negative consequences, although not fatal) | ||
2408 | @item INFO for various information. | ||
2409 | Used somewhat rarely, as GNUnet statistics is used to hold and display | ||
2410 | most of the information that users might find interesting. | ||
2411 | @item DEBUG for debugging. | ||
2412 | Does not produce much output on normal builds, but when extra logging is | ||
2413 | enabled at compile time, a staggering amount of data is outputted under | ||
2414 | this log level. | ||
2415 | @end table | ||
2416 | |||
2417 | |||
2418 | Normal builds of GNUnet (configured with @code{--enable-logging[=yes]}) | ||
2419 | are supposed to log nothing under DEBUG level. The | ||
2420 | @code{--enable-logging=verbose} configure option can be used to create a | ||
2421 | build with all logging enabled. However, such build will produce large | ||
2422 | amounts of log data, which is inconvenient when one tries to hunt down a | ||
2423 | specific problem. | ||
2424 | |||
2425 | To mitigate this problem, GNUnet provides facilities to apply a filter to | ||
2426 | reduce the logs: | ||
2427 | @table @asis | ||
2428 | |||
2429 | @item Logging by default When no log levels are configured in any other | ||
2430 | way (see below), GNUnet will default to the WARNING log level. This | ||
2431 | mostly applies to GNUnet command line utilities, services and daemons; | ||
2432 | tests will always set log level to WARNING or, if | ||
2433 | @code{--enable-logging=verbose} was passed to configure, to DEBUG. The | ||
2434 | default level is suggested for normal operation. | ||
2435 | @item The -L option Most GNUnet executables accept an "-L loglevel" or | ||
2436 | "--log=loglevel" option. If used, it makes the process set a global log | ||
2437 | level to "loglevel". Thus it is possible to run some processes | ||
2438 | with -L DEBUG, for example, and others with -L ERROR to enable specific | ||
2439 | settings to diagnose problems with a particular process. | ||
2440 | @item Configuration files. Because GNUnet | ||
2441 | service and daemon processes are usually launched by gnunet-arm, it is not | ||
2442 | possible to pass different custom command line options directly to every | ||
2443 | one of them. The options passed to @code{gnunet-arm} only affect | ||
2444 | gnunet-arm and not the rest of GNUnet. However, one can specify a | ||
2445 | configuration key "OPTIONS" in the section that corresponds to a service | ||
2446 | or a daemon, and put a value of "-L loglevel" there. This will make the | ||
2447 | respective service or daemon set its log level to "loglevel" (as the | ||
2448 | value of OPTIONS will be passed as a command-line argument). | ||
2449 | |||
2450 | To specify the same log level for all services without creating separate | ||
2451 | "OPTIONS" entries in the configuration for each one, the user can specify | ||
2452 | a config key "GLOBAL_POSTFIX" in the [arm] section of the configuration | ||
2453 | file. The value of GLOBAL_POSTFIX will be appended to all command lines | ||
2454 | used by the ARM service to run other services. It can contain any option | ||
2455 | valid for all GNUnet commands, thus in particular the "-L loglevel" | ||
2456 | option. The ARM service itself is, however, unaffected by GLOBAL_POSTFIX; | ||
2457 | to set log level for it, one has to specify "OPTIONS" key in the [arm] | ||
2458 | section. | ||
2459 | @item Environment variables. | ||
2460 | Setting global per-process log levels with "-L loglevel" does not offer | ||
2461 | sufficient log filtering granularity, as one service will call interface | ||
2462 | libraries and supporting libraries of other GNUnet services, potentially | ||
2463 | producing lots of debug log messages from these libraries. Also, changing | ||
2464 | the config file is not always convenient (especially when running the | ||
2465 | GNUnet test suite).@ To fix that, and to allow GNUnet to use different | ||
2466 | log filtering at runtime without re-compiling the whole source tree, the | ||
2467 | log calls were changed to be configurable at run time. To configure them | ||
2468 | one has to define environment variables "GNUNET_FORCE_LOGFILE", | ||
2469 | "GNUNET_LOG" and/or "GNUNET_FORCE_LOG": | ||
2470 | @itemize @bullet | ||
2471 | |||
2472 | @item "GNUNET_LOG" only affects the logging when no global log level is | ||
2473 | configured by any other means (that is, the process does not explicitly | ||
2474 | set its own log level, there are no "-L loglevel" options on command line | ||
2475 | or in configuration files), and can be used to override the default | ||
2476 | WARNING log level. | ||
2477 | |||
2478 | @item "GNUNET_FORCE_LOG" will completely override any other log | ||
2479 | configuration options given. | ||
2480 | |||
2481 | @item "GNUNET_FORCE_LOGFILE" will completely override the location of the | ||
2482 | file to log messages to. It should contain a relative or absolute file | ||
2483 | name. Setting GNUNET_FORCE_LOGFILE is equivalent to passing | ||
2484 | "--log-file=logfile" or "-l logfile" option (see below). It supports "[]" | ||
2485 | format in file names, but not "@{@}" (see below). | ||
2486 | @end itemize | ||
2487 | |||
2488 | |||
2489 | Because environment variables are inherited by child processes when they | ||
2490 | are launched, starting or re-starting the ARM service with these | ||
2491 | variables will propagate them to all other services. | ||
2492 | |||
2493 | "GNUNET_LOG" and "GNUNET_FORCE_LOG" variables must contain a specially | ||
2494 | formatted @strong{logging definition} string, which looks like this:@ | ||
2495 | |||
2496 | @c FIXME: Can we close this with [/component] instead? | ||
2497 | @example | ||
2498 | [component];[file];[function];[from_line[-to_line]];loglevel[/component...] | ||
2499 | @end example | ||
2500 | |||
2501 | That is, a logging definition consists of definition entries, separated by | ||
2502 | slashes ('/'). If only one entry is present, there is no need to add a | ||
2503 | slash to its end (although it is not forbidden either).@ All definition | ||
2504 | fields (component, file, function, lines and loglevel) are mandatory, but | ||
2505 | (except for the loglevel) they can be empty. An empty field means | ||
2506 | "match anything". Note that even if fields are empty, the semicolon (';') | ||
2507 | separators must be present.@ The loglevel field is mandatory, and must | ||
2508 | contain one of the log level names (ERROR, WARNING, INFO or DEBUG).@ | ||
2509 | The lines field might contain one non-negative number, in which case it | ||
2510 | matches only one line, or a range "from_line-to_line", in which case it | ||
2511 | matches any line in the interval [from_line;to_line] (that is, including | ||
2512 | both start and end line).@ GNUnet mostly defaults component name to the | ||
2513 | name of the service that is implemented in a process ('transport', | ||
2514 | 'core', 'peerinfo', etc), but logging calls can specify custom component | ||
2515 | names using @code{GNUNET_log_from}.@ File name and function name are | ||
2516 | provided by the compiler (__FILE__ and __FUNCTION__ built-ins). | ||
2517 | |||
2518 | Component, file and function fields are interpreted as non-extended | ||
2519 | regular expressions (GNU libc regex functions are used). Matching is | ||
2520 | case-sensitive, "^" and "$" will match the beginning and the end of the | ||
2521 | text. If a field is empty, its contents are automatically replaced with | ||
2522 | a ".*" regular expression, which matches anything. Matching is done in | ||
2523 | the default way, which means that the expression matches as long as it's | ||
2524 | contained anywhere in the string. Thus "GNUNET_" will match both | ||
2525 | "GNUNET_foo" and "BAR_GNUNET_BAZ". Use '^' and/or '$' to make sure that | ||
2526 | the expression matches at the start and/or at the end of the string. | ||
2527 | The semicolon (';') can't be escaped, and GNUnet will not use it in | ||
2528 | component names (it can't be used in function names and file names | ||
2529 | anyway). | ||
2530 | |||
2531 | @end table | ||
2532 | |||
2533 | |||
2534 | Every logging call in GNUnet code will be (at run time) matched against | ||
2535 | the log definitions passed to the process. If a log definition fields are | ||
2536 | matching the call arguments, then the call log level is compared the the | ||
2537 | log level of that definition. If the call log level is less or equal to | ||
2538 | the definition log level, the call is allowed to proceed. Otherwise the | ||
2539 | logging call is forbidden, and nothing is logged. If no definitions | ||
2540 | matched at all, GNUnet will use the global log level or (if a global log | ||
2541 | level is not specified) will default to WARNING (that is, it will allow | ||
2542 | the call to proceed, if its level is less or equal to the global log | ||
2543 | level or to WARNING). | ||
2544 | |||
2545 | That is, definitions are evaluated from left to right, and the first | ||
2546 | matching definition is used to allow or deny the logging call. Thus it is | ||
2547 | advised to place narrow definitions at the beginning of the logdef | ||
2548 | string, and generic definitions - at the end. | ||
2549 | |||
2550 | Whether a call is allowed or not is only decided the first time this | ||
2551 | particular call is made. The evaluation result is then cached, so that | ||
2552 | any attempts to make the same call later will be allowed or disallowed | ||
2553 | right away. Because of that runtime log level evaluation should not | ||
2554 | significantly affect the process performance. | ||
2555 | Log definition parsing is only done once, at the first call to | ||
2556 | @code{GNUNET_log_setup ()} made by the process (which is usually done soon after | ||
2557 | it starts). | ||
2558 | |||
2559 | At the moment of writing there is no way to specify logging definitions | ||
2560 | from configuration files, only via environment variables. | ||
2561 | |||
2562 | At the moment GNUnet will stop processing a log definition when it | ||
2563 | encounters an error in definition formatting or an error in regular | ||
2564 | expression syntax, and will not report the failure in any way. | ||
2565 | |||
2566 | |||
2567 | @c *********************************************************************** | ||
2568 | @menu | ||
2569 | * Examples:: | ||
2570 | * Log files:: | ||
2571 | * Updated behavior of GNUNET_log:: | ||
2572 | @end menu | ||
2573 | |||
2574 | @node Examples | ||
2575 | @subsubsection Examples | ||
2576 | |||
2577 | @table @asis | ||
2578 | |||
2579 | @item @code{GNUNET_FORCE_LOG=";;;;DEBUG" gnunet-arm -s} Start GNUnet | ||
2580 | process tree, running all processes with DEBUG level (one should be | ||
2581 | careful with it, as log files will grow at alarming rate!) | ||
2582 | @item @code{GNUNET_FORCE_LOG="core;;;;DEBUG" gnunet-arm -s} Start GNUnet | ||
2583 | process tree, running the core service under DEBUG level (everything else | ||
2584 | will use configured or default level). | ||
2585 | |||
2586 | @item Start GNUnet process tree, allowing any logging calls from | ||
2587 | gnunet-service-transport_validation.c (everything else will use | ||
2588 | configured or default level). | ||
2589 | |||
2590 | @example | ||
2591 | GNUNET_FORCE_LOG=";gnunet-service-transport_validation.c;;; DEBUG" \ | ||
2592 | gnunet-arm -s | ||
2593 | @end example | ||
2594 | |||
2595 | @item Start GNUnet process tree, allowing any logging calls from | ||
2596 | gnunet-gnunet-service-fs_push.c (everything else will use configured or | ||
2597 | default level). | ||
2598 | |||
2599 | @example | ||
2600 | GNUNET_FORCE_LOG="fs;gnunet-service-fs_push.c;;;DEBUG" gnunet-arm -s | ||
2601 | @end example | ||
2602 | |||
2603 | @item Start GNUnet process tree, allowing any logging calls from the | ||
2604 | GNUNET_NETWORK_socket_select function (everything else will use | ||
2605 | configured or default level). | ||
2606 | |||
2607 | @example | ||
2608 | GNUNET_FORCE_LOG=";;GNUNET_NETWORK_socket_select;;DEBUG" gnunet-arm -s | ||
2609 | @end example | ||
2610 | |||
2611 | @item Start GNUnet process tree, allowing any logging calls from the | ||
2612 | components that have "transport" in their names, and are made from | ||
2613 | function that have "send" in their names. Everything else will be allowed | ||
2614 | to be logged only if it has WARNING level. | ||
2615 | |||
2616 | @example | ||
2617 | GNUNET_FORCE_LOG="transport.*;;.*send.*;;DEBUG/;;;;WARNING" gnunet-arm -s | ||
2618 | @end example | ||
2619 | |||
2620 | @end table | ||
2621 | |||
2622 | |||
2623 | On Windows, one can use batch files to run GNUnet processes with special | ||
2624 | environment variables, without affecting the whole system. Such batch | ||
2625 | file will look like this: | ||
2626 | |||
2627 | @example | ||
2628 | set GNUNET_FORCE_LOG=;;do_transmit;;DEBUG@ gnunet-arm -s | ||
2629 | @end example | ||
2630 | |||
2631 | (note the absence of double quotes in the environment variable definition, | ||
2632 | as opposed to earlier examples, which use the shell). | ||
2633 | Another limitation, on Windows, GNUNET_FORCE_LOGFILE @strong{MUST} be set | ||
2634 | in order to GNUNET_FORCE_LOG to work. | ||
2635 | |||
2636 | |||
2637 | @cindex Log files | ||
2638 | @node Log files | ||
2639 | @subsubsection Log files | ||
2640 | |||
2641 | GNUnet can be told to log everything into a file instead of stderr (which | ||
2642 | is the default) using the "--log-file=logfile" or "-l logfile" option. | ||
2643 | This option can also be passed via command line, or from the "OPTION" and | ||
2644 | "GLOBAL_POSTFIX" configuration keys (see above). The file name passed | ||
2645 | with this option is subject to GNUnet filename expansion. If specified in | ||
2646 | "GLOBAL_POSTFIX", it is also subject to ARM service filename expansion, | ||
2647 | in particular, it may contain "@{@}" (left and right curly brace) | ||
2648 | sequence, which will be replaced by ARM with the name of the service. | ||
2649 | This is used to keep logs from more than one service separate, while only | ||
2650 | specifying one template containing "@{@}" in GLOBAL_POSTFIX. | ||
2651 | |||
2652 | As part of a secondary file name expansion, the first occurrence of "[]" | ||
2653 | sequence ("left square brace" followed by "right square brace") in the | ||
2654 | file name will be replaced with a process identifier or the process when | ||
2655 | it initializes its logging subsystem. As a result, all processes will log | ||
2656 | into different files. This is convenient for isolating messages of a | ||
2657 | particular process, and prevents I/O races when multiple processes try to | ||
2658 | write into the file at the same time. This expansion is done | ||
2659 | independently of "@{@}" expansion that ARM service does (see above). | ||
2660 | |||
2661 | The log file name that is specified via "-l" can contain format characters | ||
2662 | from the 'strftime' function family. For example, "%Y" will be replaced | ||
2663 | with the current year. Using "basename-%Y-%m-%d.log" would include the | ||
2664 | current year, month and day in the log file. If a GNUnet process runs for | ||
2665 | long enough to need more than one log file, it will eventually clean up | ||
2666 | old log files. Currently, only the last three log files (plus the current | ||
2667 | log file) are preserved. So once the fifth log file goes into use (so | ||
2668 | after 4 days if you use "%Y-%m-%d" as above), the first log file will be | ||
2669 | automatically deleted. Note that if your log file name only contains "%Y", | ||
2670 | then log files would be kept for 4 years and the logs from the first year | ||
2671 | would be deleted once year 5 begins. If you do not use any date-related | ||
2672 | string format codes, logs would never be automatically deleted by GNUnet. | ||
2673 | |||
2674 | |||
2675 | @c *********************************************************************** | ||
2676 | |||
2677 | @node Updated behavior of GNUNET_log | ||
2678 | @subsubsection Updated behavior of GNUNET_log | ||
2679 | |||
2680 | It's currently quite common to see constructions like this all over the | ||
2681 | code: | ||
2682 | |||
2683 | @example | ||
2684 | #if MESH_DEBUG | ||
2685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client disconnected\n"); | ||
2686 | #endif | ||
2687 | @end example | ||
2688 | |||
2689 | The reason for the #if is not to avoid displaying the message when | ||
2690 | disabled (GNUNET_ERROR_TYPE takes care of that), but to avoid the | ||
2691 | compiler including it in the binary at all, when compiling GNUnet for | ||
2692 | platforms with restricted storage space / memory (MIPS routers, | ||
2693 | ARM plug computers / dev boards, etc). | ||
2694 | |||
2695 | This presents several problems: the code gets ugly, hard to write and it | ||
2696 | is very easy to forget to include the #if guards, creating non-consistent | ||
2697 | code. A new change in GNUNET_log aims to solve these problems. | ||
2698 | |||
2699 | @strong{This change requires to @file{./configure} with at least | ||
2700 | @code{--enable-logging=verbose} to see debug messages.} | ||
2701 | |||
2702 | Here is an example of code with dense debug statements: | ||
2703 | |||
2704 | @example | ||
2705 | switch (restrict_topology) @{ | ||
2706 | case GNUNET_TESTING_TOPOLOGY_CLIQUE:#if VERBOSE_TESTING | ||
2707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but clique | ||
2708 | topology\n")); #endif unblacklisted_connections = create_clique (pg, | ||
2709 | &remove_connections, BLACKLIST, GNUNET_NO); break; case | ||
2710 | GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: #if VERBOSE_TESTING GNUNET_log | ||
2711 | (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but small world (ring) | ||
2712 | topology\n")); #endif unblacklisted_connections = create_small_world_ring | ||
2713 | (pg,&remove_connections, BLACKLIST); break; | ||
2714 | @end example | ||
2715 | |||
2716 | |||
2717 | Pretty hard to follow, huh? | ||
2718 | |||
2719 | From now on, it is not necessary to include the #if / #endif statements to | ||
2720 | achieve the same behavior. The @code{GNUNET_log} and @code{GNUNET_log_from} | ||
2721 | macros take | ||
2722 | care of it for you, depending on the configure option: | ||
2723 | |||
2724 | @itemize @bullet | ||
2725 | @item If @code{--enable-logging} is set to @code{no}, the binary will | ||
2726 | contain no log messages at all. | ||
2727 | @item If @code{--enable-logging} is set to @code{yes}, the binary will | ||
2728 | contain no DEBUG messages, and therefore running with @command{-L DEBUG} | ||
2729 | will have | ||
2730 | no effect. Other messages (ERROR, WARNING, INFO, etc) will be included. | ||
2731 | @item If @code{--enable-logging} is set to @code{verbose}, or | ||
2732 | @code{veryverbose} the binary will contain DEBUG messages (still, it will | ||
2733 | be necessary to run with @command{-L DEBUG} or set the DEBUG config option | ||
2734 | to show | ||
2735 | them). | ||
2736 | @end itemize | ||
2737 | |||
2738 | |||
2739 | If you are a developer: | ||
2740 | @itemize @bullet | ||
2741 | @item please make sure that you @code{./configure | ||
2742 | --enable-logging=@{verbose,veryverbose@}}, so you can see DEBUG messages. | ||
2743 | @item please remove the @code{#if} statements around @code{GNUNET_log | ||
2744 | (GNUNET_ERROR_TYPE_DEBUG, ...)} lines, to improve the readability of your | ||
2745 | code. | ||
2746 | @end itemize | ||
2747 | |||
2748 | Since now activating DEBUG automatically makes it VERBOSE and activates | ||
2749 | @strong{all} debug messages by default, you probably want to use the | ||
2750 | https://gnunet.org/logging functionality to filter only relevant messages. | ||
2751 | A suitable configuration could be: | ||
2752 | |||
2753 | @example | ||
2754 | $ export GNUNET_FORCE_LOG="^YOUR_SUBSYSTEM$;;;;DEBUG/;;;;WARNING" | ||
2755 | @end example | ||
2756 | |||
2757 | Which will behave almost like enabling DEBUG in that subsystem before the | ||
2758 | change. Of course you can adapt it to your particular needs, this is only | ||
2759 | a quick example. | ||
2760 | |||
2761 | @cindex Interprocess communication API | ||
2762 | @cindex ICP | ||
2763 | @node Interprocess communication API (IPC) | ||
2764 | @subsection Interprocess communication API (IPC) | ||
2765 | |||
2766 | In GNUnet a variety of new message types might be defined and used in | ||
2767 | interprocess communication, in this tutorial we use the | ||
2768 | @code{struct AddressLookupMessage} as a example to introduce how to | ||
2769 | construct our own message type in GNUnet and how to implement the message | ||
2770 | communication between service and client. | ||
2771 | (Here, a client uses the @code{struct AddressLookupMessage} as a request | ||
2772 | to ask the server to return the address of any other peer connecting to | ||
2773 | the service.) | ||
2774 | |||
2775 | |||
2776 | @c *********************************************************************** | ||
2777 | @menu | ||
2778 | * Define new message types:: | ||
2779 | * Define message struct:: | ||
2780 | * Client - Establish connection:: | ||
2781 | * Client - Initialize request message:: | ||
2782 | * Client - Send request and receive response:: | ||
2783 | * Server - Startup service:: | ||
2784 | * Server - Add new handles for specified messages:: | ||
2785 | * Server - Process request message:: | ||
2786 | * Server - Response to client:: | ||
2787 | * Server - Notification of clients:: | ||
2788 | * Conversion between Network Byte Order (Big Endian) and Host Byte Order:: | ||
2789 | @end menu | ||
2790 | |||
2791 | @node Define new message types | ||
2792 | @subsubsection Define new message types | ||
2793 | |||
2794 | First of all, you should define the new message type in | ||
2795 | @file{gnunet_protocols.h}: | ||
2796 | |||
2797 | @example | ||
2798 | // Request to look addresses of peers in server. | ||
2799 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP 29 | ||
2800 | // Response to the address lookup request. | ||
2801 | #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY 30 | ||
2802 | @end example | ||
2803 | |||
2804 | @c *********************************************************************** | ||
2805 | @node Define message struct | ||
2806 | @subsubsection Define message struct | ||
2807 | |||
2808 | After the type definition, the specified message structure should also be | ||
2809 | described in the header file, e.g. transport.h in our case. | ||
2810 | |||
2811 | @example | ||
2812 | struct AddressLookupMessage @{ | ||
2813 | struct GNUNET_MessageHeader header; | ||
2814 | int32_t numeric_only GNUNET_PACKED; | ||
2815 | struct GNUNET_TIME_AbsoluteNBO timeout; | ||
2816 | uint32_t addrlen GNUNET_PACKED; | ||
2817 | /* followed by 'addrlen' bytes of the actual address, then | ||
2818 | followed by the 0-terminated name of the transport */ @}; | ||
2819 | GNUNET_NETWORK_STRUCT_END | ||
2820 | @end example | ||
2821 | |||
2822 | |||
2823 | Please note @code{GNUNET_NETWORK_STRUCT_BEGIN} and @code{GNUNET_PACKED} | ||
2824 | which both ensure correct alignment when sending structs over the network. | ||
2825 | |||
2826 | @menu | ||
2827 | @end menu | ||
2828 | |||
2829 | @c *********************************************************************** | ||
2830 | @node Client - Establish connection | ||
2831 | @subsubsection Client - Establish connection | ||
2832 | @c %**end of header | ||
2833 | |||
2834 | |||
2835 | At first, on the client side, the underlying API is employed to create a | ||
2836 | new connection to a service, in our example the transport service would be | ||
2837 | connected. | ||
2838 | |||
2839 | @example | ||
2840 | struct GNUNET_CLIENT_Connection *client; | ||
2841 | client = GNUNET_CLIENT_connect ("transport", cfg); | ||
2842 | @end example | ||
2843 | |||
2844 | @c *********************************************************************** | ||
2845 | @node Client - Initialize request message | ||
2846 | @subsubsection Client - Initialize request message | ||
2847 | @c %**end of header | ||
2848 | |||
2849 | When the connection is ready, we initialize the message. In this step, | ||
2850 | all the fields of the message should be properly initialized, namely the | ||
2851 | size, type, and some extra user-defined data, such as timeout, name of | ||
2852 | transport, address and name of transport. | ||
2853 | |||
2854 | @example | ||
2855 | struct AddressLookupMessage *msg; | ||
2856 | size_t len = sizeof (struct AddressLookupMessage) | ||
2857 | + addressLen | ||
2858 | + strlen (nameTrans) | ||
2859 | + 1; | ||
2860 | msg->header->size = htons (len); | ||
2861 | msg->header->type = htons | ||
2862 | (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); | ||
2863 | msg->timeout = GNUNET_TIME_absolute_hton (abs_timeout); | ||
2864 | msg->addrlen = htonl (addressLen); | ||
2865 | char *addrbuf = (char *) &msg[1]; | ||
2866 | memcpy (addrbuf, address, addressLen); | ||
2867 | char *tbuf = &addrbuf[addressLen]; | ||
2868 | memcpy (tbuf, nameTrans, strlen (nameTrans) + 1); | ||
2869 | @end example | ||
2870 | |||
2871 | Note that, here the functions @code{htonl}, @code{htons} and | ||
2872 | @code{GNUNET_TIME_absolute_hton} are applied to convert little endian | ||
2873 | into big endian, about the usage of the big/small endian order and the | ||
2874 | corresponding conversion function please refer to Introduction of | ||
2875 | Big Endian and Little Endian. | ||
2876 | |||
2877 | @c *********************************************************************** | ||
2878 | @node Client - Send request and receive response | ||
2879 | @subsubsection Client - Send request and receive response | ||
2880 | @c %**end of header | ||
2881 | |||
2882 | @b{FIXME: This is very outdated, see the tutorial for the current API!} | ||
2883 | |||
2884 | Next, the client would send the constructed message as a request to the | ||
2885 | service and wait for the response from the service. To accomplish this | ||
2886 | goal, there are a number of API calls that can be used. In this example, | ||
2887 | @code{GNUNET_CLIENT_transmit_and_get_response} is chosen as the most | ||
2888 | appropriate function to use. | ||
2889 | |||
2890 | @example | ||
2891 | GNUNET_CLIENT_transmit_and_get_response | ||
2892 | (client, msg->header, timeout, GNUNET_YES, &address_response_processor, | ||
2893 | arp_ctx); | ||
2894 | @end example | ||
2895 | |||
2896 | the argument @code{address_response_processor} is a function with | ||
2897 | @code{GNUNET_CLIENT_MessageHandler} type, which is used to process the | ||
2898 | reply message from the service. | ||
2899 | |||
2900 | @node Server - Startup service | ||
2901 | @subsubsection Server - Startup service | ||
2902 | |||
2903 | After receiving the request message, we run a standard GNUnet service | ||
2904 | startup sequence using @code{GNUNET_SERVICE_run}, as follows, | ||
2905 | |||
2906 | @example | ||
2907 | int main(int argc, char**argv) @{ | ||
2908 | GNUNET_SERVICE_run(argc, argv, "transport" | ||
2909 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)); @} | ||
2910 | @end example | ||
2911 | |||
2912 | @c *********************************************************************** | ||
2913 | @node Server - Add new handles for specified messages | ||
2914 | @subsubsection Server - Add new handles for specified messages | ||
2915 | @c %**end of header | ||
2916 | |||
2917 | in the function above the argument @code{run} is used to initiate | ||
2918 | transport service,and defined like this: | ||
2919 | |||
2920 | @example | ||
2921 | static void run (void *cls, | ||
2922 | struct GNUNET_SERVER_Handle *serv, | ||
2923 | const struct GNUNET_CONFIGURATION_Handle *cfg) @{ | ||
2924 | GNUNET_SERVER_add_handlers (serv, handlers); @} | ||
2925 | @end example | ||
2926 | |||
2927 | |||
2928 | Here, @code{GNUNET_SERVER_add_handlers} must be called in the run | ||
2929 | function to add new handlers in the service. The parameter | ||
2930 | @code{handlers} is a list of @code{struct GNUNET_SERVER_MessageHandler} | ||
2931 | to tell the service which function should be called when a particular | ||
2932 | type of message is received, and should be defined in this way: | ||
2933 | |||
2934 | @example | ||
2935 | static struct GNUNET_SERVER_MessageHandler handlers[] = @{ | ||
2936 | @{&handle_start, | ||
2937 | NULL, | ||
2938 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, | ||
2939 | 0@}, | ||
2940 | @{&handle_send, | ||
2941 | NULL, | ||
2942 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, | ||
2943 | 0@}, | ||
2944 | @{&handle_try_connect, | ||
2945 | NULL, | ||
2946 | GNUNET_MESSAGE_TYPE_TRANSPORT_TRY_CONNECT, | ||
2947 | sizeof (struct TryConnectMessage) | ||
2948 | @}, | ||
2949 | @{&handle_address_lookup, | ||
2950 | NULL, | ||
2951 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP, | ||
2952 | 0@}, | ||
2953 | @{NULL, | ||
2954 | NULL, | ||
2955 | 0, | ||
2956 | 0@} | ||
2957 | @}; | ||
2958 | @end example | ||
2959 | |||
2960 | |||
2961 | As shown, the first member of the struct in the first area is a callback | ||
2962 | function, which is called to process the specified message types, given | ||
2963 | as the third member. The second parameter is the closure for the callback | ||
2964 | function, which is set to @code{NULL} in most cases, and the last | ||
2965 | parameter is the expected size of the message of this type, usually we | ||
2966 | set it to 0 to accept variable size, for special cases the exact size of | ||
2967 | the specified message also can be set. In addition, the terminator sign | ||
2968 | depicted as @code{@{NULL, NULL, 0, 0@}} is set in the last area. | ||
2969 | |||
2970 | @c *********************************************************************** | ||
2971 | @node Server - Process request message | ||
2972 | @subsubsection Server - Process request message | ||
2973 | @c %**end of header | ||
2974 | |||
2975 | After the initialization of transport service, the request message would | ||
2976 | be processed. Before handling the main message data, the validity of this | ||
2977 | message should be checked out, e.g., to check whether the size of message | ||
2978 | is correct. | ||
2979 | |||
2980 | @example | ||
2981 | size = ntohs (message->size); | ||
2982 | if (size < sizeof (struct AddressLookupMessage)) @{ | ||
2983 | GNUNET_break_op (0); | ||
2984 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
2985 | return; @} | ||
2986 | @end example | ||
2987 | |||
2988 | |||
2989 | Note that, opposite to the construction method of the request message in | ||
2990 | the client, in the server the function @code{nothl} and @code{ntohs} | ||
2991 | should be employed during the extraction of the data from the message, so | ||
2992 | that the data in big endian order can be converted back into little | ||
2993 | endian order. See more in detail please refer to Introduction of | ||
2994 | Big Endian and Little Endian. | ||
2995 | |||
2996 | Moreover in this example, the name of the transport stored in the message | ||
2997 | is a 0-terminated string, so we should also check whether the name of the | ||
2998 | transport in the received message is 0-terminated: | ||
2999 | |||
3000 | @example | ||
3001 | nameTransport = (const char *) &address[addressLen]; | ||
3002 | if (nameTransport[size - sizeof | ||
3003 | (struct AddressLookupMessage) | ||
3004 | - addressLen - 1] != '\0') @{ | ||
3005 | GNUNET_break_op (0); | ||
3006 | GNUNET_SERVER_receive_done (client, | ||
3007 | GNUNET_SYSERR); | ||
3008 | return; @} | ||
3009 | @end example | ||
3010 | |||
3011 | Here, @code{GNUNET_SERVER_receive_done} should be called to tell the | ||
3012 | service that the request is done and can receive the next message. The | ||
3013 | argument @code{GNUNET_SYSERR} here indicates that the service didn't | ||
3014 | understand the request message, and the processing of this request would | ||
3015 | be terminated. | ||
3016 | |||
3017 | In comparison to the aforementioned situation, when the argument is equal | ||
3018 | to @code{GNUNET_OK}, the service would continue to process the request | ||
3019 | message. | ||
3020 | |||
3021 | @c *********************************************************************** | ||
3022 | @node Server - Response to client | ||
3023 | @subsubsection Server - Response to client | ||
3024 | @c %**end of header | ||
3025 | |||
3026 | Once the processing of current request is done, the server should give the | ||
3027 | response to the client. A new @code{struct AddressLookupMessage} would be | ||
3028 | produced by the server in a similar way as the client did and sent to the | ||
3029 | client, but here the type should be | ||
3030 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY} rather than | ||
3031 | @code{GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP} in client. | ||
3032 | @example | ||
3033 | struct AddressLookupMessage *msg; | ||
3034 | size_t len = sizeof (struct AddressLookupMessage) | ||
3035 | + addressLen | ||
3036 | + strlen (nameTrans) + 1; | ||
3037 | msg->header->size = htons (len); | ||
3038 | msg->header->type = htons | ||
3039 | (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
3040 | |||
3041 | // ... | ||
3042 | |||
3043 | struct GNUNET_SERVER_TransmitContext *tc; | ||
3044 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
3045 | GNUNET_SERVER_transmit_context_append_data | ||
3046 | (tc, | ||
3047 | NULL, | ||
3048 | 0, | ||
3049 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
3050 | GNUNET_SERVER_transmit_context_run (tc, rtimeout); | ||
3051 | @end example | ||
3052 | |||
3053 | |||
3054 | Note that, there are also a number of other APIs provided to the service | ||
3055 | to send the message. | ||
3056 | |||
3057 | @c *********************************************************************** | ||
3058 | @node Server - Notification of clients | ||
3059 | @subsubsection Server - Notification of clients | ||
3060 | @c %**end of header | ||
3061 | |||
3062 | Often a service needs to (repeatedly) transmit notifications to a client | ||
3063 | or a group of clients. In these cases, the client typically has once | ||
3064 | registered for a set of events and then needs to receive a message | ||
3065 | whenever such an event happens (until the client disconnects). The use of | ||
3066 | a notification context can help manage message queues to clients and | ||
3067 | handle disconnects. Notification contexts can be used to send | ||
3068 | individualized messages to a particular client or to broadcast messages | ||
3069 | to a group of clients. An individualized notification might look like | ||
3070 | this: | ||
3071 | |||
3072 | @example | ||
3073 | GNUNET_SERVER_notification_context_unicast(nc, | ||
3074 | client, | ||
3075 | msg, | ||
3076 | GNUNET_YES); | ||
3077 | @end example | ||
3078 | |||
3079 | |||
3080 | Note that after processing the original registration message for | ||
3081 | notifications, the server code still typically needs to call | ||
3082 | @code{GNUNET_SERVER_receive_done} so that the client can transmit further | ||
3083 | messages to the server. | ||
3084 | |||
3085 | @c *********************************************************************** | ||
3086 | @node Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
3087 | @subsubsection Conversion between Network Byte Order (Big Endian) and Host Byte Order | ||
3088 | @c %** subsub? it's a referenced page on the ipc document. | ||
3089 | @c %**end of header | ||
3090 | |||
3091 | Here we can simply comprehend big endian and little endian as Network Byte | ||
3092 | Order and Host Byte Order respectively. What is the difference between | ||
3093 | both two? | ||
3094 | |||
3095 | Usually in our host computer we store the data byte as Host Byte Order, | ||
3096 | for example, we store a integer in the RAM which might occupies 4 Byte, | ||
3097 | as Host Byte Order the higher Byte would be stored at the lower address | ||
3098 | of RAM, and the lower Byte would be stored at the higher address of RAM. | ||
3099 | However, contrast to this, Network Byte Order just take the totally | ||
3100 | opposite way to store the data, says, it will store the lower Byte at the | ||
3101 | lower address, and the higher Byte will stay at higher address. | ||
3102 | |||
3103 | For the current communication of network, we normally exchange the | ||
3104 | information by surveying the data package, every two host wants to | ||
3105 | communicate with each other must send and receive data package through | ||
3106 | network. In order to maintain the identity of data through the | ||
3107 | transmission in the network, the order of the Byte storage must changed | ||
3108 | before sending and after receiving the data. | ||
3109 | |||
3110 | There ten convenient functions to realize the conversion of Byte Order in | ||
3111 | GNUnet, as following: | ||
3112 | |||
3113 | @table @asis | ||
3114 | |||
3115 | @item uint16_t htons(uint16_t hostshort) Convert host byte order to net | ||
3116 | byte order with short int | ||
3117 | @item uint32_t htonl(uint32_t hostlong) Convert host byte | ||
3118 | order to net byte order with long int | ||
3119 | @item uint16_t ntohs(uint16_t netshort) | ||
3120 | Convert net byte order to host byte order with short int | ||
3121 | @item uint32_t | ||
3122 | ntohl(uint32_t netlong) Convert net byte order to host byte order with | ||
3123 | long int | ||
3124 | @item unsigned long long GNUNET_ntohll (unsigned long long netlonglong) | ||
3125 | Convert net byte order to host byte order with long long int | ||
3126 | @item unsigned long long GNUNET_htonll (unsigned long long hostlonglong) | ||
3127 | Convert host byte order to net byte order with long long int | ||
3128 | @item struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton | ||
3129 | (struct GNUNET_TIME_Relative a) Convert relative time to network byte | ||
3130 | order. | ||
3131 | @item struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh | ||
3132 | (struct GNUNET_TIME_RelativeNBO a) Convert relative time from network | ||
3133 | byte order. | ||
3134 | @item struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton | ||
3135 | (struct GNUNET_TIME_Absolute a) Convert relative time to network byte | ||
3136 | order. | ||
3137 | @item struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh | ||
3138 | (struct GNUNET_TIME_AbsoluteNBO a) Convert relative time from network | ||
3139 | byte order. | ||
3140 | @end table | ||
3141 | |||
3142 | @cindex Cryptography API | ||
3143 | @node Cryptography API | ||
3144 | @subsection Cryptography API | ||
3145 | @c %**end of header | ||
3146 | |||
3147 | The gnunetutil APIs provides the cryptographic primitives used in GNUnet. | ||
3148 | GNUnet uses 2048 bit RSA keys for the session key exchange and for signing | ||
3149 | messages by peers and most other public-key operations. Most researchers | ||
3150 | in cryptography consider 2048 bit RSA keys as secure and practically | ||
3151 | unbreakable for a long time. The API provides functions to create a fresh | ||
3152 | key pair, read a private key from a file (or create a new file if the | ||
3153 | file does not exist), encrypt, decrypt, sign, verify and extraction of | ||
3154 | the public key into a format suitable for network transmission. | ||
3155 | |||
3156 | For the encryption of files and the actual data exchanged between peers | ||
3157 | GNUnet uses 256-bit AES encryption. Fresh, session keys are negotiated | ||
3158 | for every new connection.@ Again, there is no published technique to | ||
3159 | break this cipher in any realistic amount of time. The API provides | ||
3160 | functions for generation of keys, validation of keys (important for | ||
3161 | checking that decryptions using RSA succeeded), encryption and decryption. | ||
3162 | |||
3163 | GNUnet uses SHA-512 for computing one-way hash codes. The API provides | ||
3164 | functions to compute a hash over a block in memory or over a file on disk. | ||
3165 | |||
3166 | The crypto API also provides functions for randomizing a block of memory, | ||
3167 | obtaining a single random number and for generating a permutation of the | ||
3168 | numbers 0 to n-1. Random number generation distinguishes between WEAK and | ||
3169 | STRONG random number quality; WEAK random numbers are pseudo-random | ||
3170 | whereas STRONG random numbers use entropy gathered from the operating | ||
3171 | system. | ||
3172 | |||
3173 | Finally, the crypto API provides a means to deterministically generate a | ||
3174 | 1024-bit RSA key from a hash code. These functions should most likely not | ||
3175 | be used by most applications; most importantly, | ||
3176 | GNUNET_CRYPTO_rsa_key_create_from_hash does not create an RSA-key that | ||
3177 | should be considered secure for traditional applications of RSA. | ||
3178 | |||
3179 | @cindex Message Queue API | ||
3180 | @node Message Queue API | ||
3181 | @subsection Message Queue API | ||
3182 | @c %**end of header | ||
3183 | |||
3184 | @strong{ Introduction }@ | ||
3185 | Often, applications need to queue messages that | ||
3186 | are to be sent to other GNUnet peers, clients or services. As all of | ||
3187 | GNUnet's message-based communication APIs, by design, do not allow | ||
3188 | messages to be queued, it is common to implement custom message queues | ||
3189 | manually when they are needed. However, writing very similar code in | ||
3190 | multiple places is tedious and leads to code duplication. | ||
3191 | |||
3192 | MQ (for Message Queue) is an API that provides the functionality to | ||
3193 | implement and use message queues. We intend to eventually replace all of | ||
3194 | the custom message queue implementations in GNUnet with MQ. | ||
3195 | |||
3196 | @strong{ Basic Concepts }@ | ||
3197 | The two most important entities in MQ are queues and envelopes. | ||
3198 | |||
3199 | Every queue is backed by a specific implementation (e.g. for mesh, stream, | ||
3200 | connection, server client, etc.) that will actually deliver the queued | ||
3201 | messages. For convenience,@ some queues also allow to specify a list of | ||
3202 | message handlers. The message queue will then also wait for incoming | ||
3203 | messages and dispatch them appropriately. | ||
3204 | |||
3205 | An envelope holds the the memory for a message, as well as metadata | ||
3206 | (Where is the envelope queued? What should happen after it has been | ||
3207 | sent?). Any envelope can only be queued in one message queue. | ||
3208 | |||
3209 | @strong{ Creating Queues }@ | ||
3210 | The following is a list of currently available message queues. Note that | ||
3211 | to avoid layering issues, message queues for higher level APIs are not | ||
3212 | part of @code{libgnunetutil}, but@ the respective API itself provides the | ||
3213 | queue implementation. | ||
3214 | |||
3215 | @table @asis | ||
3216 | |||
3217 | @item @code{GNUNET_MQ_queue_for_connection_client} | ||
3218 | Transmits queued messages over a @code{GNUNET_CLIENT_Connection} handle. | ||
3219 | Also supports receiving with message handlers. | ||
3220 | |||
3221 | @item @code{GNUNET_MQ_queue_for_server_client} | ||
3222 | Transmits queued messages over a @code{GNUNET_SERVER_Client} handle. Does | ||
3223 | not support incoming message handlers. | ||
3224 | |||
3225 | @item @code{GNUNET_MESH_mq_create} Transmits queued messages over a | ||
3226 | @code{GNUNET_MESH_Tunnel} handle. Does not support incoming message | ||
3227 | handlers. | ||
3228 | |||
3229 | @item @code{GNUNET_MQ_queue_for_callbacks} This is the most general | ||
3230 | implementation. Instead of delivering and receiving messages with one of | ||
3231 | GNUnet's communication APIs, implementation callbacks are called. Refer to | ||
3232 | "Implementing Queues" for a more detailed explanation. | ||
3233 | @end table | ||
3234 | |||
3235 | |||
3236 | @strong{ Allocating Envelopes }@ | ||
3237 | A GNUnet message (as defined by the GNUNET_MessageHeader) has three | ||
3238 | parts: The size, the type, and the body. | ||
3239 | |||
3240 | MQ provides macros to allocate an envelope containing a message | ||
3241 | conveniently, automatically setting the size and type fields of the | ||
3242 | message. | ||
3243 | |||
3244 | Consider the following simple message, with the body consisting of a | ||
3245 | single number value. | ||
3246 | @c why the empty code function? | ||
3247 | @code{} | ||
3248 | |||
3249 | @example | ||
3250 | struct NumberMessage @{ | ||
3251 | /** Type: GNUNET_MESSAGE_TYPE_EXAMPLE_1 */ | ||
3252 | struct GNUNET_MessageHeader header; | ||
3253 | uint32_t number GNUNET_PACKED; | ||
3254 | @}; | ||
3255 | @end example | ||
3256 | |||
3257 | An envelope containing an instance of the NumberMessage can be | ||
3258 | constructed like this: | ||
3259 | |||
3260 | @example | ||
3261 | struct GNUNET_MQ_Envelope *ev; | ||
3262 | struct NumberMessage *msg; | ||
3263 | ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_EXAMPLE_1); | ||
3264 | msg->number = htonl (42); | ||
3265 | @end example | ||
3266 | |||
3267 | In the above code, @code{GNUNET_MQ_msg} is a macro. The return value is | ||
3268 | the newly allocated envelope. The first argument must be a pointer to some | ||
3269 | @code{struct} containing a @code{struct GNUNET_MessageHeader header} | ||
3270 | field, while the second argument is the desired message type, in host | ||
3271 | byte order. | ||
3272 | |||
3273 | The @code{msg} pointer now points to an allocated message, where the | ||
3274 | message type and the message size are already set. The message's size is | ||
3275 | inferred from the type of the @code{msg} pointer: It will be set to | ||
3276 | 'sizeof(*msg)', properly converted to network byte order. | ||
3277 | |||
3278 | If the message body's size is dynamic, the the macro | ||
3279 | @code{GNUNET_MQ_msg_extra} can be used to allocate an envelope whose | ||
3280 | message has additional space allocated after the @code{msg} structure. | ||
3281 | |||
3282 | If no structure has been defined for the message, | ||
3283 | @code{GNUNET_MQ_msg_header_extra} can be used to allocate additional space | ||
3284 | after the message header. The first argument then must be a pointer to a | ||
3285 | @code{GNUNET_MessageHeader}. | ||
3286 | |||
3287 | @strong{Envelope Properties}@ | ||
3288 | A few functions in MQ allow to set additional properties on envelopes: | ||
3289 | |||
3290 | @table @asis | ||
3291 | |||
3292 | @item @code{GNUNET_MQ_notify_sent} Allows to specify a function that will | ||
3293 | be called once the envelope's message has been sent irrevocably. | ||
3294 | An envelope can be canceled precisely up to the@ point where the notify | ||
3295 | sent callback has been called. | ||
3296 | |||
3297 | @item @code{GNUNET_MQ_disable_corking} No corking will be used when | ||
3298 | sending the message. Not every@ queue supports this flag, per default, | ||
3299 | envelopes are sent with corking.@ | ||
3300 | |||
3301 | @end table | ||
3302 | |||
3303 | |||
3304 | @strong{Sending Envelopes}@ | ||
3305 | Once an envelope has been constructed, it can be queued for sending with | ||
3306 | @code{GNUNET_MQ_send}. | ||
3307 | |||
3308 | Note that in order to avoid memory leaks, an envelope must either be sent | ||
3309 | (the queue will free it) or destroyed explicitly with | ||
3310 | @code{GNUNET_MQ_discard}. | ||
3311 | |||
3312 | @strong{Canceling Envelopes}@ | ||
3313 | An envelope queued with @code{GNUNET_MQ_send} can be canceled with | ||
3314 | @code{GNUNET_MQ_cancel}. Note that after the notify sent callback has | ||
3315 | been called, canceling a message results in undefined behavior. | ||
3316 | Thus it is unsafe to cancel an envelope that does not have a notify sent | ||
3317 | callback. When canceling an envelope, it is not necessary@ to call | ||
3318 | @code{GNUNET_MQ_discard}, and the envelope can't be sent again. | ||
3319 | |||
3320 | @strong{ Implementing Queues }@ | ||
3321 | @code{TODO} | ||
3322 | |||
3323 | @cindex Service API | ||
3324 | @node Service API | ||
3325 | @subsection Service API | ||
3326 | @c %**end of header | ||
3327 | |||
3328 | Most GNUnet code lives in the form of services. Services are processes | ||
3329 | that offer an API for other components of the system to build on. Those | ||
3330 | other components can be command-line tools for users, graphical user | ||
3331 | interfaces or other services. Services provide their API using an IPC | ||
3332 | protocol. For this, each service must listen on either a TCP port or a | ||
3333 | UNIX domain socket; for this, the service implementation uses the server | ||
3334 | API. This use of server is exposed directly to the users of the service | ||
3335 | API. Thus, when using the service API, one is usually also often using | ||
3336 | large parts of the server API. The service API provides various | ||
3337 | convenience functions, such as parsing command-line arguments and the | ||
3338 | configuration file, which are not found in the server API. | ||
3339 | The dual to the service/server API is the client API, which can be used to | ||
3340 | access services. | ||
3341 | |||
3342 | The most common way to start a service is to use the | ||
3343 | @code{GNUNET_SERVICE_run} function from the program's main function. | ||
3344 | @code{GNUNET_SERVICE_run} will then parse the command line and | ||
3345 | configuration files and, based on the options found there, | ||
3346 | start the server. It will then give back control to the main | ||
3347 | program, passing the server and the configuration to the | ||
3348 | @code{GNUNET_SERVICE_Main} callback. @code{GNUNET_SERVICE_run} | ||
3349 | will also take care of starting the scheduler loop. | ||
3350 | If this is inappropriate (for example, because the scheduler loop | ||
3351 | is already running), @code{GNUNET_SERVICE_start} and | ||
3352 | related functions provide an alternative to @code{GNUNET_SERVICE_run}. | ||
3353 | |||
3354 | When starting a service, the service_name option is used to determine | ||
3355 | which sections in the configuration file should be used to configure the | ||
3356 | service. A typical value here is the name of the @file{src/} | ||
3357 | sub-directory, for example @file{statistics}. | ||
3358 | The same string would also be given to | ||
3359 | @code{GNUNET_CLIENT_connect} to access the service. | ||
3360 | |||
3361 | Once a service has been initialized, the program should use the | ||
3362 | @code{GNUNET_SERVICE_Main} callback to register message handlers | ||
3363 | using @code{GNUNET_SERVER_add_handlers}. | ||
3364 | The service will already have registered a handler for the | ||
3365 | "TEST" message. | ||
3366 | |||
3367 | @findex GNUNET_SERVICE_Options | ||
3368 | The option bitfield (@code{enum GNUNET_SERVICE_Options}) | ||
3369 | determines how a service should behave during shutdown. | ||
3370 | There are three key strategies: | ||
3371 | |||
3372 | @table @asis | ||
3373 | |||
3374 | @item instant (@code{GNUNET_SERVICE_OPTION_NONE}) | ||
3375 | Upon receiving the shutdown | ||
3376 | signal from the scheduler, the service immediately terminates the server, | ||
3377 | closing all existing connections with clients. | ||
3378 | @item manual (@code{GNUNET_SERVICE_OPTION_MANUAL_SHUTDOWN}) | ||
3379 | The service does nothing by itself | ||
3380 | during shutdown. The main program will need to take the appropriate | ||
3381 | action by calling GNUNET_SERVER_destroy or GNUNET_SERVICE_stop (depending | ||
3382 | on how the service was initialized) to terminate the service. This method | ||
3383 | is used by gnunet-service-arm and rather uncommon. | ||
3384 | @item soft (@code{GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN}) | ||
3385 | Upon receiving the shutdown signal from the scheduler, | ||
3386 | the service immediately tells the server to stop | ||
3387 | listening for incoming clients. Requests from normal existing clients are | ||
3388 | still processed and the server/service terminates once all normal clients | ||
3389 | have disconnected. Clients that are not expected to ever disconnect (such | ||
3390 | as clients that monitor performance values) can be marked as 'monitor' | ||
3391 | clients using GNUNET_SERVER_client_mark_monitor. Those clients will | ||
3392 | continue to be processed until all 'normal' clients have disconnected. | ||
3393 | Then, the server will terminate, closing the monitor connections. | ||
3394 | This mode is for example used by 'statistics', allowing existing 'normal' | ||
3395 | clients to set (possibly persistent) statistic values before terminating. | ||
3396 | |||
3397 | @end table | ||
3398 | |||
3399 | @c *********************************************************************** | ||
3400 | @node Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
3401 | @subsection Optimizing Memory Consumption of GNUnet's (Multi-) Hash Maps | ||
3402 | @c %**end of header | ||
3403 | |||
3404 | A commonly used data structure in GNUnet is a (multi-)hash map. It is most | ||
3405 | often used to map a peer identity to some data structure, but also to map | ||
3406 | arbitrary keys to values (for example to track requests in the distributed | ||
3407 | hash table or in file-sharing). As it is commonly used, the DHT is | ||
3408 | actually sometimes responsible for a large share of GNUnet's overall | ||
3409 | memory consumption (for some processes, 30% is not uncommon). The | ||
3410 | following text documents some API quirks (and their implications for | ||
3411 | applications) that were recently introduced to minimize the footprint of | ||
3412 | the hash map. | ||
3413 | |||
3414 | |||
3415 | @c *********************************************************************** | ||
3416 | @menu | ||
3417 | * Analysis:: | ||
3418 | * Solution:: | ||
3419 | * Migration:: | ||
3420 | * Conclusion:: | ||
3421 | * Availability:: | ||
3422 | @end menu | ||
3423 | |||
3424 | @node Analysis | ||
3425 | @subsubsection Analysis | ||
3426 | @c %**end of header | ||
3427 | |||
3428 | The main reason for the "excessive" memory consumption by the hash map is | ||
3429 | that GNUnet uses 512-bit cryptographic hash codes --- and the | ||
3430 | (multi-)hash map also uses the same 512-bit 'struct GNUNET_HashCode'. As | ||
3431 | a result, storing just the keys requires 64 bytes of memory for each key. | ||
3432 | As some applications like to keep a large number of entries in the hash | ||
3433 | map (after all, that's what maps are good for), 64 bytes per hash is | ||
3434 | significant: keeping a pointer to the value and having a linked list for | ||
3435 | collisions consume between 8 and 16 bytes, and 'malloc' may add about the | ||
3436 | same overhead per allocation, putting us in the 16 to 32 byte per entry | ||
3437 | ballpark. Adding a 64-byte key then triples the overall memory | ||
3438 | requirement for the hash map. | ||
3439 | |||
3440 | To make things "worse", most of the time storing the key in the hash map | ||
3441 | is not required: it is typically already in memory elsewhere! In most | ||
3442 | cases, the values stored in the hash map are some application-specific | ||
3443 | struct that _also_ contains the hash. Here is a simplified example: | ||
3444 | |||
3445 | @example | ||
3446 | struct MyValue @{ | ||
3447 | struct GNUNET_HashCode key; | ||
3448 | unsigned int my_data; @}; | ||
3449 | |||
3450 | // ... | ||
3451 | val = GNUNET_malloc (sizeof (struct MyValue)); | ||
3452 | val->key = key; | ||
3453 | val->my_data = 42; | ||
3454 | GNUNET_CONTAINER_multihashmap_put (map, &key, val, ...); | ||
3455 | @end example | ||
3456 | |||
3457 | This is a common pattern as later the entries might need to be removed, | ||
3458 | and at that time it is convenient to have the key immediately at hand: | ||
3459 | |||
3460 | @example | ||
3461 | GNUNET_CONTAINER_multihashmap_remove (map, &val->key, val); | ||
3462 | @end example | ||
3463 | |||
3464 | |||
3465 | Note that here we end up with two times 64 bytes for the key, plus maybe | ||
3466 | 64 bytes total for the rest of the 'struct MyValue' and the map entry in | ||
3467 | the hash map. The resulting redundant storage of the key increases | ||
3468 | overall memory consumption per entry from the "optimal" 128 bytes to 192 | ||
3469 | bytes. This is not just an extreme example: overheads in practice are | ||
3470 | actually sometimes close to those highlighted in this example. This is | ||
3471 | especially true for maps with a significant number of entries, as there | ||
3472 | we tend to really try to keep the entries small. | ||
3473 | |||
3474 | @c *********************************************************************** | ||
3475 | @node Solution | ||
3476 | @subsubsection Solution | ||
3477 | @c %**end of header | ||
3478 | |||
3479 | The solution that has now been implemented is to @strong{optionally} | ||
3480 | allow the hash map to not make a (deep) copy of the hash but instead have | ||
3481 | a pointer to the hash/key in the entry. This reduces the memory | ||
3482 | consumption for the key from 64 bytes to 4 to 8 bytes. However, it can | ||
3483 | also only work if the key is actually stored in the entry (which is the | ||
3484 | case most of the time) and if the entry does not modify the key (which in | ||
3485 | all of the code I'm aware of has been always the case if there key is | ||
3486 | stored in the entry). Finally, when the client stores an entry in the | ||
3487 | hash map, it @strong{must} provide a pointer to the key within the entry, | ||
3488 | not just a pointer to a transient location of the key. If | ||
3489 | the client code does not meet these requirements, the result is a dangling | ||
3490 | pointer and undefined behavior of the (multi-)hash map API. | ||
3491 | |||
3492 | @c *********************************************************************** | ||
3493 | @node Migration | ||
3494 | @subsubsection Migration | ||
3495 | @c %**end of header | ||
3496 | |||
3497 | To use the new feature, first check that the values contain the respective | ||
3498 | key (and never modify it). Then, all calls to | ||
3499 | @code{GNUNET_CONTAINER_multihashmap_put} on the respective map must be | ||
3500 | audited and most likely changed to pass a pointer into the value's struct. | ||
3501 | For the initial example, the new code would look like this: | ||
3502 | |||
3503 | @example | ||
3504 | struct MyValue @{ | ||
3505 | struct GNUNET_HashCode key; | ||
3506 | unsigned int my_data; @}; | ||
3507 | |||
3508 | // ... | ||
3509 | val = GNUNET_malloc (sizeof (struct MyValue)); | ||
3510 | val->key = key; val->my_data = 42; | ||
3511 | GNUNET_CONTAINER_multihashmap_put (map, &val->key, val, ...); | ||
3512 | @end example | ||
3513 | |||
3514 | |||
3515 | Note that @code{&val} was changed to @code{&val->key} in the argument to | ||
3516 | the @code{put} call. This is critical as often @code{key} is on the stack | ||
3517 | or in some other transient data structure and thus having the hash map | ||
3518 | keep a pointer to @code{key} would not work. Only the key inside of | ||
3519 | @code{val} has the same lifetime as the entry in the map (this must of | ||
3520 | course be checked as well). Naturally, @code{val->key} must be | ||
3521 | initialized before the @code{put} call. Once all @code{put} calls have | ||
3522 | been converted and double-checked, you can change the call to create the | ||
3523 | hash map from | ||
3524 | |||
3525 | @example | ||
3526 | map = | ||
3527 | GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_NO); | ||
3528 | @end example | ||
3529 | |||
3530 | to | ||
3531 | |||
3532 | @example | ||
3533 | map = GNUNET_CONTAINER_multihashmap_create (SIZE, GNUNET_YES); | ||
3534 | @end example | ||
3535 | |||
3536 | If everything was done correctly, you now use about 60 bytes less memory | ||
3537 | per entry in @code{map}. However, if now (or in the future) any call to | ||
3538 | @code{put} does not ensure that the given key is valid until the entry is | ||
3539 | removed from the map, undefined behavior is likely to be observed. | ||
3540 | |||
3541 | @c *********************************************************************** | ||
3542 | @node Conclusion | ||
3543 | @subsubsection Conclusion | ||
3544 | @c %**end of header | ||
3545 | |||
3546 | The new optimization can is often applicable and can result in a | ||
3547 | reduction in memory consumption of up to 30% in practice. However, it | ||
3548 | makes the code less robust as additional invariants are imposed on the | ||
3549 | multi hash map client. Thus applications should refrain from enabling the | ||
3550 | new mode unless the resulting performance increase is deemed significant | ||
3551 | enough. In particular, it should generally not be used in new code (wait | ||
3552 | at least until benchmarks exist). | ||
3553 | |||
3554 | @c *********************************************************************** | ||
3555 | @node Availability | ||
3556 | @subsubsection Availability | ||
3557 | @c %**end of header | ||
3558 | |||
3559 | The new multi hash map code was committed in SVN 24319 (will be in GNUnet | ||
3560 | 0.9.4). Various subsystems (transport, core, dht, file-sharing) were | ||
3561 | previously audited and modified to take advantage of the new capability. | ||
3562 | In particular, memory consumption of the file-sharing service is expected | ||
3563 | to drop by 20-30% due to this change. | ||
3564 | |||
3565 | |||
3566 | @cindex CONTAINER_MDLL API | ||
3567 | @node CONTAINER_MDLL API | ||
3568 | @subsection CONTAINER_MDLL API | ||
3569 | @c %**end of header | ||
3570 | |||
3571 | This text documents the GNUNET_CONTAINER_MDLL API. The | ||
3572 | GNUNET_CONTAINER_MDLL API is similar to the GNUNET_CONTAINER_DLL API in | ||
3573 | that it provides operations for the construction and manipulation of | ||
3574 | doubly-linked lists. The key difference to the (simpler) DLL-API is that | ||
3575 | the MDLL-version allows a single element (instance of a "struct") to be | ||
3576 | in multiple linked lists at the same time. | ||
3577 | |||
3578 | Like the DLL API, the MDLL API stores (most of) the data structures for | ||
3579 | the doubly-linked list with the respective elements; only the 'head' and | ||
3580 | 'tail' pointers are stored "elsewhere" --- and the application needs to | ||
3581 | provide the locations of head and tail to each of the calls in the | ||
3582 | MDLL API. The key difference for the MDLL API is that the "next" and | ||
3583 | "previous" pointers in the struct can no longer be simply called "next" | ||
3584 | and "prev" --- after all, the element may be in multiple doubly-linked | ||
3585 | lists, so we cannot just have one "next" and one "prev" pointer! | ||
3586 | |||
3587 | The solution is to have multiple fields that must have a name of the | ||
3588 | format "next_XX" and "prev_XX" where "XX" is the name of one of the | ||
3589 | doubly-linked lists. Here is a simple example: | ||
3590 | |||
3591 | @example | ||
3592 | struct MyMultiListElement @{ | ||
3593 | struct MyMultiListElement *next_ALIST; | ||
3594 | struct MyMultiListElement *prev_ALIST; | ||
3595 | struct MyMultiListElement *next_BLIST; | ||
3596 | struct MyMultiListElement *prev_BLIST; | ||
3597 | void | ||
3598 | *data; | ||
3599 | @}; | ||
3600 | @end example | ||
3601 | |||
3602 | |||
3603 | Note that by convention, we use all-uppercase letters for the list names. | ||
3604 | In addition, the program needs to have a location for the head and tail | ||
3605 | pointers for both lists, for example: | ||
3606 | |||
3607 | @example | ||
3608 | static struct MyMultiListElement *head_ALIST; | ||
3609 | static struct MyMultiListElement *tail_ALIST; | ||
3610 | static struct MyMultiListElement *head_BLIST; | ||
3611 | static struct MyMultiListElement *tail_BLIST; | ||
3612 | @end example | ||
3613 | |||
3614 | |||
3615 | Using the MDLL-macros, we can now insert an element into the ALIST: | ||
3616 | |||
3617 | @example | ||
3618 | GNUNET_CONTAINER_MDLL_insert (ALIST, head_ALIST, tail_ALIST, element); | ||
3619 | @end example | ||
3620 | |||
3621 | |||
3622 | Passing "ALIST" as the first argument to MDLL specifies which of the | ||
3623 | next/prev fields in the 'struct MyMultiListElement' should be used. The | ||
3624 | extra "ALIST" argument and the "_ALIST" in the names of the | ||
3625 | next/prev-members are the only differences between the MDDL and DLL-API. | ||
3626 | Like the DLL-API, the MDLL-API offers functions for inserting (at head, | ||
3627 | at tail, after a given element) and removing elements from the list. | ||
3628 | Iterating over the list should be done by directly accessing the | ||
3629 | "next_XX" and/or "prev_XX" members. | ||
3630 | |||
3631 | @cindex Automatic Restart Manager | ||
3632 | @cindex ARM | ||
3633 | @node Automatic Restart Manager (ARM) | ||
3634 | @section Automatic Restart Manager (ARM) | ||
3635 | @c %**end of header | ||
3636 | |||
3637 | GNUnet's Automated Restart Manager (ARM) is the GNUnet service responsible | ||
3638 | for system initialization and service babysitting. ARM starts and halts | ||
3639 | services, detects configuration changes and restarts services impacted by | ||
3640 | the changes as needed. It's also responsible for restarting services in | ||
3641 | case of crashes and is planned to incorporate automatic debugging for | ||
3642 | diagnosing service crashes providing developers insights about crash | ||
3643 | reasons. The purpose of this document is to give GNUnet developer an idea | ||
3644 | about how ARM works and how to interact with it. | ||
3645 | |||
3646 | @menu | ||
3647 | * Basic functionality:: | ||
3648 | * Key configuration options:: | ||
3649 | * ARM - Availability:: | ||
3650 | * Reliability:: | ||
3651 | @end menu | ||
3652 | |||
3653 | @c *********************************************************************** | ||
3654 | @node Basic functionality | ||
3655 | @subsection Basic functionality | ||
3656 | @c %**end of header | ||
3657 | |||
3658 | @itemize @bullet | ||
3659 | @item ARM source code can be found under "src/arm".@ Service processes are | ||
3660 | managed by the functions in "gnunet-service-arm.c" which is controlled | ||
3661 | with "gnunet-arm.c" (main function in that file is ARM's entry point). | ||
3662 | |||
3663 | @item The functions responsible for communicating with ARM , starting and | ||
3664 | stopping services -including ARM service itself- are provided by the | ||
3665 | ARM API "arm_api.c".@ Function: GNUNET_ARM_connect() returns to the caller | ||
3666 | an ARM handle after setting it to the caller's context (configuration and | ||
3667 | scheduler in use). This handle can be used afterwards by the caller to | ||
3668 | communicate with ARM. Functions GNUNET_ARM_start_service() and | ||
3669 | GNUNET_ARM_stop_service() are used for starting and stopping services | ||
3670 | respectively. | ||
3671 | |||
3672 | @item A typical example of using these basic ARM services can be found in | ||
3673 | file test_arm_api.c. The test case connects to ARM, starts it, then uses | ||
3674 | it to start a service "resolver", stops the "resolver" then stops "ARM". | ||
3675 | @end itemize | ||
3676 | |||
3677 | @c *********************************************************************** | ||
3678 | @node Key configuration options | ||
3679 | @subsection Key configuration options | ||
3680 | @c %**end of header | ||
3681 | |||
3682 | Configurations for ARM and services should be available in a .conf file | ||
3683 | (As an example, see test_arm_api_data.conf). When running ARM, the | ||
3684 | configuration file to use should be passed to the command: | ||
3685 | |||
3686 | @example | ||
3687 | $ gnunet-arm -s -c configuration_to_use.conf | ||
3688 | @end example | ||
3689 | |||
3690 | If no configuration is passed, the default configuration file will be used | ||
3691 | (see GNUNET_PREFIX/share/gnunet/defaults.conf which is created from | ||
3692 | contrib/defaults.conf).@ Each of the services is having a section starting | ||
3693 | by the service name between square brackets, for example: "[arm]". | ||
3694 | The following options configure how ARM configures or interacts with the | ||
3695 | various services: | ||
3696 | |||
3697 | @table @asis | ||
3698 | |||
3699 | @item PORT Port number on which the service is listening for incoming TCP | ||
3700 | connections. ARM will start the services should it notice a request at | ||
3701 | this port. | ||
3702 | |||
3703 | @item HOSTNAME Specifies on which host the service is deployed. Note | ||
3704 | that ARM can only start services that are running on the local system | ||
3705 | (but will not check that the hostname matches the local machine name). | ||
3706 | This option is used by the @code{gnunet_client_lib.h} implementation to | ||
3707 | determine which system to connect to. The default is "localhost". | ||
3708 | |||
3709 | @item BINARY The name of the service binary file. | ||
3710 | |||
3711 | @item OPTIONS To be passed to the service. | ||
3712 | |||
3713 | @item PREFIX A command to pre-pend to the actual command, for example, | ||
3714 | running a service with "valgrind" or "gdb" | ||
3715 | |||
3716 | @item DEBUG Run in debug mode (much verbosity). | ||
3717 | |||
3718 | @item START_ON_DEMAND ARM will listen to UNIX domain socket and/or TCP port of | ||
3719 | the service and start the service on-demand. | ||
3720 | |||
3721 | @item IMMEDIATE_START ARM will always start this service when the peer | ||
3722 | is started. | ||
3723 | |||
3724 | @item ACCEPT_FROM IPv4 addresses the service accepts connections from. | ||
3725 | |||
3726 | @item ACCEPT_FROM6 IPv6 addresses the service accepts connections from. | ||
3727 | |||
3728 | @end table | ||
3729 | |||
3730 | |||
3731 | Options that impact the operation of ARM overall are in the "[arm]" | ||
3732 | section. ARM is a normal service and has (except for START_ON_DEMAND) all of the | ||
3733 | options that other services do. In addition, ARM has the | ||
3734 | following options: | ||
3735 | |||
3736 | @table @asis | ||
3737 | |||
3738 | @item GLOBAL_PREFIX Command to be pre-pended to all services that are | ||
3739 | going to run. | ||
3740 | |||
3741 | @item GLOBAL_POSTFIX Global option that will be supplied to all the | ||
3742 | services that are going to run. | ||
3743 | |||
3744 | @end table | ||
3745 | |||
3746 | @c *********************************************************************** | ||
3747 | @node ARM - Availability | ||
3748 | @subsection ARM - Availability | ||
3749 | @c %**end of header | ||
3750 | |||
3751 | As mentioned before, one of the features provided by ARM is starting | ||
3752 | services on demand. Consider the example of one service "client" that | ||
3753 | wants to connect to another service a "server". The "client" will ask ARM | ||
3754 | to run the "server". ARM starts the "server". The "server" starts | ||
3755 | listening to incoming connections. The "client" will establish a | ||
3756 | connection with the "server". And then, they will start to communicate | ||
3757 | together.@ One problem with that scheme is that it's slow!@ | ||
3758 | The "client" service wants to communicate with the "server" service at | ||
3759 | once and is not willing wait for it to be started and listening to | ||
3760 | incoming connections before serving its request.@ One solution for that | ||
3761 | problem will be that ARM starts all services as default services. That | ||
3762 | solution will solve the problem, yet, it's not quite practical, for some | ||
3763 | services that are going to be started can never be used or are going to | ||
3764 | be used after a relatively long time.@ | ||
3765 | The approach followed by ARM to solve this problem is as follows: | ||
3766 | |||
3767 | @itemize @bullet | ||
3768 | |||
3769 | @item For each service having a PORT field in the configuration file and | ||
3770 | that is not one of the default services ( a service that accepts incoming | ||
3771 | connections from clients), ARM creates listening sockets for all addresses | ||
3772 | associated with that service. | ||
3773 | |||
3774 | @item The "client" will immediately establish a connection with | ||
3775 | the "server". | ||
3776 | |||
3777 | @item ARM --- pretending to be the "server" --- will listen on the | ||
3778 | respective port and notice the incoming connection from the "client" | ||
3779 | (but not accept it), instead | ||
3780 | |||
3781 | @item Once there is an incoming connection, ARM will start the "server", | ||
3782 | passing on the listen sockets (now, the service is started and can do its | ||
3783 | work). | ||
3784 | |||
3785 | @item Other client services now can directly connect directly to the | ||
3786 | "server". | ||
3787 | |||
3788 | @end itemize | ||
3789 | |||
3790 | @c *********************************************************************** | ||
3791 | @node Reliability | ||
3792 | @subsection Reliability | ||
3793 | |||
3794 | One of the features provided by ARM, is the automatic restart of crashed | ||
3795 | services.@ ARM needs to know which of the running services died. Function | ||
3796 | "gnunet-service-arm.c/maint_child_death()" is responsible for that. The | ||
3797 | function is scheduled to run upon receiving a SIGCHLD signal. The | ||
3798 | function, then, iterates ARM's list of services running and monitors | ||
3799 | which service has died (crashed). For all crashing services, ARM restarts | ||
3800 | them.@ | ||
3801 | Now, considering the case of a service having a serious problem causing it | ||
3802 | to crash each time it's started by ARM. If ARM keeps blindly restarting | ||
3803 | such a service, we are going to have the pattern: | ||
3804 | start-crash-restart-crash-restart-crash and so forth!! Which is of course | ||
3805 | not practical.@ | ||
3806 | For that reason, ARM schedules the service to be restarted after waiting | ||
3807 | for some delay that grows exponentially with each crash/restart of that | ||
3808 | service.@ To clarify the idea, considering the following example: | ||
3809 | |||
3810 | @itemize @bullet | ||
3811 | |||
3812 | @item Service S crashed. | ||
3813 | |||
3814 | @item ARM receives the SIGCHLD and inspects its list of services to find | ||
3815 | the dead one(s). | ||
3816 | |||
3817 | @item ARM finds S dead and schedules it for restarting after "backoff" | ||
3818 | time which is initially set to 1ms. ARM will double the backoff time | ||
3819 | correspondent to S (now backoff(S) = 2ms) | ||
3820 | |||
3821 | @item Because there is a severe problem with S, it crashed again. | ||
3822 | |||
3823 | @item Again ARM receives the SIGCHLD and detects that it's S again that's | ||
3824 | crashed. ARM schedules it for restarting but after its new backoff time | ||
3825 | (which became 2ms), and doubles its backoff time (now backoff(S) = 4). | ||
3826 | |||
3827 | @item and so on, until backoff(S) reaches a certain threshold | ||
3828 | (@code{EXPONENTIAL_BACKOFF_THRESHOLD} is set to half an hour), | ||
3829 | after reaching it, backoff(S) will remain half an hour, | ||
3830 | hence ARM won't be busy for a lot of time trying to restart a | ||
3831 | problematic service. | ||
3832 | @end itemize | ||
3833 | |||
3834 | @cindex TRANSPORT Subsystem | ||
3835 | @node TRANSPORT Subsystem | ||
3836 | @section TRANSPORT Subsystem | ||
3837 | @c %**end of header | ||
3838 | |||
3839 | This chapter documents how the GNUnet transport subsystem works. The | ||
3840 | GNUnet transport subsystem consists of three main components: the | ||
3841 | transport API (the interface used by the rest of the system to access the | ||
3842 | transport service), the transport service itself (most of the interesting | ||
3843 | functions, such as choosing transports, happens here) and the transport | ||
3844 | plugins. A transport plugin is a concrete implementation for how two | ||
3845 | GNUnet peers communicate; many plugins exist, for example for | ||
3846 | communication via TCP, UDP, HTTP, HTTPS and others. Finally, the | ||
3847 | transport subsystem uses supporting code, especially the NAT/UPnP | ||
3848 | library to help with tasks such as NAT traversal. | ||
3849 | |||
3850 | Key tasks of the transport service include: | ||
3851 | |||
3852 | @itemize @bullet | ||
3853 | |||
3854 | @item Create our HELLO message, notify clients and neighbours if our HELLO | ||
3855 | changes (using NAT library as necessary) | ||
3856 | |||
3857 | @item Validate HELLOs from other peers (send PING), allow other peers to | ||
3858 | validate our HELLO's addresses (send PONG) | ||
3859 | |||
3860 | @item Upon request, establish connections to other peers (using address | ||
3861 | selection from ATS subsystem) and maintain them (again using PINGs and | ||
3862 | PONGs) as long as desired | ||
3863 | |||
3864 | @item Accept incoming connections, give ATS service the opportunity to | ||
3865 | switch communication channels | ||
3866 | |||
3867 | @item Notify clients about peers that have connected to us or that have | ||
3868 | been disconnected from us | ||
3869 | |||
3870 | @item If a (stateful) connection goes down unexpectedly (without explicit | ||
3871 | DISCONNECT), quickly attempt to recover (without notifying clients) but do | ||
3872 | notify clients quickly if reconnecting fails | ||
3873 | |||
3874 | @item Send (payload) messages arriving from clients to other peers via | ||
3875 | transport plugins and receive messages from other peers, forwarding | ||
3876 | those to clients | ||
3877 | |||
3878 | @item Enforce inbound traffic limits (using flow-control if it is | ||
3879 | applicable); outbound traffic limits are enforced by CORE, not by us (!) | ||
3880 | |||
3881 | @item Enforce restrictions on P2P connection as specified by the blacklist | ||
3882 | configuration and blacklisting clients | ||
3883 | @end itemize | ||
3884 | |||
3885 | Note that the term "clients" in the list above really refers to the | ||
3886 | GNUnet-CORE service, as CORE is typically the only client of the | ||
3887 | transport service. | ||
3888 | |||
3889 | @menu | ||
3890 | * Address validation protocol:: | ||
3891 | @end menu | ||
3892 | |||
3893 | @node Address validation protocol | ||
3894 | @subsection Address validation protocol | ||
3895 | @c %**end of header | ||
3896 | |||
3897 | This section documents how the GNUnet transport service validates | ||
3898 | connections with other peers. It is a high-level description of the | ||
3899 | protocol necessary to understand the details of the implementation. It | ||
3900 | should be noted that when we talk about PING and PONG messages in this | ||
3901 | section, we refer to transport-level PING and PONG messages, which are | ||
3902 | different from core-level PING and PONG messages (both in implementation | ||
3903 | and function). | ||
3904 | |||
3905 | The goal of transport-level address validation is to minimize the chances | ||
3906 | of a successful man-in-the-middle attack against GNUnet peers on the | ||
3907 | transport level. Such an attack would not allow the adversary to decrypt | ||
3908 | the P2P transmissions, but a successful attacker could at least measure | ||
3909 | traffic volumes and latencies (raising the adversaries capabilities by | ||
3910 | those of a global passive adversary in the worst case). The scenarios we | ||
3911 | are concerned about is an attacker, Mallory, giving a @code{HELLO} to | ||
3912 | Alice that claims to be for Bob, but contains Mallory's IP address | ||
3913 | instead of Bobs (for some transport). | ||
3914 | Mallory would then forward the traffic to Bob (by initiating a | ||
3915 | connection to Bob and claiming to be Alice). As a further | ||
3916 | complication, the scheme has to work even if say Alice is behind a NAT | ||
3917 | without traversal support and hence has no address of her own (and thus | ||
3918 | Alice must always initiate the connection to Bob). | ||
3919 | |||
3920 | An additional constraint is that @code{HELLO} messages do not contain a | ||
3921 | cryptographic signature since other peers must be able to edit | ||
3922 | (i.e. remove) addresses from the @code{HELLO} at any time (this was | ||
3923 | not true in GNUnet 0.8.x). A basic @strong{assumption} is that each peer | ||
3924 | knows the set of possible network addresses that it @strong{might} | ||
3925 | be reachable under (so for example, the external IP address of the | ||
3926 | NAT plus the LAN address(es) with the respective ports). | ||
3927 | |||
3928 | The solution is the following. If Alice wants to validate that a given | ||
3929 | address for Bob is valid (i.e. is actually established @strong{directly} | ||
3930 | with the intended target), she sends a PING message over that connection | ||
3931 | to Bob. Note that in this case, Alice initiated the connection so only | ||
3932 | Alice knows which address was used for sure (Alice may be behind NAT, so | ||
3933 | whatever address Bob sees may not be an address Alice knows she has). | ||
3934 | Bob checks that the address given in the @code{PING} is actually one | ||
3935 | of Bob's addresses (ie: does not belong to Mallory), and if it is, | ||
3936 | sends back a @code{PONG} (with a signature that says that Bob | ||
3937 | owns/uses the address from the @code{PING}). | ||
3938 | Alice checks the signature and is happy if it is valid and the address | ||
3939 | in the @code{PONG} is the address Alice used. | ||
3940 | This is similar to the 0.8.x protocol where the @code{HELLO} contained a | ||
3941 | signature from Bob for each address used by Bob. | ||
3942 | Here, the purpose code for the signature is | ||
3943 | @code{GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN}. After this, Alice will | ||
3944 | remember Bob's address and consider the address valid for a while (12h in | ||
3945 | the current implementation). Note that after this exchange, Alice only | ||
3946 | considers Bob's address to be valid, the connection itself is not | ||
3947 | considered 'established'. In particular, Alice may have many addresses | ||
3948 | for Bob that Alice considers valid. | ||
3949 | |||
3950 | The @code{PONG} message is protected with a nonce/challenge against replay | ||
3951 | attacks (@uref{http://en.wikipedia.org/wiki/Replay_attack, replay}) | ||
3952 | and uses an expiration time for the signature (but those are almost | ||
3953 | implementation details). | ||
3954 | |||
3955 | @cindex NAT library | ||
3956 | @node NAT library | ||
3957 | @section NAT library | ||
3958 | @c %**end of header | ||
3959 | |||
3960 | The goal of the GNUnet NAT library is to provide a general-purpose API for | ||
3961 | NAT traversal @strong{without} third-party support. So protocols that | ||
3962 | involve contacting a third peer to help establish a connection between | ||
3963 | two peers are outside of the scope of this API. That does not mean that | ||
3964 | GNUnet doesn't support involving a third peer (we can do this with the | ||
3965 | distance-vector transport or using application-level protocols), it just | ||
3966 | means that the NAT API is not concerned with this possibility. The API is | ||
3967 | written so that it will work for IPv6-NAT in the future as well as | ||
3968 | current IPv4-NAT. Furthermore, the NAT API is always used, even for peers | ||
3969 | that are not behind NAT --- in that case, the mapping provided is simply | ||
3970 | the identity. | ||
3971 | |||
3972 | NAT traversal is initiated by calling @code{GNUNET_NAT_register}. Given a | ||
3973 | set of addresses that the peer has locally bound to (TCP or UDP), the NAT | ||
3974 | library will return (via callback) a (possibly longer) list of addresses | ||
3975 | the peer @strong{might} be reachable under. Internally, depending on the | ||
3976 | configuration, the NAT library will try to punch a hole (using UPnP) or | ||
3977 | just "know" that the NAT was manually punched and generate the respective | ||
3978 | external IP address (the one that should be globally visible) based on | ||
3979 | the given information. | ||
3980 | |||
3981 | The NAT library also supports ICMP-based NAT traversal. Here, the other | ||
3982 | peer can request connection-reversal by this peer (in this special case, | ||
3983 | the peer is even allowed to configure a port number of zero). If the NAT | ||
3984 | library detects a connection-reversal request, it returns the respective | ||
3985 | target address to the client as well. It should be noted that | ||
3986 | connection-reversal is currently only intended for TCP, so other plugins | ||
3987 | @strong{must} pass @code{NULL} for the reversal callback. Naturally, the | ||
3988 | NAT library also supports requesting connection reversal from a remote | ||
3989 | peer (@code{GNUNET_NAT_run_client}). | ||
3990 | |||
3991 | Once initialized, the NAT handle can be used to test if a given address is | ||
3992 | possibly a valid address for this peer (@code{GNUNET_NAT_test_address}). | ||
3993 | This is used for validating our addresses when generating PONGs. | ||
3994 | |||
3995 | Finally, the NAT library contains an API to test if our NAT configuration | ||
3996 | is correct. Using @code{GNUNET_NAT_test_start} @strong{before} binding to | ||
3997 | the respective port, the NAT library can be used to test if the | ||
3998 | configuration works. The test function act as a local client, initialize | ||
3999 | the NAT traversal and then contact a @code{gnunet-nat-server} (running by | ||
4000 | default on @code{gnunet.org}) and ask for a connection to be established. | ||
4001 | This way, it is easy to test if the current NAT configuration is valid. | ||
4002 | |||
4003 | @node Distance-Vector plugin | ||
4004 | @section Distance-Vector plugin | ||
4005 | @c %**end of header | ||
4006 | |||
4007 | The Distance Vector (DV) transport is a transport mechanism that allows | ||
4008 | peers to act as relays for each other, thereby connecting peers that would | ||
4009 | otherwise be unable to connect. This gives a larger connection set to | ||
4010 | applications that may work better with more peers to choose from (for | ||
4011 | example, File Sharing and/or DHT). | ||
4012 | |||
4013 | The Distance Vector transport essentially has two functions. The first is | ||
4014 | "gossiping" connection information about more distant peers to directly | ||
4015 | connected peers. The second is taking messages intended for non-directly | ||
4016 | connected peers and encapsulating them in a DV wrapper that contains the | ||
4017 | required information for routing the message through forwarding peers. Via | ||
4018 | gossiping, optimal routes through the known DV neighborhood are discovered | ||
4019 | and utilized and the message encapsulation provides some benefits in | ||
4020 | addition to simply getting the message from the correct source to the | ||
4021 | proper destination. | ||
4022 | |||
4023 | The gossiping function of DV provides an up to date routing table of | ||
4024 | peers that are available up to some number of hops. We call this a | ||
4025 | fisheye view of the network (like a fish, nearby objects are known while | ||
4026 | more distant ones unknown). Gossip messages are sent only to directly | ||
4027 | connected peers, but they are sent about other knowns peers within the | ||
4028 | "fisheye distance". Whenever two peers connect, they immediately gossip | ||
4029 | to each other about their appropriate other neighbors. They also gossip | ||
4030 | about the newly connected peer to previously | ||
4031 | connected neighbors. In order to keep the routing tables up to date, | ||
4032 | disconnect notifications are propagated as gossip as well (because | ||
4033 | disconnects may not be sent/received, timeouts are also used remove | ||
4034 | stagnant routing table entries). | ||
4035 | |||
4036 | Routing of messages via DV is straightforward. When the DV transport is | ||
4037 | notified of a message destined for a non-direct neighbor, the appropriate | ||
4038 | forwarding peer is selected, and the base message is encapsulated in a DV | ||
4039 | message which contains information about the initial peer and the intended | ||
4040 | recipient. At each forwarding hop, the initial peer is validated (the | ||
4041 | forwarding peer ensures that it has the initial peer in its neighborhood, | ||
4042 | otherwise the message is dropped). Next the base message is | ||
4043 | re-encapsulated in a new DV message for the next hop in the forwarding | ||
4044 | chain (or delivered to the current peer, if it has arrived at the | ||
4045 | destination). | ||
4046 | |||
4047 | Assume a three peer network with peers Alice, Bob and Carol. Assume that | ||
4048 | |||
4049 | @example | ||
4050 | Alice <-> Bob and Bob <-> Carol | ||
4051 | @end example | ||
4052 | |||
4053 | @noindent | ||
4054 | are direct (e.g. over TCP or UDP transports) connections, but that | ||
4055 | Alice cannot directly connect to Carol. | ||
4056 | This may be the case due to NAT or firewall restrictions, or perhaps | ||
4057 | based on one of the peers respective configurations. If the Distance | ||
4058 | Vector transport is enabled on all three peers, it will automatically | ||
4059 | discover (from the gossip protocol) that Alice and Carol can connect via | ||
4060 | Bob and provide a "virtual" Alice <-> Carol connection. Routing between | ||
4061 | Alice and Carol happens as follows; Alice creates a message destined for | ||
4062 | Carol and notifies the DV transport about it. The DV transport at Alice | ||
4063 | looks up Carol in the routing table and finds that the message must be | ||
4064 | sent through Bob for Carol. The message is encapsulated setting Alice as | ||
4065 | the initiator and Carol as the destination and sent to Bob. Bob receives | ||
4066 | the messages, verifies that both Alice and Carol are known to Bob, and | ||
4067 | re-wraps the message in a new DV message for Carol. | ||
4068 | The DV transport at Carol receives this message, unwraps the original | ||
4069 | message, and delivers it to Carol as though it came directly from Alice. | ||
4070 | |||
4071 | @cindex SMTP plugin | ||
4072 | @node SMTP plugin | ||
4073 | @section SMTP plugin | ||
4074 | @c %**end of header | ||
4075 | |||
4076 | This section describes the new SMTP transport plugin for GNUnet as it | ||
4077 | exists in the 0.7.x and 0.8.x branch. SMTP support is currently not | ||
4078 | available in GNUnet 0.9.x. This page also describes the transport layer | ||
4079 | abstraction (as it existed in 0.7.x and 0.8.x) in more detail and gives | ||
4080 | some benchmarking results. The performance results presented are quite | ||
4081 | old and maybe outdated at this point. | ||
4082 | |||
4083 | @itemize @bullet | ||
4084 | @item Why use SMTP for a peer-to-peer transport? | ||
4085 | @item SMTPHow does it work? | ||
4086 | @item How do I configure my peer? | ||
4087 | @item How do I test if it works? | ||
4088 | @item How fast is it? | ||
4089 | @item Is there any additional documentation? | ||
4090 | @end itemize | ||
4091 | |||
4092 | |||
4093 | @menu | ||
4094 | * Why use SMTP for a peer-to-peer transport?:: | ||
4095 | * How does it work?:: | ||
4096 | * How do I configure my peer?:: | ||
4097 | * How do I test if it works?:: | ||
4098 | * How fast is it?:: | ||
4099 | @end menu | ||
4100 | |||
4101 | @node Why use SMTP for a peer-to-peer transport? | ||
4102 | @subsection Why use SMTP for a peer-to-peer transport? | ||
4103 | @c %**end of header | ||
4104 | |||
4105 | There are many reasons why one would not want to use SMTP: | ||
4106 | |||
4107 | @itemize @bullet | ||
4108 | @item SMTP is using more bandwidth than TCP, UDP or HTTP | ||
4109 | @item SMTP has a much higher latency. | ||
4110 | @item SMTP requires significantly more computation (encoding and decoding | ||
4111 | time) for the peers. | ||
4112 | @item SMTP is significantly more complicated to configure. | ||
4113 | @item SMTP may be abused by tricking GNUnet into sending mail to@ | ||
4114 | non-participating third parties. | ||
4115 | @end itemize | ||
4116 | |||
4117 | So why would anybody want to use SMTP? | ||
4118 | @itemize @bullet | ||
4119 | @item SMTP can be used to contact peers behind NAT boxes (in virtual | ||
4120 | private networks). | ||
4121 | @item SMTP can be used to circumvent policies that limit or prohibit | ||
4122 | peer-to-peer traffic by masking as "legitimate" traffic. | ||
4123 | @item SMTP uses E-mail addresses which are independent of a specific IP, | ||
4124 | which can be useful to address peers that use dynamic IP addresses. | ||
4125 | @item SMTP can be used to initiate a connection (e.g. initial address | ||
4126 | exchange) and peers can then negotiate the use of a more efficient | ||
4127 | protocol (e.g. TCP) for the actual communication. | ||
4128 | @end itemize | ||
4129 | |||
4130 | In summary, SMTP can for example be used to send a message to a peer | ||
4131 | behind a NAT box that has a dynamic IP to tell the peer to establish a | ||
4132 | TCP connection to a peer outside of the private network. Even an | ||
4133 | extraordinary overhead for this first message would be irrelevant in this | ||
4134 | type of situation. | ||
4135 | |||
4136 | @node How does it work? | ||
4137 | @subsection How does it work? | ||
4138 | @c %**end of header | ||
4139 | |||
4140 | When a GNUnet peer needs to send a message to another GNUnet peer that has | ||
4141 | advertised (only) an SMTP transport address, GNUnet base64-encodes the | ||
4142 | message and sends it in an E-mail to the advertised address. The | ||
4143 | advertisement contains a filter which is placed in the E-mail header, | ||
4144 | such that the receiving host can filter the tagged E-mails and forward it | ||
4145 | to the GNUnet peer process. The filter can be specified individually by | ||
4146 | each peer and be changed over time. This makes it impossible to censor | ||
4147 | GNUnet E-mail messages by searching for a generic filter. | ||
4148 | |||
4149 | @node How do I configure my peer? | ||
4150 | @subsection How do I configure my peer? | ||
4151 | @c %**end of header | ||
4152 | |||
4153 | First, you need to configure @code{procmail} to filter your inbound E-mail | ||
4154 | for GNUnet traffic. The GNUnet messages must be delivered into a pipe, for | ||
4155 | example @code{/tmp/gnunet.smtp}. You also need to define a filter that is | ||
4156 | used by @command{procmail} to detect GNUnet messages. You are free to | ||
4157 | choose whichever filter you like, but you should make sure that it does | ||
4158 | not occur in your other E-mail. In our example, we will use | ||
4159 | @code{X-mailer: GNUnet}. The @code{~/.procmailrc} configuration file then | ||
4160 | looks like this: | ||
4161 | |||
4162 | @example | ||
4163 | :0: | ||
4164 | * ^X-mailer: GNUnet | ||
4165 | /tmp/gnunet.smtp | ||
4166 | # where do you want your other e-mail delivered to | ||
4167 | # (default: /var/spool/mail/) | ||
4168 | :0: /var/spool/mail/ | ||
4169 | @end example | ||
4170 | |||
4171 | After adding this file, first make sure that your regular E-mail still | ||
4172 | works (e.g. by sending an E-mail to yourself). Then edit the GNUnet | ||
4173 | configuration. In the section @code{SMTP} you need to specify your E-mail | ||
4174 | address under @code{EMAIL}, your mail server (for outgoing mail) under | ||
4175 | @code{SERVER}, the filter (X-mailer: GNUnet in the example) under | ||
4176 | @code{FILTER} and the name of the pipe under @code{PIPE}.@ The completed | ||
4177 | section could then look like this: | ||
4178 | |||
4179 | @example | ||
4180 | EMAIL = me@@mail.gnu.org MTU = 65000 SERVER = mail.gnu.org:25 FILTER = | ||
4181 | "X-mailer: GNUnet" PIPE = /tmp/gnunet.smtp | ||
4182 | @end example | ||
4183 | |||
4184 | Finally, you need to add @code{smtp} to the list of @code{TRANSPORTS} in | ||
4185 | the @code{GNUNETD} section. GNUnet peers will use the E-mail address that | ||
4186 | you specified to contact your peer until the advertisement times out. | ||
4187 | Thus, if you are not sure if everything works properly or if you are not | ||
4188 | planning to be online for a long time, you may want to configure this | ||
4189 | timeout to be short, e.g. just one hour. For this, set | ||
4190 | @code{HELLOEXPIRES} to @code{1} in the @code{GNUNETD} section. | ||
4191 | |||
4192 | This should be it, but you may probably want to test it first. | ||
4193 | |||
4194 | @node How do I test if it works? | ||
4195 | @subsection How do I test if it works? | ||
4196 | @c %**end of header | ||
4197 | |||
4198 | Any transport can be subjected to some rudimentary tests using the | ||
4199 | @code{gnunet-transport-check} tool. The tool sends a message to the local | ||
4200 | node via the transport and checks that a valid message is received. While | ||
4201 | this test does not involve other peers and can not check if firewalls or | ||
4202 | other network obstacles prohibit proper operation, this is a great | ||
4203 | testcase for the SMTP transport since it tests pretty much nearly all of | ||
4204 | the functionality. | ||
4205 | |||
4206 | @code{gnunet-transport-check} should only be used without running | ||
4207 | @code{gnunetd} at the same time. By default, @code{gnunet-transport-check} | ||
4208 | tests all transports that are specified in the configuration file. But | ||
4209 | you can specifically test SMTP by giving the option | ||
4210 | @code{--transport=smtp}. | ||
4211 | |||
4212 | Note that this test always checks if a transport can receive and send. | ||
4213 | While you can configure most transports to only receive or only send | ||
4214 | messages, this test will only work if you have configured the transport | ||
4215 | to send and receive messages. | ||
4216 | |||
4217 | @node How fast is it? | ||
4218 | @subsection How fast is it? | ||
4219 | @c %**end of header | ||
4220 | |||
4221 | We have measured the performance of the UDP, TCP and SMTP transport layer | ||
4222 | directly and when used from an application using the GNUnet core. | ||
4223 | Measuring just the transport layer gives the better view of the actual | ||
4224 | overhead of the protocol, whereas evaluating the transport from the | ||
4225 | application puts the overhead into perspective from a practical point of | ||
4226 | view. | ||
4227 | |||
4228 | The loopback measurements of the SMTP transport were performed on three | ||
4229 | different machines spanning a range of modern SMTP configurations. We | ||
4230 | used a PIII-800 running RedHat 7.3 with the Purdue Computer Science | ||
4231 | configuration which includes filters for spam. We also used a Xenon 2 GHZ | ||
4232 | with a vanilla RedHat 8.0 sendmail configuration. Furthermore, we used | ||
4233 | qmail on a PIII-1000 running Sorcerer GNU Linux (SGL). The numbers for | ||
4234 | UDP and TCP are provided using the SGL configuration. The qmail benchmark | ||
4235 | uses qmail's internal filtering whereas the sendmail benchmarks relies on | ||
4236 | procmail to filter and deliver the mail. We used the transport layer to | ||
4237 | send a message of b bytes (excluding transport protocol headers) directly | ||
4238 | to the local machine. This way, network latency and packet loss on the | ||
4239 | wire have no impact on the timings. n messages were sent sequentially over | ||
4240 | the transport layer, sending message i+1 after the i-th message was | ||
4241 | received. All messages were sent over the same connection and the time to | ||
4242 | establish the connection was not taken into account since this overhead is | ||
4243 | minuscule in practice --- as long as a connection is used for a | ||
4244 | significant number of messages. | ||
4245 | |||
4246 | @multitable @columnfractions .20 .15 .15 .15 .15 .15 | ||
4247 | @headitem Transport @tab UDP @tab TCP @tab SMTP (Purdue sendmail) | ||
4248 | @tab SMTP (RH 8.0) @tab SMTP (SGL qmail) | ||
4249 | @item 11 bytes @tab 31 ms @tab 55 ms @tab 781 s @tab 77 s @tab 24 s | ||
4250 | @item 407 bytes @tab 37 ms @tab 62 ms @tab 789 s @tab 78 s @tab 25 s | ||
4251 | @item 1,221 bytes @tab 46 ms @tab 73 ms @tab 804 s @tab 78 s @tab 25 s | ||
4252 | @end multitable | ||
4253 | |||
4254 | The benchmarks show that UDP and TCP are, as expected, both significantly | ||
4255 | faster compared with any of the SMTP services. Among the SMTP | ||
4256 | implementations, there can be significant differences depending on the | ||
4257 | SMTP configuration. Filtering with an external tool like procmail that | ||
4258 | needs to re-parse its configuration for each mail can be very expensive. | ||
4259 | Applying spam filters can also significantly impact the performance of | ||
4260 | the underlying SMTP implementation. The microbenchmark shows that SMTP | ||
4261 | can be a viable solution for initiating peer-to-peer sessions: a couple of | ||
4262 | seconds to connect to a peer are probably not even going to be noticed by | ||
4263 | users. The next benchmark measures the possible throughput for a | ||
4264 | transport. Throughput can be measured by sending multiple messages in | ||
4265 | parallel and measuring packet loss. Note that not only UDP but also the | ||
4266 | TCP transport can actually loose messages since the TCP implementation | ||
4267 | drops messages if the @code{write} to the socket would block. While the | ||
4268 | SMTP protocol never drops messages itself, it is often so | ||
4269 | slow that only a fraction of the messages can be sent and received in the | ||
4270 | given time-bounds. For this benchmark we report the message loss after | ||
4271 | allowing t time for sending m messages. If messages were not sent (or | ||
4272 | received) after an overall timeout of t, they were considered lost. The | ||
4273 | benchmark was performed using two Xeon 2 GHZ machines running RedHat 8.0 | ||
4274 | with sendmail. The machines were connected with a direct 100 MBit Ethernet | ||
4275 | connection.@ Figures udp1200, tcp1200 and smtp-MTUs show that the | ||
4276 | throughput for messages of size 1,200 octets is 2,343 kbps, 3,310 kbps | ||
4277 | and 6 kbps for UDP, TCP and SMTP respectively. The high per-message | ||
4278 | overhead of SMTP can be improved by increasing the MTU, for example, an | ||
4279 | MTU of 12,000 octets improves the throughput to 13 kbps as figure | ||
4280 | smtp-MTUs shows. Our research paper) has some more details on the | ||
4281 | benchmarking results. | ||
4282 | |||
4283 | @cindex Bluetooth plugin | ||
4284 | @node Bluetooth plugin | ||
4285 | @section Bluetooth plugin | ||
4286 | @c %**end of header | ||
4287 | |||
4288 | This page describes the new Bluetooth transport plugin for GNUnet. The | ||
4289 | plugin is still in the testing stage so don't expect it to work | ||
4290 | perfectly. If you have any questions or problems just post them here or | ||
4291 | ask on the IRC channel. | ||
4292 | |||
4293 | @itemize @bullet | ||
4294 | @item What do I need to use the Bluetooth plugin transport? | ||
4295 | @item BluetoothHow does it work? | ||
4296 | @item What possible errors should I be aware of? | ||
4297 | @item How do I configure my peer? | ||
4298 | @item How can I test it? | ||
4299 | @end itemize | ||
4300 | |||
4301 | @menu | ||
4302 | * What do I need to use the Bluetooth plugin transport?:: | ||
4303 | * How does it work2?:: | ||
4304 | * What possible errors should I be aware of?:: | ||
4305 | * How do I configure my peer2?:: | ||
4306 | * How can I test it?:: | ||
4307 | * The implementation of the Bluetooth transport plugin:: | ||
4308 | @end menu | ||
4309 | |||
4310 | @node What do I need to use the Bluetooth plugin transport? | ||
4311 | @subsection What do I need to use the Bluetooth plugin transport? | ||
4312 | @c %**end of header | ||
4313 | |||
4314 | If you are a GNU/Linux user and you want to use the Bluetooth | ||
4315 | transport plugin you should install the | ||
4316 | @command{BlueZ development libraries} (if they aren't already | ||
4317 | installed). | ||
4318 | For instructions about how to install the libraries you should | ||
4319 | check out the BlueZ site | ||
4320 | (@uref{http://www.bluez.org/, http://www.bluez.org}). If you don't know if | ||
4321 | you have the necessary libraries, don't worry, just run the GNUnet | ||
4322 | configure script and you will be able to see a notification at the end | ||
4323 | which will warn you if you don't have the necessary libraries. | ||
4324 | |||
4325 | If you are a Windows user you should have installed the | ||
4326 | @emph{MinGW}/@emph{MSys2} with the latest updates (especially the | ||
4327 | @emph{ws2bth} header). If this is your first build of GNUnet on Windows | ||
4328 | you should check out the SBuild repository. It will semi-automatically | ||
4329 | assembles a @emph{MinGW}/@emph{MSys2} installation with a lot of extra | ||
4330 | packages which are needed for the GNUnet build. So this will ease your | ||
4331 | work!@ Finally you just have to be sure that you have the correct drivers | ||
4332 | for your Bluetooth device installed and that your device is on and in a | ||
4333 | discoverable mode. The Windows Bluetooth Stack supports only the RFCOMM | ||
4334 | protocol so we cannot turn on your device programatically! | ||
4335 | |||
4336 | @c FIXME: Change to unique title | ||
4337 | @node How does it work2? | ||
4338 | @subsection How does it work2? | ||
4339 | @c %**end of header | ||
4340 | |||
4341 | The Bluetooth transport plugin uses virtually the same code as the WLAN | ||
4342 | plugin and only the helper binary is different. The helper takes a single | ||
4343 | argument, which represents the interface name and is specified in the | ||
4344 | configuration file. Here are the basic steps that are followed by the | ||
4345 | helper binary used on GNU/Linux: | ||
4346 | |||
4347 | @itemize @bullet | ||
4348 | @item it verifies if the name corresponds to a Bluetooth interface name | ||
4349 | @item it verifies if the interface is up (if it is not, it tries to bring | ||
4350 | it up) | ||
4351 | @item it tries to enable the page and inquiry scan in order to make the | ||
4352 | device discoverable and to accept incoming connection requests | ||
4353 | @emph{The above operations require root access so you should start the | ||
4354 | transport plugin with root privileges.} | ||
4355 | @item it finds an available port number and registers a SDP service which | ||
4356 | will be used to find out on which port number is the server listening on | ||
4357 | and switch the socket in listening mode | ||
4358 | @item it sends a HELLO message with its address | ||
4359 | @item finally it forwards traffic from the reading sockets to the STDOUT | ||
4360 | and from the STDIN to the writing socket | ||
4361 | @end itemize | ||
4362 | |||
4363 | Once in a while the device will make an inquiry scan to discover the | ||
4364 | nearby devices and it will send them randomly HELLO messages for peer | ||
4365 | discovery. | ||
4366 | |||
4367 | @node What possible errors should I be aware of? | ||
4368 | @subsection What possible errors should I be aware of? | ||
4369 | @c %**end of header | ||
4370 | |||
4371 | @emph{This section is dedicated for GNU/Linux users} | ||
4372 | |||
4373 | Well there are many ways in which things could go wrong but I will try to | ||
4374 | present some tools that you could use to debug and some scenarios. | ||
4375 | |||
4376 | @itemize @bullet | ||
4377 | |||
4378 | @item @code{bluetoothd -n -d} : use this command to enable logging in the | ||
4379 | foreground and to print the logging messages | ||
4380 | |||
4381 | @item @code{hciconfig}: can be used to configure the Bluetooth devices. | ||
4382 | If you run it without any arguments it will print information about the | ||
4383 | state of the interfaces. So if you receive an error that the device | ||
4384 | couldn't be brought up you should try to bring it manually and to see if | ||
4385 | it works (use @code{hciconfig -a hciX up}). If you can't and the | ||
4386 | Bluetooth address has the form 00:00:00:00:00:00 it means that there is | ||
4387 | something wrong with the D-Bus daemon or with the Bluetooth daemon. Use | ||
4388 | @code{bluetoothd} tool to see the logs | ||
4389 | |||
4390 | @item @code{sdptool} can be used to control and interrogate SDP servers. | ||
4391 | If you encounter problems regarding the SDP server (like the SDP server is | ||
4392 | down) you should check out if the D-Bus daemon is running correctly and to | ||
4393 | see if the Bluetooth daemon started correctly(use @code{bluetoothd} tool). | ||
4394 | Also, sometimes the SDP service could work but somehow the device couldn't | ||
4395 | register its service. Use @code{sdptool browse [dev-address]} to see if | ||
4396 | the service is registered. There should be a service with the name of the | ||
4397 | interface and GNUnet as provider. | ||
4398 | |||
4399 | @item @code{hcitool} : another useful tool which can be used to configure | ||
4400 | the device and to send some particular commands to it. | ||
4401 | |||
4402 | @item @code{hcidump} : could be used for low level debugging | ||
4403 | @end itemize | ||
4404 | |||
4405 | @c FIXME: A more unique name | ||
4406 | @node How do I configure my peer2? | ||
4407 | @subsection How do I configure my peer2? | ||
4408 | @c %**end of header | ||
4409 | |||
4410 | On GNU/Linux, you just have to be sure that the interface name | ||
4411 | corresponds to the one that you want to use. | ||
4412 | Use the @code{hciconfig} tool to check that. | ||
4413 | By default it is set to hci0 but you can change it. | ||
4414 | |||
4415 | A basic configuration looks like this: | ||
4416 | |||
4417 | @example | ||
4418 | [transport-bluetooth] | ||
4419 | # Name of the interface (typically hciX) | ||
4420 | INTERFACE = hci0 | ||
4421 | # Real hardware, no testing | ||
4422 | TESTMODE = 0 TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
4423 | @end example | ||
4424 | |||
4425 | In order to use the Bluetooth transport plugin when the transport service | ||
4426 | is started, you must add the plugin name to the default transport service | ||
4427 | plugins list. For example: | ||
4428 | |||
4429 | @example | ||
4430 | [transport] ... PLUGINS = dns bluetooth ... | ||
4431 | @end example | ||
4432 | |||
4433 | If you want to use only the Bluetooth plugin set | ||
4434 | @emph{PLUGINS = bluetooth} | ||
4435 | |||
4436 | On Windows, you cannot specify which device to use. The only thing that | ||
4437 | you should do is to add @emph{bluetooth} on the plugins list of the | ||
4438 | transport service. | ||
4439 | |||
4440 | @node How can I test it? | ||
4441 | @subsection How can I test it? | ||
4442 | @c %**end of header | ||
4443 | |||
4444 | If you have two Bluetooth devices on the same machine and you are using | ||
4445 | GNU/Linux you must: | ||
4446 | |||
4447 | @itemize @bullet | ||
4448 | |||
4449 | @item create two different file configuration (one which will use the | ||
4450 | first interface (@emph{hci0}) and the other which will use the second | ||
4451 | interface (@emph{hci1})). Let's name them @emph{peer1.conf} and | ||
4452 | @emph{peer2.conf}. | ||
4453 | |||
4454 | @item run @emph{gnunet-peerinfo -c peerX.conf -s} in order to generate the | ||
4455 | peers private keys. The @strong{X} must be replace with 1 or 2. | ||
4456 | |||
4457 | @item run @emph{gnunet-arm -c peerX.conf -s -i=transport} in order to | ||
4458 | start the transport service. (Make sure that you have "bluetooth" on the | ||
4459 | transport plugins list if the Bluetooth transport service doesn't start.) | ||
4460 | |||
4461 | @item run @emph{gnunet-peerinfo -c peer1.conf -s} to get the first peer's | ||
4462 | ID. If you already know your peer ID (you saved it from the first | ||
4463 | command), this can be skipped. | ||
4464 | |||
4465 | @item run @emph{gnunet-transport -c peer2.conf -p=PEER1_ID -s} to start | ||
4466 | sending data for benchmarking to the other peer. | ||
4467 | |||
4468 | @end itemize | ||
4469 | |||
4470 | |||
4471 | This scenario will try to connect the second peer to the first one and | ||
4472 | then start sending data for benchmarking. | ||
4473 | |||
4474 | On Windows you cannot test the plugin functionality using two Bluetooth | ||
4475 | devices from the same machine because after you install the drivers there | ||
4476 | will occur some conflicts between the Bluetooth stacks. (At least that is | ||
4477 | what happened on my machine : I wasn't able to use the Bluesoleil stack and | ||
4478 | the WINDCOMM one in the same time). | ||
4479 | |||
4480 | If you have two different machines and your configuration files are good | ||
4481 | you can use the same scenario presented on the beginning of this section. | ||
4482 | |||
4483 | Another way to test the plugin functionality is to create your own | ||
4484 | application which will use the GNUnet framework with the Bluetooth | ||
4485 | transport service. | ||
4486 | |||
4487 | @node The implementation of the Bluetooth transport plugin | ||
4488 | @subsection The implementation of the Bluetooth transport plugin | ||
4489 | @c %**end of header | ||
4490 | |||
4491 | This page describes the implementation of the Bluetooth transport plugin. | ||
4492 | |||
4493 | First I want to remind you that the Bluetooth transport plugin uses | ||
4494 | virtually the same code as the WLAN plugin and only the helper binary is | ||
4495 | different. Also the scope of the helper binary from the Bluetooth | ||
4496 | transport plugin is the same as the one used for the WLAN transport | ||
4497 | plugin: it accesses the interface and then it forwards traffic in both | ||
4498 | directions between the Bluetooth interface and stdin/stdout of the | ||
4499 | process involved. | ||
4500 | |||
4501 | The Bluetooth plugin transport could be used both on GNU/Linux and Windows | ||
4502 | platforms. | ||
4503 | |||
4504 | @itemize @bullet | ||
4505 | @item Linux functionality | ||
4506 | @item Windows functionality | ||
4507 | @item Pending Features | ||
4508 | @end itemize | ||
4509 | |||
4510 | |||
4511 | |||
4512 | @menu | ||
4513 | * Linux functionality:: | ||
4514 | * THE INITIALIZATION:: | ||
4515 | * THE LOOP:: | ||
4516 | * Details about the broadcast implementation:: | ||
4517 | * Windows functionality:: | ||
4518 | * Pending features:: | ||
4519 | @end menu | ||
4520 | |||
4521 | @node Linux functionality | ||
4522 | @subsubsection Linux functionality | ||
4523 | @c %**end of header | ||
4524 | |||
4525 | In order to implement the plugin functionality on GNU/Linux I | ||
4526 | used the BlueZ stack. | ||
4527 | For the communication with the other devices I used the RFCOMM | ||
4528 | protocol. Also I used the HCI protocol to gain some control over the | ||
4529 | device. The helper binary takes a single argument (the name of the | ||
4530 | Bluetooth interface) and is separated in two stages: | ||
4531 | |||
4532 | @c %** 'THE INITIALIZATION' should be in bigger letters or stand out, not | ||
4533 | @c %** starting a new section? | ||
4534 | @node THE INITIALIZATION | ||
4535 | @subsubsection THE INITIALIZATION | ||
4536 | |||
4537 | @itemize @bullet | ||
4538 | @item first, it checks if we have root privileges | ||
4539 | (@emph{Remember that we need to have root privileges in order to be able | ||
4540 | to bring the interface up if it is down or to change its state.}). | ||
4541 | |||
4542 | @item second, it verifies if the interface with the given name exists. | ||
4543 | |||
4544 | @strong{If the interface with that name exists and it is a Bluetooth | ||
4545 | interface:} | ||
4546 | |||
4547 | @item it creates a RFCOMM socket which will be used for listening and call | ||
4548 | the @emph{open_device} method | ||
4549 | |||
4550 | On the @emph{open_device} method: | ||
4551 | @itemize @bullet | ||
4552 | @item creates a HCI socket used to send control events to the the device | ||
4553 | @item searches for the device ID using the interface name | ||
4554 | @item saves the device MAC address | ||
4555 | @item checks if the interface is down and tries to bring it UP | ||
4556 | @item checks if the interface is in discoverable mode and tries to make it | ||
4557 | discoverable | ||
4558 | @item closes the HCI socket and binds the RFCOMM one | ||
4559 | @item switches the RFCOMM socket in listening mode | ||
4560 | @item registers the SDP service (the service will be used by the other | ||
4561 | devices to get the port on which this device is listening on) | ||
4562 | @end itemize | ||
4563 | |||
4564 | @item drops the root privileges | ||
4565 | |||
4566 | @strong{If the interface is not a Bluetooth interface the helper exits | ||
4567 | with a suitable error} | ||
4568 | @end itemize | ||
4569 | |||
4570 | @c %** Same as for @node entry above | ||
4571 | @node THE LOOP | ||
4572 | @subsubsection THE LOOP | ||
4573 | |||
4574 | The helper binary uses a list where it saves all the connected neighbour | ||
4575 | devices (@emph{neighbours.devices}) and two buffers (@emph{write_pout} and | ||
4576 | @emph{write_std}). The first message which is send is a control message | ||
4577 | with the device's MAC address in order to announce the peer presence to | ||
4578 | the neighbours. Here are a short description of what happens in the main | ||
4579 | loop: | ||
4580 | |||
4581 | @itemize @bullet | ||
4582 | @item Every time when it receives something from the STDIN it processes | ||
4583 | the data and saves the message in the first buffer (@emph{write_pout}). | ||
4584 | When it has something in the buffer, it gets the destination address from | ||
4585 | the buffer, searches the destination address in the list (if there is no | ||
4586 | connection with that device, it creates a new one and saves it to the | ||
4587 | list) and sends the message. | ||
4588 | @item Every time when it receives something on the listening socket it | ||
4589 | accepts the connection and saves the socket on a list with the reading | ||
4590 | sockets. @item Every time when it receives something from a reading | ||
4591 | socket it parses the message, verifies the CRC and saves it in the | ||
4592 | @emph{write_std} buffer in order to be sent later to the STDOUT. | ||
4593 | @end itemize | ||
4594 | |||
4595 | So in the main loop we use the select function to wait until one of the | ||
4596 | file descriptor saved in one of the two file descriptors sets used is | ||
4597 | ready to use. The first set (@emph{rfds}) represents the reading set and | ||
4598 | it could contain the list with the reading sockets, the STDIN file | ||
4599 | descriptor or the listening socket. The second set (@emph{wfds}) is the | ||
4600 | writing set and it could contain the sending socket or the STDOUT file | ||
4601 | descriptor. After the select function returns, we check which file | ||
4602 | descriptor is ready to use and we do what is supposed to do on that kind | ||
4603 | of event. @emph{For example:} if it is the listening socket then we | ||
4604 | accept a new connection and save the socket in the reading list; if it is | ||
4605 | the STDOUT file descriptor, then we write to STDOUT the message from the | ||
4606 | @emph{write_std} buffer. | ||
4607 | |||
4608 | To find out on which port a device is listening on we connect to the local | ||
4609 | SDP server and search the registered service for that device. | ||
4610 | |||
4611 | @emph{You should be aware of the fact that if the device fails to connect | ||
4612 | to another one when trying to send a message it will attempt one more | ||
4613 | time. If it fails again, then it skips the message.} | ||
4614 | @emph{Also you should know that the transport Bluetooth plugin has | ||
4615 | support for @strong{broadcast messages}.} | ||
4616 | |||
4617 | @node Details about the broadcast implementation | ||
4618 | @subsubsection Details about the broadcast implementation | ||
4619 | @c %**end of header | ||
4620 | |||
4621 | First I want to point out that the broadcast functionality for the CONTROL | ||
4622 | messages is not implemented in a conventional way. Since the inquiry scan | ||
4623 | time is too big and it will take some time to send a message to all the | ||
4624 | discoverable devices I decided to tackle the problem in a different way. | ||
4625 | Here is how I did it: | ||
4626 | |||
4627 | @itemize @bullet | ||
4628 | @item If it is the first time when I have to broadcast a message I make an | ||
4629 | inquiry scan and save all the devices' addresses to a vector. | ||
4630 | @item After the inquiry scan ends I take the first address from the list | ||
4631 | and I try to connect to it. If it fails, I try to connect to the next one. | ||
4632 | If it succeeds, I save the socket to a list and send the message to the | ||
4633 | device. | ||
4634 | @item When I have to broadcast another message, first I search on the list | ||
4635 | for a new device which I'm not connected to. If there is no new device on | ||
4636 | the list I go to the beginning of the list and send the message to the | ||
4637 | old devices. After 5 cycles I make a new inquiry scan to check out if | ||
4638 | there are new discoverable devices and save them to the list. If there | ||
4639 | are no new discoverable devices I reset the cycling counter and go again | ||
4640 | through the old list and send messages to the devices saved in it. | ||
4641 | @end itemize | ||
4642 | |||
4643 | @strong{Therefore}: | ||
4644 | |||
4645 | @itemize @bullet | ||
4646 | @item every time when I have a broadcast message I look up on the list | ||
4647 | for a new device and send the message to it | ||
4648 | @item if I reached the end of the list for 5 times and I'm connected to | ||
4649 | all the devices from the list I make a new inquiry scan. | ||
4650 | @emph{The number of the list's cycles after an inquiry scan could be | ||
4651 | increased by redefining the MAX_LOOPS variable} | ||
4652 | @item when there are no new devices I send messages to the old ones. | ||
4653 | @end itemize | ||
4654 | |||
4655 | Doing so, the broadcast control messages will reach the devices but with | ||
4656 | delay. | ||
4657 | |||
4658 | @emph{NOTICE:} When I have to send a message to a certain device first I | ||
4659 | check on the broadcast list to see if we are connected to that device. If | ||
4660 | not we try to connect to it and in case of success we save the address and | ||
4661 | the socket on the list. If we are already connected to that device we | ||
4662 | simply use the socket. | ||
4663 | |||
4664 | @node Windows functionality | ||
4665 | @subsubsection Windows functionality | ||
4666 | @c %**end of header | ||
4667 | |||
4668 | For Windows I decided to use the Microsoft Bluetooth stack which has the | ||
4669 | advantage of coming standard from Windows XP SP2. The main disadvantage is | ||
4670 | that it only supports the RFCOMM protocol so we will not be able to have | ||
4671 | a low level control over the Bluetooth device. Therefore it is the user | ||
4672 | responsibility to check if the device is up and in the discoverable mode. | ||
4673 | Also there are no tools which could be used for debugging in order to read | ||
4674 | the data coming from and going to a Bluetooth device, which obviously | ||
4675 | hindered my work. Another thing that slowed down the implementation of the | ||
4676 | plugin (besides that I wasn't too accommodated with the win32 API) was that | ||
4677 | there were some bugs on MinGW regarding the Bluetooth. Now they are solved | ||
4678 | but you should keep in mind that you should have the latest updates | ||
4679 | (especially the @emph{ws2bth} header). | ||
4680 | |||
4681 | Besides the fact that it uses the Windows Sockets, the Windows | ||
4682 | implementation follows the same principles as the GNU/Linux one: | ||
4683 | |||
4684 | @itemize @bullet | ||
4685 | @item It has a initalization part where it initializes the | ||
4686 | Windows Sockets, creates a RFCOMM socket which will be binded and switched | ||
4687 | to the listening mode and registers a SDP service. In the Microsoft | ||
4688 | Bluetooth API there are two ways to work with the SDP: | ||
4689 | @itemize @bullet | ||
4690 | @item an easy way which works with very simple service records | ||
4691 | @item a hard way which is useful when you need to update or to delete the | ||
4692 | record | ||
4693 | @end itemize | ||
4694 | @end itemize | ||
4695 | |||
4696 | Since I only needed the SDP service to find out on which port the device | ||
4697 | is listening on and that did not change, I decided to use the easy way. | ||
4698 | In order to register the service I used the @emph{WSASetService} function | ||
4699 | and I generated the @emph{Universally Unique Identifier} with the | ||
4700 | @emph{guidgen.exe} Windows's tool. | ||
4701 | |||
4702 | In the loop section the only difference from the GNU/Linux implementation | ||
4703 | is that I used the @code{GNUNET_NETWORK} library for | ||
4704 | functions like @emph{accept}, @emph{bind}, @emph{connect} or | ||
4705 | @emph{select}. I decided to use the | ||
4706 | @code{GNUNET_NETWORK} library because I also needed to interact | ||
4707 | with the STDIN and STDOUT handles and on Windows | ||
4708 | the select function is only defined for sockets, | ||
4709 | and it will not work for arbitrary file handles. | ||
4710 | |||
4711 | Another difference between GNU/Linux and Windows implementation is that in | ||
4712 | GNU/Linux, the Bluetooth address is represented in 48 bits | ||
4713 | while in Windows is represented in 64 bits. | ||
4714 | Therefore I had to do some changes on @emph{plugin_transport_wlan} header. | ||
4715 | |||
4716 | Also, currently on Windows the Bluetooth plugin doesn't have support for | ||
4717 | broadcast messages. When it receives a broadcast message it will skip it. | ||
4718 | |||
4719 | @node Pending features | ||
4720 | @subsubsection Pending features | ||
4721 | @c %**end of header | ||
4722 | |||
4723 | @itemize @bullet | ||
4724 | @item Implement the broadcast functionality on Windows @emph{(currently | ||
4725 | working on)} | ||
4726 | @item Implement a testcase for the helper :@ @emph{The testcase | ||
4727 | consists of a program which emulates the plugin and uses the helper. It | ||
4728 | will simulate connections, disconnections and data transfers.} | ||
4729 | @end itemize | ||
4730 | |||
4731 | If you have a new idea about a feature of the plugin or suggestions about | ||
4732 | how I could improve the implementation you are welcome to comment or to | ||
4733 | contact me. | ||
4734 | |||
4735 | @node WLAN plugin | ||
4736 | @section WLAN plugin | ||
4737 | @c %**end of header | ||
4738 | |||
4739 | This section documents how the wlan transport plugin works. Parts which | ||
4740 | are not implemented yet or could be better implemented are described at | ||
4741 | the end. | ||
4742 | |||
4743 | @cindex ATS Subsystem | ||
4744 | @node ATS Subsystem | ||
4745 | @section ATS Subsystem | ||
4746 | @c %**end of header | ||
4747 | |||
4748 | ATS stands for "automatic transport selection", and the function of ATS in | ||
4749 | GNUnet is to decide on which address (and thus transport plugin) should | ||
4750 | be used for two peers to communicate, and what bandwidth limits should be | ||
4751 | imposed on such an individual connection. To help ATS make an informed | ||
4752 | decision, higher-level services inform the ATS service about their | ||
4753 | requirements and the quality of the service rendered. The ATS service | ||
4754 | also interacts with the transport service to be appraised of working | ||
4755 | addresses and to communicate its resource allocation decisions. Finally, | ||
4756 | the ATS service's operation can be observed using a monitoring API. | ||
4757 | |||
4758 | The main logic of the ATS service only collects the available addresses, | ||
4759 | their performance characteristics and the applications requirements, but | ||
4760 | does not make the actual allocation decision. This last critical step is | ||
4761 | left to an ATS plugin, as we have implemented (currently three) different | ||
4762 | allocation strategies which differ significantly in their performance and | ||
4763 | maturity, and it is still unclear if any particular plugin is generally | ||
4764 | superior. | ||
4765 | |||
4766 | @cindex CORE Subsystem | ||
4767 | @node CORE Subsystem | ||
4768 | @section CORE Subsystem | ||
4769 | @c %**end of header | ||
4770 | |||
4771 | The CORE subsystem in GNUnet is responsible for securing link-layer | ||
4772 | communications between nodes in the GNUnet overlay network. CORE builds | ||
4773 | on the TRANSPORT subsystem which provides for the actual, insecure, | ||
4774 | unreliable link-layer communication (for example, via UDP or WLAN), and | ||
4775 | then adds fundamental security to the connections: | ||
4776 | |||
4777 | @itemize @bullet | ||
4778 | @item confidentiality with so-called perfect forward secrecy; we use | ||
4779 | ECDHE | ||
4780 | (@uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, Elliptic-curve Diffie---Hellman}) | ||
4781 | powered by Curve25519 | ||
4782 | (@uref{http://cr.yp.to/ecdh.html, Curve25519}) for the key | ||
4783 | exchange and then use symmetric encryption, encrypting with both AES-256 | ||
4784 | (@uref{http://en.wikipedia.org/wiki/Rijndael, AES-256}) and | ||
4785 | Twofish (@uref{http://en.wikipedia.org/wiki/Twofish, Twofish}) | ||
4786 | @item @uref{http://en.wikipedia.org/wiki/Authentication, authentication} | ||
4787 | is achieved by signing the ephemeral keys using Ed25519 | ||
4788 | (@uref{http://ed25519.cr.yp.to/, Ed25519}), a deterministic | ||
4789 | variant of ECDSA | ||
4790 | (@uref{http://en.wikipedia.org/wiki/ECDSA, ECDSA}) | ||
4791 | @item integrity protection (using SHA-512 | ||
4792 | (@uref{http://en.wikipedia.org/wiki/SHA-2, SHA-512}) to do | ||
4793 | encrypt-then-MAC | ||
4794 | (@uref{http://en.wikipedia.org/wiki/Authenticated_encryption, encrypt-then-MAC})) | ||
4795 | @item Replay | ||
4796 | (@uref{http://en.wikipedia.org/wiki/Replay_attack, replay}) | ||
4797 | protection (using nonces, timestamps, challenge-response, | ||
4798 | message counters and ephemeral keys) | ||
4799 | @item liveness (keep-alive messages, timeout) | ||
4800 | @end itemize | ||
4801 | |||
4802 | @menu | ||
4803 | * Limitations:: | ||
4804 | * When is a peer "connected"?:: | ||
4805 | * libgnunetcore:: | ||
4806 | * The CORE Client-Service Protocol:: | ||
4807 | * The CORE Peer-to-Peer Protocol:: | ||
4808 | @end menu | ||
4809 | |||
4810 | @cindex core subsystem limitations | ||
4811 | @node Limitations | ||
4812 | @subsection Limitations | ||
4813 | @c %**end of header | ||
4814 | |||
4815 | CORE does not perform | ||
4816 | @uref{http://en.wikipedia.org/wiki/Routing, routing}; using CORE it is | ||
4817 | only possible to communicate with peers that happen to already be | ||
4818 | "directly" connected with each other. CORE also does not have an | ||
4819 | API to allow applications to establish such "direct" connections --- for | ||
4820 | this, applications can ask TRANSPORT, but TRANSPORT might not be able to | ||
4821 | establish a "direct" connection. The TOPOLOGY subsystem is responsible for | ||
4822 | trying to keep a few "direct" connections open at all times. Applications | ||
4823 | that need to talk to particular peers should use the CADET subsystem, as | ||
4824 | it can establish arbitrary "indirect" connections. | ||
4825 | |||
4826 | Because CORE does not perform routing, CORE must only be used directly by | ||
4827 | applications that either perform their own routing logic (such as | ||
4828 | anonymous file-sharing) or that do not require routing, for example | ||
4829 | because they are based on flooding the network. CORE communication is | ||
4830 | unreliable and delivery is possibly out-of-order. Applications that | ||
4831 | require reliable communication should use the CADET service. Each | ||
4832 | application can only queue one message per target peer with the CORE | ||
4833 | service at any time; messages cannot be larger than approximately | ||
4834 | 63 kilobytes. If messages are small, CORE may group multiple messages | ||
4835 | (possibly from different applications) prior to encryption. If permitted | ||
4836 | by the application (using the @uref{http://baus.net/on-tcp_cork/, cork} | ||
4837 | option), CORE may delay transmissions to facilitate grouping of multiple | ||
4838 | small messages. If cork is not enabled, CORE will transmit the message as | ||
4839 | soon as TRANSPORT allows it (TRANSPORT is responsible for limiting | ||
4840 | bandwidth and congestion control). CORE does not allow flow control; | ||
4841 | applications are expected to process messages at line-speed. If flow | ||
4842 | control is needed, applications should use the CADET service. | ||
4843 | |||
4844 | @cindex when is a peer connected | ||
4845 | @node When is a peer "connected"? | ||
4846 | @subsection When is a peer "connected"? | ||
4847 | @c %**end of header | ||
4848 | |||
4849 | In addition to the security features mentioned above, CORE also provides | ||
4850 | one additional key feature to applications using it, and that is a | ||
4851 | limited form of protocol-compatibility checking. CORE distinguishes | ||
4852 | between TRANSPORT-level connections (which enable communication with other | ||
4853 | peers) and application-level connections. Applications using the CORE API | ||
4854 | will (typically) learn about application-level connections from CORE, and | ||
4855 | not about TRANSPORT-level connections. When a typical application uses | ||
4856 | CORE, it will specify a set of message types | ||
4857 | (from @code{gnunet_protocols.h}) that it understands. CORE will then | ||
4858 | notify the application about connections it has with other peers if and | ||
4859 | only if those applications registered an intersecting set of message | ||
4860 | types with their CORE service. Thus, it is quite possible that CORE only | ||
4861 | exposes a subset of the established direct connections to a particular | ||
4862 | application --- and different applications running above CORE might see | ||
4863 | different sets of connections at the same time. | ||
4864 | |||
4865 | A special case are applications that do not register a handler for any | ||
4866 | message type. | ||
4867 | CORE assumes that these applications merely want to monitor connections | ||
4868 | (or "all" messages via other callbacks) and will notify those applications | ||
4869 | about all connections. This is used, for example, by the | ||
4870 | @code{gnunet-core} command-line tool to display the active connections. | ||
4871 | Note that it is also possible that the TRANSPORT service has more active | ||
4872 | connections than the CORE service, as the CORE service first has to | ||
4873 | perform a key exchange with connecting peers before exchanging information | ||
4874 | about supported message types and notifying applications about the new | ||
4875 | connection. | ||
4876 | |||
4877 | @cindex libgnunetcore | ||
4878 | @node libgnunetcore | ||
4879 | @subsection libgnunetcore | ||
4880 | @c %**end of header | ||
4881 | |||
4882 | The CORE API (defined in @file{gnunet_core_service.h}) is the basic | ||
4883 | messaging API used by P2P applications built using GNUnet. It provides | ||
4884 | applications the ability to send and receive encrypted messages to the | ||
4885 | peer's "directly" connected neighbours. | ||
4886 | |||
4887 | As CORE connections are generally "direct" connections,@ applications must | ||
4888 | not assume that they can connect to arbitrary peers this way, as "direct" | ||
4889 | connections may not always be possible. Applications using CORE are | ||
4890 | notified about which peers are connected. Creating new "direct" | ||
4891 | connections must be done using the TRANSPORT API. | ||
4892 | |||
4893 | The CORE API provides unreliable, out-of-order delivery. While the | ||
4894 | implementation tries to ensure timely, in-order delivery, both message | ||
4895 | losses and reordering are not detected and must be tolerated by the | ||
4896 | application. Most important, the core will NOT perform retransmission if | ||
4897 | messages could not be delivered. | ||
4898 | |||
4899 | Note that CORE allows applications to queue one message per connected | ||
4900 | peer. The rate at which each connection operates is influenced by the | ||
4901 | preferences expressed by local application as well as restrictions | ||
4902 | imposed by the other peer. Local applications can express their | ||
4903 | preferences for particular connections using the "performance" API of the | ||
4904 | ATS service. | ||
4905 | |||
4906 | Applications that require more sophisticated transmission capabilities | ||
4907 | such as TCP-like behavior, or if you intend to send messages to arbitrary | ||
4908 | remote peers, should use the CADET API. | ||
4909 | |||
4910 | The typical use of the CORE API is to connect to the CORE service using | ||
4911 | @code{GNUNET_CORE_connect}, process events from the CORE service (such as | ||
4912 | peers connecting, peers disconnecting and incoming messages) and send | ||
4913 | messages to connected peers using | ||
4914 | @code{GNUNET_CORE_notify_transmit_ready}. Note that applications must | ||
4915 | cancel pending transmission requests if they receive a disconnect event | ||
4916 | for a peer that had a transmission pending; furthermore, queuing more | ||
4917 | than one transmission request per peer per application using the | ||
4918 | service is not permitted. | ||
4919 | |||
4920 | The CORE API also allows applications to monitor all communications of the | ||
4921 | peer prior to encryption (for outgoing messages) or after decryption (for | ||
4922 | incoming messages). This can be useful for debugging, diagnostics or to | ||
4923 | establish the presence of cover traffic (for anonymity). As monitoring | ||
4924 | applications are often not interested in the payload, the monitoring | ||
4925 | callbacks can be configured to only provide the message headers (including | ||
4926 | the message type and size) instead of copying the full data stream to the | ||
4927 | monitoring client. | ||
4928 | |||
4929 | The init callback of the @code{GNUNET_CORE_connect} function is called | ||
4930 | with the hash of the public key of the peer. This public key is used to | ||
4931 | identify the peer globally in the GNUnet network. Applications are | ||
4932 | encouraged to check that the provided hash matches the hash that they are | ||
4933 | using (as theoretically the application may be using a different | ||
4934 | configuration file with a different private key, which would result in | ||
4935 | hard to find bugs). | ||
4936 | |||
4937 | As with most service APIs, the CORE API isolates applications from crashes | ||
4938 | of the CORE service. If the CORE service crashes, the application will see | ||
4939 | disconnect events for all existing connections. Once the connections are | ||
4940 | re-established, the applications will be receive matching connect events. | ||
4941 | |||
4942 | @cindex core clinet-service protocol | ||
4943 | @node The CORE Client-Service Protocol | ||
4944 | @subsection The CORE Client-Service Protocol | ||
4945 | @c %**end of header | ||
4946 | |||
4947 | This section describes the protocol between an application using the CORE | ||
4948 | service (the client) and the CORE service process itself. | ||
4949 | |||
4950 | |||
4951 | @menu | ||
4952 | * Setup2:: | ||
4953 | * Notifications:: | ||
4954 | * Sending:: | ||
4955 | @end menu | ||
4956 | |||
4957 | @node Setup2 | ||
4958 | @subsubsection Setup2 | ||
4959 | @c %**end of header | ||
4960 | |||
4961 | When a client connects to the CORE service, it first sends a | ||
4962 | @code{InitMessage} which specifies options for the connection and a set of | ||
4963 | message type values which are supported by the application. The options | ||
4964 | bitmask specifies which events the client would like to be notified about. | ||
4965 | The options include: | ||
4966 | |||
4967 | @table @asis | ||
4968 | @item GNUNET_CORE_OPTION_NOTHING No notifications | ||
4969 | @item GNUNET_CORE_OPTION_STATUS_CHANGE Peers connecting and disconnecting | ||
4970 | @item GNUNET_CORE_OPTION_FULL_INBOUND All inbound messages (after | ||
4971 | decryption) with full payload | ||
4972 | @item GNUNET_CORE_OPTION_HDR_INBOUND Just the @code{MessageHeader} | ||
4973 | of all inbound messages | ||
4974 | @item GNUNET_CORE_OPTION_FULL_OUTBOUND All outbound | ||
4975 | messages (prior to encryption) with full payload | ||
4976 | @item GNUNET_CORE_OPTION_HDR_OUTBOUND Just the @code{MessageHeader} of all | ||
4977 | outbound messages | ||
4978 | @end table | ||
4979 | |||
4980 | Typical applications will only monitor for connection status changes. | ||
4981 | |||
4982 | The CORE service responds to the @code{InitMessage} with an | ||
4983 | @code{InitReplyMessage} which contains the peer's identity. Afterwards, | ||
4984 | both CORE and the client can send messages. | ||
4985 | |||
4986 | @node Notifications | ||
4987 | @subsubsection Notifications | ||
4988 | @c %**end of header | ||
4989 | |||
4990 | The CORE will send @code{ConnectNotifyMessage}s and | ||
4991 | @code{DisconnectNotifyMessage}s whenever peers connect or disconnect from | ||
4992 | the CORE (assuming their type maps overlap with the message types | ||
4993 | registered by the client). When the CORE receives a message that matches | ||
4994 | the set of message types specified during the @code{InitMessage} (or if | ||
4995 | monitoring is enabled in for inbound messages in the options), it sends a | ||
4996 | @code{NotifyTrafficMessage} with the peer identity of the sender and the | ||
4997 | decrypted payload. The same message format (except with | ||
4998 | @code{GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND} for the message type) is | ||
4999 | used to notify clients monitoring outbound messages; here, the peer | ||
5000 | identity given is that of the receiver. | ||
5001 | |||
5002 | @node Sending | ||
5003 | @subsubsection Sending | ||
5004 | @c %**end of header | ||
5005 | |||
5006 | When a client wants to transmit a message, it first requests a | ||
5007 | transmission slot by sending a @code{SendMessageRequest} which specifies | ||
5008 | the priority, deadline and size of the message. Note that these values | ||
5009 | may be ignored by CORE. When CORE is ready for the message, it answers | ||
5010 | with a @code{SendMessageReady} response. The client can then transmit the | ||
5011 | payload with a @code{SendMessage} message. Note that the actual message | ||
5012 | size in the @code{SendMessage} is allowed to be smaller than the size in | ||
5013 | the original request. A client may at any time send a fresh | ||
5014 | @code{SendMessageRequest}, which then superceeds the previous | ||
5015 | @code{SendMessageRequest}, which is then no longer valid. The client can | ||
5016 | tell which @code{SendMessageRequest} the CORE service's | ||
5017 | @code{SendMessageReady} message is for as all of these messages contain a | ||
5018 | "unique" request ID (based on a counter incremented by the client | ||
5019 | for each request). | ||
5020 | |||
5021 | @cindex CORE Peer-to-Peer Protocol | ||
5022 | @node The CORE Peer-to-Peer Protocol | ||
5023 | @subsection The CORE Peer-to-Peer Protocol | ||
5024 | @c %**end of header | ||
5025 | |||
5026 | |||
5027 | @menu | ||
5028 | * Creating the EphemeralKeyMessage:: | ||
5029 | * Establishing a connection:: | ||
5030 | * Encryption and Decryption:: | ||
5031 | * Type maps:: | ||
5032 | @end menu | ||
5033 | |||
5034 | @cindex EphemeralKeyMessage creation | ||
5035 | @node Creating the EphemeralKeyMessage | ||
5036 | @subsubsection Creating the EphemeralKeyMessage | ||
5037 | @c %**end of header | ||
5038 | |||
5039 | When the CORE service starts, each peer creates a fresh ephemeral (ECC) | ||
5040 | public-private key pair and signs the corresponding | ||
5041 | @code{EphemeralKeyMessage} with its long-term key (which we usually call | ||
5042 | the peer's identity; the hash of the public long term key is what results | ||
5043 | in a @code{struct GNUNET_PeerIdentity} in all GNUnet APIs. The ephemeral | ||
5044 | key is ONLY used for an ECDHE | ||
5045 | (@uref{http://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman, Elliptic-curve Diffie---Hellman}) | ||
5046 | exchange by the CORE service to establish symmetric session keys. A peer | ||
5047 | will use the same @code{EphemeralKeyMessage} for all peers for | ||
5048 | @code{REKEY_FREQUENCY}, which is usually 12 hours. After that time, it | ||
5049 | will create a fresh ephemeral key (forgetting the old one) and broadcast | ||
5050 | the new @code{EphemeralKeyMessage} to all connected peers, resulting in | ||
5051 | fresh symmetric session keys. Note that peers independently decide on | ||
5052 | when to discard ephemeral keys; it is not a protocol violation to discard | ||
5053 | keys more often. Ephemeral keys are also never stored to disk; restarting | ||
5054 | a peer will thus always create a fresh ephemeral key. The use of ephemeral | ||
5055 | keys is what provides @uref{http://en.wikipedia.org/wiki/Forward_secrecy, forward secrecy}. | ||
5056 | |||
5057 | Just before transmission, the @code{EphemeralKeyMessage} is patched to | ||
5058 | reflect the current sender_status, which specifies the current state of | ||
5059 | the connection from the point of view of the sender. The possible values | ||
5060 | are: | ||
5061 | |||
5062 | @itemize @bullet | ||
5063 | @item @code{KX_STATE_DOWN} Initial value, never used on the network | ||
5064 | @item @code{KX_STATE_KEY_SENT} We sent our ephemeral key, do not know the | ||
5065 | key of the other peer | ||
5066 | @item @code{KX_STATE_KEY_RECEIVED} This peer has received a valid | ||
5067 | ephemeral key of the other peer, but we are waiting for the other peer to | ||
5068 | confirm it's authenticity (ability to decode) via challenge-response. | ||
5069 | @item @code{KX_STATE_UP} The connection is fully up from the point of | ||
5070 | view of the sender (now performing keep-alives) | ||
5071 | @item @code{KX_STATE_REKEY_SENT} The sender has initiated a rekeying | ||
5072 | operation; the other peer has so far failed to confirm a working | ||
5073 | connection using the new ephemeral key | ||
5074 | @end itemize | ||
5075 | |||
5076 | @node Establishing a connection | ||
5077 | @subsubsection Establishing a connection | ||
5078 | @c %**end of header | ||
5079 | |||
5080 | Peers begin their interaction by sending a @code{EphemeralKeyMessage} to | ||
5081 | the other peer once the TRANSPORT service notifies the CORE service about | ||
5082 | the connection. | ||
5083 | A peer receiving an @code{EphemeralKeyMessage} with a status | ||
5084 | indicating that the sender does not have the receiver's ephemeral key, the | ||
5085 | receiver's @code{EphemeralKeyMessage} is sent in response. | ||
5086 | Additionally, if the receiver has not yet confirmed the authenticity of | ||
5087 | the sender, it also sends an (encrypted)@code{PingMessage} with a | ||
5088 | challenge (and the identity of the target) to the other peer. Peers | ||
5089 | receiving a @code{PingMessage} respond with an (encrypted) | ||
5090 | @code{PongMessage} which includes the challenge. Peers receiving a | ||
5091 | @code{PongMessage} check the challenge, and if it matches set the | ||
5092 | connection to @code{KX_STATE_UP}. | ||
5093 | |||
5094 | @node Encryption and Decryption | ||
5095 | @subsubsection Encryption and Decryption | ||
5096 | @c %**end of header | ||
5097 | |||
5098 | All functions related to the key exchange and encryption/decryption of | ||
5099 | messages can be found in @file{gnunet-service-core_kx.c} (except for the | ||
5100 | cryptographic primitives, which are in @file{util/crypto*.c}). | ||
5101 | Given the key material from ECDHE, a Key derivation function | ||
5102 | (@uref{https://en.wikipedia.org/wiki/Key_derivation_function, Key derivation function}) | ||
5103 | is used to derive two pairs of encryption and decryption keys for AES-256 | ||
5104 | and TwoFish, as well as initialization vectors and authentication keys | ||
5105 | (for HMAC | ||
5106 | (@uref{https://en.wikipedia.org/wiki/HMAC, HMAC})). | ||
5107 | The HMAC is computed over the encrypted payload. | ||
5108 | Encrypted messages include an iv_seed and the HMAC in the header. | ||
5109 | |||
5110 | Each encrypted message in the CORE service includes a sequence number and | ||
5111 | a timestamp in the encrypted payload. The CORE service remembers the | ||
5112 | largest observed sequence number and a bit-mask which represents which of | ||
5113 | the previous 32 sequence numbers were already used. | ||
5114 | Messages with sequence numbers lower than the largest observed sequence | ||
5115 | number minus 32 are discarded. Messages with a timestamp that is less | ||
5116 | than @code{REKEY_TOLERANCE} off (5 minutes) are also discarded. This of | ||
5117 | course means that system clocks need to be reasonably synchronized for | ||
5118 | peers to be able to communicate. Additionally, as the ephemeral key | ||
5119 | changes every 12 hours, a peer would not even be able to decrypt messages | ||
5120 | older than 12 hours. | ||
5121 | |||
5122 | @node Type maps | ||
5123 | @subsubsection Type maps | ||
5124 | @c %**end of header | ||
5125 | |||
5126 | Once an encrypted connection has been established, peers begin to exchange | ||
5127 | type maps. Type maps are used to allow the CORE service to determine which | ||
5128 | (encrypted) connections should be shown to which applications. A type map | ||
5129 | is an array of 65536 bits representing the different types of messages | ||
5130 | understood by applications using the CORE service. Each CORE service | ||
5131 | maintains this map, simply by setting the respective bit for each message | ||
5132 | type supported by any of the applications using the CORE service. Note | ||
5133 | that bits for message types embedded in higher-level protocols (such as | ||
5134 | MESH) will not be included in these type maps. | ||
5135 | |||
5136 | Typically, the type map of a peer will be sparse. Thus, the CORE service | ||
5137 | attempts to compress its type map using @code{gzip}-style compression | ||
5138 | ("deflate") prior to transmission. However, if the compression fails to | ||
5139 | compact the map, the map may also be transmitted without compression | ||
5140 | (resulting in @code{GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP} or | ||
5141 | @code{GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP} messages respectively). | ||
5142 | Upon receiving a type map, the respective CORE service notifies | ||
5143 | applications about the connection to the other peer if they support any | ||
5144 | message type indicated in the type map (or no message type at all). | ||
5145 | If the CORE service experience a connect or disconnect event from an | ||
5146 | application, it updates its type map (setting or unsetting the respective | ||
5147 | bits) and notifies its neighbours about the change. | ||
5148 | The CORE services of the neighbours then in turn generate connect and | ||
5149 | disconnect events for the peer that sent the type map for their respective | ||
5150 | applications. As CORE messages may be lost, the CORE service confirms | ||
5151 | receiving a type map by sending back a | ||
5152 | @code{GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP}. If such a confirmation | ||
5153 | (with the correct hash of the type map) is not received, the sender will | ||
5154 | retransmit the type map (with exponential back-off). | ||
5155 | |||
5156 | @cindex CADET Subsystem | ||
5157 | @node CADET Subsystem | ||
5158 | @section CADET Subsystem | ||
5159 | |||
5160 | The CADET subsystem in GNUnet is responsible for secure end-to-end | ||
5161 | communications between nodes in the GNUnet overlay network. CADET builds | ||
5162 | on the CORE subsystem which provides for the link-layer communication and | ||
5163 | then adds routing, forwarding and additional security to the connections. | ||
5164 | CADET offers the same cryptographic services as CORE, but on an | ||
5165 | end-to-end level. This is done so peers retransmitting traffic on behalf | ||
5166 | of other peers cannot access the payload data. | ||
5167 | |||
5168 | @itemize @bullet | ||
5169 | @item CADET provides confidentiality with so-called perfect forward | ||
5170 | secrecy; we use ECDHE powered by Curve25519 for the key exchange and then | ||
5171 | use symmetric encryption, encrypting with both AES-256 and Twofish | ||
5172 | @item authentication is achieved by signing the ephemeral keys using | ||
5173 | Ed25519, a deterministic variant of ECDSA | ||
5174 | @item integrity protection (using SHA-512 to do encrypt-then-MAC, although | ||
5175 | only 256 bits are sent to reduce overhead) | ||
5176 | @item replay protection (using nonces, timestamps, challenge-response, | ||
5177 | message counters and ephemeral keys) | ||
5178 | @item liveness (keep-alive messages, timeout) | ||
5179 | @end itemize | ||
5180 | |||
5181 | Additional to the CORE-like security benefits, CADET offers other | ||
5182 | properties that make it a more universal service than CORE. | ||
5183 | |||
5184 | @itemize @bullet | ||
5185 | @item CADET can establish channels to arbitrary peers in GNUnet. If a | ||
5186 | peer is not immediately reachable, CADET will find a path through the | ||
5187 | network and ask other peers to retransmit the traffic on its behalf. | ||
5188 | @item CADET offers (optional) reliability mechanisms. In a reliable | ||
5189 | channel traffic is guaranteed to arrive complete, unchanged and in-order. | ||
5190 | @item CADET takes care of flow and congestion control mechanisms, not | ||
5191 | allowing the sender to send more traffic than the receiver or the network | ||
5192 | are able to process. | ||
5193 | @end itemize | ||
5194 | |||
5195 | @menu | ||
5196 | * libgnunetcadet:: | ||
5197 | @end menu | ||
5198 | |||
5199 | @cindex libgnunetcadet | ||
5200 | @node libgnunetcadet | ||
5201 | @subsection libgnunetcadet | ||
5202 | |||
5203 | |||
5204 | The CADET API (defined in @file{gnunet_cadet_service.h}) is the | ||
5205 | messaging API used by P2P applications built using GNUnet. | ||
5206 | It provides applications the ability to send and receive encrypted | ||
5207 | messages to any peer participating in GNUnet. | ||
5208 | The API is heavily base on the CORE API. | ||
5209 | |||
5210 | CADET delivers messages to other peers in "channels". | ||
5211 | A channel is a permanent connection defined by a destination peer | ||
5212 | (identified by its public key) and a port number. | ||
5213 | Internally, CADET tunnels all channels towards a destination peer | ||
5214 | using one session key and relays the data on multiple "connections", | ||
5215 | independent from the channels. | ||
5216 | |||
5217 | Each channel has optional parameters, the most important being the | ||
5218 | reliability flag. | ||
5219 | Should a message get lost on TRANSPORT/CORE level, if a channel is | ||
5220 | created with as reliable, CADET will retransmit the lost message and | ||
5221 | deliver it in order to the destination application. | ||
5222 | |||
5223 | To communicate with other peers using CADET, it is necessary to first | ||
5224 | connect to the service using @code{GNUNET_CADET_connect}. | ||
5225 | This function takes several parameters in form of callbacks, to allow the | ||
5226 | client to react to various events, like incoming channels or channels that | ||
5227 | terminate, as well as specify a list of ports the client wishes to listen | ||
5228 | to (at the moment it is not possible to start listening on further ports | ||
5229 | once connected, but nothing prevents a client to connect several times to | ||
5230 | CADET, even do one connection per listening port). | ||
5231 | The function returns a handle which has to be used for any further | ||
5232 | interaction with the service. | ||
5233 | |||
5234 | To connect to a remote peer a client has to call the | ||
5235 | @code{GNUNET_CADET_channel_create} function. The most important parameters | ||
5236 | given are the remote peer's identity (it public key) and a port, which | ||
5237 | specifies which application on the remote peer to connect to, similar to | ||
5238 | TCP/UDP ports. CADET will then find the peer in the GNUnet network and | ||
5239 | establish the proper low-level connections and do the necessary key | ||
5240 | exchanges to assure and authenticated, secure and verified communication. | ||
5241 | Similar to @code{GNUNET_CADET_connect},@code{GNUNET_CADET_create_channel} | ||
5242 | returns a handle to interact with the created channel. | ||
5243 | |||
5244 | For every message the client wants to send to the remote application, | ||
5245 | @code{GNUNET_CADET_notify_transmit_ready} must be called, indicating the | ||
5246 | channel on which the message should be sent and the size of the message | ||
5247 | (but not the message itself!). Once CADET is ready to send the message, | ||
5248 | the provided callback will fire, and the message contents are provided to | ||
5249 | this callback. | ||
5250 | |||
5251 | Please note the CADET does not provide an explicit notification of when a | ||
5252 | channel is connected. In loosely connected networks, like big wireless | ||
5253 | mesh networks, this can take several seconds, even minutes in the worst | ||
5254 | case. To be alerted when a channel is online, a client can call | ||
5255 | @code{GNUNET_CADET_notify_transmit_ready} immediately after | ||
5256 | @code{GNUNET_CADET_create_channel}. When the callback is activated, it | ||
5257 | means that the channel is online. The callback can give 0 bytes to CADET | ||
5258 | if no message is to be sent, this is OK. | ||
5259 | |||
5260 | If a transmission was requested but before the callback fires it is no | ||
5261 | longer needed, it can be canceled with | ||
5262 | @code{GNUNET_CADET_notify_transmit_ready_cancel}, which uses the handle | ||
5263 | given back by @code{GNUNET_CADET_notify_transmit_ready}. | ||
5264 | As in the case of CORE, only one message can be requested at a time: a | ||
5265 | client must not call @code{GNUNET_CADET_notify_transmit_ready} again until | ||
5266 | the callback is called or the request is canceled. | ||
5267 | |||
5268 | When a channel is no longer needed, a client can call | ||
5269 | @code{GNUNET_CADET_channel_destroy} to get rid of it. | ||
5270 | Note that CADET will try to transmit all pending traffic before notifying | ||
5271 | the remote peer of the destruction of the channel, including | ||
5272 | retransmitting lost messages if the channel was reliable. | ||
5273 | |||
5274 | Incoming channels, channels being closed by the remote peer, and traffic | ||
5275 | on any incoming or outgoing channels are given to the client when CADET | ||
5276 | executes the callbacks given to it at the time of | ||
5277 | @code{GNUNET_CADET_connect}. | ||
5278 | |||
5279 | Finally, when an application no longer wants to use CADET, it should call | ||
5280 | @code{GNUNET_CADET_disconnect}, but first all channels and pending | ||
5281 | transmissions must be closed (otherwise CADET will complain). | ||
5282 | |||
5283 | @cindex NSE Subsystem | ||
5284 | @node NSE Subsystem | ||
5285 | @section NSE Subsystem | ||
5286 | |||
5287 | |||
5288 | NSE stands for @dfn{Network Size Estimation}. The NSE subsystem provides | ||
5289 | other subsystems and users with a rough estimate of the number of peers | ||
5290 | currently participating in the GNUnet overlay. | ||
5291 | The computed value is not a precise number as producing a precise number | ||
5292 | in a decentralized, efficient and secure way is impossible. | ||
5293 | While NSE's estimate is inherently imprecise, NSE also gives the expected | ||
5294 | range. For a peer that has been running in a stable network for a | ||
5295 | while, the real network size will typically (99.7% of the time) be in the | ||
5296 | range of [2/3 estimate, 3/2 estimate]. We will now give an overview of the | ||
5297 | algorithm used to calculate the estimate; | ||
5298 | all of the details can be found in this technical report. | ||
5299 | |||
5300 | @c FIXME: link to the report. | ||
5301 | |||
5302 | @menu | ||
5303 | * Motivation:: | ||
5304 | * Principle:: | ||
5305 | * libgnunetnse:: | ||
5306 | * The NSE Client-Service Protocol:: | ||
5307 | * The NSE Peer-to-Peer Protocol:: | ||
5308 | @end menu | ||
5309 | |||
5310 | @node Motivation | ||
5311 | @subsection Motivation | ||
5312 | |||
5313 | |||
5314 | Some subsystems, like DHT, need to know the size of the GNUnet network to | ||
5315 | optimize some parameters of their own protocol. The decentralized nature | ||
5316 | of GNUnet makes efficient and securely counting the exact number of peers | ||
5317 | infeasible. Although there are several decentralized algorithms to count | ||
5318 | the number of peers in a system, so far there is none to do so securely. | ||
5319 | Other protocols may allow any malicious peer to manipulate the final | ||
5320 | result or to take advantage of the system to perform | ||
5321 | @dfn{Denial of Service} (DoS) attacks against the network. | ||
5322 | GNUnet's NSE protocol avoids these drawbacks. | ||
5323 | |||
5324 | |||
5325 | |||
5326 | @menu | ||
5327 | * Security:: | ||
5328 | @end menu | ||
5329 | |||
5330 | @cindex NSE security | ||
5331 | @cindex nse security | ||
5332 | @node Security | ||
5333 | @subsubsection Security | ||
5334 | |||
5335 | |||
5336 | The NSE subsystem is designed to be resilient against these attacks. | ||
5337 | It uses @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proofs of work} | ||
5338 | to prevent one peer from impersonating a large number of participants, | ||
5339 | which would otherwise allow an adversary to artificially inflate the | ||
5340 | estimate. | ||
5341 | The DoS protection comes from the time-based nature of the protocol: | ||
5342 | the estimates are calculated periodically and out-of-time traffic is | ||
5343 | either ignored or stored for later retransmission by benign peers. | ||
5344 | In particular, peers cannot trigger global network communication at will. | ||
5345 | |||
5346 | @cindex NSE principle | ||
5347 | @cindex nse principle | ||
5348 | @node Principle | ||
5349 | @subsection Principle | ||
5350 | |||
5351 | |||
5352 | The algorithm calculates the estimate by finding the globally closest | ||
5353 | peer ID to a random, time-based value. | ||
5354 | |||
5355 | The idea is that the closer the ID is to the random value, the more | ||
5356 | "densely packed" the ID space is, and therefore, more peers are in the | ||
5357 | network. | ||
5358 | |||
5359 | |||
5360 | |||
5361 | @menu | ||
5362 | * Example:: | ||
5363 | * Algorithm:: | ||
5364 | * Target value:: | ||
5365 | * Timing:: | ||
5366 | * Controlled Flooding:: | ||
5367 | * Calculating the estimate:: | ||
5368 | @end menu | ||
5369 | |||
5370 | @node Example | ||
5371 | @subsubsection Example | ||
5372 | |||
5373 | |||
5374 | Suppose all peers have IDs between 0 and 100 (our ID space), and the | ||
5375 | random value is 42. | ||
5376 | If the closest peer has the ID 70 we can imagine that the average | ||
5377 | "distance" between peers is around 30 and therefore the are around 3 | ||
5378 | peers in the whole ID space. On the other hand, if the closest peer has | ||
5379 | the ID 44, we can imagine that the space is rather packed with peers, | ||
5380 | maybe as much as 50 of them. | ||
5381 | Naturally, we could have been rather unlucky, and there is only one peer | ||
5382 | and happens to have the ID 44. Thus, the current estimate is calculated | ||
5383 | as the average over multiple rounds, and not just a single sample. | ||
5384 | |||
5385 | @node Algorithm | ||
5386 | @subsubsection Algorithm | ||
5387 | |||
5388 | |||
5389 | Given that example, one can imagine that the job of the subsystem is to | ||
5390 | efficiently communicate the ID of the closest peer to the target value | ||
5391 | to all the other peers, who will calculate the estimate from it. | ||
5392 | |||
5393 | @node Target value | ||
5394 | @subsubsection Target value | ||
5395 | |||
5396 | @c %**end of header | ||
5397 | |||
5398 | The target value itself is generated by hashing the current time, rounded | ||
5399 | down to an agreed value. If the rounding amount is 1h (default) and the | ||
5400 | time is 12:34:56, the time to hash would be 12:00:00. The process is | ||
5401 | repeated each rounding amount (in this example would be every hour). | ||
5402 | Every repetition is called a round. | ||
5403 | |||
5404 | @node Timing | ||
5405 | @subsubsection Timing | ||
5406 | @c %**end of header | ||
5407 | |||
5408 | The NSE subsystem has some timing control to avoid everybody broadcasting | ||
5409 | its ID all at one. Once each peer has the target random value, it | ||
5410 | compares its own ID to the target and calculates the hypothetical size of | ||
5411 | the network if that peer were to be the closest. | ||
5412 | Then it compares the hypothetical size with the estimate from the previous | ||
5413 | rounds. For each value there is an associated point in the period, | ||
5414 | let's call it "broadcast time". If its own hypothetical estimate | ||
5415 | is the same as the previous global estimate, its "broadcast time" will be | ||
5416 | in the middle of the round. If its bigger it will be earlier and if its | ||
5417 | smaller (the most likely case) it will be later. This ensures that the | ||
5418 | peers closest to the target value start broadcasting their ID the first. | ||
5419 | |||
5420 | @node Controlled Flooding | ||
5421 | @subsubsection Controlled Flooding | ||
5422 | |||
5423 | @c %**end of header | ||
5424 | |||
5425 | When a peer receives a value, first it verifies that it is closer than the | ||
5426 | closest value it had so far, otherwise it answers the incoming message | ||
5427 | with a message containing the better value. Then it checks a proof of | ||
5428 | work that must be included in the incoming message, to ensure that the | ||
5429 | other peer's ID is not made up (otherwise a malicious peer could claim to | ||
5430 | have an ID of exactly the target value every round). Once validated, it | ||
5431 | compares the broadcast time of the received value with the current time | ||
5432 | and if it's not too early, sends the received value to its neighbors. | ||
5433 | Otherwise it stores the value until the correct broadcast time comes. | ||
5434 | This prevents unnecessary traffic of sub-optimal values, since a better | ||
5435 | value can come before the broadcast time, rendering the previous one | ||
5436 | obsolete and saving the traffic that would have been used to broadcast it | ||
5437 | to the neighbors. | ||
5438 | |||
5439 | @node Calculating the estimate | ||
5440 | @subsubsection Calculating the estimate | ||
5441 | |||
5442 | @c %**end of header | ||
5443 | |||
5444 | Once the closest ID has been spread across the network each peer gets the | ||
5445 | exact distance between this ID and the target value of the round and | ||
5446 | calculates the estimate with a mathematical formula described in the tech | ||
5447 | report. The estimate generated with this method for a single round is not | ||
5448 | very precise. Remember the case of the example, where the only peer is the | ||
5449 | ID 44 and we happen to generate the target value 42, thinking there are | ||
5450 | 50 peers in the network. Therefore, the NSE subsystem remembers the last | ||
5451 | 64 estimates and calculates an average over them, giving a result of which | ||
5452 | usually has one bit of uncertainty (the real size could be half of the | ||
5453 | estimate or twice as much). Note that the actual network size is | ||
5454 | calculated in powers of two of the raw input, thus one bit of uncertainty | ||
5455 | means a factor of two in the size estimate. | ||
5456 | |||
5457 | @cindex libgnunetnse | ||
5458 | @node libgnunetnse | ||
5459 | @subsection libgnunetnse | ||
5460 | |||
5461 | @c %**end of header | ||
5462 | |||
5463 | The NSE subsystem has the simplest API of all services, with only two | ||
5464 | calls: @code{GNUNET_NSE_connect} and @code{GNUNET_NSE_disconnect}. | ||
5465 | |||
5466 | The connect call gets a callback function as a parameter and this function | ||
5467 | is called each time the network agrees on an estimate. This usually is | ||
5468 | once per round, with some exceptions: if the closest peer has a late | ||
5469 | local clock and starts spreading its ID after everyone else agreed on a | ||
5470 | value, the callback might be activated twice in a round, the second value | ||
5471 | being always bigger than the first. The default round time is set to | ||
5472 | 1 hour. | ||
5473 | |||
5474 | The disconnect call disconnects from the NSE subsystem and the callback | ||
5475 | is no longer called with new estimates. | ||
5476 | |||
5477 | |||
5478 | |||
5479 | @menu | ||
5480 | * Results:: | ||
5481 | * libgnunetnse - Examples:: | ||
5482 | @end menu | ||
5483 | |||
5484 | @node Results | ||
5485 | @subsubsection Results | ||
5486 | |||
5487 | @c %**end of header | ||
5488 | |||
5489 | The callback provides two values: the average and the | ||
5490 | @uref{http://en.wikipedia.org/wiki/Standard_deviation, standard deviation} | ||
5491 | of the last 64 rounds. The values provided by the callback function are | ||
5492 | logarithmic, this means that the real estimate numbers can be obtained by | ||
5493 | calculating 2 to the power of the given value (2average). From a | ||
5494 | statistics point of view this means that: | ||
5495 | |||
5496 | @itemize @bullet | ||
5497 | @item 68% of the time the real size is included in the interval | ||
5498 | [(2average-stddev), 2] | ||
5499 | @item 95% of the time the real size is included in the interval | ||
5500 | [(2average-2*stddev, 2^average+2*stddev] | ||
5501 | @item 99.7% of the time the real size is included in the interval | ||
5502 | [(2average-3*stddev, 2average+3*stddev] | ||
5503 | @end itemize | ||
5504 | |||
5505 | The expected standard variation for 64 rounds in a network of stable size | ||
5506 | is 0.2. Thus, we can say that normally: | ||
5507 | |||
5508 | @itemize @bullet | ||
5509 | @item 68% of the time the real size is in the range [-13%, +15%] | ||
5510 | @item 95% of the time the real size is in the range [-24%, +32%] | ||
5511 | @item 99.7% of the time the real size is in the range [-34%, +52%] | ||
5512 | @end itemize | ||
5513 | |||
5514 | As said in the introduction, we can be quite sure that usually the real | ||
5515 | size is between one third and three times the estimate. This can of | ||
5516 | course vary with network conditions. | ||
5517 | Thus, applications may want to also consider the provided standard | ||
5518 | deviation value, not only the average (in particular, if the standard | ||
5519 | variation is very high, the average maybe meaningless: the network size is | ||
5520 | changing rapidly). | ||
5521 | |||
5522 | @node libgnunetnse - Examples | ||
5523 | @subsubsection libgnunetnse -Examples | ||
5524 | |||
5525 | @c %**end of header | ||
5526 | |||
5527 | Let's close with a couple examples. | ||
5528 | |||
5529 | @table @asis | ||
5530 | |||
5531 | @item Average: 10, std dev: 1 Here the estimate would be | ||
5532 | 2^10 = 1024 peers. (The range in which we can be 95% sure is: | ||
5533 | [2^8, 2^12] = [256, 4096]. We can be very (>99.7%) sure that the network | ||
5534 | is not a hundred peers and absolutely sure that it is not a million peers, | ||
5535 | but somewhere around a thousand.) | ||
5536 | |||
5537 | @item Average 22, std dev: 0.2 Here the estimate would be | ||
5538 | 2^22 = 4 Million peers. (The range in which we can be 99.7% sure | ||
5539 | is: [2^21.4, 2^22.6] = [2.8M, 6.3M]. We can be sure that the network size | ||
5540 | is around four million, with absolutely way of it being 1 million.) | ||
5541 | |||
5542 | @end table | ||
5543 | |||
5544 | To put this in perspective, if someone remembers the LHC Higgs boson | ||
5545 | results, were announced with "5 sigma" and "6 sigma" certainties. In this | ||
5546 | case a 5 sigma minimum would be 2 million and a 6 sigma minimum, | ||
5547 | 1.8 million. | ||
5548 | |||
5549 | @node The NSE Client-Service Protocol | ||
5550 | @subsection The NSE Client-Service Protocol | ||
5551 | |||
5552 | @c %**end of header | ||
5553 | |||
5554 | As with the API, the client-service protocol is very simple, only has 2 | ||
5555 | different messages, defined in @code{src/nse/nse.h}: | ||
5556 | |||
5557 | @itemize @bullet | ||
5558 | @item @code{GNUNET_MESSAGE_TYPE_NSE_START}@ This message has no parameters | ||
5559 | and is sent from the client to the service upon connection. | ||
5560 | @item @code{GNUNET_MESSAGE_TYPE_NSE_ESTIMATE}@ This message is sent from | ||
5561 | the service to the client for every new estimate and upon connection. | ||
5562 | Contains a timestamp for the estimate, the average and the standard | ||
5563 | deviation for the respective round. | ||
5564 | @end itemize | ||
5565 | |||
5566 | When the @code{GNUNET_NSE_disconnect} API call is executed, the client | ||
5567 | simply disconnects from the service, with no message involved. | ||
5568 | |||
5569 | @cindex NSE Peer-to-Peer Protocol | ||
5570 | @node The NSE Peer-to-Peer Protocol | ||
5571 | @subsection The NSE Peer-to-Peer Protocol | ||
5572 | |||
5573 | @c %**end of header | ||
5574 | |||
5575 | The NSE subsystem only has one message in the P2P protocol, the | ||
5576 | @code{GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD} message. | ||
5577 | |||
5578 | This message key contents are the timestamp to identify the round | ||
5579 | (differences in system clocks may cause some peers to send messages way | ||
5580 | too early or way too late, so the timestamp allows other peers to | ||
5581 | identify such messages easily), the | ||
5582 | @uref{http://en.wikipedia.org/wiki/Proof-of-work_system, proof of work} | ||
5583 | used to make it difficult to mount a | ||
5584 | @uref{http://en.wikipedia.org/wiki/Sybil_attack, Sybil attack}, and the | ||
5585 | public key, which is used to verify the signature on the message. | ||
5586 | |||
5587 | Every peer stores a message for the previous, current and next round. The | ||
5588 | messages for the previous and current round are given to peers that | ||
5589 | connect to us. The message for the next round is simply stored until our | ||
5590 | system clock advances to the next round. The message for the current round | ||
5591 | is what we are flooding the network with right now. | ||
5592 | At the beginning of each round the peer does the following: | ||
5593 | |||
5594 | @itemize @bullet | ||
5595 | @item calculates its own distance to the target value | ||
5596 | @item creates, signs and stores the message for the current round (unless | ||
5597 | it has a better message in the "next round" slot which came early in the | ||
5598 | previous round) | ||
5599 | @item calculates, based on the stored round message (own or received) when | ||
5600 | to start flooding it to its neighbors | ||
5601 | @end itemize | ||
5602 | |||
5603 | Upon receiving a message the peer checks the validity of the message | ||
5604 | (round, proof of work, signature). The next action depends on the | ||
5605 | contents of the incoming message: | ||
5606 | |||
5607 | @itemize @bullet | ||
5608 | @item if the message is worse than the current stored message, the peer | ||
5609 | sends the current message back immediately, to stop the other peer from | ||
5610 | spreading suboptimal results | ||
5611 | @item if the message is better than the current stored message, the peer | ||
5612 | stores the new message and calculates the new target time to start | ||
5613 | spreading it to its neighbors (excluding the one the message came from) | ||
5614 | @item if the message is for the previous round, it is compared to the | ||
5615 | message stored in the "previous round slot", which may then be updated | ||
5616 | @item if the message is for the next round, it is compared to the message | ||
5617 | stored in the "next round slot", which again may then be updated | ||
5618 | @end itemize | ||
5619 | |||
5620 | Finally, when it comes to send the stored message for the current round to | ||
5621 | the neighbors there is a random delay added for each neighbor, to avoid | ||
5622 | traffic spikes and minimize cross-messages. | ||
5623 | |||
5624 | @cindex HOSTLIST Subsystem | ||
5625 | @node HOSTLIST Subsystem | ||
5626 | @section HOSTLIST Subsystem | ||
5627 | |||
5628 | @c %**end of header | ||
5629 | |||
5630 | Peers in the GNUnet overlay network need address information so that they | ||
5631 | can connect with other peers. GNUnet uses so called HELLO messages to | ||
5632 | store and exchange peer addresses. | ||
5633 | GNUnet provides several methods for peers to obtain this information: | ||
5634 | |||
5635 | @itemize @bullet | ||
5636 | @item out-of-band exchange of HELLO messages (manually, using for example | ||
5637 | gnunet-peerinfo) | ||
5638 | @item HELLO messages shipped with GNUnet (automatic with distribution) | ||
5639 | @item UDP neighbor discovery in LAN (IPv4 broadcast, IPv6 multicast) | ||
5640 | @item topology gossiping (learning from other peers we already connected | ||
5641 | to), and | ||
5642 | @item the HOSTLIST daemon covered in this section, which is particularly | ||
5643 | relevant for bootstrapping new peers. | ||
5644 | @end itemize | ||
5645 | |||
5646 | New peers have no existing connections (and thus cannot learn from gossip | ||
5647 | among peers), may not have other peers in their LAN and might be started | ||
5648 | with an outdated set of HELLO messages from the distribution. | ||
5649 | In this case, getting new peers to connect to the network requires either | ||
5650 | manual effort or the use of a HOSTLIST to obtain HELLOs. | ||
5651 | |||
5652 | @menu | ||
5653 | * HELLOs:: | ||
5654 | * Overview for the HOSTLIST subsystem:: | ||
5655 | * Interacting with the HOSTLIST daemon:: | ||
5656 | * Hostlist security address validation:: | ||
5657 | * The HOSTLIST daemon:: | ||
5658 | * The HOSTLIST server:: | ||
5659 | * The HOSTLIST client:: | ||
5660 | * Usage:: | ||
5661 | @end menu | ||
5662 | |||
5663 | @node HELLOs | ||
5664 | @subsection HELLOs | ||
5665 | |||
5666 | @c %**end of header | ||
5667 | |||
5668 | The basic information peers require to connect to other peers are | ||
5669 | contained in so called HELLO messages you can think of as a business card. | ||
5670 | Besides the identity of the peer (based on the cryptographic public key) a | ||
5671 | HELLO message may contain address information that specifies ways to | ||
5672 | contact a peer. By obtaining HELLO messages, a peer can learn how to | ||
5673 | contact other peers. | ||
5674 | |||
5675 | @node Overview for the HOSTLIST subsystem | ||
5676 | @subsection Overview for the HOSTLIST subsystem | ||
5677 | |||
5678 | @c %**end of header | ||
5679 | |||
5680 | The HOSTLIST subsystem provides a way to distribute and obtain contact | ||
5681 | information to connect to other peers using a simple HTTP GET request. | ||
5682 | It's implementation is split in three parts, the main file for the daemon | ||
5683 | itself (@file{gnunet-daemon-hostlist.c}), the HTTP client used to download | ||
5684 | peer information (@file{hostlist-client.c}) and the server component used | ||
5685 | to provide this information to other peers (@file{hostlist-server.c}). | ||
5686 | The server is basically a small HTTP web server (based on GNU | ||
5687 | libmicrohttpd) which provides a list of HELLOs known to the local peer for | ||
5688 | download. The client component is basically a HTTP client | ||
5689 | (based on libcurl) which can download hostlists from one or more websites. | ||
5690 | The hostlist format is a binary blob containing a sequence of HELLO | ||
5691 | messages. Note that any HTTP server can theoretically serve a hostlist, | ||
5692 | the build-in hostlist server makes it simply convenient to offer this | ||
5693 | service. | ||
5694 | |||
5695 | |||
5696 | @menu | ||
5697 | * Features:: | ||
5698 | * HOSTLIST - Limitations:: | ||
5699 | @end menu | ||
5700 | |||
5701 | @node Features | ||
5702 | @subsubsection Features | ||
5703 | |||
5704 | @c %**end of header | ||
5705 | |||
5706 | The HOSTLIST daemon can: | ||
5707 | |||
5708 | @itemize @bullet | ||
5709 | @item provide HELLO messages with validated addresses obtained from | ||
5710 | PEERINFO to download for other peers | ||
5711 | @item download HELLO messages and forward these message to the TRANSPORT | ||
5712 | subsystem for validation | ||
5713 | @item advertises the URL of this peer's hostlist address to other peers | ||
5714 | via gossip | ||
5715 | @item automatically learn about hostlist servers from the gossip of other | ||
5716 | peers | ||
5717 | @end itemize | ||
5718 | |||
5719 | @node HOSTLIST - Limitations | ||
5720 | @subsubsection HOSTLIST - Limitations | ||
5721 | |||
5722 | @c %**end of header | ||
5723 | |||
5724 | The HOSTLIST daemon does not: | ||
5725 | |||
5726 | @itemize @bullet | ||
5727 | @item verify the cryptographic information in the HELLO messages | ||
5728 | @item verify the address information in the HELLO messages | ||
5729 | @end itemize | ||
5730 | |||
5731 | @node Interacting with the HOSTLIST daemon | ||
5732 | @subsection Interacting with the HOSTLIST daemon | ||
5733 | |||
5734 | @c %**end of header | ||
5735 | |||
5736 | The HOSTLIST subsystem is currently implemented as a daemon, so there is | ||
5737 | no need for the user to interact with it and therefore there is no | ||
5738 | command line tool and no API to communicate with the daemon. In the | ||
5739 | future, we can envision changing this to allow users to manually trigger | ||
5740 | the download of a hostlist. | ||
5741 | |||
5742 | Since there is no command line interface to interact with HOSTLIST, the | ||
5743 | only way to interact with the hostlist is to use STATISTICS to obtain or | ||
5744 | modify information about the status of HOSTLIST: | ||
5745 | |||
5746 | @example | ||
5747 | $ gnunet-statistics -s hostlist | ||
5748 | @end example | ||
5749 | |||
5750 | @noindent | ||
5751 | In particular, HOSTLIST includes a @strong{persistent} value in statistics | ||
5752 | that specifies when the hostlist server might be queried next. As this | ||
5753 | value is exponentially increasing during runtime, developers may want to | ||
5754 | reset or manually adjust it. Note that HOSTLIST (but not STATISTICS) needs | ||
5755 | to be shutdown if changes to this value are to have any effect on the | ||
5756 | daemon (as HOSTLIST does not monitor STATISTICS for changes to the | ||
5757 | download frequency). | ||
5758 | |||
5759 | @node Hostlist security address validation | ||
5760 | @subsection Hostlist security address validation | ||
5761 | |||
5762 | @c %**end of header | ||
5763 | |||
5764 | Since information obtained from other parties cannot be trusted without | ||
5765 | validation, we have to distinguish between @emph{validated} and | ||
5766 | @emph{not validated} addresses. Before using (and so trusting) | ||
5767 | information from other parties, this information has to be double-checked | ||
5768 | (validated). Address validation is not done by HOSTLIST but by the | ||
5769 | TRANSPORT service. | ||
5770 | |||
5771 | The HOSTLIST component is functionally located between the PEERINFO and | ||
5772 | the TRANSPORT subsystem. When acting as a server, the daemon obtains valid | ||
5773 | (@emph{validated}) peer information (HELLO messages) from the PEERINFO | ||
5774 | service and provides it to other peers. When acting as a client, it | ||
5775 | contacts the HOSTLIST servers specified in the configuration, downloads | ||
5776 | the (unvalidated) list of HELLO messages and forwards these information | ||
5777 | to the TRANSPORT server to validate the addresses. | ||
5778 | |||
5779 | @cindex HOSTLIST daemon | ||
5780 | @node The HOSTLIST daemon | ||
5781 | @subsection The HOSTLIST daemon | ||
5782 | |||
5783 | @c %**end of header | ||
5784 | |||
5785 | The hostlist daemon is the main component of the HOSTLIST subsystem. It is | ||
5786 | started by the ARM service and (if configured) starts the HOSTLIST client | ||
5787 | and server components. | ||
5788 | |||
5789 | If the daemon provides a hostlist itself it can advertise it's own | ||
5790 | hostlist to other peers. To do so it sends a | ||
5791 | @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} message to other peers | ||
5792 | when they connect to this peer on the CORE level. This hostlist | ||
5793 | advertisement message contains the URL to access the HOSTLIST HTTP | ||
5794 | server of the sender. The daemon may also subscribe to this type of | ||
5795 | message from CORE service, and then forward these kind of message to the | ||
5796 | HOSTLIST client. The client then uses all available URLs to download peer | ||
5797 | information when necessary. | ||
5798 | |||
5799 | When starting, the HOSTLIST daemon first connects to the CORE subsystem | ||
5800 | and if hostlist learning is enabled, registers a CORE handler to receive | ||
5801 | this kind of messages. Next it starts (if configured) the client and | ||
5802 | server. It passes pointers to CORE connect and disconnect and receive | ||
5803 | handlers where the client and server store their functions, so the daemon | ||
5804 | can notify them about CORE events. | ||
5805 | |||
5806 | To clean up on shutdown, the daemon has a cleaning task, shutting down all | ||
5807 | subsystems and disconnecting from CORE. | ||
5808 | |||
5809 | @cindex HOSTLIST server | ||
5810 | @node The HOSTLIST server | ||
5811 | @subsection The HOSTLIST server | ||
5812 | |||
5813 | @c %**end of header | ||
5814 | |||
5815 | The server provides a way for other peers to obtain HELLOs. Basically it | ||
5816 | is a small web server other peers can connect to and download a list of | ||
5817 | HELLOs using standard HTTP; it may also advertise the URL of the hostlist | ||
5818 | to other peers connecting on CORE level. | ||
5819 | |||
5820 | |||
5821 | @menu | ||
5822 | * The HTTP Server:: | ||
5823 | * Advertising the URL:: | ||
5824 | @end menu | ||
5825 | |||
5826 | @node The HTTP Server | ||
5827 | @subsubsection The HTTP Server | ||
5828 | |||
5829 | @c %**end of header | ||
5830 | |||
5831 | During startup, the server starts a web server listening on the port | ||
5832 | specified with the HTTPPORT value (default 8080). In addition it connects | ||
5833 | to the PEERINFO service to obtain peer information. The HOSTLIST server | ||
5834 | uses the GNUNET_PEERINFO_iterate function to request HELLO information for | ||
5835 | all peers and adds their information to a new hostlist if they are | ||
5836 | suitable (expired addresses and HELLOs without addresses are both not | ||
5837 | suitable) and the maximum size for a hostlist is not exceeded | ||
5838 | (MAX_BYTES_PER_HOSTLISTS = 500000). | ||
5839 | When PEERINFO finishes (with a last NULL callback), the server destroys | ||
5840 | the previous hostlist response available for download on the web server | ||
5841 | and replaces it with the updated hostlist. The hostlist format is | ||
5842 | basically a sequence of HELLO messages (as obtained from PEERINFO) without | ||
5843 | any special tokenization. Since each HELLO message contains a size field, | ||
5844 | the response can easily be split into separate HELLO messages by the | ||
5845 | client. | ||
5846 | |||
5847 | A HOSTLIST client connecting to the HOSTLIST server will receive the | ||
5848 | hostlist as a HTTP response and the the server will terminate the | ||
5849 | connection with the result code @code{HTTP 200 OK}. | ||
5850 | The connection will be closed immediately if no hostlist is available. | ||
5851 | |||
5852 | @node Advertising the URL | ||
5853 | @subsubsection Advertising the URL | ||
5854 | |||
5855 | @c %**end of header | ||
5856 | |||
5857 | The server also advertises the URL to download the hostlist to other peers | ||
5858 | if hostlist advertisement is enabled. | ||
5859 | When a new peer connects and has hostlist learning enabled, the server | ||
5860 | sends a @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} message to this | ||
5861 | peer using the CORE service. | ||
5862 | |||
5863 | @cindex HOSTLIST client | ||
5864 | @node The HOSTLIST client | ||
5865 | @subsection The HOSTLIST client | ||
5866 | |||
5867 | @c %**end of header | ||
5868 | |||
5869 | The client provides the functionality to download the list of HELLOs from | ||
5870 | a set of URLs. | ||
5871 | It performs a standard HTTP request to the URLs configured and learned | ||
5872 | from advertisement messages received from other peers. When a HELLO is | ||
5873 | downloaded, the HOSTLIST client forwards the HELLO to the TRANSPORT | ||
5874 | service for validation. | ||
5875 | |||
5876 | The client supports two modes of operation: | ||
5877 | |||
5878 | @itemize @bullet | ||
5879 | @item download of HELLOs (bootstrapping) | ||
5880 | @item learning of URLs | ||
5881 | @end itemize | ||
5882 | |||
5883 | @menu | ||
5884 | * Bootstrapping:: | ||
5885 | * Learning:: | ||
5886 | @end menu | ||
5887 | |||
5888 | @node Bootstrapping | ||
5889 | @subsubsection Bootstrapping | ||
5890 | |||
5891 | @c %**end of header | ||
5892 | |||
5893 | For bootstrapping, it schedules a task to download the hostlist from the | ||
5894 | set of known URLs. | ||
5895 | The downloads are only performed if the number of current | ||
5896 | connections is smaller than a minimum number of connections | ||
5897 | (at the moment 4). | ||
5898 | The interval between downloads increases exponentially; however, the | ||
5899 | exponential growth is limited if it becomes longer than an hour. | ||
5900 | At that point, the frequency growth is capped at | ||
5901 | (#number of connections * 1h). | ||
5902 | |||
5903 | Once the decision has been taken to download HELLOs, the daemon chooses a | ||
5904 | random URL from the list of known URLs. URLs can be configured in the | ||
5905 | configuration or be learned from advertisement messages. | ||
5906 | The client uses a HTTP client library (libcurl) to initiate the download | ||
5907 | using the libcurl multi interface. | ||
5908 | Libcurl passes the data to the callback_download function which | ||
5909 | stores the data in a buffer if space is available and the maximum size for | ||
5910 | a hostlist download is not exceeded (MAX_BYTES_PER_HOSTLISTS = 500000). | ||
5911 | When a full HELLO was downloaded, the HOSTLIST client offers this | ||
5912 | HELLO message to the TRANSPORT service for validation. | ||
5913 | When the download is finished or failed, statistical information about the | ||
5914 | quality of this URL is updated. | ||
5915 | |||
5916 | @cindex HOSTLIST learning | ||
5917 | @node Learning | ||
5918 | @subsubsection Learning | ||
5919 | |||
5920 | @c %**end of header | ||
5921 | |||
5922 | The client also manages hostlist advertisements from other peers. The | ||
5923 | HOSTLIST daemon forwards @code{GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT} | ||
5924 | messages to the client subsystem, which extracts the URL from the message. | ||
5925 | Next, a test of the newly obtained URL is performed by triggering a | ||
5926 | download from the new URL. If the URL works correctly, it is added to the | ||
5927 | list of working URLs. | ||
5928 | |||
5929 | The size of the list of URLs is restricted, so if an additional server is | ||
5930 | added and the list is full, the URL with the worst quality ranking | ||
5931 | (determined through successful downloads and number of HELLOs e.g.) is | ||
5932 | discarded. During shutdown the list of URLs is saved to a file for | ||
5933 | persistance and loaded on startup. URLs from the configuration file are | ||
5934 | never discarded. | ||
5935 | |||
5936 | @node Usage | ||
5937 | @subsection Usage | ||
5938 | |||
5939 | @c %**end of header | ||
5940 | |||
5941 | To start HOSTLIST by default, it has to be added to the DEFAULTSERVICES | ||
5942 | section for the ARM services. This is done in the default configuration. | ||
5943 | |||
5944 | For more information on how to configure the HOSTLIST subsystem see the | ||
5945 | installation handbook:@ | ||
5946 | Configuring the hostlist to bootstrap@ | ||
5947 | Configuring your peer to provide a hostlist | ||
5948 | |||
5949 | @cindex IDENTITY Subsystem | ||
5950 | @node IDENTITY Subsystem | ||
5951 | @section IDENTITY Subsystem | ||
5952 | |||
5953 | @c %**end of header | ||
5954 | |||
5955 | Identities of "users" in GNUnet are called egos. | ||
5956 | Egos can be used as pseudonyms ("fake names") or be tied to an | ||
5957 | organization (for example, "GNU") or even the actual identity of a human. | ||
5958 | GNUnet users are expected to have many egos. They might have one tied to | ||
5959 | their real identity, some for organizations they manage, and more for | ||
5960 | different domains where they want to operate under a pseudonym. | ||
5961 | |||
5962 | The IDENTITY service allows users to manage their egos. The identity | ||
5963 | service manages the private keys egos of the local user; it does not | ||
5964 | manage identities of other users (public keys). Public keys for other | ||
5965 | users need names to become manageable. GNUnet uses the | ||
5966 | @dfn{GNU Name System} (GNS) to give names to other users and manage their | ||
5967 | public keys securely. This chapter is about the IDENTITY service, | ||
5968 | which is about the management of private keys. | ||
5969 | |||
5970 | On the network, an ego corresponds to an ECDSA key (over Curve25519, | ||
5971 | using RFC 6979, as required by GNS). Thus, users can perform actions | ||
5972 | under a particular ego by using (signing with) a particular private key. | ||
5973 | Other users can then confirm that the action was really performed by that | ||
5974 | ego by checking the signature against the respective public key. | ||
5975 | |||
5976 | The IDENTITY service allows users to associate a human-readable name with | ||
5977 | each ego. This way, users can use names that will remind them of the | ||
5978 | purpose of a particular ego. | ||
5979 | The IDENTITY service will store the respective private keys and | ||
5980 | allows applications to access key information by name. | ||
5981 | Users can change the name that is locally (!) associated with an ego. | ||
5982 | Egos can also be deleted, which means that the private key will be removed | ||
5983 | and it thus will not be possible to perform actions with that ego in the | ||
5984 | future. | ||
5985 | |||
5986 | Additionally, the IDENTITY subsystem can associate service functions with | ||
5987 | egos. | ||
5988 | For example, GNS requires the ego that should be used for the shorten | ||
5989 | zone. GNS will ask IDENTITY for an ego for the "gns-short" service. | ||
5990 | The IDENTITY service has a mapping of such service strings to the name of | ||
5991 | the ego that the user wants to use for this service, for example | ||
5992 | "my-short-zone-ego". | ||
5993 | |||
5994 | Finally, the IDENTITY API provides access to a special ego, the | ||
5995 | anonymous ego. The anonymous ego is special in that its private key is not | ||
5996 | really private, but fixed and known to everyone. | ||
5997 | Thus, anyone can perform actions as anonymous. This can be useful as with | ||
5998 | this trick, code does not have to contain a special case to distinguish | ||
5999 | between anonymous and pseudonymous egos. | ||
6000 | |||
6001 | @menu | ||
6002 | * libgnunetidentity:: | ||
6003 | * The IDENTITY Client-Service Protocol:: | ||
6004 | @end menu | ||
6005 | |||
6006 | @cindex libgnunetidentity | ||
6007 | @node libgnunetidentity | ||
6008 | @subsection libgnunetidentity | ||
6009 | @c %**end of header | ||
6010 | |||
6011 | |||
6012 | @menu | ||
6013 | * Connecting to the service:: | ||
6014 | * Operations on Egos:: | ||
6015 | * The anonymous Ego:: | ||
6016 | * Convenience API to lookup a single ego:: | ||
6017 | * Associating egos with service functions:: | ||
6018 | @end menu | ||
6019 | |||
6020 | @node Connecting to the service | ||
6021 | @subsubsection Connecting to the service | ||
6022 | |||
6023 | @c %**end of header | ||
6024 | |||
6025 | First, typical clients connect to the identity service using | ||
6026 | @code{GNUNET_IDENTITY_connect}. This function takes a callback as a | ||
6027 | parameter. | ||
6028 | If the given callback parameter is non-null, it will be invoked to notify | ||
6029 | the application about the current state of the identities in the system. | ||
6030 | |||
6031 | @itemize @bullet | ||
6032 | @item First, it will be invoked on all known egos at the time of the | ||
6033 | connection. For each ego, a handle to the ego and the user's name for the | ||
6034 | ego will be passed to the callback. Furthermore, a @code{void **} context | ||
6035 | argument will be provided which gives the client the opportunity to | ||
6036 | associate some state with the ego. | ||
6037 | @item Second, the callback will be invoked with NULL for the ego, the name | ||
6038 | and the context. This signals that the (initial) iteration over all egos | ||
6039 | has completed. | ||
6040 | @item Then, the callback will be invoked whenever something changes about | ||
6041 | an ego. | ||
6042 | If an ego is renamed, the callback is invoked with the ego handle of the | ||
6043 | ego that was renamed, and the new name. If an ego is deleted, the callback | ||
6044 | is invoked with the ego handle and a name of NULL. In the deletion case, | ||
6045 | the application should also release resources stored in the context. | ||
6046 | @item When the application destroys the connection to the identity service | ||
6047 | using @code{GNUNET_IDENTITY_disconnect}, the callback is again invoked | ||
6048 | with the ego and a name of NULL (equivalent to deletion of the egos). | ||
6049 | This should again be used to clean up the per-ego context. | ||
6050 | @end itemize | ||
6051 | |||
6052 | The ego handle passed to the callback remains valid until the callback is | ||
6053 | invoked with a name of NULL, so it is safe to store a reference to the | ||
6054 | ego's handle. | ||
6055 | |||
6056 | @node Operations on Egos | ||
6057 | @subsubsection Operations on Egos | ||
6058 | |||
6059 | @c %**end of header | ||
6060 | |||
6061 | Given an ego handle, the main operations are to get its associated private | ||
6062 | key using @code{GNUNET_IDENTITY_ego_get_private_key} or its associated | ||
6063 | public key using @code{GNUNET_IDENTITY_ego_get_public_key}. | ||
6064 | |||
6065 | The other operations on egos are pretty straightforward. | ||
6066 | Using @code{GNUNET_IDENTITY_create}, an application can request the | ||
6067 | creation of an ego by specifying the desired name. | ||
6068 | The operation will fail if that name is | ||
6069 | already in use. Using @code{GNUNET_IDENTITY_rename} the name of an | ||
6070 | existing ego can be changed. Finally, egos can be deleted using | ||
6071 | @code{GNUNET_IDENTITY_delete}. All of these operations will trigger | ||
6072 | updates to the callback given to the @code{GNUNET_IDENTITY_connect} | ||
6073 | function of all applications that are connected with the identity service | ||
6074 | at the time. @code{GNUNET_IDENTITY_cancel} can be used to cancel the | ||
6075 | operations before the respective continuations would be called. | ||
6076 | It is not guaranteed that the operation will not be completed anyway, | ||
6077 | only the continuation will no longer be called. | ||
6078 | |||
6079 | @node The anonymous Ego | ||
6080 | @subsubsection The anonymous Ego | ||
6081 | |||
6082 | @c %**end of header | ||
6083 | |||
6084 | A special way to obtain an ego handle is to call | ||
6085 | @code{GNUNET_IDENTITY_ego_get_anonymous}, which returns an ego for the | ||
6086 | "anonymous" user --- anyone knows and can get the private key for this | ||
6087 | user, so it is suitable for operations that are supposed to be anonymous | ||
6088 | but require signatures (for example, to avoid a special path in the code). | ||
6089 | The anonymous ego is always valid and accessing it does not require a | ||
6090 | connection to the identity service. | ||
6091 | |||
6092 | @node Convenience API to lookup a single ego | ||
6093 | @subsubsection Convenience API to lookup a single ego | ||
6094 | |||
6095 | |||
6096 | As applications commonly simply have to lookup a single ego, there is a | ||
6097 | convenience API to do just that. Use @code{GNUNET_IDENTITY_ego_lookup} to | ||
6098 | lookup a single ego by name. Note that this is the user's name for the | ||
6099 | ego, not the service function. The resulting ego will be returned via a | ||
6100 | callback and will only be valid during that callback. The operation can | ||
6101 | be canceled via @code{GNUNET_IDENTITY_ego_lookup_cancel} | ||
6102 | (cancellation is only legal before the callback is invoked). | ||
6103 | |||
6104 | @node Associating egos with service functions | ||
6105 | @subsubsection Associating egos with service functions | ||
6106 | |||
6107 | |||
6108 | The @code{GNUNET_IDENTITY_set} function is used to associate a particular | ||
6109 | ego with a service function. The name used by the service and the ego are | ||
6110 | given as arguments. | ||
6111 | Afterwards, the service can use its name to lookup the associated ego | ||
6112 | using @code{GNUNET_IDENTITY_get}. | ||
6113 | |||
6114 | @node The IDENTITY Client-Service Protocol | ||
6115 | @subsection The IDENTITY Client-Service Protocol | ||
6116 | |||
6117 | @c %**end of header | ||
6118 | |||
6119 | A client connecting to the identity service first sends a message with | ||
6120 | type | ||
6121 | @code{GNUNET_MESSAGE_TYPE_IDENTITY_START} to the service. After that, the | ||
6122 | client will receive information about changes to the egos by receiving | ||
6123 | messages of type @code{GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE}. | ||
6124 | Those messages contain the private key of the ego and the user's name of | ||
6125 | the ego (or zero bytes for the name to indicate that the ego was deleted). | ||
6126 | A special bit @code{end_of_list} is used to indicate the end of the | ||
6127 | initial iteration over the identity service's egos. | ||
6128 | |||
6129 | The client can trigger changes to the egos by sending @code{CREATE}, | ||
6130 | @code{RENAME} or @code{DELETE} messages. | ||
6131 | The CREATE message contains the private key and the desired name.@ | ||
6132 | The RENAME message contains the old name and the new name.@ | ||
6133 | The DELETE message only needs to include the name of the ego to delete.@ | ||
6134 | The service responds to each of these messages with a @code{RESULT_CODE} | ||
6135 | message which indicates success or error of the operation, and possibly | ||
6136 | a human-readable error message. | ||
6137 | |||
6138 | Finally, the client can bind the name of a service function to an ego by | ||
6139 | sending a @code{SET_DEFAULT} message with the name of the service function | ||
6140 | and the private key of the ego. | ||
6141 | Such bindings can then be resolved using a @code{GET_DEFAULT} message, | ||
6142 | which includes the name of the service function. The identity service | ||
6143 | will respond to a GET_DEFAULT request with a SET_DEFAULT message | ||
6144 | containing the respective information, or with a RESULT_CODE to | ||
6145 | indicate an error. | ||
6146 | |||
6147 | @cindex NAMESTORE Subsystem | ||
6148 | @node NAMESTORE Subsystem | ||
6149 | @section NAMESTORE Subsystem | ||
6150 | |||
6151 | The NAMESTORE subsystem provides persistent storage for local GNS zone | ||
6152 | information. All local GNS zone information are managed by NAMESTORE. It | ||
6153 | provides both the functionality to administer local GNS information (e.g. | ||
6154 | delete and add records) as well as to retrieve GNS information (e.g to | ||
6155 | list name information in a client). | ||
6156 | NAMESTORE does only manage the persistent storage of zone information | ||
6157 | belonging to the user running the service: GNS information from other | ||
6158 | users obtained from the DHT are stored by the NAMECACHE subsystem. | ||
6159 | |||
6160 | NAMESTORE uses a plugin-based database backend to store GNS information | ||
6161 | with good performance. Here sqlite, MySQL and PostgreSQL are supported | ||
6162 | database backends. | ||
6163 | NAMESTORE clients interact with the IDENTITY subsystem to obtain | ||
6164 | cryptographic information about zones based on egos as described with the | ||
6165 | IDENTITY subsystem, but internally NAMESTORE refers to zones using the | ||
6166 | ECDSA private key. | ||
6167 | In addition, it collaborates with the NAMECACHE subsystem and | ||
6168 | stores zone information when local information are modified in the | ||
6169 | GNS cache to increase look-up performance for local information. | ||
6170 | |||
6171 | NAMESTORE provides functionality to look-up and store records, to iterate | ||
6172 | over a specific or all zones and to monitor zones for changes. NAMESTORE | ||
6173 | functionality can be accessed using the NAMESTORE api or the NAMESTORE | ||
6174 | command line tool. | ||
6175 | |||
6176 | @menu | ||
6177 | * libgnunetnamestore:: | ||
6178 | @end menu | ||
6179 | |||
6180 | @cindex libgnunetnamestore | ||
6181 | @node libgnunetnamestore | ||
6182 | @subsection libgnunetnamestore | ||
6183 | |||
6184 | To interact with NAMESTORE clients first connect to the NAMESTORE service | ||
6185 | using the @code{GNUNET_NAMESTORE_connect} passing a configuration handle. | ||
6186 | As a result they obtain a NAMESTORE handle, they can use for operations, | ||
6187 | or NULL is returned if the connection failed. | ||
6188 | |||
6189 | To disconnect from NAMESTORE, clients use | ||
6190 | @code{GNUNET_NAMESTORE_disconnect} and specify the handle to disconnect. | ||
6191 | |||
6192 | NAMESTORE internally uses the ECDSA private key to refer to zones. These | ||
6193 | private keys can be obtained from the IDENTITY subsytem. | ||
6194 | Here @emph{egos} @emph{can be used to refer to zones or the default ego | ||
6195 | assigned to the GNS subsystem can be used to obtained the master zone's | ||
6196 | private key.} | ||
6197 | |||
6198 | |||
6199 | @menu | ||
6200 | * Editing Zone Information:: | ||
6201 | * Iterating Zone Information:: | ||
6202 | * Monitoring Zone Information:: | ||
6203 | @end menu | ||
6204 | |||
6205 | @node Editing Zone Information | ||
6206 | @subsubsection Editing Zone Information | ||
6207 | |||
6208 | @c %**end of header | ||
6209 | |||
6210 | NAMESTORE provides functions to lookup records stored under a label in a | ||
6211 | zone and to store records under a label in a zone. | ||
6212 | |||
6213 | To store (and delete) records, the client uses the | ||
6214 | @code{GNUNET_NAMESTORE_records_store} function and has to provide | ||
6215 | namestore handle to use, the private key of the zone, the label to store | ||
6216 | the records under, the records and number of records plus an callback | ||
6217 | function. | ||
6218 | After the operation is performed NAMESTORE will call the provided | ||
6219 | callback function with the result GNUNET_SYSERR on failure | ||
6220 | (including timeout/queue drop/failure to validate), GNUNET_NO if content | ||
6221 | was already there or not found GNUNET_YES (or other positive value) on | ||
6222 | success plus an additional error message. | ||
6223 | |||
6224 | Records are deleted by using the store command with 0 records to store. | ||
6225 | It is important to note, that records are not merged when records exist | ||
6226 | with the label. | ||
6227 | So a client has first to retrieve records, merge with existing records | ||
6228 | and then store the result. | ||
6229 | |||
6230 | To perform a lookup operation, the client uses the | ||
6231 | @code{GNUNET_NAMESTORE_records_store} function. Here it has to pass the | ||
6232 | namestore handle, the private key of the zone and the label. It also has | ||
6233 | to provide a callback function which will be called with the result of | ||
6234 | the lookup operation: | ||
6235 | the zone for the records, the label, and the records including the | ||
6236 | number of records included. | ||
6237 | |||
6238 | A special operation is used to set the preferred nickname for a zone. | ||
6239 | This nickname is stored with the zone and is automatically merged with | ||
6240 | all labels and records stored in a zone. Here the client uses the | ||
6241 | @code{GNUNET_NAMESTORE_set_nick} function and passes the private key of | ||
6242 | the zone, the nickname as string plus a the callback with the result of | ||
6243 | the operation. | ||
6244 | |||
6245 | @node Iterating Zone Information | ||
6246 | @subsubsection Iterating Zone Information | ||
6247 | |||
6248 | @c %**end of header | ||
6249 | |||
6250 | A client can iterate over all information in a zone or all zones managed | ||
6251 | by NAMESTORE. | ||
6252 | Here a client uses the @code{GNUNET_NAMESTORE_zone_iteration_start} | ||
6253 | function and passes the namestore handle, the zone to iterate over and a | ||
6254 | callback function to call with the result. | ||
6255 | If the client wants to iterate over all the WHAT!? FIXME, it passes NULL for the zone. | ||
6256 | A @code{GNUNET_NAMESTORE_ZoneIterator} handle is returned to be used to | ||
6257 | continue iteration. | ||
6258 | |||
6259 | NAMESTORE calls the callback for every result and expects the client to | ||
6260 | call @code{GNUNET_NAMESTORE_zone_iterator_next} to continue to iterate or | ||
6261 | @code{GNUNET_NAMESTORE_zone_iterator_stop} to interrupt the iteration. | ||
6262 | When NAMESTORE reached the last item it will call the callback with a | ||
6263 | NULL value to indicate. | ||
6264 | |||
6265 | @node Monitoring Zone Information | ||
6266 | @subsubsection Monitoring Zone Information | ||
6267 | |||
6268 | @c %**end of header | ||
6269 | |||
6270 | Clients can also monitor zones to be notified about changes. Here the | ||
6271 | clients uses the @code{GNUNET_NAMESTORE_zone_monitor_start} function and | ||
6272 | passes the private key of the zone and and a callback function to call | ||
6273 | with updates for a zone. | ||
6274 | The client can specify to obtain zone information first by iterating over | ||
6275 | the zone and specify a synchronization callback to be called when the | ||
6276 | client and the namestore are synced. | ||
6277 | |||
6278 | On an update, NAMESTORE will call the callback with the private key of the | ||
6279 | zone, the label and the records and their number. | ||
6280 | |||
6281 | To stop monitoring, the client calls | ||
6282 | @code{GNUNET_NAMESTORE_zone_monitor_stop} and passes the handle obtained | ||
6283 | from the function to start the monitoring. | ||
6284 | |||
6285 | @cindex PEERINFO Subsystem | ||
6286 | @node PEERINFO Subsystem | ||
6287 | @section PEERINFO Subsystem | ||
6288 | |||
6289 | @c %**end of header | ||
6290 | |||
6291 | The PEERINFO subsystem is used to store verified (validated) information | ||
6292 | about known peers in a persistent way. It obtains these addresses for | ||
6293 | example from TRANSPORT service which is in charge of address validation. | ||
6294 | Validation means that the information in the HELLO message are checked by | ||
6295 | connecting to the addresses and performing a cryptographic handshake to | ||
6296 | authenticate the peer instance stating to be reachable with these | ||
6297 | addresses. | ||
6298 | Peerinfo does not validate the HELLO messages itself but only stores them | ||
6299 | and gives them to interested clients. | ||
6300 | |||
6301 | As future work, we think about moving from storing just HELLO messages to | ||
6302 | providing a generic persistent per-peer information store. | ||
6303 | More and more subsystems tend to need to store per-peer information in | ||
6304 | persistent way. | ||
6305 | To not duplicate this functionality we plan to provide a PEERSTORE | ||
6306 | service providing this functionality. | ||
6307 | |||
6308 | @menu | ||
6309 | * PEERINFO - Features:: | ||
6310 | * PEERINFO - Limitations:: | ||
6311 | * DeveloperPeer Information:: | ||
6312 | * Startup:: | ||
6313 | * Managing Information:: | ||
6314 | * Obtaining Information:: | ||
6315 | * The PEERINFO Client-Service Protocol:: | ||
6316 | * libgnunetpeerinfo:: | ||
6317 | @end menu | ||
6318 | |||
6319 | @node PEERINFO - Features | ||
6320 | @subsection PEERINFO - Features | ||
6321 | |||
6322 | @c %**end of header | ||
6323 | |||
6324 | @itemize @bullet | ||
6325 | @item Persistent storage | ||
6326 | @item Client notification mechanism on update | ||
6327 | @item Periodic clean up for expired information | ||
6328 | @item Differentiation between public and friend-only HELLO | ||
6329 | @end itemize | ||
6330 | |||
6331 | @node PEERINFO - Limitations | ||
6332 | @subsection PEERINFO - Limitations | ||
6333 | |||
6334 | |||
6335 | @itemize @bullet | ||
6336 | @item Does not perform HELLO validation | ||
6337 | @end itemize | ||
6338 | |||
6339 | @node DeveloperPeer Information | ||
6340 | @subsection DeveloperPeer Information | ||
6341 | |||
6342 | @c %**end of header | ||
6343 | |||
6344 | The PEERINFO subsystem stores these information in the form of HELLO | ||
6345 | messages you can think of as business cards. | ||
6346 | These HELLO messages contain the public key of a peer and the addresses | ||
6347 | a peer can be reached under. | ||
6348 | The addresses include an expiration date describing how long they are | ||
6349 | valid. This information is updated regularly by the TRANSPORT service by | ||
6350 | revalidating the address. | ||
6351 | If an address is expired and not renewed, it can be removed from the | ||
6352 | HELLO message. | ||
6353 | |||
6354 | Some peer do not want to have their HELLO messages distributed to other | ||
6355 | peers, especially when GNUnet's friend-to-friend modus is enabled. | ||
6356 | To prevent this undesired distribution. PEERINFO distinguishes between | ||
6357 | @emph{public} and @emph{friend-only} HELLO messages. | ||
6358 | Public HELLO messages can be freely distributed to other (possibly | ||
6359 | unknown) peers (for example using the hostlist, gossiping, broadcasting), | ||
6360 | whereas friend-only HELLO messages may not be distributed to other peers. | ||
6361 | Friend-only HELLO messages have an additional flag @code{friend_only} set | ||
6362 | internally. For public HELLO message this flag is not set. | ||
6363 | PEERINFO does and cannot not check if a client is allowed to obtain a | ||
6364 | specific HELLO type. | ||
6365 | |||
6366 | The HELLO messages can be managed using the GNUnet HELLO library. | ||
6367 | Other GNUnet systems can obtain these information from PEERINFO and use | ||
6368 | it for their purposes. | ||
6369 | Clients are for example the HOSTLIST component providing these | ||
6370 | information to other peers in form of a hostlist or the TRANSPORT | ||
6371 | subsystem using these information to maintain connections to other peers. | ||
6372 | |||
6373 | @node Startup | ||
6374 | @subsection Startup | ||
6375 | |||
6376 | @c %**end of header | ||
6377 | |||
6378 | During startup the PEERINFO services loads persistent HELLOs from disk. | ||
6379 | First PEERINFO parses the directory configured in the HOSTS value of the | ||
6380 | @code{PEERINFO} configuration section to store PEERINFO information. | ||
6381 | For all files found in this directory valid HELLO messages are extracted. | ||
6382 | In addition it loads HELLO messages shipped with the GNUnet distribution. | ||
6383 | These HELLOs are used to simplify network bootstrapping by providing | ||
6384 | valid peer information with the distribution. | ||
6385 | The use of these HELLOs can be prevented by setting the | ||
6386 | @code{USE_INCLUDED_HELLOS} in the @code{PEERINFO} configuration section to | ||
6387 | @code{NO}. Files containing invalid information are removed. | ||
6388 | |||
6389 | @node Managing Information | ||
6390 | @subsection Managing Information | ||
6391 | |||
6392 | @c %**end of header | ||
6393 | |||
6394 | The PEERINFO services stores information about known PEERS and a single | ||
6395 | HELLO message for every peer. | ||
6396 | A peer does not need to have a HELLO if no information are available. | ||
6397 | HELLO information from different sources, for example a HELLO obtained | ||
6398 | from a remote HOSTLIST and a second HELLO stored on disk, are combined | ||
6399 | and merged into one single HELLO message per peer which will be given to | ||
6400 | clients. During this merge process the HELLO is immediately written to | ||
6401 | disk to ensure persistence. | ||
6402 | |||
6403 | PEERINFO in addition periodically scans the directory where information | ||
6404 | are stored for empty HELLO messages with expired TRANSPORT addresses. | ||
6405 | This periodic task scans all files in the directory and recreates the | ||
6406 | HELLO messages it finds. | ||
6407 | Expired TRANSPORT addresses are removed from the HELLO and if the | ||
6408 | HELLO does not contain any valid addresses, it is discarded and removed | ||
6409 | from the disk. | ||
6410 | |||
6411 | @node Obtaining Information | ||
6412 | @subsection Obtaining Information | ||
6413 | |||
6414 | @c %**end of header | ||
6415 | |||
6416 | When a client requests information from PEERINFO, PEERINFO performs a | ||
6417 | lookup for the respective peer or all peers if desired and transmits this | ||
6418 | information to the client. | ||
6419 | The client can specify if friend-only HELLOs have to be included or not | ||
6420 | and PEERINFO filters the respective HELLO messages before transmitting | ||
6421 | information. | ||
6422 | |||
6423 | To notify clients about changes to PEERINFO information, PEERINFO | ||
6424 | maintains a list of clients interested in this notifications. | ||
6425 | Such a notification occurs if a HELLO for a peer was updated (due to a | ||
6426 | merge for example) or a new peer was added. | ||
6427 | |||
6428 | @node The PEERINFO Client-Service Protocol | ||
6429 | @subsection The PEERINFO Client-Service Protocol | ||
6430 | |||
6431 | @c %**end of header | ||
6432 | |||
6433 | To connect and disconnect to and from the PEERINFO Service PEERINFO | ||
6434 | utilizes the util client/server infrastructure, so no special messages | ||
6435 | types are used here. | ||
6436 | |||
6437 | To add information for a peer, the plain HELLO message is transmitted to | ||
6438 | the service without any wrapping. All pieces of information required are | ||
6439 | stored within the HELLO message. | ||
6440 | The PEERINFO service provides a message handler accepting and processing | ||
6441 | these HELLO messages. | ||
6442 | |||
6443 | When obtaining PEERINFO information using the iterate functionality | ||
6444 | specific messages are used. To obtain information for all peers, a | ||
6445 | @code{struct ListAllPeersMessage} with message type | ||
6446 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL} and a flag | ||
6447 | include_friend_only to indicate if friend-only HELLO messages should be | ||
6448 | included are transmitted. If information for a specific peer is required | ||
6449 | a @code{struct ListAllPeersMessage} with | ||
6450 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_GET} containing the peer identity is | ||
6451 | used. | ||
6452 | |||
6453 | For both variants the PEERINFO service replies for each HELLO message it | ||
6454 | wants to transmit with a @code{struct ListAllPeersMessage} with type | ||
6455 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO} containing the plain HELLO. | ||
6456 | The final message is @code{struct GNUNET_MessageHeader} with type | ||
6457 | @code{GNUNET_MESSAGE_TYPE_PEERINFO_INFO}. If the client receives this | ||
6458 | message, it can proceed with the next request if any is pending. | ||
6459 | |||
6460 | @node libgnunetpeerinfo | ||
6461 | @subsection libgnunetpeerinfo | ||
6462 | |||
6463 | @c %**end of header | ||
6464 | |||
6465 | The PEERINFO API consists mainly of three different functionalities: | ||
6466 | |||
6467 | @itemize @bullet | ||
6468 | @item maintaining a connection to the service | ||
6469 | @item adding new information to the PEERINFO service | ||
6470 | @item retrieving information from the PEERINFO service | ||
6471 | @end itemize | ||
6472 | |||
6473 | @menu | ||
6474 | * Connecting to the PEERINFO Service:: | ||
6475 | * Adding Information to the PEERINFO Service:: | ||
6476 | * Obtaining Information from the PEERINFO Service:: | ||
6477 | @end menu | ||
6478 | |||
6479 | @node Connecting to the PEERINFO Service | ||
6480 | @subsubsection Connecting to the PEERINFO Service | ||
6481 | |||
6482 | @c %**end of header | ||
6483 | |||
6484 | To connect to the PEERINFO service the function | ||
6485 | @code{GNUNET_PEERINFO_connect} is used, taking a configuration handle as | ||
6486 | an argument, and to disconnect from PEERINFO the function | ||
6487 | @code{GNUNET_PEERINFO_disconnect}, taking the PEERINFO | ||
6488 | handle returned from the connect function has to be called. | ||
6489 | |||
6490 | @node Adding Information to the PEERINFO Service | ||
6491 | @subsubsection Adding Information to the PEERINFO Service | ||
6492 | |||
6493 | @c %**end of header | ||
6494 | |||
6495 | @code{GNUNET_PEERINFO_add_peer} adds a new peer to the PEERINFO subsystem | ||
6496 | storage. This function takes the PEERINFO handle as an argument, the HELLO | ||
6497 | message to store and a continuation with a closure to be called with the | ||
6498 | result of the operation. | ||
6499 | The @code{GNUNET_PEERINFO_add_peer} returns a handle to this operation | ||
6500 | allowing to cancel the operation with the respective cancel function | ||
6501 | @code{GNUNET_PEERINFO_add_peer_cancel}. To retrieve information from | ||
6502 | PEERINFO you can iterate over all information stored with PEERINFO or you | ||
6503 | can tell PEERINFO to notify if new peer information are available. | ||
6504 | |||
6505 | @node Obtaining Information from the PEERINFO Service | ||
6506 | @subsubsection Obtaining Information from the PEERINFO Service | ||
6507 | |||
6508 | @c %**end of header | ||
6509 | |||
6510 | To iterate over information in PEERINFO you use | ||
6511 | @code{GNUNET_PEERINFO_iterate}. | ||
6512 | This function expects the PEERINFO handle, a flag if HELLO messages | ||
6513 | intended for friend only mode should be included, a timeout how long the | ||
6514 | operation should take and a callback with a callback closure to be called | ||
6515 | for the results. | ||
6516 | If you want to obtain information for a specific peer, you can specify | ||
6517 | the peer identity, if this identity is NULL, information for all peers are | ||
6518 | returned. The function returns a handle to allow to cancel the operation | ||
6519 | using @code{GNUNET_PEERINFO_iterate_cancel}. | ||
6520 | |||
6521 | To get notified when peer information changes, you can use | ||
6522 | @code{GNUNET_PEERINFO_notify}. | ||
6523 | This function expects a configuration handle and a flag if friend-only | ||
6524 | HELLO messages should be included. The PEERINFO service will notify you | ||
6525 | about every change and the callback function will be called to notify you | ||
6526 | about changes. The function returns a handle to cancel notifications | ||
6527 | with @code{GNUNET_PEERINFO_notify_cancel}. | ||
6528 | |||
6529 | @cindex PEERSTORE Subsystem | ||
6530 | @node PEERSTORE Subsystem | ||
6531 | @section PEERSTORE Subsystem | ||
6532 | |||
6533 | @c %**end of header | ||
6534 | |||
6535 | GNUnet's PEERSTORE subsystem offers persistent per-peer storage for other | ||
6536 | GNUnet subsystems. GNUnet subsystems can use PEERSTORE to persistently | ||
6537 | store and retrieve arbitrary data. | ||
6538 | Each data record stored with PEERSTORE contains the following fields: | ||
6539 | |||
6540 | @itemize @bullet | ||
6541 | @item subsystem: Name of the subsystem responsible for the record. | ||
6542 | @item peerid: Identity of the peer this record is related to. | ||
6543 | @item key: a key string identifying the record. | ||
6544 | @item value: binary record value. | ||
6545 | @item expiry: record expiry date. | ||
6546 | @end itemize | ||
6547 | |||
6548 | @menu | ||
6549 | * Functionality:: | ||
6550 | * Architecture:: | ||
6551 | * libgnunetpeerstore:: | ||
6552 | @end menu | ||
6553 | |||
6554 | @node Functionality | ||
6555 | @subsection Functionality | ||
6556 | |||
6557 | @c %**end of header | ||
6558 | |||
6559 | Subsystems can store any type of value under a (subsystem, peerid, key) | ||
6560 | combination. A "replace" flag set during store operations forces the | ||
6561 | PEERSTORE to replace any old values stored under the same | ||
6562 | (subsystem, peerid, key) combination with the new value. | ||
6563 | Additionally, an expiry date is set after which the record is *possibly* | ||
6564 | deleted by PEERSTORE. | ||
6565 | |||
6566 | Subsystems can iterate over all values stored under any of the following | ||
6567 | combination of fields: | ||
6568 | |||
6569 | @itemize @bullet | ||
6570 | @item (subsystem) | ||
6571 | @item (subsystem, peerid) | ||
6572 | @item (subsystem, key) | ||
6573 | @item (subsystem, peerid, key) | ||
6574 | @end itemize | ||
6575 | |||
6576 | Subsystems can also request to be notified about any new values stored | ||
6577 | under a (subsystem, peerid, key) combination by sending a "watch" | ||
6578 | request to PEERSTORE. | ||
6579 | |||
6580 | @node Architecture | ||
6581 | @subsection Architecture | ||
6582 | |||
6583 | @c %**end of header | ||
6584 | |||
6585 | PEERSTORE implements the following components: | ||
6586 | |||
6587 | @itemize @bullet | ||
6588 | @item PEERSTORE service: Handles store, iterate and watch operations. | ||
6589 | @item PEERSTORE API: API to be used by other subsystems to communicate and | ||
6590 | issue commands to the PEERSTORE service. | ||
6591 | @item PEERSTORE plugins: Handles the persistent storage. At the moment, | ||
6592 | only an "sqlite" plugin is implemented. | ||
6593 | @end itemize | ||
6594 | |||
6595 | @cindex libgnunetpeerstore | ||
6596 | @node libgnunetpeerstore | ||
6597 | @subsection libgnunetpeerstore | ||
6598 | |||
6599 | @c %**end of header | ||
6600 | |||
6601 | libgnunetpeerstore is the library containing the PEERSTORE API. Subsystems | ||
6602 | wishing to communicate with the PEERSTORE service use this API to open a | ||
6603 | connection to PEERSTORE. This is done by calling | ||
6604 | @code{GNUNET_PEERSTORE_connect} which returns a handle to the newly | ||
6605 | created connection. | ||
6606 | This handle has to be used with any further calls to the API. | ||
6607 | |||
6608 | To store a new record, the function @code{GNUNET_PEERSTORE_store} is to | ||
6609 | be used which requires the record fields and a continuation function that | ||
6610 | will be called by the API after the STORE request is sent to the | ||
6611 | PEERSTORE service. | ||
6612 | Note that calling the continuation function does not mean that the record | ||
6613 | is successfully stored, only that the STORE request has been successfully | ||
6614 | sent to the PEERSTORE service. | ||
6615 | @code{GNUNET_PEERSTORE_store_cancel} can be called to cancel the STORE | ||
6616 | request only before the continuation function has been called. | ||
6617 | |||
6618 | To iterate over stored records, the function | ||
6619 | @code{GNUNET_PEERSTORE_iterate} is | ||
6620 | to be used. @emph{peerid} and @emph{key} can be set to NULL. An iterator | ||
6621 | callback function will be called with each matching record found and a | ||
6622 | NULL record at the end to signal the end of result set. | ||
6623 | @code{GNUNET_PEERSTORE_iterate_cancel} can be used to cancel the ITERATE | ||
6624 | request before the iterator callback is called with a NULL record. | ||
6625 | |||
6626 | To be notified with new values stored under a (subsystem, peerid, key) | ||
6627 | combination, the function @code{GNUNET_PEERSTORE_watch} is to be used. | ||
6628 | This will register the watcher with the PEERSTORE service, any new | ||
6629 | records matching the given combination will trigger the callback | ||
6630 | function passed to @code{GNUNET_PEERSTORE_watch}. This continues until | ||
6631 | @code{GNUNET_PEERSTORE_watch_cancel} is called or the connection to the | ||
6632 | service is destroyed. | ||
6633 | |||
6634 | After the connection is no longer needed, the function | ||
6635 | @code{GNUNET_PEERSTORE_disconnect} can be called to disconnect from the | ||
6636 | PEERSTORE service. | ||
6637 | Any pending ITERATE or WATCH requests will be destroyed. | ||
6638 | If the @code{sync_first} flag is set to @code{GNUNET_YES}, the API will | ||
6639 | delay the disconnection until all pending STORE requests are sent to | ||
6640 | the PEERSTORE service, otherwise, the pending STORE requests will be | ||
6641 | destroyed as well. | ||
6642 | |||
6643 | @cindex SET Subsystem | ||
6644 | @node SET Subsystem | ||
6645 | @section SET Subsystem | ||
6646 | |||
6647 | @c %**end of header | ||
6648 | |||
6649 | The SET service implements efficient set operations between two peers | ||
6650 | over a mesh tunnel. | ||
6651 | Currently, set union and set intersection are the only supported | ||
6652 | operations. Elements of a set consist of an @emph{element type} and | ||
6653 | arbitrary binary @emph{data}. | ||
6654 | The size of an element's data is limited to around 62 KB. | ||
6655 | |||
6656 | @menu | ||
6657 | * Local Sets:: | ||
6658 | * Set Modifications:: | ||
6659 | * Set Operations:: | ||
6660 | * Result Elements:: | ||
6661 | * libgnunetset:: | ||
6662 | * The SET Client-Service Protocol:: | ||
6663 | * The SET Intersection Peer-to-Peer Protocol:: | ||
6664 | * The SET Union Peer-to-Peer Protocol:: | ||
6665 | @end menu | ||
6666 | |||
6667 | @node Local Sets | ||
6668 | @subsection Local Sets | ||
6669 | |||
6670 | @c %**end of header | ||
6671 | |||
6672 | Sets created by a local client can be modified and reused for multiple | ||
6673 | operations. As each set operation requires potentially expensive special | ||
6674 | auxiliary data to be computed for each element of a set, a set can only | ||
6675 | participate in one type of set operation (i.e. union or intersection). | ||
6676 | The type of a set is determined upon its creation. | ||
6677 | If a the elements of a set are needed for an operation of a different | ||
6678 | type, all of the set's element must be copied to a new set of appropriate | ||
6679 | type. | ||
6680 | |||
6681 | @node Set Modifications | ||
6682 | @subsection Set Modifications | ||
6683 | |||
6684 | @c %**end of header | ||
6685 | |||
6686 | Even when set operations are active, one can add to and remove elements | ||
6687 | from a set. | ||
6688 | However, these changes will only be visible to operations that have been | ||
6689 | created after the changes have taken place. That is, every set operation | ||
6690 | only sees a snapshot of the set from the time the operation was started. | ||
6691 | This mechanism is @emph{not} implemented by copying the whole set, but by | ||
6692 | attaching @emph{generation information} to each element and operation. | ||
6693 | |||
6694 | @node Set Operations | ||
6695 | @subsection Set Operations | ||
6696 | |||
6697 | @c %**end of header | ||
6698 | |||
6699 | Set operations can be started in two ways: Either by accepting an | ||
6700 | operation request from a remote peer, or by requesting a set operation | ||
6701 | from a remote peer. | ||
6702 | Set operations are uniquely identified by the involved @emph{peers}, an | ||
6703 | @emph{application id} and the @emph{operation type}. | ||
6704 | |||
6705 | The client is notified of incoming set operations by @emph{set listeners}. | ||
6706 | A set listener listens for incoming operations of a specific operation | ||
6707 | type and application id. | ||
6708 | Once notified of an incoming set request, the client can accept the set | ||
6709 | request (providing a local set for the operation) or reject it. | ||
6710 | |||
6711 | @node Result Elements | ||
6712 | @subsection Result Elements | ||
6713 | |||
6714 | @c %**end of header | ||
6715 | |||
6716 | The SET service has three @emph{result modes} that determine how an | ||
6717 | operation's result set is delivered to the client: | ||
6718 | |||
6719 | @itemize @bullet | ||
6720 | @item @strong{Full Result Set.} All elements of set resulting from the set | ||
6721 | operation are returned to the client. | ||
6722 | @item @strong{Added Elements.} Only elements that result from the | ||
6723 | operation and are not already in the local peer's set are returned. | ||
6724 | Note that for some operations (like set intersection) this result mode | ||
6725 | will never return any elements. | ||
6726 | This can be useful if only the remove peer is actually interested in | ||
6727 | the result of the set operation. | ||
6728 | @item @strong{Removed Elements.} Only elements that are in the local | ||
6729 | peer's initial set but not in the operation's result set are returned. | ||
6730 | Note that for some operations (like set union) this result mode will | ||
6731 | never return any elements. This can be useful if only the remove peer is | ||
6732 | actually interested in the result of the set operation. | ||
6733 | @end itemize | ||
6734 | |||
6735 | @cindex libgnunetset | ||
6736 | @node libgnunetset | ||
6737 | @subsection libgnunetset | ||
6738 | |||
6739 | @c %**end of header | ||
6740 | |||
6741 | @menu | ||
6742 | * Sets:: | ||
6743 | * Listeners:: | ||
6744 | * Operations:: | ||
6745 | * Supplying a Set:: | ||
6746 | * The Result Callback:: | ||
6747 | @end menu | ||
6748 | |||
6749 | @node Sets | ||
6750 | @subsubsection Sets | ||
6751 | |||
6752 | @c %**end of header | ||
6753 | |||
6754 | New sets are created with @code{GNUNET_SET_create}. Both the local peer's | ||
6755 | configuration (as each set has its own client connection) and the | ||
6756 | operation type must be specified. | ||
6757 | The set exists until either the client calls @code{GNUNET_SET_destroy} or | ||
6758 | the client's connection to the service is disrupted. | ||
6759 | In the latter case, the client is notified by the return value of | ||
6760 | functions dealing with sets. This return value must always be checked. | ||
6761 | |||
6762 | Elements are added and removed with @code{GNUNET_SET_add_element} and | ||
6763 | @code{GNUNET_SET_remove_element}. | ||
6764 | |||
6765 | @node Listeners | ||
6766 | @subsubsection Listeners | ||
6767 | |||
6768 | @c %**end of header | ||
6769 | |||
6770 | Listeners are created with @code{GNUNET_SET_listen}. Each time time a | ||
6771 | remote peer suggests a set operation with an application id and operation | ||
6772 | type matching a listener, the listener's callback is invoked. | ||
6773 | The client then must synchronously call either @code{GNUNET_SET_accept} | ||
6774 | or @code{GNUNET_SET_reject}. Note that the operation will not be started | ||
6775 | until the client calls @code{GNUNET_SET_commit} | ||
6776 | (see Section "Supplying a Set"). | ||
6777 | |||
6778 | @node Operations | ||
6779 | @subsubsection Operations | ||
6780 | |||
6781 | @c %**end of header | ||
6782 | |||
6783 | Operations to be initiated by the local peer are created with | ||
6784 | @code{GNUNET_SET_prepare}. Note that the operation will not be started | ||
6785 | until the client calls @code{GNUNET_SET_commit} | ||
6786 | (see Section "Supplying a Set"). | ||
6787 | |||
6788 | @node Supplying a Set | ||
6789 | @subsubsection Supplying a Set | ||
6790 | |||
6791 | @c %**end of header | ||
6792 | |||
6793 | To create symmetry between the two ways of starting a set operation | ||
6794 | (accepting and initiating it), the operation handles returned by | ||
6795 | @code{GNUNET_SET_accept} and @code{GNUNET_SET_prepare} do not yet have a | ||
6796 | set to operate on, thus they can not do any work yet. | ||
6797 | |||
6798 | The client must call @code{GNUNET_SET_commit} to specify a set to use for | ||
6799 | an operation. @code{GNUNET_SET_commit} may only be called once per set | ||
6800 | operation. | ||
6801 | |||
6802 | @node The Result Callback | ||
6803 | @subsubsection The Result Callback | ||
6804 | |||
6805 | @c %**end of header | ||
6806 | |||
6807 | Clients must specify both a result mode and a result callback with | ||
6808 | @code{GNUNET_SET_accept} and @code{GNUNET_SET_prepare}. The result | ||
6809 | callback with a status indicating either that an element was received, or | ||
6810 | the operation failed or succeeded. | ||
6811 | The interpretation of the received element depends on the result mode. | ||
6812 | The callback needs to know which result mode it is used in, as the | ||
6813 | arguments do not indicate if an element is part of the full result set, | ||
6814 | or if it is in the difference between the original set and the final set. | ||
6815 | |||
6816 | @node The SET Client-Service Protocol | ||
6817 | @subsection The SET Client-Service Protocol | ||
6818 | |||
6819 | @c %**end of header | ||
6820 | |||
6821 | @menu | ||
6822 | * Creating Sets:: | ||
6823 | * Listeners2:: | ||
6824 | * Initiating Operations:: | ||
6825 | * Modifying Sets:: | ||
6826 | * Results and Operation Status:: | ||
6827 | * Iterating Sets:: | ||
6828 | @end menu | ||
6829 | |||
6830 | @node Creating Sets | ||
6831 | @subsubsection Creating Sets | ||
6832 | |||
6833 | @c %**end of header | ||
6834 | |||
6835 | For each set of a client, there exists a client connection to the service. | ||
6836 | Sets are created by sending the @code{GNUNET_SERVICE_SET_CREATE} message | ||
6837 | over a new client connection. Multiple operations for one set are | ||
6838 | multiplexed over one client connection, using a request id supplied by | ||
6839 | the client. | ||
6840 | |||
6841 | @node Listeners2 | ||
6842 | @subsubsection Listeners2 | ||
6843 | |||
6844 | @c %**end of header | ||
6845 | |||
6846 | Each listener also requires a seperate client connection. By sending the | ||
6847 | @code{GNUNET_SERVICE_SET_LISTEN} message, the client notifies the service | ||
6848 | of the application id and operation type it is interested in. A client | ||
6849 | rejects an incoming request by sending @code{GNUNET_SERVICE_SET_REJECT} | ||
6850 | on the listener's client connection. | ||
6851 | In contrast, when accepting an incoming request, a | ||
6852 | @code{GNUNET_SERVICE_SET_ACCEPT} message must be sent over the@ set that | ||
6853 | is supplied for the set operation. | ||
6854 | |||
6855 | @node Initiating Operations | ||
6856 | @subsubsection Initiating Operations | ||
6857 | |||
6858 | @c %**end of header | ||
6859 | |||
6860 | Operations with remote peers are initiated by sending a | ||
6861 | @code{GNUNET_SERVICE_SET_EVALUATE} message to the service. The@ client | ||
6862 | connection that this message is sent by determines the set to use. | ||
6863 | |||
6864 | @node Modifying Sets | ||
6865 | @subsubsection Modifying Sets | ||
6866 | |||
6867 | @c %**end of header | ||
6868 | |||
6869 | Sets are modified with the @code{GNUNET_SERVICE_SET_ADD} and | ||
6870 | @code{GNUNET_SERVICE_SET_REMOVE} messages. | ||
6871 | |||
6872 | |||
6873 | @c %@menu | ||
6874 | @c %* Results and Operation Status:: | ||
6875 | @c %* Iterating Sets:: | ||
6876 | @c %@end menu | ||
6877 | |||
6878 | @node Results and Operation Status | ||
6879 | @subsubsection Results and Operation Status | ||
6880 | @c %**end of header | ||
6881 | |||
6882 | The service notifies the client of result elements and success/failure of | ||
6883 | a set operation with the @code{GNUNET_SERVICE_SET_RESULT} message. | ||
6884 | |||
6885 | @node Iterating Sets | ||
6886 | @subsubsection Iterating Sets | ||
6887 | |||
6888 | @c %**end of header | ||
6889 | |||
6890 | All elements of a set can be requested by sending | ||
6891 | @code{GNUNET_SERVICE_SET_ITER_REQUEST}. The server responds with | ||
6892 | @code{GNUNET_SERVICE_SET_ITER_ELEMENT} and eventually terminates the | ||
6893 | iteration with @code{GNUNET_SERVICE_SET_ITER_DONE}. | ||
6894 | After each received element, the client | ||
6895 | must send @code{GNUNET_SERVICE_SET_ITER_ACK}. Note that only one set | ||
6896 | iteration may be active for a set at any given time. | ||
6897 | |||
6898 | @node The SET Intersection Peer-to-Peer Protocol | ||
6899 | @subsection The SET Intersection Peer-to-Peer Protocol | ||
6900 | |||
6901 | @c %**end of header | ||
6902 | |||
6903 | The intersection protocol operates over CADET and starts with a | ||
6904 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer | ||
6905 | initiating the operation to the peer listening for inbound requests. | ||
6906 | It includes the number of elements of the initiating peer, which is used | ||
6907 | to decide which side will send a Bloom filter first. | ||
6908 | |||
6909 | The listening peer checks if the operation type and application | ||
6910 | identifier are acceptable for its current state. | ||
6911 | If not, it responds with a GNUNET_MESSAGE_TYPE_SET_RESULT and a status of | ||
6912 | GNUNET_SET_STATUS_FAILURE (and terminates the CADET channel). | ||
6913 | |||
6914 | If the application accepts the request, the listener sends back a | ||
6915 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO} if it has | ||
6916 | more elements in the set than the client. | ||
6917 | Otherwise, it immediately starts with the Bloom filter exchange. | ||
6918 | If the initiator receives a | ||
6919 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO} response, | ||
6920 | it beings the Bloom filter exchange, unless the set size is indicated to | ||
6921 | be zero, in which case the intersection is considered finished after | ||
6922 | just the initial handshake. | ||
6923 | |||
6924 | |||
6925 | @menu | ||
6926 | * The Bloom filter exchange:: | ||
6927 | * Salt:: | ||
6928 | @end menu | ||
6929 | |||
6930 | @node The Bloom filter exchange | ||
6931 | @subsubsection The Bloom filter exchange | ||
6932 | |||
6933 | @c %**end of header | ||
6934 | |||
6935 | In this phase, each peer transmits a Bloom filter over the remaining | ||
6936 | keys of the local set to the other peer using a | ||
6937 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF} message. This | ||
6938 | message additionally includes the number of elements left in the sender's | ||
6939 | set, as well as the XOR over all of the keys in that set. | ||
6940 | |||
6941 | The number of bits 'k' set per element in the Bloom filter is calculated | ||
6942 | based on the relative size of the two sets. | ||
6943 | Furthermore, the size of the Bloom filter is calculated based on 'k' and | ||
6944 | the number of elements in the set to maximize the amount of data filtered | ||
6945 | per byte transmitted on the wire (while avoiding an excessively high | ||
6946 | number of iterations). | ||
6947 | |||
6948 | The receiver of the message removes all elements from its local set that | ||
6949 | do not pass the Bloom filter test. | ||
6950 | It then checks if the set size of the sender and the XOR over the keys | ||
6951 | match what is left of its own set. If they do, it sends a | ||
6952 | @code{GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE} back to indicate | ||
6953 | that the latest set is the final result. | ||
6954 | Otherwise, the receiver starts another Bloom filter exchange, except | ||
6955 | this time as the sender. | ||
6956 | |||
6957 | @node Salt | ||
6958 | @subsubsection Salt | ||
6959 | |||
6960 | @c %**end of header | ||
6961 | |||
6962 | Bloomfilter operations are probabilistic: With some non-zero probability | ||
6963 | the test may incorrectly say an element is in the set, even though it is | ||
6964 | not. | ||
6965 | |||
6966 | To mitigate this problem, the intersection protocol iterates exchanging | ||
6967 | Bloom filters using a different random 32-bit salt in each iteration (the | ||
6968 | salt is also included in the message). | ||
6969 | With different salts, set operations may fail for different elements. | ||
6970 | Merging the results from the executions, the probability of failure drops | ||
6971 | to zero. | ||
6972 | |||
6973 | The iterations terminate once both peers have established that they have | ||
6974 | sets of the same size, and where the XOR over all keys computes the same | ||
6975 | 512-bit value (leaving a failure probability of 2-511). | ||
6976 | |||
6977 | @node The SET Union Peer-to-Peer Protocol | ||
6978 | @subsection The SET Union Peer-to-Peer Protocol | ||
6979 | |||
6980 | @c %**end of header | ||
6981 | |||
6982 | The SET union protocol is based on Eppstein's efficient set reconciliation | ||
6983 | without prior context. You should read this paper first if you want to | ||
6984 | understand the protocol. | ||
6985 | |||
6986 | The union protocol operates over CADET and starts with a | ||
6987 | GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST being sent by the peer | ||
6988 | initiating the operation to the peer listening for inbound requests. | ||
6989 | It includes the number of elements of the initiating peer, which is | ||
6990 | currently not used. | ||
6991 | |||
6992 | The listening peer checks if the operation type and application | ||
6993 | identifier are acceptable for its current state. If not, it responds with | ||
6994 | a @code{GNUNET_MESSAGE_TYPE_SET_RESULT} and a status of | ||
6995 | @code{GNUNET_SET_STATUS_FAILURE} (and terminates the CADET channel). | ||
6996 | |||
6997 | If the application accepts the request, it sends back a strata estimator | ||
6998 | using a message of type GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE. The | ||
6999 | initiator evaluates the strata estimator and initiates the exchange of | ||
7000 | invertible Bloom filters, sending a GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
7001 | |||
7002 | During the IBF exchange, if the receiver cannot invert the Bloom filter or | ||
7003 | detects a cycle, it sends a larger IBF in response (up to a defined | ||
7004 | maximum limit; if that limit is reached, the operation fails). | ||
7005 | Elements decoded while processing the IBF are transmitted to the other | ||
7006 | peer using GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, or requested from the | ||
7007 | other peer using GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS messages, | ||
7008 | depending on the sign observed during decoding of the IBF. | ||
7009 | Peers respond to a GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS message | ||
7010 | with the respective element in a GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS | ||
7011 | message. If the IBF fully decodes, the peer responds with a | ||
7012 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE message instead of another | ||
7013 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF. | ||
7014 | |||
7015 | All Bloom filter operations use a salt to mingle keys before hashing them | ||
7016 | into buckets, such that future iterations have a fresh chance of | ||
7017 | succeeding if they failed due to collisions before. | ||
7018 | |||
7019 | @cindex STATISTICS Subsystem | ||
7020 | @node STATISTICS Subsystem | ||
7021 | @section STATISTICS Subsystem | ||
7022 | |||
7023 | @c %**end of header | ||
7024 | |||
7025 | In GNUnet, the STATISTICS subsystem offers a central place for all | ||
7026 | subsystems to publish unsigned 64-bit integer run-time statistics. | ||
7027 | Keeping this information centrally means that there is a unified way for | ||
7028 | the user to obtain data on all subsystems, and individual subsystems do | ||
7029 | not have to always include a custom data export method for performance | ||
7030 | metrics and other statistics. For example, the TRANSPORT system uses | ||
7031 | STATISTICS to update information about the number of directly connected | ||
7032 | peers and the bandwidth that has been consumed by the various plugins. | ||
7033 | This information is valuable for diagnosing connectivity and performance | ||
7034 | issues. | ||
7035 | |||
7036 | Following the GNUnet service architecture, the STATISTICS subsystem is | ||
7037 | divided into an API which is exposed through the header | ||
7038 | @strong{gnunet_statistics_service.h} and the STATISTICS service | ||
7039 | @strong{gnunet-service-statistics}. The @strong{gnunet-statistics} | ||
7040 | command-line tool can be used to obtain (and change) information about | ||
7041 | the values stored by the STATISTICS service. The STATISTICS service does | ||
7042 | not communicate with other peers. | ||
7043 | |||
7044 | Data is stored in the STATISTICS service in the form of tuples | ||
7045 | @strong{(subsystem, name, value, persistence)}. The subsystem determines | ||
7046 | to which other GNUnet's subsystem the data belongs. name is the name | ||
7047 | through which value is associated. It uniquely identifies the record | ||
7048 | from among other records belonging to the same subsystem. | ||
7049 | In some parts of the code, the pair @strong{(subsystem, name)} is called | ||
7050 | a @strong{statistic} as it identifies the values stored in the STATISTCS | ||
7051 | service.The persistence flag determines if the record has to be preserved | ||
7052 | across service restarts. A record is said to be persistent if this flag | ||
7053 | is set for it; if not, the record is treated as a non-persistent record | ||
7054 | and it is lost after service restart. Persistent records are written to | ||
7055 | and read from the file @strong{statistics.data} before shutdown | ||
7056 | and upon startup. The file is located in the HOME directory of the peer. | ||
7057 | |||
7058 | An anomaly of the STATISTICS service is that it does not terminate | ||
7059 | immediately upon receiving a shutdown signal if it has any clients | ||
7060 | connected to it. It waits for all the clients that are not monitors to | ||
7061 | close their connections before terminating itself. | ||
7062 | This is to prevent the loss of data during peer shutdown --- delaying the | ||
7063 | STATISTICS service shutdown helps other services to store important data | ||
7064 | to STATISTICS during shutdown. | ||
7065 | |||
7066 | @menu | ||
7067 | * libgnunetstatistics:: | ||
7068 | * The STATISTICS Client-Service Protocol:: | ||
7069 | @end menu | ||
7070 | |||
7071 | @cindex libgnunetstatistics | ||
7072 | @node libgnunetstatistics | ||
7073 | @subsection libgnunetstatistics | ||
7074 | |||
7075 | @c %**end of header | ||
7076 | |||
7077 | @strong{libgnunetstatistics} is the library containing the API for the | ||
7078 | STATISTICS subsystem. Any process requiring to use STATISTICS should use | ||
7079 | this API by to open a connection to the STATISTICS service. | ||
7080 | This is done by calling the function @code{GNUNET_STATISTICS_create()}. | ||
7081 | This function takes the subsystem's name which is trying to use STATISTICS | ||
7082 | and a configuration. | ||
7083 | All values written to STATISTICS with this connection will be placed in | ||
7084 | the section corresponding to the given subsystem's name. | ||
7085 | The connection to STATISTICS can be destroyed with the function | ||
7086 | @code{GNUNET_STATISTICS_destroy()}. This function allows for the | ||
7087 | connection to be destroyed immediately or upon transferring all | ||
7088 | pending write requests to the service. | ||
7089 | |||
7090 | Note: STATISTICS subsystem can be disabled by setting @code{DISABLE = YES} | ||
7091 | under the @code{[STATISTICS]} section in the configuration. With such a | ||
7092 | configuration all calls to @code{GNUNET_STATISTICS_create()} return | ||
7093 | @code{NULL} as the STATISTICS subsystem is unavailable and no other | ||
7094 | functions from the API can be used. | ||
7095 | |||
7096 | |||
7097 | @menu | ||
7098 | * Statistics retrieval:: | ||
7099 | * Setting statistics and updating them:: | ||
7100 | * Watches:: | ||
7101 | @end menu | ||
7102 | |||
7103 | @node Statistics retrieval | ||
7104 | @subsubsection Statistics retrieval | ||
7105 | |||
7106 | @c %**end of header | ||
7107 | |||
7108 | Once a connection to the statistics service is obtained, information | ||
7109 | about any other system which uses statistics can be retrieved with the | ||
7110 | function GNUNET_STATISTICS_get(). | ||
7111 | This function takes the connection handle, the name of the subsystem | ||
7112 | whose information we are interested in (a @code{NULL} value will | ||
7113 | retrieve information of all available subsystems using STATISTICS), the | ||
7114 | name of the statistic we are interested in (a @code{NULL} value will | ||
7115 | retrieve all available statistics), a continuation callback which is | ||
7116 | called when all of requested information is retrieved, an iterator | ||
7117 | callback which is called for each parameter in the retrieved information | ||
7118 | and a closure for the aforementioned callbacks. The library then invokes | ||
7119 | the iterator callback for each value matching the request. | ||
7120 | |||
7121 | Call to @code{GNUNET_STATISTICS_get()} is asynchronous and can be | ||
7122 | canceled with the function @code{GNUNET_STATISTICS_get_cancel()}. | ||
7123 | This is helpful when retrieving statistics takes too long and especially | ||
7124 | when we want to shutdown and cleanup everything. | ||
7125 | |||
7126 | @node Setting statistics and updating them | ||
7127 | @subsubsection Setting statistics and updating them | ||
7128 | |||
7129 | @c %**end of header | ||
7130 | |||
7131 | So far we have seen how to retrieve statistics, here we will learn how we | ||
7132 | can set statistics and update them so that other subsystems can retrieve | ||
7133 | them. | ||
7134 | |||
7135 | A new statistic can be set using the function | ||
7136 | @code{GNUNET_STATISTICS_set()}. | ||
7137 | This function takes the name of the statistic and its value and a flag to | ||
7138 | make the statistic persistent. | ||
7139 | The value of the statistic should be of the type @code{uint64_t}. | ||
7140 | The function does not take the name of the subsystem; it is determined | ||
7141 | from the previous @code{GNUNET_STATISTICS_create()} invocation. If | ||
7142 | the given statistic is already present, its value is overwritten. | ||
7143 | |||
7144 | An existing statistics can be updated, i.e its value can be increased or | ||
7145 | decreased by an amount with the function | ||
7146 | @code{GNUNET_STATISTICS_update()}. | ||
7147 | The parameters to this function are similar to | ||
7148 | @code{GNUNET_STATISTICS_set()}, except that it takes the amount to be | ||
7149 | changed as a type @code{int64_t} instead of the value. | ||
7150 | |||
7151 | The library will combine multiple set or update operations into one | ||
7152 | message if the client performs requests at a rate that is faster than the | ||
7153 | available IPC with the STATISTICS service. Thus, the client does not have | ||
7154 | to worry about sending requests too quickly. | ||
7155 | |||
7156 | @node Watches | ||
7157 | @subsubsection Watches | ||
7158 | |||
7159 | @c %**end of header | ||
7160 | |||
7161 | As interesting feature of STATISTICS lies in serving notifications | ||
7162 | whenever a statistic of our interest is modified. | ||
7163 | This is achieved by registering a watch through the function | ||
7164 | @code{GNUNET_STATISTICS_watch()}. | ||
7165 | The parameters of this function are similar to those of | ||
7166 | @code{GNUNET_STATISTICS_get()}. | ||
7167 | Changes to the respective statistic's value will then cause the given | ||
7168 | iterator callback to be called. | ||
7169 | Note: A watch can only be registered for a specific statistic. Hence | ||
7170 | the subsystem name and the parameter name cannot be @code{NULL} in a | ||
7171 | call to @code{GNUNET_STATISTICS_watch()}. | ||
7172 | |||
7173 | A registered watch will keep notifying any value changes until | ||
7174 | @code{GNUNET_STATISTICS_watch_cancel()} is called with the same | ||
7175 | parameters that are used for registering the watch. | ||
7176 | |||
7177 | @node The STATISTICS Client-Service Protocol | ||
7178 | @subsection The STATISTICS Client-Service Protocol | ||
7179 | @c %**end of header | ||
7180 | |||
7181 | |||
7182 | @menu | ||
7183 | * Statistics retrieval2:: | ||
7184 | * Setting and updating statistics:: | ||
7185 | * Watching for updates:: | ||
7186 | @end menu | ||
7187 | |||
7188 | @node Statistics retrieval2 | ||
7189 | @subsubsection Statistics retrieval2 | ||
7190 | |||
7191 | @c %**end of header | ||
7192 | |||
7193 | To retrieve statistics, the client transmits a message of type | ||
7194 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_GET} containing the given subsystem | ||
7195 | name and statistic parameter to the STATISTICS service. | ||
7196 | The service responds with a message of type | ||
7197 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_VALUE} for each of the statistics | ||
7198 | parameters that match the client request for the client. The end of | ||
7199 | information retrieved is signaled by the service by sending a message of | ||
7200 | type @code{GNUNET_MESSAGE_TYPE_STATISTICS_END}. | ||
7201 | |||
7202 | @node Setting and updating statistics | ||
7203 | @subsubsection Setting and updating statistics | ||
7204 | |||
7205 | @c %**end of header | ||
7206 | |||
7207 | The subsystem name, parameter name, its value and the persistence flag are | ||
7208 | communicated to the service through the message | ||
7209 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}. | ||
7210 | |||
7211 | When the service receives a message of type | ||
7212 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET}, it retrieves the subsystem | ||
7213 | name and checks for a statistic parameter with matching the name given in | ||
7214 | the message. | ||
7215 | If a statistic parameter is found, the value is overwritten by the new | ||
7216 | value from the message; if not found then a new statistic parameter is | ||
7217 | created with the given name and value. | ||
7218 | |||
7219 | In addition to just setting an absolute value, it is possible to perform a | ||
7220 | relative update by sending a message of type | ||
7221 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_SET} with an update flag | ||
7222 | (@code{GNUNET_STATISTICS_SETFLAG_RELATIVE}) signifying that the value in | ||
7223 | the message should be treated as an update value. | ||
7224 | |||
7225 | @node Watching for updates | ||
7226 | @subsubsection Watching for updates | ||
7227 | |||
7228 | @c %**end of header | ||
7229 | |||
7230 | The function registers the watch at the service by sending a message of | ||
7231 | type @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH}. The service then sends | ||
7232 | notifications through messages of type | ||
7233 | @code{GNUNET_MESSAGE_TYPE_STATISTICS_WATCH_VALUE} whenever the statistic | ||
7234 | parameter's value is changed. | ||
7235 | |||
7236 | @cindex DHT | ||
7237 | @cindex Distributed Hash Table | ||
7238 | @node Distributed Hash Table (DHT) | ||
7239 | @section Distributed Hash Table (DHT) | ||
7240 | |||
7241 | @c %**end of header | ||
7242 | |||
7243 | GNUnet includes a generic distributed hash table that can be used by | ||
7244 | developers building P2P applications in the framework. | ||
7245 | This section documents high-level features and how developers are | ||
7246 | expected to use the DHT. | ||
7247 | We have a research paper detailing how the DHT works. | ||
7248 | Also, Nate's thesis includes a detailed description and performance | ||
7249 | analysis (in chapter 6). | ||
7250 | |||
7251 | Key features of GNUnet's DHT include: | ||
7252 | |||
7253 | @itemize @bullet | ||
7254 | @item stores key-value pairs with values up to (approximately) 63k in size | ||
7255 | @item works with many underlay network topologies (small-world, random | ||
7256 | graph), underlay does not need to be a full mesh / clique | ||
7257 | @item support for extended queries (more than just a simple 'key'), | ||
7258 | filtering duplicate replies within the network (bloomfilter) and content | ||
7259 | validation (for details, please read the subsection on the block library) | ||
7260 | @item can (optionally) return paths taken by the PUT and GET operations | ||
7261 | to the application | ||
7262 | @item provides content replication to handle churn | ||
7263 | @end itemize | ||
7264 | |||
7265 | GNUnet's DHT is randomized and unreliable. Unreliable means that there is | ||
7266 | no strict guarantee that a value stored in the DHT is always | ||
7267 | found --- values are only found with high probability. | ||
7268 | While this is somewhat true in all P2P DHTs, GNUnet developers should be | ||
7269 | particularly wary of this fact (this will help you write secure, | ||
7270 | fault-tolerant code). Thus, when writing any application using the DHT, | ||
7271 | you should always consider the possibility that a value stored in the | ||
7272 | DHT by you or some other peer might simply not be returned, or returned | ||
7273 | with a significant delay. | ||
7274 | Your application logic must be written to tolerate this (naturally, some | ||
7275 | loss of performance or quality of service is expected in this case). | ||
7276 | |||
7277 | @menu | ||
7278 | * Block library and plugins:: | ||
7279 | * libgnunetdht:: | ||
7280 | * The DHT Client-Service Protocol:: | ||
7281 | * The DHT Peer-to-Peer Protocol:: | ||
7282 | @end menu | ||
7283 | |||
7284 | @node Block library and plugins | ||
7285 | @subsection Block library and plugins | ||
7286 | |||
7287 | @c %**end of header | ||
7288 | |||
7289 | @menu | ||
7290 | * What is a Block?:: | ||
7291 | * The API of libgnunetblock:: | ||
7292 | * Queries:: | ||
7293 | * Sample Code:: | ||
7294 | * Conclusion2:: | ||
7295 | @end menu | ||
7296 | |||
7297 | @node What is a Block? | ||
7298 | @subsubsection What is a Block? | ||
7299 | |||
7300 | @c %**end of header | ||
7301 | |||
7302 | Blocks are small (< 63k) pieces of data stored under a key (struct | ||
7303 | GNUNET_HashCode). Blocks have a type (enum GNUNET_BlockType) which defines | ||
7304 | their data format. Blocks are used in GNUnet as units of static data | ||
7305 | exchanged between peers and stored (or cached) locally. | ||
7306 | Uses of blocks include file-sharing (the files are broken up into blocks), | ||
7307 | the VPN (DNS information is stored in blocks) and the DHT (all | ||
7308 | information in the DHT and meta-information for the maintenance of the | ||
7309 | DHT are both stored using blocks). | ||
7310 | The block subsystem provides a few common functions that must be | ||
7311 | available for any type of block. | ||
7312 | |||
7313 | @cindex libgnunetblock API | ||
7314 | @node The API of libgnunetblock | ||
7315 | @subsubsection The API of libgnunetblock | ||
7316 | |||
7317 | @c %**end of header | ||
7318 | |||
7319 | The block library requires for each (family of) block type(s) a block | ||
7320 | plugin (implementing @file{gnunet_block_plugin.h}) that provides basic | ||
7321 | functions that are needed by the DHT (and possibly other subsystems) to | ||
7322 | manage the block. | ||
7323 | These block plugins are typically implemented within their respective | ||
7324 | subsystems. | ||
7325 | The main block library is then used to locate, load and query the | ||
7326 | appropriate block plugin. | ||
7327 | Which plugin is appropriate is determined by the block type (which is | ||
7328 | just a 32-bit integer). Block plugins contain code that specifies which | ||
7329 | block types are supported by a given plugin. The block library loads all | ||
7330 | block plugins that are installed at the local peer and forwards the | ||
7331 | application request to the respective plugin. | ||
7332 | |||
7333 | The central functions of the block APIs (plugin and main library) are to | ||
7334 | allow the mapping of blocks to their respective key (if possible) and the | ||
7335 | ability to check that a block is well-formed and matches a given | ||
7336 | request (again, if possible). | ||
7337 | This way, GNUnet can avoid storing invalid blocks, storing blocks under | ||
7338 | the wrong key and forwarding blocks in response to a query that they do | ||
7339 | not answer. | ||
7340 | |||
7341 | One key function of block plugins is that it allows GNUnet to detect | ||
7342 | duplicate replies (via the Bloom filter). All plugins MUST support | ||
7343 | detecting duplicate replies (by adding the current response to the | ||
7344 | Bloom filter and rejecting it if it is encountered again). | ||
7345 | If a plugin fails to do this, responses may loop in the network. | ||
7346 | |||
7347 | @node Queries | ||
7348 | @subsubsection Queries | ||
7349 | @c %**end of header | ||
7350 | |||
7351 | The query format for any block in GNUnet consists of four main components. | ||
7352 | First, the type of the desired block must be specified. Second, the query | ||
7353 | must contain a hash code. The hash code is used for lookups in hash | ||
7354 | tables and databases and must not be unique for the block (however, if | ||
7355 | possible a unique hash should be used as this would be best for | ||
7356 | performance). | ||
7357 | Third, an optional Bloom filter can be specified to exclude known results; | ||
7358 | replies that hash to the bits set in the Bloom filter are considered | ||
7359 | invalid. False-positives can be eliminated by sending the same query | ||
7360 | again with a different Bloom filter mutator value, which parameterizes | ||
7361 | the hash function that is used. | ||
7362 | Finally, an optional application-specific "eXtended query" (xquery) can | ||
7363 | be specified to further constrain the results. It is entirely up to | ||
7364 | the type-specific plugin to determine whether or not a given block | ||
7365 | matches a query (type, hash, Bloom filter, and xquery). | ||
7366 | Naturally, not all xquery's are valid and some types of blocks may not | ||
7367 | support Bloom filters either, so the plugin also needs to check if the | ||
7368 | query is valid in the first place. | ||
7369 | |||
7370 | Depending on the results from the plugin, the DHT will then discard the | ||
7371 | (invalid) query, forward the query, discard the (invalid) reply, cache the | ||
7372 | (valid) reply, and/or forward the (valid and non-duplicate) reply. | ||
7373 | |||
7374 | @node Sample Code | ||
7375 | @subsubsection Sample Code | ||
7376 | |||
7377 | @c %**end of header | ||
7378 | |||
7379 | The source code in @strong{plugin_block_test.c} is a good starting point | ||
7380 | for new block plugins --- it does the minimal work by implementing a | ||
7381 | plugin that performs no validation at all. | ||
7382 | The respective @strong{Makefile.am} shows how to build and install a | ||
7383 | block plugin. | ||
7384 | |||
7385 | @node Conclusion2 | ||
7386 | @subsubsection Conclusion2 | ||
7387 | |||
7388 | @c %**end of header | ||
7389 | |||
7390 | In conclusion, GNUnet subsystems that want to use the DHT need to define a | ||
7391 | block format and write a plugin to match queries and replies. For testing, | ||
7392 | the @code{GNUNET_BLOCK_TYPE_TEST} block type can be used; it accepts | ||
7393 | any query as valid and any reply as matching any query. | ||
7394 | This type is also used for the DHT command line tools. | ||
7395 | However, it should NOT be used for normal applications due to the lack | ||
7396 | of error checking that results from this primitive implementation. | ||
7397 | |||
7398 | @cindex libgnunetdht | ||
7399 | @node libgnunetdht | ||
7400 | @subsection libgnunetdht | ||
7401 | |||
7402 | @c %**end of header | ||
7403 | |||
7404 | The DHT API itself is pretty simple and offers the usual GET and PUT | ||
7405 | functions that work as expected. The specified block type refers to the | ||
7406 | block library which allows the DHT to run application-specific logic for | ||
7407 | data stored in the network. | ||
7408 | |||
7409 | |||
7410 | @menu | ||
7411 | * GET:: | ||
7412 | * PUT:: | ||
7413 | * MONITOR:: | ||
7414 | * DHT Routing Options:: | ||
7415 | @end menu | ||
7416 | |||
7417 | @node GET | ||
7418 | @subsubsection GET | ||
7419 | |||
7420 | @c %**end of header | ||
7421 | |||
7422 | When using GET, the main consideration for developers (other than the | ||
7423 | block library) should be that after issuing a GET, the DHT will | ||
7424 | continuously cause (small amounts of) network traffic until the operation | ||
7425 | is explicitly canceled. | ||
7426 | So GET does not simply send out a single network request once; instead, | ||
7427 | the DHT will continue to search for data. This is needed to achieve good | ||
7428 | success rates and also handles the case where the respective PUT | ||
7429 | operation happens after the GET operation was started. | ||
7430 | Developers should not cancel an existing GET operation and then | ||
7431 | explicitly re-start it to trigger a new round of network requests; | ||
7432 | this is simply inefficient, especially as the internal automated version | ||
7433 | can be more efficient, for example by filtering results in the network | ||
7434 | that have already been returned. | ||
7435 | |||
7436 | If an application that performs a GET request has a set of replies that it | ||
7437 | already knows and would like to filter, it can call@ | ||
7438 | @code{GNUNET_DHT_get_filter_known_results} with an array of hashes over | ||
7439 | the respective blocks to tell the DHT that these results are not | ||
7440 | desired (any more). | ||
7441 | This way, the DHT will filter the respective blocks using the block | ||
7442 | library in the network, which may result in a significant reduction in | ||
7443 | bandwidth consumption. | ||
7444 | |||
7445 | @node PUT | ||
7446 | @subsubsection PUT | ||
7447 | |||
7448 | @c %**end of header | ||
7449 | |||
7450 | @c inconsistent use of ``must'' above it's written ``MUST'' | ||
7451 | In contrast to GET operations, developers @strong{must} manually re-run | ||
7452 | PUT operations periodically (if they intend the content to continue to be | ||
7453 | available). Content stored in the DHT expires or might be lost due to | ||
7454 | churn. | ||
7455 | Furthermore, GNUnet's DHT typically requires multiple rounds of PUT | ||
7456 | operations before a key-value pair is consistently available to all | ||
7457 | peers (the DHT randomizes paths and thus storage locations, and only | ||
7458 | after multiple rounds of PUTs there will be a sufficient number of | ||
7459 | replicas in large DHTs). An explicit PUT operation using the DHT API will | ||
7460 | only cause network traffic once, so in order to ensure basic availability | ||
7461 | and resistance to churn (and adversaries), PUTs must be repeated. | ||
7462 | While the exact frequency depends on the application, a rule of thumb is | ||
7463 | that there should be at least a dozen PUT operations within the content | ||
7464 | lifetime. Content in the DHT typically expires after one day, so | ||
7465 | DHT PUT operations should be repeated at least every 1-2 hours. | ||
7466 | |||
7467 | @node MONITOR | ||
7468 | @subsubsection MONITOR | ||
7469 | |||
7470 | @c %**end of header | ||
7471 | |||
7472 | The DHT API also allows applications to monitor messages crossing the | ||
7473 | local DHT service. | ||
7474 | The types of messages used by the DHT are GET, PUT and RESULT messages. | ||
7475 | Using the monitoring API, applications can choose to monitor these | ||
7476 | requests, possibly limiting themselves to requests for a particular block | ||
7477 | type. | ||
7478 | |||
7479 | The monitoring API is not only useful for diagnostics, it can also be | ||
7480 | used to trigger application operations based on PUT operations. | ||
7481 | For example, an application may use PUTs to distribute work requests to | ||
7482 | other peers. | ||
7483 | The workers would then monitor for PUTs that give them work, instead of | ||
7484 | looking for work using GET operations. | ||
7485 | This can be beneficial, especially if the workers have no good way to | ||
7486 | guess the keys under which work would be stored. | ||
7487 | Naturally, additional protocols might be needed to ensure that the desired | ||
7488 | number of workers will process the distributed workload. | ||
7489 | |||
7490 | @node DHT Routing Options | ||
7491 | @subsubsection DHT Routing Options | ||
7492 | |||
7493 | @c %**end of header | ||
7494 | |||
7495 | There are two important options for GET and PUT requests: | ||
7496 | |||
7497 | @table @asis | ||
7498 | @item GNUNET_DHT_RO_DEMULITPLEX_EVERYWHERE This option means that all | ||
7499 | peers should process the request, even if their peer ID is not closest to | ||
7500 | the key. For a PUT request, this means that all peers that a request | ||
7501 | traverses may make a copy of the data. | ||
7502 | Similarly for a GET request, all peers will check their local database | ||
7503 | for a result. Setting this option can thus significantly improve caching | ||
7504 | and reduce bandwidth consumption --- at the expense of a larger DHT | ||
7505 | database. If in doubt, we recommend that this option should be used. | ||
7506 | @item GNUNET_DHT_RO_RECORD_ROUTE This option instructs the DHT to record | ||
7507 | the path that a GET or a PUT request is taking through the overlay | ||
7508 | network. The resulting paths are then returned to the application with | ||
7509 | the respective result. This allows the receiver of a result to construct | ||
7510 | a path to the originator of the data, which might then be used for | ||
7511 | routing. Naturally, setting this option requires additional bandwidth | ||
7512 | and disk space, so applications should only set this if the paths are | ||
7513 | needed by the application logic. | ||
7514 | @item GNUNET_DHT_RO_FIND_PEER This option is an internal option used by | ||
7515 | the DHT's peer discovery mechanism and should not be used by applications. | ||
7516 | @item GNUNET_DHT_RO_BART This option is currently not implemented. It may | ||
7517 | in the future offer performance improvements for clique topologies. | ||
7518 | @end table | ||
7519 | |||
7520 | @node The DHT Client-Service Protocol | ||
7521 | @subsection The DHT Client-Service Protocol | ||
7522 | |||
7523 | @c %**end of header | ||
7524 | |||
7525 | @menu | ||
7526 | * PUTting data into the DHT:: | ||
7527 | * GETting data from the DHT:: | ||
7528 | * Monitoring the DHT:: | ||
7529 | @end menu | ||
7530 | |||
7531 | @node PUTting data into the DHT | ||
7532 | @subsubsection PUTting data into the DHT | ||
7533 | |||
7534 | @c %**end of header | ||
7535 | |||
7536 | To store (PUT) data into the DHT, the client sends a | ||
7537 | @code{struct GNUNET_DHT_ClientPutMessage} to the service. | ||
7538 | This message specifies the block type, routing options, the desired | ||
7539 | replication level, the expiration time, key, | ||
7540 | value and a 64-bit unique ID for the operation. The service responds with | ||
7541 | a @code{struct GNUNET_DHT_ClientPutConfirmationMessage} with the same | ||
7542 | 64-bit unique ID. Note that the service sends the confirmation as soon as | ||
7543 | it has locally processed the PUT request. The PUT may still be | ||
7544 | propagating through the network at this time. | ||
7545 | |||
7546 | In the future, we may want to change this to provide (limited) feedback | ||
7547 | to the client, for example if we detect that the PUT operation had no | ||
7548 | effect because the same key-value pair was already stored in the DHT. | ||
7549 | However, changing this would also require additional state and messages | ||
7550 | in the P2P interaction. | ||
7551 | |||
7552 | @node GETting data from the DHT | ||
7553 | @subsubsection GETting data from the DHT | ||
7554 | |||
7555 | @c %**end of header | ||
7556 | |||
7557 | To retrieve (GET) data from the DHT, the client sends a | ||
7558 | @code{struct GNUNET_DHT_ClientGetMessage} to the service. The message | ||
7559 | specifies routing options, a replication level (for replicating the GET, | ||
7560 | not the content), the desired block type, the key, the (optional) | ||
7561 | extended query and unique 64-bit request ID. | ||
7562 | |||
7563 | Additionally, the client may send any number of | ||
7564 | @code{struct GNUNET_DHT_ClientGetResultSeenMessage}s to notify the | ||
7565 | service about results that the client is already aware of. | ||
7566 | These messages consist of the key, the unique 64-bit ID of the request, | ||
7567 | and an arbitrary number of hash codes over the blocks that the client is | ||
7568 | already aware of. As messages are restricted to 64k, a client that | ||
7569 | already knows more than about a thousand blocks may need to send | ||
7570 | several of these messages. Naturally, the client should transmit these | ||
7571 | messages as quickly as possible after the original GET request such that | ||
7572 | the DHT can filter those results in the network early on. Naturally, as | ||
7573 | these messages are sent after the original request, it is conceivable | ||
7574 | that the DHT service may return blocks that match those already known | ||
7575 | to the client anyway. | ||
7576 | |||
7577 | In response to a GET request, the service will send @code{struct | ||
7578 | GNUNET_DHT_ClientResultMessage}s to the client. These messages contain the | ||
7579 | block type, expiration, key, unique ID of the request and of course the | ||
7580 | value (a block). Depending on the options set for the respective | ||
7581 | operations, the replies may also contain the path the GET and/or the PUT | ||
7582 | took through the network. | ||
7583 | |||
7584 | A client can stop receiving replies either by disconnecting or by sending | ||
7585 | a @code{struct GNUNET_DHT_ClientGetStopMessage} which must contain the | ||
7586 | key and the 64-bit unique ID of the original request. Using an | ||
7587 | explicit "stop" message is more common as this allows a client to run | ||
7588 | many concurrent GET operations over the same connection with the DHT | ||
7589 | service --- and to stop them individually. | ||
7590 | |||
7591 | @node Monitoring the DHT | ||
7592 | @subsubsection Monitoring the DHT | ||
7593 | |||
7594 | @c %**end of header | ||
7595 | |||
7596 | To begin monitoring, the client sends a | ||
7597 | @code{struct GNUNET_DHT_MonitorStartStop} message to the DHT service. | ||
7598 | In this message, flags can be set to enable (or disable) monitoring of | ||
7599 | GET, PUT and RESULT messages that pass through a peer. The message can | ||
7600 | also restrict monitoring to a particular block type or a particular key. | ||
7601 | Once monitoring is enabled, the DHT service will notify the client about | ||
7602 | any matching event using @code{struct GNUNET_DHT_MonitorGetMessage}s for | ||
7603 | GET events, @code{struct GNUNET_DHT_MonitorPutMessage} for PUT events | ||
7604 | and @code{struct GNUNET_DHT_MonitorGetRespMessage} for RESULTs. Each of | ||
7605 | these messages contains all of the information about the event. | ||
7606 | |||
7607 | @node The DHT Peer-to-Peer Protocol | ||
7608 | @subsection The DHT Peer-to-Peer Protocol | ||
7609 | @c %**end of header | ||
7610 | |||
7611 | |||
7612 | @menu | ||
7613 | * Routing GETs or PUTs:: | ||
7614 | * PUTting data into the DHT2:: | ||
7615 | * GETting data from the DHT2:: | ||
7616 | @end menu | ||
7617 | |||
7618 | @node Routing GETs or PUTs | ||
7619 | @subsubsection Routing GETs or PUTs | ||
7620 | |||
7621 | @c %**end of header | ||
7622 | |||
7623 | When routing GETs or PUTs, the DHT service selects a suitable subset of | ||
7624 | neighbours for forwarding. The exact number of neighbours can be zero or | ||
7625 | more and depends on the hop counter of the query (initially zero) in | ||
7626 | relation to the (log of) the network size estimate, the desired | ||
7627 | replication level and the peer's connectivity. | ||
7628 | Depending on the hop counter and our network size estimate, the selection | ||
7629 | of the peers maybe randomized or by proximity to the key. | ||
7630 | Furthermore, requests include a set of peers that a request has already | ||
7631 | traversed; those peers are also excluded from the selection. | ||
7632 | |||
7633 | @node PUTting data into the DHT2 | ||
7634 | @subsubsection PUTting data into the DHT2 | ||
7635 | |||
7636 | @c %**end of header | ||
7637 | |||
7638 | To PUT data into the DHT, the service sends a @code{struct PeerPutMessage} | ||
7639 | of type @code{GNUNET_MESSAGE_TYPE_DHT_P2P_PUT} to the respective | ||
7640 | neighbour. | ||
7641 | In addition to the usual information about the content (type, routing | ||
7642 | options, desired replication level for the content, expiration time, key | ||
7643 | and value), the message contains a fixed-size Bloom filter with | ||
7644 | information about which peers (may) have already seen this request. | ||
7645 | This Bloom filter is used to ensure that DHT messages never loop back to | ||
7646 | a peer that has already processed the request. | ||
7647 | Additionally, the message includes the current hop counter and, depending | ||
7648 | on the routing options, the message may include the full path that the | ||
7649 | message has taken so far. | ||
7650 | The Bloom filter should already contain the identity of the previous hop; | ||
7651 | however, the path should not include the identity of the previous hop and | ||
7652 | the receiver should append the identity of the sender to the path, not | ||
7653 | its own identity (this is done to reduce bandwidth). | ||
7654 | |||
7655 | @node GETting data from the DHT2 | ||
7656 | @subsubsection GETting data from the DHT2 | ||
7657 | |||
7658 | @c %**end of header | ||
7659 | |||
7660 | A peer can search the DHT by sending @code{struct PeerGetMessage}s of type | ||
7661 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_GET} to other peers. In addition to the | ||
7662 | usual information about the request (type, routing options, desired | ||
7663 | replication level for the request, the key and the extended query), a GET | ||
7664 | request also contains a hop counter, a Bloom filter over the peers | ||
7665 | that have processed the request already and depending on the routing | ||
7666 | options the full path traversed by the GET. | ||
7667 | Finally, a GET request includes a variable-size second Bloom filter and a | ||
7668 | so-called Bloom filter mutator value which together indicate which | ||
7669 | replies the sender has already seen. During the lookup, each block that | ||
7670 | matches they block type, key and extended query is additionally subjected | ||
7671 | to a test against this Bloom filter. | ||
7672 | The block plugin is expected to take the hash of the block and combine it | ||
7673 | with the mutator value and check if the result is not yet in the Bloom | ||
7674 | filter. The originator of the query will from time to time modify the | ||
7675 | mutator to (eventually) allow false-positives filtered by the Bloom filter | ||
7676 | to be returned. | ||
7677 | |||
7678 | Peers that receive a GET request perform a local lookup (depending on | ||
7679 | their proximity to the key and the query options) and forward the request | ||
7680 | to other peers. | ||
7681 | They then remember the request (including the Bloom filter for blocking | ||
7682 | duplicate results) and when they obtain a matching, non-filtered response | ||
7683 | a @code{struct PeerResultMessage} of type | ||
7684 | @code{GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT} is forwarded to the previous | ||
7685 | hop. | ||
7686 | Whenever a result is forwarded, the block plugin is used to update the | ||
7687 | Bloom filter accordingly, to ensure that the same result is never | ||
7688 | forwarded more than once. | ||
7689 | The DHT service may also cache forwarded results locally if the | ||
7690 | "CACHE_RESULTS" option is set to "YES" in the configuration. | ||
7691 | |||
7692 | @cindex GNS | ||
7693 | @cindex GNU Name System | ||
7694 | @node GNU Name System (GNS) | ||
7695 | @section GNU Name System (GNS) | ||
7696 | |||
7697 | @c %**end of header | ||
7698 | |||
7699 | The GNU Name System (GNS) is a decentralized database that enables users | ||
7700 | to securely resolve names to values. | ||
7701 | Names can be used to identify other users (for example, in social | ||
7702 | networking), or network services (for example, VPN services running at a | ||
7703 | peer in GNUnet, or purely IP-based services on the Internet). | ||
7704 | Users interact with GNS by typing in a hostname that ends in a | ||
7705 | top-level domain that is configured in the ``GNS'' section, matches | ||
7706 | an identity of the user or ends in a Base32-encoded public key. | ||
7707 | |||
7708 | Videos giving an overview of most of the GNS and the motivations behind | ||
7709 | it is available here and here. | ||
7710 | The remainder of this chapter targets developers that are familiar with | ||
7711 | high level concepts of GNS as presented in these talks. | ||
7712 | @c TODO: Add links to here and here and to these. | ||
7713 | |||
7714 | GNS-aware applications should use the GNS resolver to obtain the | ||
7715 | respective records that are stored under that name in GNS. | ||
7716 | Each record consists of a type, value, expiration time and flags. | ||
7717 | |||
7718 | The type specifies the format of the value. Types below 65536 correspond | ||
7719 | to DNS record types, larger values are used for GNS-specific records. | ||
7720 | Applications can define new GNS record types by reserving a number and | ||
7721 | implementing a plugin (which mostly needs to convert the binary value | ||
7722 | representation to a human-readable text format and vice-versa). | ||
7723 | The expiration time specifies how long the record is to be valid. | ||
7724 | The GNS API ensures that applications are only given non-expired values. | ||
7725 | The flags are typically irrelevant for applications, as GNS uses them | ||
7726 | internally to control visibility and validity of records. | ||
7727 | |||
7728 | Records are stored along with a signature. | ||
7729 | The signature is generated using the private key of the authoritative | ||
7730 | zone. This allows any GNS resolver to verify the correctness of a | ||
7731 | name-value mapping. | ||
7732 | |||
7733 | Internally, GNS uses the NAMECACHE to cache information obtained from | ||
7734 | other users, the NAMESTORE to store information specific to the local | ||
7735 | users, and the DHT to exchange data between users. | ||
7736 | A plugin API is used to enable applications to define new GNS | ||
7737 | record types. | ||
7738 | |||
7739 | @menu | ||
7740 | * libgnunetgns:: | ||
7741 | * libgnunetgnsrecord:: | ||
7742 | * GNS plugins:: | ||
7743 | * The GNS Client-Service Protocol:: | ||
7744 | * Hijacking the DNS-Traffic using gnunet-service-dns:: | ||
7745 | * Serving DNS lookups via GNS on W32:: | ||
7746 | @end menu | ||
7747 | |||
7748 | @node libgnunetgns | ||
7749 | @subsection libgnunetgns | ||
7750 | |||
7751 | @c %**end of header | ||
7752 | |||
7753 | The GNS API itself is extremely simple. Clients first connect to the | ||
7754 | GNS service using @code{GNUNET_GNS_connect}. | ||
7755 | They can then perform lookups using @code{GNUNET_GNS_lookup} or cancel | ||
7756 | pending lookups using @code{GNUNET_GNS_lookup_cancel}. | ||
7757 | Once finished, clients disconnect using @code{GNUNET_GNS_disconnect}. | ||
7758 | |||
7759 | @menu | ||
7760 | * Looking up records:: | ||
7761 | * Accessing the records:: | ||
7762 | * Creating records:: | ||
7763 | * Future work:: | ||
7764 | @end menu | ||
7765 | |||
7766 | @node Looking up records | ||
7767 | @subsubsection Looking up records | ||
7768 | |||
7769 | @c %**end of header | ||
7770 | |||
7771 | @code{GNUNET_GNS_lookup} takes a number of arguments: | ||
7772 | |||
7773 | @table @asis | ||
7774 | @item handle This is simply the GNS connection handle from | ||
7775 | @code{GNUNET_GNS_connect}. | ||
7776 | @item name The client needs to specify the name to | ||
7777 | be resolved. This can be any valid DNS or GNS hostname. | ||
7778 | @item zone The client | ||
7779 | needs to specify the public key of the GNS zone against which the | ||
7780 | resolution should be done. | ||
7781 | Note that a key must be provided, the client should | ||
7782 | look up plausible values using its configuration, | ||
7783 | the identity service and by attempting to interpret the | ||
7784 | TLD as a base32-encoded public key. | ||
7785 | @item type This is the desired GNS or DNS record type | ||
7786 | to look for. While all records for the given name will be returned, this | ||
7787 | can be important if the client wants to resolve record types that | ||
7788 | themselves delegate resolution, such as CNAME, PKEY or GNS2DNS. | ||
7789 | Resolving a record of any of these types will only work if the respective | ||
7790 | record type is specified in the request, as the GNS resolver will | ||
7791 | otherwise follow the delegation and return the records from the | ||
7792 | respective destination, instead of the delegating record. | ||
7793 | @item only_cached This argument should typically be set to | ||
7794 | @code{GNUNET_NO}. Setting it to @code{GNUNET_YES} disables resolution via | ||
7795 | the overlay network. | ||
7796 | @item shorten_zone_key If GNS encounters new names during resolution, | ||
7797 | their respective zones can automatically be learned and added to the | ||
7798 | "shorten zone". If this is desired, clients must pass the private key of | ||
7799 | the shorten zone. If NULL is passed, shortening is disabled. | ||
7800 | @item proc This argument identifies | ||
7801 | the function to call with the result. It is given proc_cls, the number of | ||
7802 | records found (possibly zero) and the array of the records as arguments. | ||
7803 | proc will only be called once. After proc,> has been called, the lookup | ||
7804 | must no longer be canceled. | ||
7805 | @item proc_cls The closure for proc. | ||
7806 | @end table | ||
7807 | |||
7808 | @node Accessing the records | ||
7809 | @subsubsection Accessing the records | ||
7810 | |||
7811 | @c %**end of header | ||
7812 | |||
7813 | The @code{libgnunetgnsrecord} library provides an API to manipulate the | ||
7814 | GNS record array that is given to proc. In particular, it offers | ||
7815 | functions such as converting record values to human-readable | ||
7816 | strings (and back). However, most @code{libgnunetgnsrecord} functions are | ||
7817 | not interesting to GNS client applications. | ||
7818 | |||
7819 | For DNS records, the @code{libgnunetdnsparser} library provides | ||
7820 | functions for parsing (and serializing) common types of DNS records. | ||
7821 | |||
7822 | @node Creating records | ||
7823 | @subsubsection Creating records | ||
7824 | |||
7825 | @c %**end of header | ||
7826 | |||
7827 | Creating GNS records is typically done by building the respective record | ||
7828 | information (possibly with the help of @code{libgnunetgnsrecord} and | ||
7829 | @code{libgnunetdnsparser}) and then using the @code{libgnunetnamestore} to | ||
7830 | publish the information. The GNS API is not involved in this | ||
7831 | operation. | ||
7832 | |||
7833 | @node Future work | ||
7834 | @subsubsection Future work | ||
7835 | |||
7836 | @c %**end of header | ||
7837 | |||
7838 | In the future, we want to expand @code{libgnunetgns} to allow | ||
7839 | applications to observe shortening operations performed during GNS | ||
7840 | resolution, for example so that users can receive visual feedback when | ||
7841 | this happens. | ||
7842 | |||
7843 | @node libgnunetgnsrecord | ||
7844 | @subsection libgnunetgnsrecord | ||
7845 | |||
7846 | @c %**end of header | ||
7847 | |||
7848 | The @code{libgnunetgnsrecord} library is used to manipulate GNS | ||
7849 | records (in plaintext or in their encrypted format). | ||
7850 | Applications mostly interact with @code{libgnunetgnsrecord} by using the | ||
7851 | functions to convert GNS record values to strings or vice-versa, or to | ||
7852 | lookup a GNS record type number by name (or vice-versa). | ||
7853 | The library also provides various other functions that are mostly | ||
7854 | used internally within GNS, such as converting keys to names, checking for | ||
7855 | expiration, encrypting GNS records to GNS blocks, verifying GNS block | ||
7856 | signatures and decrypting GNS records from GNS blocks. | ||
7857 | |||
7858 | We will now discuss the four commonly used functions of the API.@ | ||
7859 | @code{libgnunetgnsrecord} does not perform these operations itself, | ||
7860 | but instead uses plugins to perform the operation. | ||
7861 | GNUnet includes plugins to support common DNS record types as well as | ||
7862 | standard GNS record types. | ||
7863 | |||
7864 | @menu | ||
7865 | * Value handling:: | ||
7866 | * Type handling:: | ||
7867 | @end menu | ||
7868 | |||
7869 | @node Value handling | ||
7870 | @subsubsection Value handling | ||
7871 | |||
7872 | @c %**end of header | ||
7873 | |||
7874 | @code{GNUNET_GNSRECORD_value_to_string} can be used to convert | ||
7875 | the (binary) representation of a GNS record value to a human readable, | ||
7876 | 0-terminated UTF-8 string. | ||
7877 | NULL is returned if the specified record type is not supported by any | ||
7878 | available plugin. | ||
7879 | |||
7880 | @code{GNUNET_GNSRECORD_string_to_value} can be used to try to convert a | ||
7881 | human readable string to the respective (binary) representation of | ||
7882 | a GNS record value. | ||
7883 | |||
7884 | @node Type handling | ||
7885 | @subsubsection Type handling | ||
7886 | |||
7887 | @c %**end of header | ||
7888 | |||
7889 | @code{GNUNET_GNSRECORD_typename_to_number} can be used to obtain the | ||
7890 | numeric value associated with a given typename. For example, given the | ||
7891 | typename "A" (for DNS A reocrds), the function will return the number 1. | ||
7892 | A list of common DNS record types is | ||
7893 | @uref{http://en.wikipedia.org/wiki/List_of_DNS_record_types, here}. | ||
7894 | Note that not all DNS record types are supported by GNUnet GNSRECORD | ||
7895 | plugins at this time. | ||
7896 | |||
7897 | @code{GNUNET_GNSRECORD_number_to_typename} can be used to obtain the | ||
7898 | typename associated with a given numeric value. | ||
7899 | For example, given the type number 1, the function will return the | ||
7900 | typename "A". | ||
7901 | |||
7902 | @node GNS plugins | ||
7903 | @subsection GNS plugins | ||
7904 | |||
7905 | @c %**end of header | ||
7906 | |||
7907 | Adding a new GNS record type typically involves writing (or extending) a | ||
7908 | GNSRECORD plugin. The plugin needs to implement the | ||
7909 | @code{gnunet_gnsrecord_plugin.h} API which provides basic functions that | ||
7910 | are needed by GNSRECORD to convert typenames and values of the respective | ||
7911 | record type to strings (and back). | ||
7912 | These gnsrecord plugins are typically implemented within their respective | ||
7913 | subsystems. | ||
7914 | Examples for such plugins can be found in the GNSRECORD, GNS and | ||
7915 | CONVERSATION subsystems. | ||
7916 | |||
7917 | The @code{libgnunetgnsrecord} library is then used to locate, load and | ||
7918 | query the appropriate gnsrecord plugin. | ||
7919 | Which plugin is appropriate is determined by the record type (which is | ||
7920 | just a 32-bit integer). The @code{libgnunetgnsrecord} library loads all | ||
7921 | block plugins that are installed at the local peer and forwards the | ||
7922 | application request to the plugins. If the record type is not | ||
7923 | supported by the plugin, it should simply return an error code. | ||
7924 | |||
7925 | The central functions of the block APIs (plugin and main library) are the | ||
7926 | same four functions for converting between values and strings, and | ||
7927 | typenames and numbers documented in the previous subsection. | ||
7928 | |||
7929 | @node The GNS Client-Service Protocol | ||
7930 | @subsection The GNS Client-Service Protocol | ||
7931 | @c %**end of header | ||
7932 | |||
7933 | The GNS client-service protocol consists of two simple messages, the | ||
7934 | @code{LOOKUP} message and the @code{LOOKUP_RESULT}. Each @code{LOOKUP} | ||
7935 | message contains a unique 32-bit identifier, which will be included in the | ||
7936 | corresponding response. Thus, clients can send many lookup requests in | ||
7937 | parallel and receive responses out-of-order. | ||
7938 | A @code{LOOKUP} request also includes the public key of the GNS zone, | ||
7939 | the desired record type and fields specifying whether shortening is | ||
7940 | enabled or networking is disabled. Finally, the @code{LOOKUP} message | ||
7941 | includes the name to be resolved. | ||
7942 | |||
7943 | The response includes the number of records and the records themselves | ||
7944 | in the format created by @code{GNUNET_GNSRECORD_records_serialize}. | ||
7945 | They can thus be deserialized using | ||
7946 | @code{GNUNET_GNSRECORD_records_deserialize}. | ||
7947 | |||
7948 | @node Hijacking the DNS-Traffic using gnunet-service-dns | ||
7949 | @subsection Hijacking the DNS-Traffic using gnunet-service-dns | ||
7950 | |||
7951 | @c %**end of header | ||
7952 | |||
7953 | This section documents how the gnunet-service-dns (and the | ||
7954 | gnunet-helper-dns) intercepts DNS queries from the local system. | ||
7955 | This is merely one method for how we can obtain GNS queries. | ||
7956 | It is also possible to change @code{resolv.conf} to point to a machine | ||
7957 | running @code{gnunet-dns2gns} or to modify libc's name system switch | ||
7958 | (NSS) configuration to include a GNS resolution plugin. | ||
7959 | The method described in this chapter is more of a last-ditch catch-all | ||
7960 | approach. | ||
7961 | |||
7962 | @code{gnunet-service-dns} enables intercepting DNS traffic using policy | ||
7963 | based routing. | ||
7964 | We MARK every outgoing DNS-packet if it was not sent by our application. | ||
7965 | Using a second routing table in the Linux kernel these marked packets are | ||
7966 | then routed through our virtual network interface and can thus be | ||
7967 | captured unchanged. | ||
7968 | |||
7969 | Our application then reads the query and decides how to handle it. | ||
7970 | If the query can be addressed via GNS, it is passed to | ||
7971 | @code{gnunet-service-gns} and resolved internally using GNS. | ||
7972 | In the future, a reverse query for an address of the configured virtual | ||
7973 | network could be answered with records kept about previous forward | ||
7974 | queries. | ||
7975 | Queries that are not hijacked by some application using the DNS service | ||
7976 | will be sent to the original recipient. | ||
7977 | The answer to the query will always be sent back through the virtual | ||
7978 | interface with the original nameserver as source address. | ||
7979 | |||
7980 | |||
7981 | @menu | ||
7982 | * Network Setup Details:: | ||
7983 | @end menu | ||
7984 | |||
7985 | @node Network Setup Details | ||
7986 | @subsubsection Network Setup Details | ||
7987 | |||
7988 | @c %**end of header | ||
7989 | |||
7990 | The DNS interceptor adds the following rules to the Linux kernel: | ||
7991 | @example | ||
7992 | iptables -t mangle -I OUTPUT 1 -p udp --sport $LOCALPORT --dport 53 \ | ||
7993 | -j ACCEPT iptables -t mangle -I OUTPUT 2 -p udp --dport 53 -j MARK \ | ||
7994 | --set-mark 3 ip rule add fwmark 3 table2 ip route add default via \ | ||
7995 | $VIRTUALDNS table2 | ||
7996 | @end example | ||
7997 | |||
7998 | @c FIXME: Rewrite to reflect display which is no longer content by line | ||
7999 | @c FIXME: due to the < 74 characters limit. | ||
8000 | Line 1 makes sure that all packets coming from a port our application | ||
8001 | opened beforehand (@code{$LOCALPORT}) will be routed normally. | ||
8002 | Line 2 marks every other packet to a DNS-Server with mark 3 (chosen | ||
8003 | arbitrarily). The third line adds a routing policy based on this mark | ||
8004 | 3 via the routing table. | ||
8005 | |||
8006 | @node Serving DNS lookups via GNS on W32 | ||
8007 | @subsection Serving DNS lookups via GNS on W32 | ||
8008 | |||
8009 | @c %**end of header | ||
8010 | |||
8011 | This section documents how the libw32nsp (and | ||
8012 | gnunet-gns-helper-service-w32) do DNS resolutions of DNS queries on the | ||
8013 | local system. This only applies to GNUnet running on W32. | ||
8014 | |||
8015 | W32 has a concept of "Namespaces" and "Namespace providers". | ||
8016 | These are used to present various name systems to applications in a | ||
8017 | generic way. | ||
8018 | Namespaces include DNS, mDNS, NLA and others. For each namespace any | ||
8019 | number of providers could be registered, and they are queried in an order | ||
8020 | of priority (which is adjustable). | ||
8021 | |||
8022 | Applications can resolve names by using WSALookupService*() family of | ||
8023 | functions. | ||
8024 | |||
8025 | However, these are WSA-only facilities. Common BSD socket functions for | ||
8026 | namespace resolutions are gethostbyname and getaddrinfo (among others). | ||
8027 | These functions are implemented internally (by default - by mswsock, | ||
8028 | which also implements the default DNS provider) as wrappers around | ||
8029 | WSALookupService*() functions (see "Sample Code for a Service Provider" | ||
8030 | on MSDN). | ||
8031 | |||
8032 | On W32 GNUnet builds a libw32nsp - a namespace provider, which can then be | ||
8033 | installed into the system by using w32nsp-install (and uninstalled by | ||
8034 | w32nsp-uninstall), as described in "Installation Handbook". | ||
8035 | |||
8036 | libw32nsp is very simple and has almost no dependencies. As a response to | ||
8037 | NSPLookupServiceBegin(), it only checks that the provider GUID passed to | ||
8038 | it by the caller matches GNUnet DNS Provider GUID, | ||
8039 | then connects to | ||
8040 | gnunet-gns-helper-service-w32 at 127.0.0.1:5353 (hardcoded) and sends the | ||
8041 | name resolution request there, returning the connected socket to the | ||
8042 | caller. | ||
8043 | |||
8044 | When the caller invokes NSPLookupServiceNext(), libw32nsp reads a | ||
8045 | completely formed reply from that socket, unmarshalls it, then gives | ||
8046 | it back to the caller. | ||
8047 | |||
8048 | At the moment gnunet-gns-helper-service-w32 is implemented to ever give | ||
8049 | only one reply, and subsequent calls to NSPLookupServiceNext() will fail | ||
8050 | with WSA_NODATA (first call to NSPLookupServiceNext() might also fail if | ||
8051 | GNS failed to find the name, or there was an error connecting to it). | ||
8052 | |||
8053 | gnunet-gns-helper-service-w32 does most of the processing: | ||
8054 | |||
8055 | @itemize @bullet | ||
8056 | @item Maintains a connection to GNS. | ||
8057 | @item Reads GNS config and loads appropriate keys. | ||
8058 | @item Checks service GUID and decides on the type of record to look up, | ||
8059 | refusing to make a lookup outright when unsupported service GUID is | ||
8060 | passed. | ||
8061 | @item Launches the lookup | ||
8062 | @end itemize | ||
8063 | |||
8064 | When lookup result arrives, gnunet-gns-helper-service-w32 forms a complete | ||
8065 | reply (including filling a WSAQUERYSETW structure and, possibly, a binary | ||
8066 | blob with a hostent structure for gethostbyname() client), marshalls it, | ||
8067 | and sends it back to libw32nsp. If no records were found, it sends an | ||
8068 | empty header. | ||
8069 | |||
8070 | This works for most normal applications that use gethostbyname() or | ||
8071 | getaddrinfo() to resolve names, but fails to do anything with | ||
8072 | applications that use alternative means of resolving names (such as | ||
8073 | sending queries to a DNS server directly by themselves). | ||
8074 | This includes some of well known utilities, like "ping" and "nslookup". | ||
8075 | |||
8076 | @cindex GNS Namecache | ||
8077 | @node GNS Namecache | ||
8078 | @section GNS Namecache | ||
8079 | |||
8080 | @c %**end of header | ||
8081 | |||
8082 | The NAMECACHE subsystem is responsible for caching (encrypted) resolution | ||
8083 | results of the GNU Name System (GNS). GNS makes zone information available | ||
8084 | to other users via the DHT. However, as accessing the DHT for every | ||
8085 | lookup is expensive (and as the DHT's local cache is lost whenever the | ||
8086 | peer is restarted), GNS uses the NAMECACHE as a more persistent cache for | ||
8087 | DHT lookups. | ||
8088 | Thus, instead of always looking up every name in the DHT, GNS first | ||
8089 | checks if the result is already available locally in the NAMECACHE. | ||
8090 | Only if there is no result in the NAMECACHE, GNS queries the DHT. | ||
8091 | The NAMECACHE stores data in the same (encrypted) format as the DHT. | ||
8092 | It thus makes no sense to iterate over all items in the | ||
8093 | NAMECACHE --- the NAMECACHE does not have a way to provide the keys | ||
8094 | required to decrypt the entries. | ||
8095 | |||
8096 | Blocks in the NAMECACHE share the same expiration mechanism as blocks in | ||
8097 | the DHT --- the block expires wheneever any of the records in | ||
8098 | the (encrypted) block expires. | ||
8099 | The expiration time of the block is the only information stored in | ||
8100 | plaintext. The NAMECACHE service internally performs all of the required | ||
8101 | work to expire blocks, clients do not have to worry about this. | ||
8102 | Also, given that NAMECACHE stores only GNS blocks that local users | ||
8103 | requested, there is no configuration option to limit the size of the | ||
8104 | NAMECACHE. It is assumed to be always small enough (a few MB) to fit on | ||
8105 | the drive. | ||
8106 | |||
8107 | The NAMECACHE supports the use of different database backends via a | ||
8108 | plugin API. | ||
8109 | |||
8110 | @menu | ||
8111 | * libgnunetnamecache:: | ||
8112 | * The NAMECACHE Client-Service Protocol:: | ||
8113 | * The NAMECACHE Plugin API:: | ||
8114 | @end menu | ||
8115 | |||
8116 | @node libgnunetnamecache | ||
8117 | @subsection libgnunetnamecache | ||
8118 | |||
8119 | @c %**end of header | ||
8120 | |||
8121 | The NAMECACHE API consists of five simple functions. First, there is | ||
8122 | @code{GNUNET_NAMECACHE_connect} to connect to the NAMECACHE service. | ||
8123 | This returns the handle required for all other operations on the | ||
8124 | NAMECACHE. Using @code{GNUNET_NAMECACHE_block_cache} clients can insert a | ||
8125 | block into the cache. | ||
8126 | @code{GNUNET_NAMECACHE_lookup_block} can be used to lookup blocks that | ||
8127 | were stored in the NAMECACHE. Both operations can be canceled using | ||
8128 | @code{GNUNET_NAMECACHE_cancel}. Note that canceling a | ||
8129 | @code{GNUNET_NAMECACHE_block_cache} operation can result in the block | ||
8130 | being stored in the NAMECACHE --- or not. Cancellation primarily ensures | ||
8131 | that the continuation function with the result of the operation will no | ||
8132 | longer be invoked. | ||
8133 | Finally, @code{GNUNET_NAMECACHE_disconnect} closes the connection to the | ||
8134 | NAMECACHE. | ||
8135 | |||
8136 | The maximum size of a block that can be stored in the NAMECACHE is | ||
8137 | @code{GNUNET_NAMECACHE_MAX_VALUE_SIZE}, which is defined to be 63 kB. | ||
8138 | |||
8139 | @node The NAMECACHE Client-Service Protocol | ||
8140 | @subsection The NAMECACHE Client-Service Protocol | ||
8141 | |||
8142 | @c %**end of header | ||
8143 | |||
8144 | All messages in the NAMECACHE IPC protocol start with the | ||
8145 | @code{struct GNUNET_NAMECACHE_Header} which adds a request | ||
8146 | ID (32-bit integer) to the standard message header. | ||
8147 | The request ID is used to match requests with the | ||
8148 | respective responses from the NAMECACHE, as they are allowed to happen | ||
8149 | out-of-order. | ||
8150 | |||
8151 | |||
8152 | @menu | ||
8153 | * Lookup:: | ||
8154 | * Store:: | ||
8155 | @end menu | ||
8156 | |||
8157 | @node Lookup | ||
8158 | @subsubsection Lookup | ||
8159 | |||
8160 | @c %**end of header | ||
8161 | |||
8162 | The @code{struct LookupBlockMessage} is used to lookup a block stored in | ||
8163 | the cache. | ||
8164 | It contains the query hash. The NAMECACHE always responds with a | ||
8165 | @code{struct LookupBlockResponseMessage}. If the NAMECACHE has no | ||
8166 | response, it sets the expiration time in the response to zero. | ||
8167 | Otherwise, the response is expected to contain the expiration time, the | ||
8168 | ECDSA signature, the derived key and the (variable-size) encrypted data | ||
8169 | of the block. | ||
8170 | |||
8171 | @node Store | ||
8172 | @subsubsection Store | ||
8173 | |||
8174 | @c %**end of header | ||
8175 | |||
8176 | The @code{struct BlockCacheMessage} is used to cache a block in the | ||
8177 | NAMECACHE. | ||
8178 | It has the same structure as the @code{struct LookupBlockResponseMessage}. | ||
8179 | The service responds with a @code{struct BlockCacheResponseMessage} which | ||
8180 | contains the result of the operation (success or failure). | ||
8181 | In the future, we might want to make it possible to provide an error | ||
8182 | message as well. | ||
8183 | |||
8184 | @node The NAMECACHE Plugin API | ||
8185 | @subsection The NAMECACHE Plugin API | ||
8186 | @c %**end of header | ||
8187 | |||
8188 | The NAMECACHE plugin API consists of two functions, @code{cache_block} to | ||
8189 | store a block in the database, and @code{lookup_block} to lookup a block | ||
8190 | in the database. | ||
8191 | |||
8192 | |||
8193 | @menu | ||
8194 | * Lookup2:: | ||
8195 | * Store2:: | ||
8196 | @end menu | ||
8197 | |||
8198 | @node Lookup2 | ||
8199 | @subsubsection Lookup2 | ||
8200 | |||
8201 | @c %**end of header | ||
8202 | |||
8203 | The @code{lookup_block} function is expected to return at most one block | ||
8204 | to the iterator, and return @code{GNUNET_NO} if there were no non-expired | ||
8205 | results. | ||
8206 | If there are multiple non-expired results in the cache, the lookup is | ||
8207 | supposed to return the result with the largest expiration time. | ||
8208 | |||
8209 | @node Store2 | ||
8210 | @subsubsection Store2 | ||
8211 | |||
8212 | @c %**end of header | ||
8213 | |||
8214 | The @code{cache_block} function is expected to try to store the block in | ||
8215 | the database, and return @code{GNUNET_SYSERR} if this was not possible | ||
8216 | for any reason. | ||
8217 | Furthermore, @code{cache_block} is expected to implicitly perform cache | ||
8218 | maintenance and purge blocks from the cache that have expired. Note that | ||
8219 | @code{cache_block} might encounter the case where the database already has | ||
8220 | another block stored under the same key. In this case, the plugin must | ||
8221 | ensure that the block with the larger expiration time is preserved. | ||
8222 | Obviously, this can done either by simply adding new blocks and selecting | ||
8223 | for the most recent expiration time during lookup, or by checking which | ||
8224 | block is more recent during the store operation. | ||
8225 | |||
8226 | @cindex REVOCATION Subsystem | ||
8227 | @node REVOCATION Subsystem | ||
8228 | @section REVOCATION Subsystem | ||
8229 | @c %**end of header | ||
8230 | |||
8231 | The REVOCATION subsystem is responsible for key revocation of Egos. | ||
8232 | If a user learns that theis private key has been compromised or has lost | ||
8233 | it, they can use the REVOCATION system to inform all of the other users | ||
8234 | that their private key is no longer valid. | ||
8235 | The subsystem thus includes ways to query for the validity of keys and to | ||
8236 | propagate revocation messages. | ||
8237 | |||
8238 | @menu | ||
8239 | * Dissemination:: | ||
8240 | * Revocation Message Design Requirements:: | ||
8241 | * libgnunetrevocation:: | ||
8242 | * The REVOCATION Client-Service Protocol:: | ||
8243 | * The REVOCATION Peer-to-Peer Protocol:: | ||
8244 | @end menu | ||
8245 | |||
8246 | @node Dissemination | ||
8247 | @subsection Dissemination | ||
8248 | |||
8249 | @c %**end of header | ||
8250 | |||
8251 | When a revocation is performed, the revocation is first of all | ||
8252 | disseminated by flooding the overlay network. | ||
8253 | The goal is to reach every peer, so that when a peer needs to check if a | ||
8254 | key has been revoked, this will be purely a local operation where the | ||
8255 | peer looks at its local revocation list. Flooding the network is also the | ||
8256 | most robust form of key revocation --- an adversary would have to control | ||
8257 | a separator of the overlay graph to restrict the propagation of the | ||
8258 | revocation message. Flooding is also very easy to implement --- peers that | ||
8259 | receive a revocation message for a key that they have never seen before | ||
8260 | simply pass the message to all of their neighbours. | ||
8261 | |||
8262 | Flooding can only distribute the revocation message to peers that are | ||
8263 | online. | ||
8264 | In order to notify peers that join the network later, the revocation | ||
8265 | service performs efficient set reconciliation over the sets of known | ||
8266 | revocation messages whenever two peers (that both support REVOCATION | ||
8267 | dissemination) connect. | ||
8268 | The SET service is used to perform this operation efficiently. | ||
8269 | |||
8270 | @node Revocation Message Design Requirements | ||
8271 | @subsection Revocation Message Design Requirements | ||
8272 | |||
8273 | @c %**end of header | ||
8274 | |||
8275 | However, flooding is also quite costly, creating O(|E|) messages on a | ||
8276 | network with |E| edges. | ||
8277 | Thus, revocation messages are required to contain a proof-of-work, the | ||
8278 | result of an expensive computation (which, however, is cheap to verify). | ||
8279 | Only peers that have expended the CPU time necessary to provide | ||
8280 | this proof will be able to flood the network with the revocation message. | ||
8281 | This ensures that an attacker cannot simply flood the network with | ||
8282 | millions of revocation messages. The proof-of-work required by GNUnet is | ||
8283 | set to take days on a typical PC to compute; if the ability to quickly | ||
8284 | revoke a key is needed, users have the option to pre-compute revocation | ||
8285 | messages to store off-line and use instantly after their key has expired. | ||
8286 | |||
8287 | Revocation messages must also be signed by the private key that is being | ||
8288 | revoked. Thus, they can only be created while the private key is in the | ||
8289 | possession of the respective user. This is another reason to create a | ||
8290 | revocation message ahead of time and store it in a secure location. | ||
8291 | |||
8292 | @node libgnunetrevocation | ||
8293 | @subsection libgnunetrevocation | ||
8294 | |||
8295 | @c %**end of header | ||
8296 | |||
8297 | The REVOCATION API consists of two parts, to query and to issue | ||
8298 | revocations. | ||
8299 | |||
8300 | |||
8301 | @menu | ||
8302 | * Querying for revoked keys:: | ||
8303 | * Preparing revocations:: | ||
8304 | * Issuing revocations:: | ||
8305 | @end menu | ||
8306 | |||
8307 | @node Querying for revoked keys | ||
8308 | @subsubsection Querying for revoked keys | ||
8309 | |||
8310 | @c %**end of header | ||
8311 | |||
8312 | @code{GNUNET_REVOCATION_query} is used to check if a given ECDSA public | ||
8313 | key has been revoked. | ||
8314 | The given callback will be invoked with the result of the check. | ||
8315 | The query can be canceled using @code{GNUNET_REVOCATION_query_cancel} on | ||
8316 | the return value. | ||
8317 | |||
8318 | @node Preparing revocations | ||
8319 | @subsubsection Preparing revocations | ||
8320 | |||
8321 | @c %**end of header | ||
8322 | |||
8323 | It is often desirable to create a revocation record ahead-of-time and | ||
8324 | store it in an off-line location to be used later in an emergency. | ||
8325 | This is particularly true for GNUnet revocations, where performing the | ||
8326 | revocation operation itself is computationally expensive and thus is | ||
8327 | likely to take some time. | ||
8328 | Thus, if users want the ability to perform revocations quickly in an | ||
8329 | emergency, they must pre-compute the revocation message. | ||
8330 | The revocation API enables this with two functions that are used to | ||
8331 | compute the revocation message, but not trigger the actual revocation | ||
8332 | operation. | ||
8333 | |||
8334 | @code{GNUNET_REVOCATION_check_pow} should be used to calculate the | ||
8335 | proof-of-work required in the revocation message. This function takes the | ||
8336 | public key, the required number of bits for the proof of work (which in | ||
8337 | GNUnet is a network-wide constant) and finally a proof-of-work number as | ||
8338 | arguments. | ||
8339 | The function then checks if the given proof-of-work number is a valid | ||
8340 | proof of work for the given public key. Clients preparing a revocation | ||
8341 | are expected to call this function repeatedly (typically with a | ||
8342 | monotonically increasing sequence of numbers of the proof-of-work number) | ||
8343 | until a given number satisfies the check. | ||
8344 | That number should then be saved for later use in the revocation | ||
8345 | operation. | ||
8346 | |||
8347 | @code{GNUNET_REVOCATION_sign_revocation} is used to generate the | ||
8348 | signature that is required in a revocation message. | ||
8349 | It takes the private key that (possibly in the future) is to be revoked | ||
8350 | and returns the signature. | ||
8351 | The signature can again be saved to disk for later use, which will then | ||
8352 | allow performing a revocation even without access to the private key. | ||
8353 | |||
8354 | @node Issuing revocations | ||
8355 | @subsubsection Issuing revocations | ||
8356 | |||
8357 | |||
8358 | Given a ECDSA public key, the signature from @code{GNUNET_REVOCATION_sign} | ||
8359 | and the proof-of-work, | ||
8360 | @code{GNUNET_REVOCATION_revoke} can be used to perform the | ||
8361 | actual revocation. The given callback is called upon completion of the | ||
8362 | operation. @code{GNUNET_REVOCATION_revoke_cancel} can be used to stop the | ||
8363 | library from calling the continuation; however, in that case it is | ||
8364 | undefined whether or not the revocation operation will be executed. | ||
8365 | |||
8366 | @node The REVOCATION Client-Service Protocol | ||
8367 | @subsection The REVOCATION Client-Service Protocol | ||
8368 | |||
8369 | |||
8370 | The REVOCATION protocol consists of four simple messages. | ||
8371 | |||
8372 | A @code{QueryMessage} containing a public ECDSA key is used to check if a | ||
8373 | particular key has been revoked. The service responds with a | ||
8374 | @code{QueryResponseMessage} which simply contains a bit that says if the | ||
8375 | given public key is still valid, or if it has been revoked. | ||
8376 | |||
8377 | The second possible interaction is for a client to revoke a key by | ||
8378 | passing a @code{RevokeMessage} to the service. The @code{RevokeMessage} | ||
8379 | contains the ECDSA public key to be revoked, a signature by the | ||
8380 | corresponding private key and the proof-of-work, The service responds | ||
8381 | with a @code{RevocationResponseMessage} which can be used to indicate | ||
8382 | that the @code{RevokeMessage} was invalid (i.e. proof of work incorrect), | ||
8383 | or otherwise indicates that the revocation has been processed | ||
8384 | successfully. | ||
8385 | |||
8386 | @node The REVOCATION Peer-to-Peer Protocol | ||
8387 | @subsection The REVOCATION Peer-to-Peer Protocol | ||
8388 | |||
8389 | @c %**end of header | ||
8390 | |||
8391 | Revocation uses two disjoint ways to spread revocation information among | ||
8392 | peers. | ||
8393 | First of all, P2P gossip exchanged via CORE-level neighbours is used to | ||
8394 | quickly spread revocations to all connected peers. | ||
8395 | Second, whenever two peers (that both support revocations) connect, | ||
8396 | the SET service is used to compute the union of the respective revocation | ||
8397 | sets. | ||
8398 | |||
8399 | In both cases, the exchanged messages are @code{RevokeMessage}s which | ||
8400 | contain the public key that is being revoked, a matching ECDSA signature, | ||
8401 | and a proof-of-work. | ||
8402 | Whenever a peer learns about a new revocation this way, it first | ||
8403 | validates the signature and the proof-of-work, then stores it to disk | ||
8404 | (typically to a file $GNUNET_DATA_HOME/revocation.dat) and finally | ||
8405 | spreads the information to all directly connected neighbours. | ||
8406 | |||
8407 | For computing the union using the SET service, the peer with the smaller | ||
8408 | hashed peer identity will connect (as a "client" in the two-party set | ||
8409 | protocol) to the other peer after one second (to reduce traffic spikes | ||
8410 | on connect) and initiate the computation of the set union. | ||
8411 | All revocation services use a common hash to identify the SET operation | ||
8412 | over revocation sets. | ||
8413 | |||
8414 | The current implementation accepts revocation set union operations from | ||
8415 | all peers at any time; however, well-behaved peers should only initiate | ||
8416 | this operation once after establishing a connection to a peer with a | ||
8417 | larger hashed peer identity. | ||
8418 | |||
8419 | @cindex FS | ||
8420 | @cindex FS Subsystem | ||
8421 | @node File-sharing (FS) Subsystem | ||
8422 | @section File-sharing (FS) Subsystem | ||
8423 | |||
8424 | @c %**end of header | ||
8425 | |||
8426 | This chapter describes the details of how the file-sharing service works. | ||
8427 | As with all services, it is split into an API (libgnunetfs), the service | ||
8428 | process (gnunet-service-fs) and user interface(s). | ||
8429 | The file-sharing service uses the datastore service to store blocks and | ||
8430 | the DHT (and indirectly datacache) for lookups for non-anonymous | ||
8431 | file-sharing. | ||
8432 | Furthermore, the file-sharing service uses the block library (and the | ||
8433 | block fs plugin) for validation of DHT operations. | ||
8434 | |||
8435 | In contrast to many other services, libgnunetfs is rather complex since | ||
8436 | the client library includes a large number of high-level abstractions; | ||
8437 | this is necessary since the Fs service itself largely only operates on | ||
8438 | the block level. | ||
8439 | The FS library is responsible for providing a file-based abstraction to | ||
8440 | applications, including directories, meta data, keyword search, | ||
8441 | verification, and so on. | ||
8442 | |||
8443 | The method used by GNUnet to break large files into blocks and to use | ||
8444 | keyword search is called the | ||
8445 | "Encoding for Censorship Resistant Sharing" (ECRS). | ||
8446 | ECRS is largely implemented in the fs library; block validation is also | ||
8447 | reflected in the block FS plugin and the FS service. | ||
8448 | ECRS on-demand encoding is implemented in the FS service. | ||
8449 | |||
8450 | NOTE: The documentation in this chapter is quite incomplete. | ||
8451 | |||
8452 | @menu | ||
8453 | * Encoding for Censorship-Resistant Sharing (ECRS):: | ||
8454 | * File-sharing persistence directory structure:: | ||
8455 | @end menu | ||
8456 | |||
8457 | @cindex ECRS | ||
8458 | @cindex Encoding for Censorship-Resistant Sharing | ||
8459 | @node Encoding for Censorship-Resistant Sharing (ECRS) | ||
8460 | @subsection Encoding for Censorship-Resistant Sharing (ECRS) | ||
8461 | |||
8462 | @c %**end of header | ||
8463 | |||
8464 | When GNUnet shares files, it uses a content encoding that is called ECRS, | ||
8465 | the Encoding for Censorship-Resistant Sharing. | ||
8466 | Most of ECRS is described in the (so far unpublished) research paper | ||
8467 | attached to this page. ECRS obsoletes the previous ESED and ESED II | ||
8468 | encodings which were used in GNUnet before version 0.7.0. | ||
8469 | The rest of this page assumes that the reader is familiar with the | ||
8470 | attached paper. What follows is a description of some minor extensions | ||
8471 | that GNUnet makes over what is described in the paper. | ||
8472 | The reason why these extensions are not in the paper is that we felt | ||
8473 | that they were obvious or trivial extensions to the original scheme and | ||
8474 | thus did not warrant space in the research report. | ||
8475 | |||
8476 | @menu | ||
8477 | * Namespace Advertisements:: | ||
8478 | * KSBlocks:: | ||
8479 | @end menu | ||
8480 | |||
8481 | @node Namespace Advertisements | ||
8482 | @subsubsection Namespace Advertisements | ||
8483 | |||
8484 | @c %**end of header | ||
8485 | @c %**FIXME: all zeroses -> ? | ||
8486 | |||
8487 | An @code{SBlock} with identifier all zeros is a signed | ||
8488 | advertisement for a namespace. This special @code{SBlock} contains | ||
8489 | metadata describing the content of the namespace. | ||
8490 | Instead of the name of the identifier for a potential update, it contains | ||
8491 | the identifier for the root of the namespace. | ||
8492 | The URI should always be empty. The @code{SBlock} is signed with the | ||
8493 | content provider's RSA private key (just like any other SBlock). Peers | ||
8494 | can search for @code{SBlock}s in order to find out more about a namespace. | ||
8495 | |||
8496 | @node KSBlocks | ||
8497 | @subsubsection KSBlocks | ||
8498 | |||
8499 | @c %**end of header | ||
8500 | |||
8501 | GNUnet implements @code{KSBlocks} which are @code{KBlocks} that, instead | ||
8502 | of encrypting a CHK and metadata, encrypt an @code{SBlock} instead. | ||
8503 | In other words, @code{KSBlocks} enable GNUnet to find @code{SBlocks} | ||
8504 | using the global keyword search. | ||
8505 | Usually the encrypted @code{SBlock} is a namespace advertisement. | ||
8506 | The rationale behind @code{KSBlock}s and @code{SBlock}s is to enable | ||
8507 | peers to discover namespaces via keyword searches, and, to associate | ||
8508 | useful information with namespaces. When GNUnet finds @code{KSBlocks} | ||
8509 | during a normal keyword search, it adds the information to an internal | ||
8510 | list of discovered namespaces. Users looking for interesting namespaces | ||
8511 | can then inspect this list, reducing the need for out-of-band discovery | ||
8512 | of namespaces. | ||
8513 | Naturally, namespaces (or more specifically, namespace advertisements) can | ||
8514 | also be referenced from directories, but @code{KSBlock}s should make it | ||
8515 | easier to advertise namespaces for the owner of the pseudonym since they | ||
8516 | eliminate the need to first create a directory. | ||
8517 | |||
8518 | Collections are also advertised using @code{KSBlock}s. | ||
8519 | |||
8520 | @c https://gnunet.org/sites/default/files/ecrs.pdf | ||
8521 | |||
8522 | @node File-sharing persistence directory structure | ||
8523 | @subsection File-sharing persistence directory structure | ||
8524 | |||
8525 | @c %**end of header | ||
8526 | |||
8527 | This section documents how the file-sharing library implements | ||
8528 | persistence of file-sharing operations and specifically the resulting | ||
8529 | directory structure. | ||
8530 | This code is only active if the @code{GNUNET_FS_FLAGS_PERSISTENCE} flag | ||
8531 | was set when calling @code{GNUNET_FS_start}. | ||
8532 | In this case, the file-sharing library will try hard to ensure that all | ||
8533 | major operations (searching, downloading, publishing, unindexing) are | ||
8534 | persistent, that is, can live longer than the process itself. | ||
8535 | More specifically, an operation is supposed to live until it is | ||
8536 | explicitly stopped. | ||
8537 | |||
8538 | If @code{GNUNET_FS_stop} is called before an operation has been stopped, a | ||
8539 | @code{SUSPEND} event is generated and then when the process calls | ||
8540 | @code{GNUNET_FS_start} next time, a @code{RESUME} event is generated. | ||
8541 | Additionally, even if an application crashes (segfault, SIGKILL, system | ||
8542 | crash) and hence @code{GNUNET_FS_stop} is never called and no | ||
8543 | @code{SUSPEND} events are generated, operations are still resumed (with | ||
8544 | @code{RESUME} events). | ||
8545 | This is implemented by constantly writing the current state of the | ||
8546 | file-sharing operations to disk. | ||
8547 | Specifically, the current state is always written to disk whenever | ||
8548 | anything significant changes (the exception are block-wise progress in | ||
8549 | publishing and unindexing, since those operations would be slowed down | ||
8550 | significantly and can be resumed cheaply even without detailed | ||
8551 | accounting). | ||
8552 | Note that if the process crashes (or is killed) during a serialization | ||
8553 | operation, FS does not guarantee that this specific operation is | ||
8554 | recoverable (no strict transactional semantics, again for performance | ||
8555 | reasons). However, all other unrelated operations should resume nicely. | ||
8556 | |||
8557 | Since we need to serialize the state continuously and want to recover as | ||
8558 | much as possible even after crashing during a serialization operation, | ||
8559 | we do not use one large file for serialization. | ||
8560 | Instead, several directories are used for the various operations. | ||
8561 | When @code{GNUNET_FS_start} executes, the master directories are scanned | ||
8562 | for files describing operations to resume. | ||
8563 | Sometimes, these operations can refer to related operations in child | ||
8564 | directories which may also be resumed at this point. | ||
8565 | Note that corrupted files are cleaned up automatically. | ||
8566 | However, dangling files in child directories (those that are not | ||
8567 | referenced by files from the master directories) are not automatically | ||
8568 | removed. | ||
8569 | |||
8570 | Persistence data is kept in a directory that begins with the "STATE_DIR" | ||
8571 | prefix from the configuration file | ||
8572 | (by default, "$SERVICEHOME/persistence/") followed by the name of the | ||
8573 | client as given to @code{GNUNET_FS_start} (for example, "gnunet-gtk") | ||
8574 | followed by the actual name of the master or child directory. | ||
8575 | |||
8576 | The names for the master directories follow the names of the operations: | ||
8577 | |||
8578 | @itemize @bullet | ||
8579 | @item "search" | ||
8580 | @item "download" | ||
8581 | @item "publish" | ||
8582 | @item "unindex" | ||
8583 | @end itemize | ||
8584 | |||
8585 | Each of the master directories contains names (chosen at random) for each | ||
8586 | active top-level (master) operation. | ||
8587 | Note that a download that is associated with a search result is not a | ||
8588 | top-level operation. | ||
8589 | |||
8590 | In contrast to the master directories, the child directories are only | ||
8591 | consulted when another operation refers to them. | ||
8592 | For each search, a subdirectory (named after the master search | ||
8593 | synchronization file) contains the search results. | ||
8594 | Search results can have an associated download, which is then stored in | ||
8595 | the general "download-child" directory. | ||
8596 | Downloads can be recursive, in which case children are stored in | ||
8597 | subdirectories mirroring the structure of the recursive download | ||
8598 | (either starting in the master "download" directory or in the | ||
8599 | "download-child" directory depending on how the download was initiated). | ||
8600 | For publishing operations, the "publish-file" directory contains | ||
8601 | information about the individual files and directories that are part of | ||
8602 | the publication. | ||
8603 | However, this directory structure is flat and does not mirror the | ||
8604 | structure of the publishing operation. | ||
8605 | Note that unindex operations cannot have associated child operations. | ||
8606 | |||
8607 | @cindex REGEX subsystem | ||
8608 | @node REGEX Subsystem | ||
8609 | @section REGEX Subsystem | ||
8610 | |||
8611 | @c %**end of header | ||
8612 | |||
8613 | Using the REGEX subsystem, you can discover peers that offer a particular | ||
8614 | service using regular expressions. | ||
8615 | The peers that offer a service specify it using a regular expressions. | ||
8616 | Peers that want to patronize a service search using a string. | ||
8617 | The REGEX subsystem will then use the DHT to return a set of matching | ||
8618 | offerers to the patrons. | ||
8619 | |||
8620 | For the technical details, we have Max's defense talk and Max's Master's | ||
8621 | thesis. | ||
8622 | |||
8623 | @c An additional publication is under preparation and available to | ||
8624 | @c team members (in Git). | ||
8625 | @c FIXME: Where is the file? Point to it. Assuming that it's szengel2012ms | ||
8626 | |||
8627 | @menu | ||
8628 | * How to run the regex profiler:: | ||
8629 | @end menu | ||
8630 | |||
8631 | @node How to run the regex profiler | ||
8632 | @subsection How to run the regex profiler | ||
8633 | |||
8634 | @c %**end of header | ||
8635 | |||
8636 | The gnunet-regex-profiler can be used to profile the usage of mesh/regex | ||
8637 | for a given set of regular expressions and strings. | ||
8638 | Mesh/regex allows you to announce your peer ID under a certain regex and | ||
8639 | search for peers matching a particular regex using a string. | ||
8640 | See @uref{https://gnunet.org/szengel2012ms, szengel2012ms} for a full | ||
8641 | introduction. | ||
8642 | |||
8643 | First of all, the regex profiler uses GNUnet testbed, thus all the | ||
8644 | implications for testbed also apply to the regex profiler | ||
8645 | (for example you need password-less ssh login to the machines listed in | ||
8646 | your hosts file). | ||
8647 | |||
8648 | @strong{Configuration} | ||
8649 | |||
8650 | Moreover, an appropriate configuration file is needed. | ||
8651 | Generally you can refer to the | ||
8652 | @file{contrib/regex_profiler_infiniband.conf} file in the sourcecode | ||
8653 | of GNUnet for an example configuration. | ||
8654 | In the following paragraph the important details are highlighted. | ||
8655 | |||
8656 | Announcing of the regular expressions is done by the | ||
8657 | gnunet-daemon-regexprofiler, therefore you have to make sure it is | ||
8658 | started, by adding it to the START_ON_DEMAND set of ARM: | ||
8659 | |||
8660 | @example | ||
8661 | [regexprofiler] | ||
8662 | START_ON_DEMAND = YES | ||
8663 | @end example | ||
8664 | |||
8665 | @noindent | ||
8666 | Furthermore you have to specify the location of the binary: | ||
8667 | |||
8668 | @example | ||
8669 | [regexprofiler] | ||
8670 | # Location of the gnunet-daemon-regexprofiler binary. | ||
8671 | BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-daemon-regexprofiler | ||
8672 | # Regex prefix that will be applied to all regular expressions and | ||
8673 | # search string. | ||
8674 | REGEX_PREFIX = "GNVPN-0001-PAD" | ||
8675 | @end example | ||
8676 | |||
8677 | @noindent | ||
8678 | When running the profiler with a large scale deployment, you probably | ||
8679 | want to reduce the workload of each peer. | ||
8680 | Use the following options to do this. | ||
8681 | |||
8682 | @example | ||
8683 | [dht] | ||
8684 | # Force network size estimation | ||
8685 | FORCE_NSE = 1 | ||
8686 | |||
8687 | [dhtcache] | ||
8688 | DATABASE = heap | ||
8689 | # Disable RC-file for Bloom filter? (for benchmarking with limited IO | ||
8690 | # availability) | ||
8691 | DISABLE_BF_RC = YES | ||
8692 | # Disable Bloom filter entirely | ||
8693 | DISABLE_BF = YES | ||
8694 | |||
8695 | [nse] | ||
8696 | # Minimize proof-of-work CPU consumption by NSE | ||
8697 | WORKBITS = 1 | ||
8698 | @end example | ||
8699 | |||
8700 | @noindent | ||
8701 | @strong{Options} | ||
8702 | |||
8703 | To finally run the profiler some options and the input data need to be | ||
8704 | specified on the command line. | ||
8705 | |||
8706 | @example | ||
8707 | gnunet-regex-profiler -c config-file -d log-file -n num-links \ | ||
8708 | -p path-compression-length -s search-delay -t matching-timeout \ | ||
8709 | -a num-search-strings hosts-file policy-dir search-strings-file | ||
8710 | @end example | ||
8711 | |||
8712 | @noindent | ||
8713 | Where... | ||
8714 | |||
8715 | @itemize @bullet | ||
8716 | @item ... @code{config-file} means the configuration file created earlier. | ||
8717 | @item ... @code{log-file} is the file where to write statistics output. | ||
8718 | @item ... @code{num-links} indicates the number of random links between | ||
8719 | started peers. | ||
8720 | @item ... @code{path-compression-length} is the maximum path compression | ||
8721 | length in the DFA. | ||
8722 | @item ... @code{search-delay} time to wait between peers finished linking | ||
8723 | and starting to match strings. | ||
8724 | @item ... @code{matching-timeout} timeout after which to cancel the | ||
8725 | searching. | ||
8726 | @item ... @code{num-search-strings} number of strings in the | ||
8727 | search-strings-file. | ||
8728 | @item ... the @code{hosts-file} should contain a list of hosts for the | ||
8729 | testbed, one per line in the following format: | ||
8730 | |||
8731 | @itemize @bullet | ||
8732 | @item @code{user@@host_ip:port} | ||
8733 | @end itemize | ||
8734 | @item ... the @code{policy-dir} is a folder containing text files | ||
8735 | containing one or more regular expressions. A peer is started for each | ||
8736 | file in that folder and the regular expressions in the corresponding file | ||
8737 | are announced by this peer. | ||
8738 | @item ... the @code{search-strings-file} is a text file containing search | ||
8739 | strings, one in each line. | ||
8740 | @end itemize | ||
8741 | |||
8742 | @noindent | ||
8743 | You can create regular expressions and search strings for every AS in the | ||
8744 | Internet using the attached scripts. You need one of the | ||
8745 | @uref{http://data.caida.org/datasets/routing/routeviews-prefix2as/, CAIDA routeviews prefix2as} | ||
8746 | data files for this. Run | ||
8747 | |||
8748 | @example | ||
8749 | create_regex.py <filename> <output path> | ||
8750 | @end example | ||
8751 | |||
8752 | @noindent | ||
8753 | to create the regular expressions and | ||
8754 | |||
8755 | @example | ||
8756 | create_strings.py <input path> <outfile> | ||
8757 | @end example | ||
8758 | |||
8759 | @noindent | ||
8760 | to create a search strings file from the previously created | ||
8761 | regular expressions. | ||
8762 | |||
8763 | @cindex REST subsystem | ||
8764 | @node REST Subsystem | ||
8765 | @section REST Subsystem | ||
8766 | |||
8767 | @c %**end of header | ||
8768 | |||
8769 | Using the REST subsystem, you can expose REST-based APIs or services. | ||
8770 | The REST service is designed as a pluggable architecture. | ||
8771 | To create a new REST endpoint, simply add a library in the form | ||
8772 | ``plugin_rest_*''. | ||
8773 | The REST service will automatically load all REST plugins on startup. | ||
8774 | |||
8775 | @strong{Configuration} | ||
8776 | |||
8777 | The REST service can be configured in various ways. | ||
8778 | The reference config file can be found in | ||
8779 | @file{src/rest/rest.conf}: | ||
8780 | @example | ||
8781 | [rest] | ||
8782 | REST_PORT=7776 | ||
8783 | REST_ALLOW_HEADERS=Authorization,Accept,Content-Type | ||
8784 | REST_ALLOW_ORIGIN=* | ||
8785 | REST_ALLOW_CREDENTIALS=true | ||
8786 | @end example | ||
8787 | |||
8788 | The port as well as | ||
8789 | @deffn{cross-origin resource sharing} (CORS) | ||
8790 | @end deffn | ||
8791 | headers that are supposed to be advertised by the rest service are | ||
8792 | configurable. | ||
8793 | |||
8794 | @menu | ||
8795 | * Namespace considerations:: | ||
8796 | * Endpoint documentation:: | ||
8797 | @end menu | ||
8798 | |||
8799 | @node Namespace considerations | ||
8800 | @subsection Namespace considerations | ||
8801 | |||
8802 | The @command{gnunet-rest-service} will load all plugins that are installed. | ||
8803 | As such it is important that the endpoint namespaces do not clash. | ||
8804 | |||
8805 | For example, plugin X might expose the endpoint ``/xxx'' while plugin Y | ||
8806 | exposes endpoint ``/xxx/yyy''. | ||
8807 | This is a problem if plugin X is also supposed to handle a call | ||
8808 | to ``/xxx/yyy''. | ||
8809 | Currently the REST service will not complain or warn about such clashes, | ||
8810 | so please make sure that endpoints are unambiguous. | ||
8811 | |||
8812 | @node Endpoint documentation | ||
8813 | @subsection Endpoint documentation | ||
8814 | |||
8815 | This is WIP. Endpoints should be documented appropriately. | ||
8816 | Preferably using annotations. | ||
8817 | |||
diff --git a/doc/documentation/chapters/installation.texi b/doc/documentation/chapters/installation.texi deleted file mode 100644 index 6b68ac498..000000000 --- a/doc/documentation/chapters/installation.texi +++ /dev/null | |||
@@ -1,2233 +0,0 @@ | |||
1 | @node Installing GNUnet | ||
2 | @chapter Installing GNUnet | ||
3 | |||
4 | This guide is intended for those who want to install Gnunet from | ||
5 | source. For instructions on how to install GNUnet as a binary package | ||
6 | please refer to the official documentation of your operating system or | ||
7 | package manager. | ||
8 | |||
9 | @menu | ||
10 | * Installing dependencies:: | ||
11 | * Getting the Source Code:: | ||
12 | * Create @code{gnunet} user and group:: | ||
13 | * Preparing and Compiling the Source Code:: | ||
14 | * Installation:: | ||
15 | * MOVED FROM USER Checking the Installation:: | ||
16 | * MOVED FROM USER The graphical configuration interface:: | ||
17 | * MOVED FROM USER Config Leftovers:: | ||
18 | @end menu | ||
19 | |||
20 | @c ----------------------------------------------------------------------- | ||
21 | @node Installing dependencies | ||
22 | @section Installing dependencies | ||
23 | GNUnet needs few libraries and applications for being able to run and | ||
24 | another few optional ones for using certain features. Preferably they | ||
25 | should be installed with a package manager. Just in case we include a | ||
26 | link to the project websites. | ||
27 | |||
28 | The mandatory libraries and applications are | ||
29 | @itemize @bullet | ||
30 | @item libtool | ||
31 | @item autoconf @geq{}2.59 | ||
32 | @item automake @geq{}1.11.1 | ||
33 | @item pkg-config | ||
34 | @item libgcrypt @geq{}1.6 | ||
35 | @item libextractor | ||
36 | @item libidn | ||
37 | @item libmicrohttpd @geq{}0.9.52 | ||
38 | @item libnss | ||
39 | @item libunistring | ||
40 | @item gettext | ||
41 | @item glibc | ||
42 | @item libgmp | ||
43 | @item gnutls | ||
44 | @item libcurl (has to be linked to GnuTLS) or libgnurl | ||
45 | @item zlib | ||
46 | @end itemize | ||
47 | |||
48 | In addition GNUnet needs one of of these three databases | ||
49 | @itemize @bullet | ||
50 | @item sqlite + libsqlite (the default, requires no further configuration) | ||
51 | @item postgres + libpq | ||
52 | @item mysql + libmysqlclient | ||
53 | @end itemize | ||
54 | |||
55 | These are the dependencies only required for certain features | ||
56 | @itemize @bullet | ||
57 | @item Texinfo (for building the documentation) | ||
58 | @item Texlive (for building the documentation) | ||
59 | @item miniupnpc (for traversing NAT boxes more reliably) | ||
60 | @item libopus (for running the GNUnet conversation telephony application) | ||
61 | @item libpulse (for running the GNUnet conversation telephony application) | ||
62 | @item libogg (for running the GNUnet conversation telephony application) | ||
63 | @item bluez (for bluetooth support) | ||
64 | @item libpbc | ||
65 | (for attribute-based encryption and the identity provider subsystem) | ||
66 | @item libgabe | ||
67 | (for attribute-based encryption and the identity provider subsystem) | ||
68 | @end itemize | ||
69 | |||
70 | @c ----------------------------------------------------------------------- | ||
71 | @node Getting the Source Code | ||
72 | @section Getting the Source Code | ||
73 | You can either download the source code using git (you obviously need | ||
74 | git installed) or as an archive. | ||
75 | |||
76 | Using git type | ||
77 | @example | ||
78 | git clone https://gnunet.org/git/gnunet.git | ||
79 | @end example | ||
80 | |||
81 | The archive can be found at | ||
82 | @uref{https://gnunet.org/downloads}. Extract it using a graphical | ||
83 | archive tool or @code{tar}: | ||
84 | @example | ||
85 | tar xzvf gnunet-0.11.0pre66.tar.gz | ||
86 | @end example | ||
87 | |||
88 | In the next chapter we will assume that the source code is available | ||
89 | in the home directory at @code{~/gnunet}. | ||
90 | |||
91 | @c ----------------------------------------------------------------------- | ||
92 | @node Create @code{gnunet} user and group | ||
93 | @section Create @code{gnunet} user and group | ||
94 | The GNUnet services should be run as a dedicated user called | ||
95 | @code{gnunet}. For using them a user should be in the same group as | ||
96 | this system user. | ||
97 | |||
98 | Create user @code{gnunet} who is member of the group @code{gnunet} and | ||
99 | specify a home directory where the GNUnet services will store | ||
100 | persistant data such as information about peers. | ||
101 | @example | ||
102 | $ sudo useradd --system --groups gnunet --home-dir /var/lib/gnunet | ||
103 | @end example | ||
104 | |||
105 | Now add your own user to the @code{gnunet} group. | ||
106 | @example | ||
107 | $ sudo adduser alice gnunet | ||
108 | @end example | ||
109 | |||
110 | @c ----------------------------------------------------------------------- | ||
111 | @node Preparing and Compiling the Source Code | ||
112 | @section Preparing and Compiling the Source Code | ||
113 | For preparing the source code for compilation a bootstrap script and | ||
114 | @code{configure} has to be run from the source code directory. When | ||
115 | running @code{configure} the following options can be specified to | ||
116 | customize the compilation and installation process: | ||
117 | |||
118 | @itemize @bullet | ||
119 | @item @code{--disable-documentation} - don't build the configuration documents | ||
120 | @item @code{--enable-looging=[LOGLEVEL]} - choose a loglevel (@code{debug}, @code{info}, @code{warning} or @code{error}) | ||
121 | @item @code{--prefix=[PATH]} - the directory where the GNUnet libraries and binaries will be installed | ||
122 | @item @code{--with-extractor=[PATH]} - the path to libextractor | ||
123 | @item @code{--with-libidn=[PATH]} - the path to libidn | ||
124 | @item @code{--with-microhttpd=[PATH]} - the path to libmicrohttpd | ||
125 | @item @code{--with-sqlite=[PATH]} - the path to libsqlite | ||
126 | @item @code{--with-zlib=[PATH]} - the path to zlib | ||
127 | @item @code{--with-sudo=[PATH]} - path to the sudo binary (no need to run @code{make install} as root if specified) | ||
128 | @end itemize | ||
129 | |||
130 | The following example configures the installation prefix | ||
131 | @code{/usr/lib} and disables building the documentation | ||
132 | @example | ||
133 | $ cd ~/gnunet | ||
134 | $ ./bootstrap | ||
135 | $ configure --prefix=/usr/lib --disable-configuration | ||
136 | @end example | ||
137 | |||
138 | After running the bootstrap script and @code{configure} successfully | ||
139 | the source code can be compiled with make. Here @code{-j5} specifies | ||
140 | that 5 threads should be used. | ||
141 | @example | ||
142 | $ make -j5 | ||
143 | @end example | ||
144 | |||
145 | @c ----------------------------------------------------------------------- | ||
146 | @node Installation | ||
147 | @section Installation | ||
148 | The compiled binaries can be installed using @code{make install}. It | ||
149 | needs to be run as root (or with sudo) because some binaries need the | ||
150 | @code{suid} bit set. Without that some GNUnet subsystems (such as VPN) | ||
151 | will not work. | ||
152 | |||
153 | @example | ||
154 | $ sudo make install | ||
155 | @end example | ||
156 | |||
157 | One important library is the GNS plugin for NSS (the name services | ||
158 | switch) which allows using GNS (the GNU name system) in the normal DNS | ||
159 | resolution process. Unfortunately NSS expects it in a specific | ||
160 | location (probably @code{/lib}) which may differ from the installation | ||
161 | prefix (see @code{--prefix} option in the previous section). This is | ||
162 | why the pugin has to be installed manually. | ||
163 | |||
164 | Find the directory where nss plugins are installed on your system, e.g. | ||
165 | |||
166 | @example | ||
167 | $ ls -l /lib/libnss_* | ||
168 | /lib/libnss_mymachines.so.2 | ||
169 | /lib/libnss_resolve.so.2 | ||
170 | /lib/libnss_myhostname.so.2 | ||
171 | /lib/libnss_systemd.so.2 | ||
172 | @end example | ||
173 | |||
174 | Copy the GNS NSS plugin to that directory: | ||
175 | |||
176 | @example | ||
177 | cp ~/gnunet/src/gns/nss/libnss_gns.so.2 /lib | ||
178 | @end example | ||
179 | |||
180 | Now, to activate the plugin, you need to edit your | ||
181 | @code{/etc/nsswitch.conf} where you should find a line like this: | ||
182 | |||
183 | @example | ||
184 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
185 | @end example | ||
186 | |||
187 | The exact details may differ a bit, which is fine. Add the text | ||
188 | @code{"gns [NOTFOUND=return]"} after @code{"files"}. | ||
189 | |||
190 | @example | ||
191 | hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
192 | @end example | ||
193 | |||
194 | Optionally, if GNS shall be used with a browser, execute the GNS | ||
195 | CA-setup script. It will isetup the GNS Certificate Authority with the | ||
196 | user's browser. | ||
197 | @example | ||
198 | $ gnunet-gns-proxy-setup-ca | ||
199 | @end example | ||
200 | |||
201 | Finally install a configuration file in | ||
202 | @code{~/.gnunet/gnunet.conf}. Below you find an example config which | ||
203 | allows you to start GNUnet. | ||
204 | |||
205 | @example | ||
206 | [arm] | ||
207 | SYSTEM_ONLY = NO | ||
208 | USER_ONLY = NO | ||
209 | |||
210 | [transport] | ||
211 | PLUGINS = tcp | ||
212 | @end example | ||
213 | |||
214 | |||
215 | |||
216 | |||
217 | |||
218 | |||
219 | @node MOVED FROM USER Checking the Installation | ||
220 | @section MOVED FROM USER Checking the Installation | ||
221 | @c %**end of header | ||
222 | |||
223 | This section describes a quick, casual way to check if your GNUnet | ||
224 | installation works. However, if it does not, we do not cover | ||
225 | steps for recovery --- for this, please study the instructions | ||
226 | provided in the developer handbook as well as the system-specific | ||
227 | instruction in the source code repository. | ||
228 | Please note that the system specific instructions are not provided | ||
229 | as part of this handbook!. | ||
230 | |||
231 | |||
232 | @menu | ||
233 | * gnunet-gtk:: | ||
234 | * Statistics:: | ||
235 | * Peer Information:: | ||
236 | @end menu | ||
237 | |||
238 | @cindex GNUnet GTK | ||
239 | @cindex GTK | ||
240 | @cindex GTK user interface | ||
241 | @node gnunet-gtk | ||
242 | @subsection gnunet-gtk | ||
243 | @c %**end of header | ||
244 | |||
245 | The @command{gnunet-gtk} package contains several graphical | ||
246 | user interfaces for the respective GNUnet applications. | ||
247 | Currently these interfaces cover: | ||
248 | |||
249 | @itemize @bullet | ||
250 | @item Statistics | ||
251 | @item Peer Information | ||
252 | @item GNU Name System | ||
253 | @item File Sharing | ||
254 | @item Identity Management | ||
255 | @item Conversation | ||
256 | @end itemize | ||
257 | |||
258 | @node Statistics | ||
259 | @subsection Statistics | ||
260 | @c %**end of header | ||
261 | |||
262 | We assume that you have started gnunet via @code{gnunet-arm} or via your | ||
263 | system-provided method for starting services. | ||
264 | First, you should launch GNUnet gtk. | ||
265 | You can do this from the command-line by typing | ||
266 | |||
267 | @example | ||
268 | gnunet-statistics-gtk | ||
269 | @end example | ||
270 | |||
271 | If your peer is running correctly, you should see a bunch | ||
272 | of lines, all of which should be ``significantly'' above zero (at | ||
273 | least if your peer has been running for more than a few seconds). The | ||
274 | lines indicate how many other peers your peer is connected to (via | ||
275 | different mechanisms) and how large the entire overlay network is | ||
276 | currently estimated to be. The X-axis represents time (in seconds | ||
277 | since the start of @command{gnunet-gtk}). | ||
278 | |||
279 | You can click on "Traffic" to see information about the amount of | ||
280 | bandwidth your peer has consumed, and on "Storage" to check the amount | ||
281 | of storage available and used by your peer. Note that "Traffic" is | ||
282 | plotted cumulatively, so you should see a strict upwards trend in the | ||
283 | traffic. | ||
284 | |||
285 | The term ``peer'' is a common word used in | ||
286 | federated and distributed networks to describe a participating device | ||
287 | which is connected to the network. Thus, your Personal Computer or | ||
288 | whatever it is you are looking at the Gtk+ interface describes a | ||
289 | ``Peer'' or a ``Node''. | ||
290 | |||
291 | @node Peer Information | ||
292 | @subsection Peer Information | ||
293 | @c %**end of header | ||
294 | |||
295 | First, you should launch the graphical user interface. You can do | ||
296 | this from the command-line by typing | ||
297 | |||
298 | @example | ||
299 | $ gnunet-peerinfo-gtk | ||
300 | @end example | ||
301 | |||
302 | Once you have done this, you will see a list of known peers (by the | ||
303 | first four characters of their public key), their friend status (all | ||
304 | should be marked as not-friends initially), their connectivity (green | ||
305 | is connected, red is disconnected), assigned bandwidth, country of | ||
306 | origin (if determined) and address information. If hardly any peers | ||
307 | are listed and/or if there are very few peers with a green light for | ||
308 | connectivity, there is likely a problem with your network | ||
309 | configuration. | ||
310 | |||
311 | @c NOTE: Inserted from Installation Handbook in original ``order'': | ||
312 | @c FIXME: Move this to User Handbook. | ||
313 | @node MOVED FROM USER The graphical configuration interface | ||
314 | @section MOVED FROM USER The graphical configuration interface | ||
315 | |||
316 | If you also would like to use @command{gnunet-gtk} and | ||
317 | @command{gnunet-setup} (highly recommended for beginners), do: | ||
318 | |||
319 | @menu | ||
320 | * Configuring your peer:: | ||
321 | * Configuring the Friend-to-Friend (F2F) mode:: | ||
322 | * Configuring the hostlist to bootstrap:: | ||
323 | * Configuration of the HOSTLIST proxy settings:: | ||
324 | * Configuring your peer to provide a hostlist :: | ||
325 | * Configuring the datastore:: | ||
326 | * Configuring the MySQL database:: | ||
327 | * Reasons for using MySQL:: | ||
328 | * Reasons for not using MySQL:: | ||
329 | * Setup Instructions:: | ||
330 | * Testing:: | ||
331 | * Performance Tuning:: | ||
332 | * Setup for running Testcases:: | ||
333 | * Configuring the Postgres database:: | ||
334 | * Reasons to use Postgres:: | ||
335 | * Reasons not to use Postgres:: | ||
336 | * Manual setup instructions:: | ||
337 | * Testing the setup manually:: | ||
338 | * Configuring the datacache:: | ||
339 | * Configuring the file-sharing service:: | ||
340 | * Configuring logging:: | ||
341 | * Configuring the transport service and plugins:: | ||
342 | * Configuring the WLAN transport plugin:: | ||
343 | * Configuring HTTP(S) reverse proxy functionality using Apache or nginx:: | ||
344 | * Blacklisting peers:: | ||
345 | * Configuration of the HTTP and HTTPS transport plugins:: | ||
346 | * Configuring the GNU Name System:: | ||
347 | * Configuring the GNUnet VPN:: | ||
348 | * Bandwidth Configuration:: | ||
349 | * Configuring NAT:: | ||
350 | * Peer configuration for distributions:: | ||
351 | @end menu | ||
352 | |||
353 | @node Configuring your peer | ||
354 | @subsection Configuring your peer | ||
355 | |||
356 | This chapter will describe the various configuration options in GNUnet. | ||
357 | |||
358 | The easiest way to configure your peer is to use the | ||
359 | @command{gnunet-setup} tool. | ||
360 | @command{gnunet-setup} is part of the @command{gnunet-gtk} | ||
361 | application. You might have to install it separately. | ||
362 | |||
363 | Many of the specific sections from this chapter actually are linked from | ||
364 | within @command{gnunet-setup} to help you while using the setup tool. | ||
365 | |||
366 | While you can also configure your peer by editing the configuration | ||
367 | file by hand, this is not recommended for anyone except for developers | ||
368 | as it requires a more in-depth understanding of the configuration files | ||
369 | and internal dependencies of GNUnet. | ||
370 | |||
371 | @node Configuring the Friend-to-Friend (F2F) mode | ||
372 | @subsection Configuring the Friend-to-Friend (F2F) mode | ||
373 | |||
374 | GNUnet knows three basic modes of operation: | ||
375 | @itemize @bullet | ||
376 | @item In standard "peer-to-peer" mode, | ||
377 | your peer will connect to any peer. | ||
378 | @item In the pure "friend-to-friend" | ||
379 | mode, your peer will ONLY connect to peers from a list of friends | ||
380 | specified in the configuration. | ||
381 | @item Finally, in mixed mode, | ||
382 | GNUnet will only connect to arbitrary peers if it | ||
383 | has at least a specified number of connections to friends. | ||
384 | @end itemize | ||
385 | |||
386 | When configuring any of the F2F ("friend-to-friend") modes, | ||
387 | you first need to create a file with the peer identities | ||
388 | of your friends. Ask your friends to run | ||
389 | |||
390 | @example | ||
391 | $ gnunet-peerinfo -sq | ||
392 | @end example | ||
393 | |||
394 | @noindent | ||
395 | The resulting output of this command needs to be added to your | ||
396 | @file{friends} file, which is simply a plain text file with one line | ||
397 | per friend with the output from the above command. | ||
398 | |||
399 | You then specify the location of your @file{friends} file in the | ||
400 | @code{FRIENDS} option of the "topology" section. | ||
401 | |||
402 | Once you have created the @file{friends} file, you can tell GNUnet to only | ||
403 | connect to your friends by setting the @code{FRIENDS-ONLY} option | ||
404 | (again in the "topology" section) to YES. | ||
405 | |||
406 | If you want to run in mixed-mode, set "FRIENDS-ONLY" to NO and configure a | ||
407 | minimum number of friends to have (before connecting to arbitrary peers) | ||
408 | under the "MINIMUM-FRIENDS" option. | ||
409 | |||
410 | If you want to operate in normal P2P-only mode, simply set | ||
411 | @code{MINIMUM-FRIENDS} to zero and @code{FRIENDS_ONLY} to NO. | ||
412 | This is the default. | ||
413 | |||
414 | @node Configuring the hostlist to bootstrap | ||
415 | @subsection Configuring the hostlist to bootstrap | ||
416 | |||
417 | After installing the software you need to get connected to the GNUnet | ||
418 | network. The configuration file included in your download is already | ||
419 | configured to connect you to the GNUnet network. | ||
420 | In this section the relevant configuration settings are explained. | ||
421 | |||
422 | To get an initial connection to the GNUnet network and to get to know | ||
423 | peers already connected to the network you can use the so called | ||
424 | "bootstrap servers". | ||
425 | These servers can give you a list of peers connected to the network. | ||
426 | To use these bootstrap servers you have to configure the hostlist daemon | ||
427 | to activate bootstrapping. | ||
428 | |||
429 | To activate bootstrapping, edit the @code{[hostlist]}-section in your | ||
430 | configuration file. You have to set the argument @command{-b} in the | ||
431 | options line: | ||
432 | |||
433 | @example | ||
434 | [hostlist] | ||
435 | OPTIONS = -b | ||
436 | @end example | ||
437 | |||
438 | Additionally you have to specify which server you want to use. | ||
439 | The default bootstrapping server is | ||
440 | "@uref{http://v10.gnunet.org/hostlist, http://v10.gnunet.org/hostlist}". | ||
441 | [^] To set the server you have to edit the line "SERVERS" in the hostlist | ||
442 | section. To use the default server you should set the lines to | ||
443 | |||
444 | @example | ||
445 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
446 | @end example | ||
447 | |||
448 | @noindent | ||
449 | To use bootstrapping your configuration file should include these lines: | ||
450 | |||
451 | @example | ||
452 | [hostlist] | ||
453 | OPTIONS = -b | ||
454 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
455 | @end example | ||
456 | |||
457 | @noindent | ||
458 | Besides using bootstrap servers you can configure your GNUnet peer to | ||
459 | receive hostlist advertisements. | ||
460 | Peers offering hostlists to other peers can send advertisement messages | ||
461 | to peers that connect to them. If you configure your peer to receive these | ||
462 | messages, your peer can download these lists and connect to the peers | ||
463 | included. These lists are persistent, which means that they are saved to | ||
464 | your hard disk regularly and are loaded during startup. | ||
465 | |||
466 | To activate hostlist learning you have to add the @command{-e} | ||
467 | switch to the @code{OPTIONS} line in the hostlist section: | ||
468 | |||
469 | @example | ||
470 | [hostlist] | ||
471 | OPTIONS = -b -e | ||
472 | @end example | ||
473 | |||
474 | @noindent | ||
475 | Furthermore you can specify in which file the lists are saved. | ||
476 | To save the lists in the file @file{hostlists.file} just add the line: | ||
477 | |||
478 | @example | ||
479 | HOSTLISTFILE = hostlists.file | ||
480 | @end example | ||
481 | |||
482 | @noindent | ||
483 | Best practice is to activate both bootstrapping and hostlist learning. | ||
484 | So your configuration file should include these lines: | ||
485 | |||
486 | @example | ||
487 | [hostlist] | ||
488 | OPTIONS = -b -e | ||
489 | HTTPPORT = 8080 | ||
490 | SERVERS = http://v10.gnunet.org/hostlist [^] | ||
491 | HOSTLISTFILE = $SERVICEHOME/hostlists.file | ||
492 | @end example | ||
493 | |||
494 | @node Configuration of the HOSTLIST proxy settings | ||
495 | @subsection Configuration of the HOSTLIST proxy settings | ||
496 | |||
497 | The hostlist client can be configured to use a proxy to connect to the | ||
498 | hostlist server. | ||
499 | This functionality can be configured in the configuration file directly | ||
500 | or using the @command{gnunet-setup} tool. | ||
501 | |||
502 | The hostlist client supports the following proxy types at the moment: | ||
503 | |||
504 | @itemize @bullet | ||
505 | @item HTTP and HTTP 1.0 only proxy | ||
506 | @item SOCKS 4/4a/5/5 with hostname | ||
507 | @end itemize | ||
508 | |||
509 | In addition authentication at the proxy with username and password can be | ||
510 | configured. | ||
511 | |||
512 | To configure proxy support for the hostlist client in the | ||
513 | @command{gnunet-setup} tool, select the "hostlist" tab and select | ||
514 | the appropriate proxy type. | ||
515 | The hostname or IP address (including port if required) has to be entered | ||
516 | in the "Proxy hostname" textbox. If required, enter username and password | ||
517 | in the "Proxy username" and "Proxy password" boxes. | ||
518 | Be aware that this information will be stored in the configuration in | ||
519 | plain text (TODO: Add explanation and generalize the part in Chapter 3.6 | ||
520 | about the encrypted home). | ||
521 | |||
522 | To provide these options directly in the configuration, you can | ||
523 | enter the following settings in the @code{[hostlist]} section of | ||
524 | the configuration: | ||
525 | |||
526 | @example | ||
527 | # Type of proxy server, | ||
528 | # Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME | ||
529 | # Default: HTTP | ||
530 | # PROXY_TYPE = HTTP | ||
531 | |||
532 | # Hostname or IP of proxy server | ||
533 | # PROXY = | ||
534 | # User name for proxy server | ||
535 | # PROXY_USERNAME = | ||
536 | # User password for proxy server | ||
537 | # PROXY_PASSWORD = | ||
538 | @end example | ||
539 | |||
540 | @node Configuring your peer to provide a hostlist | ||
541 | @subsection Configuring your peer to provide a hostlist | ||
542 | |||
543 | If you operate a peer permanently connected to GNUnet you can configure | ||
544 | your peer to act as a hostlist server, providing other peers the list of | ||
545 | peers known to him. | ||
546 | |||
547 | Your server can act as a bootstrap server and peers needing to obtain a | ||
548 | list of peers can contact it to download this list. | ||
549 | To download this hostlist the peer uses HTTP. | ||
550 | For this reason you have to build your peer with libgnurl (or libcurl) | ||
551 | and microhttpd support. | ||
552 | |||
553 | To configure your peer to act as a bootstrap server you have to add the | ||
554 | @command{-p} option to @code{OPTIONS} in the @code{[hostlist]} section | ||
555 | of your configuration file. | ||
556 | Besides that you have to specify a port number for the http server. | ||
557 | In conclusion you have to add the following lines: | ||
558 | |||
559 | @example | ||
560 | [hostlist] | ||
561 | HTTPPORT = 12980 | ||
562 | OPTIONS = -p | ||
563 | @end example | ||
564 | |||
565 | @noindent | ||
566 | If your peer acts as a bootstrap server other peers should know about | ||
567 | that. You can advertise the hostlist your are providing to other peers. | ||
568 | Peers connecting to your peer will get a message containing an | ||
569 | advertisement for your hostlist and the URL where it can be downloaded. | ||
570 | If this peer is in learning mode, it will test the hostlist and, in the | ||
571 | case it can obtain the list successfully, it will save it for | ||
572 | bootstrapping. | ||
573 | |||
574 | To activate hostlist advertisement on your peer, you have to set the | ||
575 | following lines in your configuration file: | ||
576 | |||
577 | @example | ||
578 | [hostlist] | ||
579 | EXTERNAL_DNS_NAME = example.org | ||
580 | HTTPPORT = 12981 | ||
581 | OPTIONS = -p -a | ||
582 | @end example | ||
583 | |||
584 | @noindent | ||
585 | With this configuration your peer will a act as a bootstrap server and | ||
586 | advertise this hostlist to other peers connecting to it. | ||
587 | The URL used to download the list will be | ||
588 | @code{@uref{http://example.org:12981/, http://example.org:12981/}}. | ||
589 | |||
590 | Please notice: | ||
591 | |||
592 | @itemize @bullet | ||
593 | @item The hostlist is @b{not} human readable, so you should not try to | ||
594 | download it using your webbrowser. Just point your GNUnet peer to the | ||
595 | address! | ||
596 | @item Advertising without providing a hostlist does not make sense and | ||
597 | will not work. | ||
598 | @end itemize | ||
599 | |||
600 | @node Configuring the datastore | ||
601 | @subsection Configuring the datastore | ||
602 | |||
603 | The datastore is what GNUnet uses for long-term storage of file-sharing | ||
604 | data. Note that long-term does not mean 'forever' since content does have | ||
605 | an expiration date, and of course storage space is finite (and hence | ||
606 | sometimes content may have to be discarded). | ||
607 | |||
608 | Use the @code{QUOTA} option to specify how many bytes of storage space | ||
609 | you are willing to dedicate to GNUnet. | ||
610 | |||
611 | In addition to specifying the maximum space GNUnet is allowed to use for | ||
612 | the datastore, you need to specify which database GNUnet should use to do | ||
613 | so. Currently, you have the choice between sqLite, MySQL and Postgres. | ||
614 | |||
615 | @node Configuring the MySQL database | ||
616 | @subsection Configuring the MySQL database | ||
617 | |||
618 | This section describes how to setup the MySQL database for GNUnet. | ||
619 | |||
620 | Note that the mysql plugin does NOT work with mysql before 4.1 since we | ||
621 | need prepared statements. | ||
622 | We are generally testing the code against MySQL 5.1 at this point. | ||
623 | |||
624 | @node Reasons for using MySQL | ||
625 | @subsection Reasons for using MySQL | ||
626 | |||
627 | @itemize @bullet | ||
628 | |||
629 | @item On up-to-date hardware wher | ||
630 | mysql can be used comfortably, this module | ||
631 | will have better performance than the other database choices (according | ||
632 | to our tests). | ||
633 | |||
634 | @item Its often possible to recover the mysql database from internal | ||
635 | inconsistencies. Some of the other databases do not support repair. | ||
636 | @end itemize | ||
637 | |||
638 | @node Reasons for not using MySQL | ||
639 | @subsection Reasons for not using MySQL | ||
640 | |||
641 | @itemize @bullet | ||
642 | @item Memory usage (likely not an issue if you have more than 1 GB) | ||
643 | @item Complex manual setup | ||
644 | @end itemize | ||
645 | |||
646 | @node Setup Instructions | ||
647 | @subsection Setup Instructions | ||
648 | |||
649 | @itemize @bullet | ||
650 | |||
651 | @item In @file{gnunet.conf} set in section @code{DATASTORE} the value for | ||
652 | @code{DATABASE} to @code{mysql}. | ||
653 | |||
654 | @item Access mysql as root: | ||
655 | |||
656 | @example | ||
657 | $ mysql -u root -p | ||
658 | @end example | ||
659 | |||
660 | @noindent | ||
661 | and issue the following commands, replacing $USER with the username | ||
662 | that will be running @command{gnunet-arm} (so typically "gnunet"): | ||
663 | |||
664 | @example | ||
665 | CREATE DATABASE gnunet; | ||
666 | GRANT select,insert,update,delete,create,alter,drop,create \ | ||
667 | temporary tables ON gnunet.* TO $USER@@localhost; | ||
668 | SET PASSWORD FOR $USER@@localhost=PASSWORD('$the_password_you_like'); | ||
669 | FLUSH PRIVILEGES; | ||
670 | @end example | ||
671 | |||
672 | @item | ||
673 | In the $HOME directory of $USER, create a @file{.my.cnf} file with the | ||
674 | following lines | ||
675 | |||
676 | @example | ||
677 | [client] | ||
678 | user=$USER | ||
679 | password=$the_password_you_like | ||
680 | @end example | ||
681 | |||
682 | @end itemize | ||
683 | |||
684 | That's it. Note that @file{.my.cnf} file is a slight security risk unless | ||
685 | its on a safe partition. The @file{$HOME/.my.cnf} can of course be | ||
686 | a symbolic link. | ||
687 | Luckily $USER has only privileges to mess up GNUnet's tables, | ||
688 | which should be pretty harmless. | ||
689 | |||
690 | @node Testing | ||
691 | @subsection Testing | ||
692 | |||
693 | You should briefly try if the database connection works. First, login | ||
694 | as $USER. Then use: | ||
695 | |||
696 | @example | ||
697 | $ mysql -u $USER | ||
698 | mysql> use gnunet; | ||
699 | @end example | ||
700 | |||
701 | @noindent | ||
702 | If you get the message | ||
703 | |||
704 | @example | ||
705 | Database changed | ||
706 | @end example | ||
707 | |||
708 | @noindent | ||
709 | it probably works. | ||
710 | |||
711 | If you get | ||
712 | |||
713 | @example | ||
714 | ERROR 2002: Can't connect to local MySQL server | ||
715 | through socket '/tmp/mysql.sock' (2) | ||
716 | @end example | ||
717 | |||
718 | @noindent | ||
719 | it may be resolvable by | ||
720 | |||
721 | @example | ||
722 | ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock | ||
723 | @end example | ||
724 | |||
725 | @noindent | ||
726 | so there may be some additional trouble depending on your mysql setup. | ||
727 | |||
728 | @node Performance Tuning | ||
729 | @subsection Performance Tuning | ||
730 | |||
731 | For GNUnet, you probably want to set the option | ||
732 | |||
733 | @example | ||
734 | innodb_flush_log_at_trx_commit = 0 | ||
735 | @end example | ||
736 | |||
737 | @noindent | ||
738 | for a rather dramatic boost in MySQL performance. However, this reduces | ||
739 | the "safety" of your database as with this options you may loose | ||
740 | transactions during a power outage. | ||
741 | While this is totally harmless for GNUnet, the option applies to all | ||
742 | applications using MySQL. So you should set it if (and only if) GNUnet is | ||
743 | the only application on your system using MySQL. | ||
744 | |||
745 | @node Setup for running Testcases | ||
746 | @subsection Setup for running Testcases | ||
747 | |||
748 | If you want to run the testcases, you must create a second database | ||
749 | "gnunetcheck" with the same username and password. This database will | ||
750 | then be used for testing (@command{make check}). | ||
751 | |||
752 | @node Configuring the Postgres database | ||
753 | @subsection Configuring the Postgres database | ||
754 | |||
755 | This text describes how to setup the Postgres database for GNUnet. | ||
756 | |||
757 | This Postgres plugin was developed for Postgres 8.3 but might work for | ||
758 | earlier versions as well. | ||
759 | |||
760 | @node Reasons to use Postgres | ||
761 | @subsection Reasons to use Postgres | ||
762 | |||
763 | @itemize @bullet | ||
764 | @item Easier to setup than MySQL | ||
765 | @item Real database | ||
766 | @end itemize | ||
767 | |||
768 | @node Reasons not to use Postgres | ||
769 | @subsection Reasons not to use Postgres | ||
770 | |||
771 | @itemize @bullet | ||
772 | @item Quite slow | ||
773 | @item Still some manual setup required | ||
774 | @end itemize | ||
775 | |||
776 | @node Manual setup instructions | ||
777 | @subsection Manual setup instructions | ||
778 | |||
779 | @itemize @bullet | ||
780 | @item In @file{gnunet.conf} set in section @code{DATASTORE} the value for | ||
781 | @code{DATABASE} to @code{postgres}. | ||
782 | @item Access Postgres to create a user: | ||
783 | |||
784 | @table @asis | ||
785 | @item with Postgres 8.x, use: | ||
786 | |||
787 | @example | ||
788 | # su - postgres | ||
789 | $ createuser | ||
790 | @end example | ||
791 | |||
792 | @noindent | ||
793 | and enter the name of the user running GNUnet for the role interactively. | ||
794 | Then, when prompted, do not set it to superuser, allow the creation of | ||
795 | databases, and do not allow the creation of new roles. | ||
796 | |||
797 | @item with Postgres 9.x, use: | ||
798 | |||
799 | @example | ||
800 | # su - postgres | ||
801 | $ createuser -d $GNUNET_USER | ||
802 | @end example | ||
803 | |||
804 | @noindent | ||
805 | where $GNUNET_USER is the name of the user running GNUnet. | ||
806 | |||
807 | @end table | ||
808 | |||
809 | |||
810 | @item | ||
811 | As that user (so typically as user "gnunet"), create a database (or two): | ||
812 | |||
813 | @example | ||
814 | $ createdb gnunet | ||
815 | # this way you can run "make check" | ||
816 | $ createdb gnunetcheck | ||
817 | @end example | ||
818 | |||
819 | @end itemize | ||
820 | |||
821 | Now you should be able to start @code{gnunet-arm}. | ||
822 | |||
823 | @node Testing the setup manually | ||
824 | @subsection Testing the setup manually | ||
825 | |||
826 | You may want to try if the database connection works. First, again login | ||
827 | as the user who will run @command{gnunet-arm}. Then use: | ||
828 | |||
829 | @example | ||
830 | $ psql gnunet # or gnunetcheck | ||
831 | gnunet=> \dt | ||
832 | @end example | ||
833 | |||
834 | @noindent | ||
835 | If, after you have started @command{gnunet-arm} at least once, you get | ||
836 | a @code{gn090} table here, it probably works. | ||
837 | |||
838 | @node Configuring the datacache | ||
839 | @subsection Configuring the datacache | ||
840 | @c %**end of header | ||
841 | |||
842 | The datacache is what GNUnet uses for storing temporary data. This data is | ||
843 | expected to be wiped completely each time GNUnet is restarted (or the | ||
844 | system is rebooted). | ||
845 | |||
846 | You need to specify how many bytes GNUnet is allowed to use for the | ||
847 | datacache using the @code{QUOTA} option in the section @code{[dhtcache]}. | ||
848 | Furthermore, you need to specify which database backend should be used to | ||
849 | store the data. Currently, you have the choice between | ||
850 | sqLite, MySQL and Postgres. | ||
851 | |||
852 | @node Configuring the file-sharing service | ||
853 | @subsection Configuring the file-sharing service | ||
854 | |||
855 | In order to use GNUnet for file-sharing, you first need to make sure | ||
856 | that the file-sharing service is loaded. | ||
857 | This is done by setting the @code{START_ON_DEMAND} option in | ||
858 | section @code{[fs]} to "YES". Alternatively, you can run | ||
859 | |||
860 | @example | ||
861 | $ gnunet-arm -i fs | ||
862 | @end example | ||
863 | |||
864 | @noindent | ||
865 | to start the file-sharing service by hand. | ||
866 | |||
867 | Except for configuring the database and the datacache the only important | ||
868 | option for file-sharing is content migration. | ||
869 | |||
870 | Content migration allows your peer to cache content from other peers as | ||
871 | well as send out content stored on your system without explicit requests. | ||
872 | This content replication has positive and negative impacts on both system | ||
873 | performance and privacy. | ||
874 | |||
875 | FIXME: discuss the trade-offs. Here is some older text about it... | ||
876 | |||
877 | Setting this option to YES allows gnunetd to migrate data to the local | ||
878 | machine. Setting this option to YES is highly recommended for efficiency. | ||
879 | Its also the default. If you set this value to YES, GNUnet will store | ||
880 | content on your machine that you cannot decrypt. | ||
881 | While this may protect you from liability if the judge is sane, it may | ||
882 | not (IANAL). If you put illegal content on your machine yourself, setting | ||
883 | this option to YES will probably increase your chances to get away with it | ||
884 | since you can plausibly deny that you inserted the content. | ||
885 | Note that in either case, your anonymity would have to be broken first | ||
886 | (which may be possible depending on the size of the GNUnet network and the | ||
887 | strength of the adversary). | ||
888 | |||
889 | @node Configuring logging | ||
890 | @subsection Configuring logging | ||
891 | |||
892 | Logging in GNUnet 0.9.0 is controlled via the "-L" and "-l" options. | ||
893 | Using @code{-L}, a log level can be specified. With log level | ||
894 | @code{ERROR} only serious errors are logged. | ||
895 | The default log level is @code{WARNING} which causes anything of | ||
896 | concern to be logged. | ||
897 | Log level @code{INFO} can be used to log anything that might be | ||
898 | interesting information whereas | ||
899 | @code{DEBUG} can be used by developers to log debugging messages | ||
900 | (but you need to run @code{./configure} with | ||
901 | @code{--enable-logging=verbose} to get them compiled). | ||
902 | The @code{-l} option is used to specify the log file. | ||
903 | |||
904 | Since most GNUnet services are managed by @code{gnunet-arm}, using the | ||
905 | @code{-l} or @code{-L} options directly is not possible. | ||
906 | Instead, they can be specified using the @code{OPTIONS} configuration | ||
907 | value in the respective section for the respective service. | ||
908 | In order to enable logging globally without editing the @code{OPTIONS} | ||
909 | values for each service, @command{gnunet-arm} supports a | ||
910 | @code{GLOBAL_POSTFIX} option. | ||
911 | The value specified here is given as an extra option to all services for | ||
912 | which the configuration does contain a service-specific @code{OPTIONS} | ||
913 | field. | ||
914 | |||
915 | @code{GLOBAL_POSTFIX} can contain the special sequence "@{@}" which | ||
916 | is replaced by the name of the service that is being started. | ||
917 | Furthermore, @code{GLOBAL_POSTFIX} is special in that sequences | ||
918 | starting with "$" anywhere in the string are expanded (according | ||
919 | to options in @code{PATHS}); this expansion otherwise is | ||
920 | only happening for filenames and then the "$" must be the | ||
921 | first character in the option. Both of these restrictions do | ||
922 | not apply to @code{GLOBAL_POSTFIX}. | ||
923 | Note that specifying @code{%} anywhere in the @code{GLOBAL_POSTFIX} | ||
924 | disables both of these features. | ||
925 | |||
926 | In summary, in order to get all services to log at level | ||
927 | @code{INFO} to log-files called @code{SERVICENAME-logs}, the | ||
928 | following global prefix should be used: | ||
929 | |||
930 | @example | ||
931 | GLOBAL_POSTFIX = -l $SERVICEHOME/@{@}-logs -L INFO | ||
932 | @end example | ||
933 | |||
934 | @node Configuring the transport service and plugins | ||
935 | @subsection Configuring the transport service and plugins | ||
936 | |||
937 | The transport service in GNUnet is responsible to maintain basic | ||
938 | connectivity to other peers. | ||
939 | Besides initiating and keeping connections alive it is also responsible | ||
940 | for address validation. | ||
941 | |||
942 | The GNUnet transport supports more than one transport protocol. | ||
943 | These protocols are configured together with the transport service. | ||
944 | |||
945 | The configuration section for the transport service itself is quite | ||
946 | similar to all the other services | ||
947 | |||
948 | @example | ||
949 | START_ON_DEMAND = YES | ||
950 | @@UNIXONLY@@ PORT = 2091 | ||
951 | HOSTNAME = localhost | ||
952 | HOME = $SERVICEHOME | ||
953 | CONFIG = $DEFAULTCONFIG | ||
954 | BINARY = gnunet-service-transport | ||
955 | #PREFIX = valgrind | ||
956 | NEIGHBOUR_LIMIT = 50 | ||
957 | ACCEPT_FROM = 127.0.0.1; | ||
958 | ACCEPT_FROM6 = ::1; | ||
959 | PLUGINS = tcp udp | ||
960 | UNIXPATH = /tmp/gnunet-service-transport.sock | ||
961 | @end example | ||
962 | |||
963 | Different are the settings for the plugins to load @code{PLUGINS}. | ||
964 | The first setting specifies which transport plugins to load. | ||
965 | |||
966 | @itemize @bullet | ||
967 | @item transport-unix | ||
968 | A plugin for local only communication with UNIX domain sockets. Used for | ||
969 | testing and available on unix systems only. Just set the port | ||
970 | |||
971 | @example | ||
972 | [transport-unix] | ||
973 | PORT = 22086 | ||
974 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
975 | @end example | ||
976 | |||
977 | @item transport-tcp | ||
978 | A plugin for communication with TCP. Set port to 0 for client mode with | ||
979 | outbound only connections | ||
980 | |||
981 | @example | ||
982 | [transport-tcp] | ||
983 | # Use 0 to ONLY advertise as a peer behind NAT (no port binding) | ||
984 | PORT = 2086 | ||
985 | ADVERTISED_PORT = 2086 | ||
986 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
987 | # Maximum number of open TCP connections allowed | ||
988 | MAX_CONNECTIONS = 128 | ||
989 | @end example | ||
990 | |||
991 | @item transport-udp | ||
992 | A plugin for communication with UDP. Supports peer discovery using | ||
993 | broadcasts. | ||
994 | |||
995 | @example | ||
996 | [transport-udp] | ||
997 | PORT = 2086 | ||
998 | BROADCAST = YES | ||
999 | BROADCAST_INTERVAL = 30 s | ||
1000 | MAX_BPS = 1000000 | ||
1001 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1002 | @end example | ||
1003 | |||
1004 | @item transport-http | ||
1005 | HTTP and HTTPS support is split in two part: a client plugin initiating | ||
1006 | outbound connections and a server part accepting connections from the | ||
1007 | client. The client plugin just takes the maximum number of connections as | ||
1008 | an argument. | ||
1009 | |||
1010 | @example | ||
1011 | [transport-http_client] | ||
1012 | MAX_CONNECTIONS = 128 | ||
1013 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1014 | @end example | ||
1015 | |||
1016 | @example | ||
1017 | [transport-https_client] | ||
1018 | MAX_CONNECTIONS = 128 | ||
1019 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1020 | @end example | ||
1021 | |||
1022 | @noindent | ||
1023 | The server has a port configured and the maximum number of connections. | ||
1024 | The HTTPS part has two files with the certificate key and the certificate | ||
1025 | file. | ||
1026 | |||
1027 | The server plugin supports reverse proxies, so a external hostname can be | ||
1028 | set using the @code{EXTERNAL_HOSTNAME} setting. | ||
1029 | The webserver under this address should forward the request to the peer | ||
1030 | and the configure port. | ||
1031 | |||
1032 | @example | ||
1033 | [transport-http_server] | ||
1034 | EXTERNAL_HOSTNAME = fulcrum.net.in.tum.de/gnunet | ||
1035 | PORT = 1080 | ||
1036 | MAX_CONNECTIONS = 128 | ||
1037 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1038 | @end example | ||
1039 | |||
1040 | @example | ||
1041 | [transport-https_server] | ||
1042 | PORT = 4433 | ||
1043 | CRYPTO_INIT = NORMAL | ||
1044 | KEY_FILE = https.key | ||
1045 | CERT_FILE = https.cert | ||
1046 | MAX_CONNECTIONS = 128 | ||
1047 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1048 | @end example | ||
1049 | |||
1050 | @item transport-wlan | ||
1051 | |||
1052 | The next section describes how to setup the WLAN plugin, | ||
1053 | so here only the settings. Just specify the interface to use: | ||
1054 | |||
1055 | @example | ||
1056 | [transport-wlan] | ||
1057 | # Name of the interface in monitor mode (typically monX) | ||
1058 | INTERFACE = mon0 | ||
1059 | # Real hardware, no testing | ||
1060 | TESTMODE = 0 | ||
1061 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||
1062 | @end example | ||
1063 | @end itemize | ||
1064 | |||
1065 | @node Configuring the WLAN transport plugin | ||
1066 | @subsection Configuring the WLAN transport plugin | ||
1067 | |||
1068 | The wlan transport plugin enables GNUnet to send and to receive data on a | ||
1069 | wlan interface. | ||
1070 | It has not to be connected to a wlan network as long as sender and | ||
1071 | receiver are on the same channel. This enables you to get connection to | ||
1072 | GNUnet where no internet access is possible, for example during | ||
1073 | catastrophes or when censorship cuts you off from the internet. | ||
1074 | |||
1075 | |||
1076 | @menu | ||
1077 | * Requirements for the WLAN plugin:: | ||
1078 | * Configuration:: | ||
1079 | * Before starting GNUnet:: | ||
1080 | * Limitations and known bugs:: | ||
1081 | @end menu | ||
1082 | |||
1083 | |||
1084 | @node Requirements for the WLAN plugin | ||
1085 | @subsubsection Requirements for the WLAN plugin | ||
1086 | |||
1087 | @itemize @bullet | ||
1088 | |||
1089 | @item wlan network card with monitor support and packet injection | ||
1090 | (see @uref{http://www.aircrack-ng.org/, aircrack-ng.org}) | ||
1091 | |||
1092 | @item Linux kernel with mac80211 stack, introduced in 2.6.22, tested with | ||
1093 | 2.6.35 and 2.6.38 | ||
1094 | |||
1095 | @item Wlantools to create the a monitor interface, tested with airmon-ng | ||
1096 | of the aircrack-ng package | ||
1097 | @end itemize | ||
1098 | |||
1099 | @node Configuration | ||
1100 | @subsubsection Configuration | ||
1101 | |||
1102 | There are the following options for the wlan plugin (they should be like | ||
1103 | this in your default config file, you only need to adjust them if the | ||
1104 | values are incorrect for your system) | ||
1105 | |||
1106 | @example | ||
1107 | # section for the wlan transport plugin | ||
1108 | [transport-wlan] | ||
1109 | # interface to use, more information in the | ||
1110 | # "Before starting GNUnet" section of the handbook. | ||
1111 | INTERFACE = mon0 | ||
1112 | # testmode for developers: | ||
1113 | # 0 use wlan interface, | ||
1114 | #1 or 2 use loopback driver for tests 1 = server, 2 = client | ||
1115 | TESTMODE = 0 | ||
1116 | @end example | ||
1117 | |||
1118 | @node Before starting GNUnet | ||
1119 | @subsubsection Before starting GNUnet | ||
1120 | |||
1121 | Before starting GNUnet, you have to make sure that your wlan interface is | ||
1122 | in monitor mode. | ||
1123 | One way to put the wlan interface into monitor mode (if your interface | ||
1124 | name is wlan0) is by executing: | ||
1125 | |||
1126 | @example | ||
1127 | sudo airmon-ng start wlan0 | ||
1128 | @end example | ||
1129 | |||
1130 | @noindent | ||
1131 | Here is an example what the result should look like: | ||
1132 | |||
1133 | @example | ||
1134 | Interface Chipset Driver | ||
1135 | wlan0 Intel 4965 a/b/g/n iwl4965 - [phy0] | ||
1136 | (monitor mode enabled on mon0) | ||
1137 | @end example | ||
1138 | |||
1139 | @noindent | ||
1140 | The monitor interface is mon0 is the one that you have to put into the | ||
1141 | configuration file. | ||
1142 | |||
1143 | @node Limitations and known bugs | ||
1144 | @subsubsection Limitations and known bugs | ||
1145 | |||
1146 | Wlan speed is at the maximum of 1 Mbit/s because support for choosing the | ||
1147 | wlan speed with packet injection was removed in newer kernels. | ||
1148 | Please pester the kernel developers about fixing this. | ||
1149 | |||
1150 | The interface channel depends on the wlan network that the card is | ||
1151 | connected to. If no connection has been made since the start of the | ||
1152 | computer, it is usually the first channel of the card. | ||
1153 | Peers will only find each other and communicate if they are on the same | ||
1154 | channel. Channels must be set manually, i.e. using: | ||
1155 | |||
1156 | @example | ||
1157 | iwconfig wlan0 channel 1 | ||
1158 | @end example | ||
1159 | |||
1160 | @node Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
1161 | @subsection Configuring HTTP(S) reverse proxy functionality using Apache or nginx | ||
1162 | |||
1163 | The HTTP plugin supports data transfer using reverse proxies. A reverse | ||
1164 | proxy forwards the HTTP request he receives with a certain URL to another | ||
1165 | webserver, here a GNUnet peer. | ||
1166 | |||
1167 | So if you have a running Apache or nginx webserver you can configure it to | ||
1168 | be a GNUnet reverse proxy. Especially if you have a well-known webiste | ||
1169 | this improves censorship resistance since it looks as normal surfing | ||
1170 | behaviour. | ||
1171 | |||
1172 | To do so, you have to do two things: | ||
1173 | |||
1174 | @itemize @bullet | ||
1175 | @item Configure your webserver to forward the GNUnet HTTP traffic | ||
1176 | @item Configure your GNUnet peer to announce the respective address | ||
1177 | @end itemize | ||
1178 | |||
1179 | As an example we want to use GNUnet peer running: | ||
1180 | |||
1181 | @itemize @bullet | ||
1182 | |||
1183 | @item HTTP server plugin on @code{gnunet.foo.org:1080} | ||
1184 | |||
1185 | @item HTTPS server plugin on @code{gnunet.foo.org:4433} | ||
1186 | |||
1187 | @item A apache or nginx webserver on | ||
1188 | @uref{http://www.foo.org/, http://www.foo.org:80/} | ||
1189 | |||
1190 | @item A apache or nginx webserver on https://www.foo.org:443/ | ||
1191 | @end itemize | ||
1192 | |||
1193 | And we want the webserver to accept GNUnet traffic under | ||
1194 | @code{http://www.foo.org/bar/}. The required steps are described here: | ||
1195 | |||
1196 | @menu | ||
1197 | * Reverse Proxy - Configure your Apache2 HTTP webserver:: | ||
1198 | * Reverse Proxy - Configure your Apache2 HTTPS webserver:: | ||
1199 | * Reverse Proxy - Configure your nginx HTTPS webserver:: | ||
1200 | * Reverse Proxy - Configure your nginx HTTP webserver:: | ||
1201 | * Reverse Proxy - Configure your GNUnet peer:: | ||
1202 | @end menu | ||
1203 | |||
1204 | @node Reverse Proxy - Configure your Apache2 HTTP webserver | ||
1205 | @subsubsection Reverse Proxy - Configure your Apache2 HTTP webserver | ||
1206 | |||
1207 | First of all you need mod_proxy installed. | ||
1208 | |||
1209 | Edit your webserver configuration. Edit | ||
1210 | @code{/etc/apache2/apache2.conf} or the site-specific configuration file. | ||
1211 | |||
1212 | In the respective @code{server config},@code{virtual host} or | ||
1213 | @code{directory} section add the following lines: | ||
1214 | |||
1215 | @example | ||
1216 | ProxyTimeout 300 | ||
1217 | ProxyRequests Off | ||
1218 | <Location /bar/ > | ||
1219 | ProxyPass http://gnunet.foo.org:1080/ | ||
1220 | ProxyPassReverse http://gnunet.foo.org:1080/ | ||
1221 | </Location> | ||
1222 | @end example | ||
1223 | |||
1224 | @node Reverse Proxy - Configure your Apache2 HTTPS webserver | ||
1225 | @subsubsection Reverse Proxy - Configure your Apache2 HTTPS webserver | ||
1226 | |||
1227 | We assume that you already have an HTTPS server running, if not please | ||
1228 | check how to configure a HTTPS host. An uncomplicated to use example | ||
1229 | is the example configuration file for Apache2/HTTPD provided in | ||
1230 | @file{apache2/sites-available/default-ssl}. | ||
1231 | |||
1232 | In the respective HTTPS @code{server config},@code{virtual host} or | ||
1233 | @code{directory} section add the following lines: | ||
1234 | |||
1235 | @example | ||
1236 | SSLProxyEngine On | ||
1237 | ProxyTimeout 300 | ||
1238 | ProxyRequests Off | ||
1239 | <Location /bar/ > | ||
1240 | ProxyPass https://gnunet.foo.org:4433/ | ||
1241 | ProxyPassReverse https://gnunet.foo.org:4433/ | ||
1242 | </Location> | ||
1243 | @end example | ||
1244 | |||
1245 | @noindent | ||
1246 | More information about the apache mod_proxy configuration can be found | ||
1247 | in the | ||
1248 | @uref{http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass, Apache documentation}. | ||
1249 | |||
1250 | @node Reverse Proxy - Configure your nginx HTTPS webserver | ||
1251 | @subsubsection Reverse Proxy - Configure your nginx HTTPS webserver | ||
1252 | |||
1253 | Since nginx does not support chunked encoding, you first of all have to | ||
1254 | install the @code{chunkin} | ||
1255 | @uref{http://wiki.nginx.org/HttpChunkinModule, module}. | ||
1256 | |||
1257 | To enable chunkin add: | ||
1258 | |||
1259 | @example | ||
1260 | chunkin on; | ||
1261 | error_page 411 = @@my_411_error; | ||
1262 | location @@my_411_error @{ | ||
1263 | chunkin_resume; | ||
1264 | @} | ||
1265 | @end example | ||
1266 | |||
1267 | @noindent | ||
1268 | Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or | ||
1269 | the site-specific configuration file. | ||
1270 | |||
1271 | In the @code{server} section add: | ||
1272 | |||
1273 | @example | ||
1274 | location /bar/ @{ | ||
1275 | proxy_pass http://gnunet.foo.org:1080/; | ||
1276 | proxy_buffering off; | ||
1277 | proxy_connect_timeout 5; # more than http_server | ||
1278 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout | ||
1279 | proxy_http_version 1.1; # 1.0 default | ||
1280 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504; | ||
1281 | @} | ||
1282 | @end example | ||
1283 | |||
1284 | @node Reverse Proxy - Configure your nginx HTTP webserver | ||
1285 | @subsubsection Reverse Proxy - Configure your nginx HTTP webserver | ||
1286 | |||
1287 | Edit your webserver configuration. Edit @file{/etc/nginx/nginx.conf} or | ||
1288 | the site-specific configuration file. | ||
1289 | |||
1290 | In the @code{server} section add: | ||
1291 | |||
1292 | @example | ||
1293 | ssl_session_timeout 6m; | ||
1294 | location /bar/ | ||
1295 | @{ | ||
1296 | proxy_pass https://gnunet.foo.org:4433/; | ||
1297 | proxy_buffering off; | ||
1298 | proxy_connect_timeout 5; # more than http_server | ||
1299 | proxy_read_timeout 350; # 60 default, 300s is GNUnet's idle timeout | ||
1300 | proxy_http_version 1.1; # 1.0 default | ||
1301 | proxy_next_upstream error timeout invalid_header http_500 http_503 http_502 http_504; | ||
1302 | @} | ||
1303 | @end example | ||
1304 | |||
1305 | @node Reverse Proxy - Configure your GNUnet peer | ||
1306 | @subsubsection Reverse Proxy - Configure your GNUnet peer | ||
1307 | |||
1308 | To have your GNUnet peer announce the address, you have to specify the | ||
1309 | @code{EXTERNAL_HOSTNAME} option in the @code{[transport-http_server]} | ||
1310 | section: | ||
1311 | |||
1312 | @example | ||
1313 | [transport-http_server] | ||
1314 | EXTERNAL_HOSTNAME = http://www.foo.org/bar/ | ||
1315 | @end example | ||
1316 | |||
1317 | @noindent | ||
1318 | and/or @code{[transport-https_server]} section: | ||
1319 | |||
1320 | @example | ||
1321 | [transport-https_server] | ||
1322 | EXTERNAL_HOSTNAME = https://www.foo.org/bar/ | ||
1323 | @end example | ||
1324 | |||
1325 | @noindent | ||
1326 | Now restart your webserver and your peer... | ||
1327 | |||
1328 | @node Blacklisting peers | ||
1329 | @subsection Blacklisting peers | ||
1330 | |||
1331 | Transport service supports to deny connecting to a specific peer of to a | ||
1332 | specific peer with a specific transport plugin using te blacklisting | ||
1333 | component of transport service. With@ blacklisting it is possible to deny | ||
1334 | connections to specific peers of@ to use a specific plugin to a specific | ||
1335 | peer. Peers can be blacklisted using@ the configuration or a blacklist | ||
1336 | client can be asked. | ||
1337 | |||
1338 | To blacklist peers using the configuration you have to add a section to | ||
1339 | your configuration containing the peer id of the peer to blacklist and | ||
1340 | the plugin@ if required. | ||
1341 | |||
1342 | Examples: | ||
1343 | |||
1344 | To blacklist connections to P565... on peer AG2P... using tcp add: | ||
1345 | |||
1346 | @c FIXME: This is too long and produces errors in the pdf. | ||
1347 | @example | ||
1348 | [transport-blacklist AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520] | ||
1349 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = tcp | ||
1350 | @end example | ||
1351 | |||
1352 | To blacklist connections to P565... on peer AG2P... using all plugins add: | ||
1353 | |||
1354 | @example | ||
1355 | [transport-blacklist-AG2PHES1BARB9IJCPAMJTFPVJ5V3A72S3F2A8SBUB8DAQ2V0O3V8G6G2JU56FHGFOHMQVKBSQFV98TCGTC3RJ1NINP82G0RC00N1520] | ||
1356 | P565723JO1C2HSN6J29TAQ22MN6CI8HTMUU55T0FUQG4CMDGGEQ8UCNBKUMB94GC8R9G4FB2SF9LDOBAJ6AMINBP4JHHDD6L7VD801G = | ||
1357 | @end example | ||
1358 | |||
1359 | You can also add a blacklist client usign the blacklist API. On a | ||
1360 | blacklist check, blacklisting first checks internally if the peer is | ||
1361 | blacklisted and if not, it asks the blacklisting clients. Clients are | ||
1362 | asked if it is OK to connect to a peer ID, the plugin is omitted. | ||
1363 | |||
1364 | On blacklist check for (peer, plugin) | ||
1365 | |||
1366 | @itemize @bullet | ||
1367 | @item Do we have a local blacklist entry for this peer and this plugin? | ||
1368 | @item YES: disallow connection | ||
1369 | @item Do we have a local blacklist entry for this peer and all plugins? | ||
1370 | @item YES: disallow connection | ||
1371 | @item Does one of the clients disallow? | ||
1372 | @item YES: disallow connection | ||
1373 | @end itemize | ||
1374 | |||
1375 | @node Configuration of the HTTP and HTTPS transport plugins | ||
1376 | @subsection Configuration of the HTTP and HTTPS transport plugins | ||
1377 | |||
1378 | The client parts of the http and https transport plugins can be configured | ||
1379 | to use a proxy to connect to the hostlist server. This functionality can | ||
1380 | be configured in the configuration file directly or using the | ||
1381 | gnunet-setup tool. | ||
1382 | |||
1383 | Both the HTTP and HTTPS clients support the following proxy types at | ||
1384 | the moment: | ||
1385 | |||
1386 | @itemize @bullet | ||
1387 | @item HTTP 1.1 proxy | ||
1388 | @item SOCKS 4/4a/5/5 with hostname | ||
1389 | @end itemize | ||
1390 | |||
1391 | In addition authentication at the proxy with username and password can be | ||
1392 | configured. | ||
1393 | |||
1394 | To configure proxy support for the clients in the gnunet-setup tool, | ||
1395 | select the "transport" tab and activate the respective plugin. Now you | ||
1396 | can select the appropriate proxy type. The hostname or IP address | ||
1397 | (including port if required) has to be entered in the "Proxy hostname" | ||
1398 | textbox. If required, enter username and password in the "Proxy username" | ||
1399 | and "Proxy password" boxes. Be aware that these information will be stored | ||
1400 | in the configuration in plain text. | ||
1401 | |||
1402 | To configure these options directly in the configuration, you can | ||
1403 | configure the following settings in the @code{[transport-http_client]} | ||
1404 | and @code{[transport-https_client]} section of the configuration: | ||
1405 | |||
1406 | @example | ||
1407 | # Type of proxy server, | ||
1408 | # Valid values: HTTP, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME | ||
1409 | # Default: HTTP | ||
1410 | # PROXY_TYPE = HTTP | ||
1411 | |||
1412 | # Hostname or IP of proxy server | ||
1413 | # PROXY = | ||
1414 | # User name for proxy server | ||
1415 | # PROXY_USERNAME = | ||
1416 | # User password for proxy server | ||
1417 | # PROXY_PASSWORD = | ||
1418 | @end example | ||
1419 | |||
1420 | @node Configuring the GNU Name System | ||
1421 | @subsection Configuring the GNU Name System | ||
1422 | |||
1423 | @menu | ||
1424 | * Configuring system-wide DNS interception:: | ||
1425 | * Configuring the GNS nsswitch plugin:: | ||
1426 | * Configuring GNS on W32:: | ||
1427 | * GNS Proxy Setup:: | ||
1428 | * Setup of the GNS CA:: | ||
1429 | * Testing the GNS setup:: | ||
1430 | @end menu | ||
1431 | |||
1432 | |||
1433 | @node Configuring system-wide DNS interception | ||
1434 | @subsubsection Configuring system-wide DNS interception | ||
1435 | |||
1436 | Before you install GNUnet, make sure you have a user and group 'gnunet' | ||
1437 | as well as an empty group 'gnunetdns'. | ||
1438 | |||
1439 | When using GNUnet with system-wide DNS interception, it is absolutely | ||
1440 | necessary for all GNUnet service processes to be started by | ||
1441 | @code{gnunet-service-arm} as user and group 'gnunet'. You also need to be | ||
1442 | sure to run @code{make install} as root (or use the @code{sudo} option to | ||
1443 | configure) to grant GNUnet sufficient privileges. | ||
1444 | |||
1445 | With this setup, all that is required for enabling system-wide DNS | ||
1446 | interception is for some GNUnet component (VPN or GNS) to request it. | ||
1447 | The @code{gnunet-service-dns} will then start helper programs that will | ||
1448 | make the necessary changes to your firewall (@code{iptables}) rules. | ||
1449 | |||
1450 | Note that this will NOT work if your system sends out DNS traffic to a | ||
1451 | link-local IPv6 address, as in this case GNUnet can intercept the traffic, | ||
1452 | but not inject the responses from the link-local IPv6 address. Hence you | ||
1453 | cannot use system-wide DNS interception in conjunction with link-local | ||
1454 | IPv6-based DNS servers. If such a DNS server is used, it will bypass | ||
1455 | GNUnet's DNS traffic interception. | ||
1456 | |||
1457 | Using the GNU Name System (GNS) requires two different configuration | ||
1458 | steps. | ||
1459 | First of all, GNS needs to be integrated with the operating system. Most | ||
1460 | of this section is about the operating system level integration. | ||
1461 | |||
1462 | The remainder of this chapter will detail the various methods for | ||
1463 | configuring the use of GNS with your operating system. | ||
1464 | |||
1465 | At this point in time you have different options depending on your OS: | ||
1466 | |||
1467 | @table @asis | ||
1468 | |||
1469 | @item Use the gnunet-gns-proxy This approach works for all operating | ||
1470 | systems and is likely the easiest. However, it enables GNS only for | ||
1471 | browsers, not for other applications that might be using DNS, such as SSH. | ||
1472 | Still, using the proxy is required for using HTTP with GNS and is thus | ||
1473 | recommended for all users. To do this, you simply have to run the | ||
1474 | @code{gnunet-gns-proxy-setup-ca} script as the user who will run the | ||
1475 | browser (this will create a GNS certificate authority (CA) on your system | ||
1476 | and import its key into your browser), then start @code{gnunet-gns-proxy} | ||
1477 | and inform your browser to use the Socks5 proxy which | ||
1478 | @code{gnunet-gns-proxy} makes available by default on port 7777. | ||
1479 | @item Use a nsswitch plugin (recommended on GNU systems) | ||
1480 | This approach has the advantage of offering fully personalized resolution | ||
1481 | even on multi-user systems. A potential disadvantage is that some | ||
1482 | applications might be able to bypass GNS. | ||
1483 | @item Use a W32 resolver plugin (recommended on W32) | ||
1484 | This is currently the only option on W32 systems. | ||
1485 | @item Use system-wide DNS packet interception | ||
1486 | This approach is recommended for the GNUnet VPN. It can be used to handle | ||
1487 | GNS at the same time; however, if you only use this method, you will only | ||
1488 | get one root zone per machine (not so great for multi-user systems). | ||
1489 | @end table | ||
1490 | |||
1491 | You can combine system-wide DNS packet interception with the nsswitch | ||
1492 | plugin. | ||
1493 | The setup of the system-wide DNS interception is described here. All of | ||
1494 | the other GNS-specific configuration steps are described in the following | ||
1495 | sections. | ||
1496 | |||
1497 | @node Configuring the GNS nsswitch plugin | ||
1498 | @subsubsection Configuring the GNS nsswitch plugin | ||
1499 | |||
1500 | The Name Service Switch (NSS) is a facility in Unix-like operating systems | ||
1501 | (in most cases provided by the GNU C Library) | ||
1502 | that provides a variety of sources for common configuration databases and | ||
1503 | name resolution mechanisms. | ||
1504 | A superuser (system administrator) usually configures the | ||
1505 | operating system's name services using the file | ||
1506 | @file{/etc/nsswitch.conf}. | ||
1507 | |||
1508 | GNS provides a NSS plugin to integrate GNS name resolution with the | ||
1509 | operating system's name resolution process. | ||
1510 | To use the GNS NSS plugin you have to either | ||
1511 | |||
1512 | @itemize @bullet | ||
1513 | @item install GNUnet as root or | ||
1514 | @item compile GNUnet with the @code{--with-sudo=yes} switch. | ||
1515 | @end itemize | ||
1516 | |||
1517 | Name resolution is controlled by the @emph{hosts} section in the NSS | ||
1518 | configuration. By default this section first performs a lookup in the | ||
1519 | @file{/etc/hosts} file and then in DNS. | ||
1520 | The nsswitch file should contain a line similar to: | ||
1521 | |||
1522 | @example | ||
1523 | hosts: files dns [NOTFOUND=return] mdns4_minimal mdns4 | ||
1524 | @end example | ||
1525 | |||
1526 | @noindent | ||
1527 | Here the GNS NSS plugin can be added to perform a GNS lookup before | ||
1528 | performing a DNS lookup. | ||
1529 | The GNS NSS plugin has to be added to the "hosts" section in | ||
1530 | @file{/etc/nsswitch.conf} file before DNS related plugins: | ||
1531 | |||
1532 | @example | ||
1533 | ... | ||
1534 | hosts: files gns [NOTFOUND=return] dns mdns4_minimal mdns4 | ||
1535 | ... | ||
1536 | @end example | ||
1537 | |||
1538 | @noindent | ||
1539 | The @code{NOTFOUND=return} will ensure that if a @code{.gnu} name is not | ||
1540 | found in GNS it will not be queried in DNS. | ||
1541 | |||
1542 | @node Configuring GNS on W32 | ||
1543 | @subsubsection Configuring GNS on W32 | ||
1544 | |||
1545 | This document is a guide to configuring GNU Name System on W32-compatible | ||
1546 | platforms. | ||
1547 | |||
1548 | After GNUnet is installed, run the w32nsp-install tool: | ||
1549 | |||
1550 | @example | ||
1551 | w32nsp-install.exe libw32nsp-0.dll | ||
1552 | @end example | ||
1553 | |||
1554 | @noindent | ||
1555 | ('0' is the library version of W32 NSP; it might increase in the future, | ||
1556 | change the invocation accordingly). | ||
1557 | |||
1558 | This will install GNS namespace provider into the system and allow other | ||
1559 | applications to resolve names that end in '@strong{gnu}' | ||
1560 | and '@strong{zkey}'. Note that namespace provider requires | ||
1561 | gnunet-gns-helper-service-w32 to be running, as well as gns service | ||
1562 | itself (and its usual dependencies). | ||
1563 | |||
1564 | Namespace provider is hardcoded to connect to @strong{127.0.0.1:5353}, | ||
1565 | and this is where gnunet-gns-helper-service-w32 should be listening to | ||
1566 | (and is configured to listen to by default). | ||
1567 | |||
1568 | To uninstall the provider, run: | ||
1569 | |||
1570 | @example | ||
1571 | w32nsp-uninstall.exe | ||
1572 | @end example | ||
1573 | |||
1574 | @noindent | ||
1575 | (uses provider GUID to uninstall it, does not need a dll name). | ||
1576 | |||
1577 | Note that while MSDN claims that other applications will only be able to | ||
1578 | use the new namespace provider after re-starting, in reality they might | ||
1579 | stat to use it without that. Conversely, they might stop using the | ||
1580 | provider after it's been uninstalled, even if they were not re-started. | ||
1581 | W32 will not permit namespace provider library to be deleted or | ||
1582 | overwritten while the provider is installed, and while there is at least | ||
1583 | one process still using it (even after it was uninstalled). | ||
1584 | |||
1585 | @node GNS Proxy Setup | ||
1586 | @subsubsection GNS Proxy Setup | ||
1587 | |||
1588 | When using the GNU Name System (GNS) to browse the WWW, there are several | ||
1589 | issues that can be solved by adding the GNS Proxy to your setup: | ||
1590 | |||
1591 | @itemize @bullet | ||
1592 | |||
1593 | @item If the target website does not support GNS, it might assume that it | ||
1594 | is operating under some name in the legacy DNS system (such as | ||
1595 | example.com). It may then attempt to set cookies for that domain, and the | ||
1596 | web server might expect a @code{Host: example.com} header in the request | ||
1597 | from your browser. | ||
1598 | However, your browser might be using @code{example.gnu} for the | ||
1599 | @code{Host} header and might only accept (and send) cookies for | ||
1600 | @code{example.gnu}. The GNS Proxy will perform the necessary translations | ||
1601 | of the hostnames for cookies and HTTP headers (using the LEHO record for | ||
1602 | the target domain as the desired substitute). | ||
1603 | |||
1604 | @item If using HTTPS, the target site might include an SSL certificate | ||
1605 | which is either only valid for the LEHO domain or might match a TLSA | ||
1606 | record in GNS. However, your browser would expect a valid certificate for | ||
1607 | @code{example.gnu}, not for some legacy domain name. The proxy will | ||
1608 | validate the certificate (either against LEHO or TLSA) and then | ||
1609 | on-the-fly produce a valid certificate for the exchange, signed by your | ||
1610 | own CA. Assuming you installed the CA of your proxy in your browser's | ||
1611 | certificate authority list, your browser will then trust the | ||
1612 | HTTPS/SSL/TLS connection, as the hostname mismatch is hidden by the proxy. | ||
1613 | |||
1614 | @item Finally, the proxy will in the future indicate to the server that it | ||
1615 | speaks GNS, which will enable server operators to deliver GNS-enabled web | ||
1616 | sites to your browser (and continue to deliver legacy links to legacy | ||
1617 | browsers) | ||
1618 | @end itemize | ||
1619 | |||
1620 | @node Setup of the GNS CA | ||
1621 | @subsubsection Setup of the GNS CA | ||
1622 | |||
1623 | First you need to create a CA certificate that the proxy can use. | ||
1624 | To do so use the provided script gnunet-gns-proxy-ca: | ||
1625 | |||
1626 | @example | ||
1627 | $ gnunet-gns-proxy-setup-ca | ||
1628 | @end example | ||
1629 | |||
1630 | @noindent | ||
1631 | This will create a personal certification authority for you and add this | ||
1632 | authority to the firefox and chrome database. The proxy will use the this | ||
1633 | CA certificate to generate @code{*.gnu} client certificates on the fly. | ||
1634 | |||
1635 | Note that the proxy uses libcurl. Make sure your version of libcurl uses | ||
1636 | GnuTLS and NOT OpenSSL. The proxy will @b{not} work with libcurl compiled | ||
1637 | against OpenSSL. | ||
1638 | |||
1639 | You can check the configuration your libcurl was build with by | ||
1640 | running: | ||
1641 | |||
1642 | @example | ||
1643 | curl --version | ||
1644 | @end example | ||
1645 | |||
1646 | the output will look like this (without the linebreaks): | ||
1647 | |||
1648 | @example | ||
1649 | gnurl --version | ||
1650 | curl 7.56.0 (x86_64-unknown-linux-gnu) libcurl/7.56.0 \ | ||
1651 | GnuTLS/3.5.13 zlib/1.2.11 libidn2/2.0.4 | ||
1652 | Release-Date: 2017-10-08 | ||
1653 | Protocols: http https | ||
1654 | Features: AsynchDNS IDN IPv6 Largefile NTLM SSL libz \ | ||
1655 | TLS-SRP UnixSockets HTTPS-proxy | ||
1656 | @end example | ||
1657 | |||
1658 | @node Testing the GNS setup | ||
1659 | @subsubsection Testing the GNS setup | ||
1660 | |||
1661 | Now for testing purposes we can create some records in our zone to test | ||
1662 | the SSL functionality of the proxy: | ||
1663 | |||
1664 | @example | ||
1665 | $ gnunet-identity -C test | ||
1666 | $ gnunet-namestore -a -e "1 d" -n "homepage" \ | ||
1667 | -t A -V 131.159.74.67 -z test | ||
1668 | $ gnunet-namestore -a -e "1 d" -n "homepage" \ | ||
1669 | -t LEHO -V "gnunet.org" -z test | ||
1670 | @end example | ||
1671 | |||
1672 | @noindent | ||
1673 | At this point we can start the proxy. Simply execute | ||
1674 | |||
1675 | @example | ||
1676 | $ gnunet-gns-proxy | ||
1677 | @end example | ||
1678 | |||
1679 | @noindent | ||
1680 | Configure your browser to use this SOCKSv5 proxy on port 7777 and visit | ||
1681 | this link. | ||
1682 | If you use @command{Firefox} (or one of its derivatives/forks such as | ||
1683 | Icecat) you also have to go to @code{about:config} and set the key | ||
1684 | @code{network.proxy.socks_remote_dns} to @code{true}. | ||
1685 | |||
1686 | When you visit @code{https://homepage.test/}, you should get to the | ||
1687 | @code{https://gnunet.org/} frontpage and the browser (with the correctly | ||
1688 | configured proxy) should give you a valid SSL certificate for | ||
1689 | @code{homepage.gnu} and no warnings. It should look like this: | ||
1690 | |||
1691 | @c FIXME: Image does not exist, create it or save it from Drupal? | ||
1692 | @c @image{images/gnunethpgns.png,5in,, picture of homepage.gnu in Webbrowser} | ||
1693 | |||
1694 | |||
1695 | @node Configuring the GNUnet VPN | ||
1696 | @subsection Configuring the GNUnet VPN | ||
1697 | |||
1698 | @menu | ||
1699 | * IPv4 address for interface:: | ||
1700 | * IPv6 address for interface:: | ||
1701 | * Configuring the GNUnet VPN DNS:: | ||
1702 | * Configuring the GNUnet VPN Exit Service:: | ||
1703 | * IP Address of external DNS resolver:: | ||
1704 | * IPv4 address for Exit interface:: | ||
1705 | * IPv6 address for Exit interface:: | ||
1706 | @end menu | ||
1707 | |||
1708 | Before configuring the GNUnet VPN, please make sure that system-wide DNS | ||
1709 | interception is configured properly as described in the section on the | ||
1710 | GNUnet DNS setup. @pxref{Configuring the GNU Name System}, | ||
1711 | if you haven't done so already. | ||
1712 | |||
1713 | The default options for the GNUnet VPN are usually sufficient to use | ||
1714 | GNUnet as a Layer 2 for your Internet connection. | ||
1715 | However, what you always have to specify is which IP protocol you want | ||
1716 | to tunnel: IPv4, IPv6 or both. | ||
1717 | Furthermore, if you tunnel both, you most likely should also tunnel | ||
1718 | all of your DNS requests. | ||
1719 | You theoretically can tunnel "only" your DNS traffic, but that usually | ||
1720 | makes little sense. | ||
1721 | |||
1722 | The other options as shown on the gnunet-setup tool are: | ||
1723 | |||
1724 | @node IPv4 address for interface | ||
1725 | @subsubsection IPv4 address for interface | ||
1726 | |||
1727 | This is the IPv4 address the VPN interface will get. You should pick an | ||
1728 | 'private' IPv4 network that is not yet in use for you system. For example, | ||
1729 | if you use @code{10.0.0.1/255.255.0.0} already, you might use | ||
1730 | @code{10.1.0.1/255.255.0.0}. | ||
1731 | If you use @code{10.0.0.1/255.0.0.0} already, then you might use | ||
1732 | @code{192.168.0.1/255.255.0.0}. | ||
1733 | If your system is not in a private IP-network, using any of the above will | ||
1734 | work fine. | ||
1735 | You should try to make the mask of the address big enough | ||
1736 | (@code{255.255.0.0} or, even better, @code{255.0.0.0}) to allow more | ||
1737 | mappings of remote IP Addresses into this range. | ||
1738 | However, even a @code{255.255.255.0} mask will suffice for most users. | ||
1739 | |||
1740 | @node IPv6 address for interface | ||
1741 | @subsubsection IPv6 address for interface | ||
1742 | |||
1743 | The IPv6 address the VPN interface will get. Here you can specify any | ||
1744 | non-link-local address (the address should not begin with @code{fe80:}). | ||
1745 | A subnet Unique Local Unicast (@code{fd00::/8} prefix) that you are | ||
1746 | currently not using would be a good choice. | ||
1747 | |||
1748 | @node Configuring the GNUnet VPN DNS | ||
1749 | @subsubsection Configuring the GNUnet VPN DNS | ||
1750 | |||
1751 | To resolve names for remote nodes, activate the DNS exit option. | ||
1752 | |||
1753 | @node Configuring the GNUnet VPN Exit Service | ||
1754 | @subsubsection Configuring the GNUnet VPN Exit Service | ||
1755 | |||
1756 | If you want to allow other users to share your Internet connection (yes, | ||
1757 | this may be dangerous, just as running a Tor exit node) or want to | ||
1758 | provide access to services on your host (this should be less dangerous, | ||
1759 | as long as those services are secure), you have to enable the GNUnet exit | ||
1760 | daemon. | ||
1761 | |||
1762 | You then get to specify which exit functions you want to provide. By | ||
1763 | enabling the exit daemon, you will always automatically provide exit | ||
1764 | functions for manually configured local services (this component of the | ||
1765 | system is under | ||
1766 | development and not documented further at this time). As for those | ||
1767 | services you explicitly specify the target IP address and port, there is | ||
1768 | no significant security risk in doing so. | ||
1769 | |||
1770 | Furthermore, you can serve as a DNS, IPv4 or IPv6 exit to the Internet. | ||
1771 | Being a DNS exit is usually pretty harmless. However, enabling IPv4 or | ||
1772 | IPv6-exit without further precautions may enable adversaries to access | ||
1773 | your local network, send spam, attack other systems from your Internet | ||
1774 | connection and to other mischief that will appear to come from your | ||
1775 | machine. This may or may not get you into legal trouble. | ||
1776 | If you want to allow IPv4 or IPv6-exit functionality, you should strongly | ||
1777 | consider adding additional firewall rules manually to protect your local | ||
1778 | network and to restrict outgoing TCP traffic (i.e. by not allowing access | ||
1779 | to port 25). While we plan to improve exit-filtering in the future, | ||
1780 | you're currently on your own here. | ||
1781 | Essentially, be prepared for any kind of IP-traffic to exit the respective | ||
1782 | TUN interface (and GNUnet will enable IP-forwarding and NAT for the | ||
1783 | interface automatically). | ||
1784 | |||
1785 | Additional configuration options of the exit as shown by the gnunet-setup | ||
1786 | tool are: | ||
1787 | |||
1788 | @node IP Address of external DNS resolver | ||
1789 | @subsubsection IP Address of external DNS resolver | ||
1790 | |||
1791 | If DNS traffic is to exit your machine, it will be send to this DNS | ||
1792 | resolver. You can specify an IPv4 or IPv6 address. | ||
1793 | |||
1794 | @node IPv4 address for Exit interface | ||
1795 | @subsubsection IPv4 address for Exit interface | ||
1796 | |||
1797 | This is the IPv4 address the Interface will get. Make the mask of the | ||
1798 | address big enough (255.255.0.0 or, even better, 255.0.0.0) to allow more | ||
1799 | mappings of IP addresses into this range. As for the VPN interface, any | ||
1800 | unused, private IPv4 address range will do. | ||
1801 | |||
1802 | @node IPv6 address for Exit interface | ||
1803 | @subsubsection IPv6 address for Exit interface | ||
1804 | |||
1805 | The public IPv6 address the interface will get. If your kernel is not a | ||
1806 | very recent kernel and you are willing to manually enable IPv6-NAT, the | ||
1807 | IPv6 address you specify here must be a globally routed IPv6 address of | ||
1808 | your host. | ||
1809 | |||
1810 | Suppose your host has the address @code{2001:4ca0::1234/64}, then | ||
1811 | using @code{2001:4ca0::1:0/112} would be fine (keep the first 64 bits, | ||
1812 | then change at least one bit in the range before the bitmask, in the | ||
1813 | example above we changed bit 111 from 0 to 1). | ||
1814 | |||
1815 | You may also have to configure your router to route traffic for the entire | ||
1816 | subnet (@code{2001:4ca0::1:0/112} for example) through your computer (this | ||
1817 | should be automatic with IPv6, but obviously anything can be | ||
1818 | disabled). | ||
1819 | |||
1820 | @node Bandwidth Configuration | ||
1821 | @subsection Bandwidth Configuration | ||
1822 | |||
1823 | You can specify how many bandwidth GNUnet is allowed to use to receive | ||
1824 | and send data. This is important for users with limited bandwidth or | ||
1825 | traffic volume. | ||
1826 | |||
1827 | @node Configuring NAT | ||
1828 | @subsection Configuring NAT | ||
1829 | |||
1830 | Most hosts today do not have a normal global IP address but instead are | ||
1831 | behind a router performing Network Address Translation (NAT) which assigns | ||
1832 | each host in the local network a private IP address. | ||
1833 | As a result, these machines cannot trivially receive inbound connections | ||
1834 | from the Internet. GNUnet supports NAT traversal to enable these machines | ||
1835 | to receive incoming connections from other peers despite their | ||
1836 | limitations. | ||
1837 | |||
1838 | In an ideal world, you can press the "Attempt automatic configuration" | ||
1839 | button in gnunet-setup to automatically configure your peer correctly. | ||
1840 | Alternatively, your distribution might have already triggered this | ||
1841 | automatic configuration during the installation process. | ||
1842 | However, automatic configuration can fail to determine the optimal | ||
1843 | settings, resulting in your peer either not receiving as many connections | ||
1844 | as possible, or in the worst case it not connecting to the network at all. | ||
1845 | |||
1846 | To manually configure the peer, you need to know a few things about your | ||
1847 | network setup. First, determine if you are behind a NAT in the first | ||
1848 | place. | ||
1849 | This is always the case if your IP address starts with "10.*" or | ||
1850 | "192.168.*". Next, if you have control over your NAT router, you may | ||
1851 | choose to manually configure it to allow GNUnet traffic to your host. | ||
1852 | If you have configured your NAT to forward traffic on ports 2086 (and | ||
1853 | possibly 1080) to your host, you can check the "NAT ports have been opened | ||
1854 | manually" option, which corresponds to the "PUNCHED_NAT" option in the | ||
1855 | configuration file. If you did not punch your NAT box, it may still be | ||
1856 | configured to support UPnP, which allows GNUnet to automatically | ||
1857 | configure it. In that case, you need to install the "upnpc" command, | ||
1858 | enable UPnP (or PMP) on your NAT box and set the "Enable NAT traversal | ||
1859 | via UPnP or PMP" option (corresponding to "ENABLE_UPNP" in the | ||
1860 | configuration file). | ||
1861 | |||
1862 | Some NAT boxes can be traversed using the autonomous NAT traversal method. | ||
1863 | This requires certain GNUnet components to be installed with "SUID" | ||
1864 | privileges on your system (so if you're installing on a system you do | ||
1865 | not have administrative rights to, this will not work). | ||
1866 | If you installed as 'root', you can enable autonomous NAT traversal by | ||
1867 | checking the "Enable NAT traversal using ICMP method". | ||
1868 | The ICMP method requires a way to determine your NAT's external (global) | ||
1869 | IP address. This can be done using either UPnP, DynDNS, or by manual | ||
1870 | configuration. If you have a DynDNS name or know your external IP address, | ||
1871 | you should enter that name under "External (public) IPv4 address" (which | ||
1872 | corresponds to the "EXTERNAL_ADDRESS" option in the configuration file). | ||
1873 | If you leave the option empty, GNUnet will try to determine your external | ||
1874 | IP address automatically (which may fail, in which case autonomous | ||
1875 | NAT traversal will then not work). | ||
1876 | |||
1877 | Finally, if you yourself are not behind NAT but want to be able to | ||
1878 | connect to NATed peers using autonomous NAT traversal, you need to check | ||
1879 | the "Enable connecting to NATed peers using ICMP method" box. | ||
1880 | |||
1881 | |||
1882 | @node Peer configuration for distributions | ||
1883 | @subsection Peer configuration for distributions | ||
1884 | |||
1885 | The "GNUNET_DATA_HOME" in "[path]" in @file{/etc/gnunet.conf} should be | ||
1886 | manually set to "/var/lib/gnunet/data/" as the default | ||
1887 | "~/.local/share/gnunet/" is probably not that appropriate in this case. | ||
1888 | Similarly, distributions may consider pointing "GNUNET_RUNTIME_DIR" to | ||
1889 | "/var/run/gnunet/" and "GNUNET_HOME" to "/var/lib/gnunet/". Also, should a | ||
1890 | distribution decide to override system defaults, all of these changes | ||
1891 | should be done in a custom @file{/etc/gnunet.conf} and not in the files | ||
1892 | in the @file{config.d/} directory. | ||
1893 | |||
1894 | Given the proposed access permissions, the "gnunet-setup" tool must be | ||
1895 | run as use "gnunet" (and with option "-c /etc/gnunet.conf" so that it | ||
1896 | modifies the system configuration). As always, gnunet-setup should be run | ||
1897 | after the GNUnet peer was stopped using "gnunet-arm -e". Distributions | ||
1898 | might want to include a wrapper for gnunet-setup that allows the | ||
1899 | desktop-user to "sudo" (i.e. using gtksudo) to the "gnunet" user account | ||
1900 | and then runs "gnunet-arm -e", "gnunet-setup" and "gnunet-arm -s" in | ||
1901 | sequence. | ||
1902 | |||
1903 | @node MOVED FROM USER Config Leftovers | ||
1904 | @section MOVED FROM USER Config Leftovers | ||
1905 | |||
1906 | This section describes how to start a GNUnet peer. It assumes that you | ||
1907 | have already compiled and installed GNUnet and its' dependencies. | ||
1908 | Before you start a GNUnet peer, you may want to create a configuration | ||
1909 | file using gnunet-setup (but you do not have to). | ||
1910 | Sane defaults should exist in your | ||
1911 | @file{$GNUNET_PREFIX/share/gnunet/config.d/} directory, so in practice | ||
1912 | you could simply start without any configuration. If you want to | ||
1913 | configure your peer later, you need to stop it before invoking the | ||
1914 | @code{gnunet-setup} tool to customize further and to test your | ||
1915 | configuration (@code{gnunet-setup} has build-in test functions). | ||
1916 | |||
1917 | The most important option you might have to still set by hand is in | ||
1918 | [PATHS]. Here, you use the option "GNUNET_HOME" to specify the path where | ||
1919 | GNUnet should store its data. | ||
1920 | It defaults to @code{$HOME/}, which again should work for most users. | ||
1921 | Make sure that the directory specified as GNUNET_HOME is writable to | ||
1922 | the user that you will use to run GNUnet (note that you can run frontends | ||
1923 | using other users, GNUNET_HOME must only be accessible to the user used to | ||
1924 | run the background processes). | ||
1925 | |||
1926 | You will also need to make one central decision: should all of GNUnet be | ||
1927 | run under your normal UID, or do you want distinguish between system-wide | ||
1928 | (user-independent) GNUnet services and personal GNUnet services. The | ||
1929 | multi-user setup is slightly more complicated, but also more secure and | ||
1930 | generally recommended. | ||
1931 | |||
1932 | @menu | ||
1933 | * The Single-User Setup:: | ||
1934 | * The Multi-User Setup:: | ||
1935 | * Killing GNUnet services:: | ||
1936 | * Access Control for GNUnet:: | ||
1937 | @end menu | ||
1938 | |||
1939 | @node The Single-User Setup | ||
1940 | @subsection The Single-User Setup | ||
1941 | |||
1942 | For the single-user setup, you do not need to do anything special and can | ||
1943 | just start the GNUnet background processes using @code{gnunet-arm}. | ||
1944 | By default, GNUnet looks in @file{~/.config/gnunet.conf} for a | ||
1945 | configuration (or @code{$XDG_CONFIG_HOME/gnunet.conf} if@ | ||
1946 | @code{$XDG_CONFIG_HOME} is defined). If your configuration lives | ||
1947 | elsewhere, you need to pass the @code{-c FILENAME} option to all GNUnet | ||
1948 | commands. | ||
1949 | |||
1950 | Assuming the configuration file is called @file{~/.config/gnunet.conf}, | ||
1951 | you start your peer using the @code{gnunet-arm} command (say as user | ||
1952 | @code{gnunet}) using: | ||
1953 | |||
1954 | @example | ||
1955 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
1956 | @end example | ||
1957 | |||
1958 | @noindent | ||
1959 | The "-s" option here is for "start". The command should return almost | ||
1960 | instantly. If you want to stop GNUnet, you can use: | ||
1961 | |||
1962 | @example | ||
1963 | gnunet-arm -c ~/.config/gnunet.conf -e | ||
1964 | @end example | ||
1965 | |||
1966 | @noindent | ||
1967 | The "-e" option here is for "end". | ||
1968 | |||
1969 | Note that this will only start the basic peer, no actual applications | ||
1970 | will be available. | ||
1971 | If you want to start the file-sharing service, use (after starting | ||
1972 | GNUnet): | ||
1973 | |||
1974 | @example | ||
1975 | gnunet-arm -c ~/.config/gnunet.conf -i fs | ||
1976 | @end example | ||
1977 | |||
1978 | @noindent | ||
1979 | The "-i fs" option here is for "initialize" the "fs" (file-sharing) | ||
1980 | application. You can also selectively kill only file-sharing support using | ||
1981 | |||
1982 | @example | ||
1983 | gnunet-arm -c ~/.config/gnunet.conf -k fs | ||
1984 | @end example | ||
1985 | |||
1986 | @noindent | ||
1987 | Assuming that you want certain services (like file-sharing) to be always | ||
1988 | automatically started whenever you start GNUnet, you can activate them by | ||
1989 | setting "IMMEDIATE_START=YES" in the respective section of the configuration | ||
1990 | file (for example, "[fs]"). Then GNUnet with file-sharing support would | ||
1991 | be started whenever you@ enter: | ||
1992 | |||
1993 | @example | ||
1994 | gnunet-arm -c ~/.config/gnunet.conf -s | ||
1995 | @end example | ||
1996 | |||
1997 | @noindent | ||
1998 | Alternatively, you can combine the two options: | ||
1999 | |||
2000 | @example | ||
2001 | gnunet-arm -c ~/.config/gnunet.conf -s -i fs | ||
2002 | @end example | ||
2003 | |||
2004 | @noindent | ||
2005 | Using @code{gnunet-arm} is also the preferred method for initializing | ||
2006 | GNUnet from @code{init}. | ||
2007 | |||
2008 | Finally, you should edit your @code{crontab} (using the @code{crontab} | ||
2009 | command) and insert a line@ | ||
2010 | |||
2011 | @example | ||
2012 | @@reboot gnunet-arm -c ~/.config/gnunet.conf -s | ||
2013 | @end example | ||
2014 | |||
2015 | to automatically start your peer whenever your system boots. | ||
2016 | |||
2017 | @node The Multi-User Setup | ||
2018 | @subsection The Multi-User Setup | ||
2019 | |||
2020 | This requires you to create a user @code{gnunet} and an additional group | ||
2021 | @code{gnunetdns}, prior to running @code{make install} during | ||
2022 | installation. | ||
2023 | Then, you create a configuration file @file{/etc/gnunet.conf} which should | ||
2024 | contain the lines:@ | ||
2025 | |||
2026 | @example | ||
2027 | [arm] | ||
2028 | START_SYSTEM_SERVICES = YES | ||
2029 | START_USER_SERVICES = NO | ||
2030 | @end example | ||
2031 | |||
2032 | @noindent | ||
2033 | Then, perform the same steps to run GNUnet as in the per-user | ||
2034 | configuration, except as user @code{gnunet} (including the | ||
2035 | @code{crontab} installation). | ||
2036 | You may also want to run @code{gnunet-setup} to configure your peer | ||
2037 | (databases, etc.). | ||
2038 | Make sure to pass @code{-c /etc/gnunet.conf} to all commands. If you | ||
2039 | run @code{gnunet-setup} as user @code{gnunet}, you might need to change | ||
2040 | permissions on @file{/etc/gnunet.conf} so that the @code{gnunet} user can | ||
2041 | write to the file (during setup). | ||
2042 | |||
2043 | Afterwards, you need to perform another setup step for each normal user | ||
2044 | account from which you want to access GNUnet. First, grant the normal user | ||
2045 | (@code{$USER}) permission to the group gnunet: | ||
2046 | |||
2047 | @example | ||
2048 | # adduser $USER gnunet | ||
2049 | @end example | ||
2050 | |||
2051 | @noindent | ||
2052 | Then, create a configuration file in @file{~/.config/gnunet.conf} for the | ||
2053 | $USER with the lines: | ||
2054 | |||
2055 | @example | ||
2056 | [arm] | ||
2057 | START_SYSTEM_SERVICES = NO | ||
2058 | START_USER_SERVICES = YES | ||
2059 | @end example | ||
2060 | |||
2061 | @noindent | ||
2062 | This will ensure that @code{gnunet-arm} when started by the normal user | ||
2063 | will only run services that are per-user, and otherwise rely on the | ||
2064 | system-wide services. | ||
2065 | Note that the normal user may run gnunet-setup, but the | ||
2066 | configuration would be ineffective as the system-wide services will use | ||
2067 | @file{/etc/gnunet.conf} and ignore options set by individual users. | ||
2068 | |||
2069 | Again, each user should then start the peer using | ||
2070 | @file{gnunet-arm -s} --- and strongly consider adding logic to start | ||
2071 | the peer automatically to their crontab. | ||
2072 | |||
2073 | Afterwards, you should see two (or more, if you have more than one USER) | ||
2074 | @code{gnunet-service-arm} processes running in your system. | ||
2075 | |||
2076 | @node Killing GNUnet services | ||
2077 | @subsection Killing GNUnet services | ||
2078 | |||
2079 | It is not necessary to stop GNUnet services explicitly when shutting | ||
2080 | down your computer. | ||
2081 | |||
2082 | It should be noted that manually killing "most" of the | ||
2083 | @code{gnunet-service} processes is generally not a successful method for | ||
2084 | stopping a peer (since @code{gnunet-service-arm} will instantly restart | ||
2085 | them). The best way to explicitly stop a peer is using | ||
2086 | @code{gnunet-arm -e}; note that the per-user services may need to be | ||
2087 | terminated before the system-wide services will terminate normally. | ||
2088 | |||
2089 | @node Access Control for GNUnet | ||
2090 | @subsection Access Control for GNUnet | ||
2091 | |||
2092 | This chapter documents how we plan to make access control work within the | ||
2093 | GNUnet system for a typical peer. It should be read as a best-practice | ||
2094 | installation guide for advanced users and builders of binary | ||
2095 | distributions. The recommendations in this guide apply to POSIX-systems | ||
2096 | with full support for UNIX domain sockets only. | ||
2097 | |||
2098 | Note that this is an advanced topic. The discussion presumes a very good | ||
2099 | understanding of users, groups and file permissions. Normal users on | ||
2100 | hosts with just a single user can just install GNUnet under their own | ||
2101 | account (and possibly allow the installer to use SUDO to grant additional | ||
2102 | permissions for special GNUnet tools that need additional rights). | ||
2103 | The discussion below largely applies to installations where multiple users | ||
2104 | share a system and to installations where the best possible security is | ||
2105 | paramount. | ||
2106 | |||
2107 | A typical GNUnet system consists of components that fall into four | ||
2108 | categories: | ||
2109 | |||
2110 | @table @asis | ||
2111 | |||
2112 | @item User interfaces | ||
2113 | User interfaces are not security sensitive and are supposed to be run and | ||
2114 | used by normal system users. | ||
2115 | The GTK GUIs and most command-line programs fall into this category. | ||
2116 | Some command-line tools (like gnunet-transport) should be excluded as they | ||
2117 | offer low-level access that normal users should not need. | ||
2118 | @item System services and support tools | ||
2119 | System services should always run and offer services that can then be | ||
2120 | accessed by the normal users. | ||
2121 | System services do not require special permissions, but as they are not | ||
2122 | specific to a particular user, they probably should not run as a | ||
2123 | particular user. Also, there should typically only be one GNUnet peer per | ||
2124 | host. System services include the gnunet-service and gnunet-daemon | ||
2125 | programs; support tools include command-line programs such as gnunet-arm. | ||
2126 | @item Privileged helpers | ||
2127 | Some GNUnet components require root rights to open raw sockets or perform | ||
2128 | other special operations. These gnunet-helper binaries are typically | ||
2129 | installed SUID and run from services or daemons. | ||
2130 | @item Critical services | ||
2131 | Some GNUnet services (such as the DNS service) can manipulate the service | ||
2132 | in deep and possibly highly security sensitive ways. For example, the DNS | ||
2133 | service can be used to intercept and alter any DNS query originating from | ||
2134 | the local machine. Access to the APIs of these critical services and their | ||
2135 | privileged helpers must be tightly controlled. | ||
2136 | @end table | ||
2137 | |||
2138 | @c FIXME: The titles of these chapters are too long in the index. | ||
2139 | |||
2140 | @menu | ||
2141 | * Recommendation - Disable access to services via TCP:: | ||
2142 | * Recommendation - Run most services as system user "gnunet":: | ||
2143 | * Recommendation - Control access to services using group "gnunet":: | ||
2144 | * Recommendation - Limit access to certain SUID binaries by group "gnunet":: | ||
2145 | * Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns":: | ||
2146 | * Differences between "make install" and these recommendations:: | ||
2147 | @end menu | ||
2148 | |||
2149 | @node Recommendation - Disable access to services via TCP | ||
2150 | @subsubsection Recommendation - Disable access to services via TCP | ||
2151 | |||
2152 | GNUnet services allow two types of access: via TCP socket or via UNIX | ||
2153 | domain socket. | ||
2154 | If the service is available via TCP, access control can only be | ||
2155 | implemented by restricting connections to a particular range of IP | ||
2156 | addresses. | ||
2157 | This is acceptable for non-critical services that are supposed to be | ||
2158 | available to all users on the local system or local network. | ||
2159 | However, as TCP is generally less efficient and it is rarely the case | ||
2160 | that a single GNUnet peer is supposed to serve an entire local network, | ||
2161 | the default configuration should disable TCP access to all GNUnet | ||
2162 | services on systems with support for UNIX domain sockets. | ||
2163 | As of GNUnet 0.9.2, configuration files with TCP access disabled should be | ||
2164 | generated by default. Users can re-enable TCP access to particular | ||
2165 | services simply by specifying a non-zero port number in the section of | ||
2166 | the respective service. | ||
2167 | |||
2168 | |||
2169 | @node Recommendation - Run most services as system user "gnunet" | ||
2170 | @subsubsection Recommendation - Run most services as system user "gnunet" | ||
2171 | |||
2172 | GNUnet's main services should be run as a separate user "gnunet" in a | ||
2173 | special group "gnunet". | ||
2174 | The user "gnunet" should start the peer using "gnunet-arm -s" during | ||
2175 | system startup. The home directory for this user should be | ||
2176 | @file{/var/lib/gnunet} and the configuration file should be | ||
2177 | @file{/etc/gnunet.conf}. | ||
2178 | Only the @code{gnunet} user should have the right to access | ||
2179 | @file{/var/lib/gnunet} (@emph{mode: 700}). | ||
2180 | |||
2181 | @node Recommendation - Control access to services using group "gnunet" | ||
2182 | @subsubsection Recommendation - Control access to services using group "gnunet" | ||
2183 | |||
2184 | Users that should be allowed to use the GNUnet peer should be added to the | ||
2185 | group "gnunet". Using GNUnet's access control mechanism for UNIX domain | ||
2186 | sockets, those services that are considered useful to ordinary users | ||
2187 | should be made available by setting "UNIX_MATCH_GID=YES" for those | ||
2188 | services. | ||
2189 | Again, as shipped, GNUnet provides reasonable defaults. | ||
2190 | Permissions to access the transport and core subsystems might additionally | ||
2191 | be granted without necessarily causing security concerns. | ||
2192 | Some services, such as DNS, must NOT be made accessible to the "gnunet" | ||
2193 | group (and should thus only be accessible to the "gnunet" user and | ||
2194 | services running with this UID). | ||
2195 | |||
2196 | @node Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
2197 | @subsubsection Recommendation - Limit access to certain SUID binaries by group "gnunet" | ||
2198 | |||
2199 | Most of GNUnet's SUID binaries should be safe even if executed by normal | ||
2200 | users. However, it is possible to reduce the risk a little bit more by | ||
2201 | making these binaries owned by the group "gnunet" and restricting their | ||
2202 | execution to user of the group "gnunet" as well (4750). | ||
2203 | |||
2204 | @node Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
2205 | @subsubsection Recommendation - Limit access to critical gnunet-helper-dns to group "gnunetdns" | ||
2206 | |||
2207 | A special group "gnunetdns" should be created for controlling access to | ||
2208 | the "gnunet-helper-dns". | ||
2209 | The binary should then be owned by root and be in group "gnunetdns" and | ||
2210 | be installed SUID and only be group-executable (2750). | ||
2211 | @b{Note that the group "gnunetdns" should have no users in it at all, | ||
2212 | ever.} | ||
2213 | The "gnunet-service-dns" program should be executed by user "gnunet" (via | ||
2214 | gnunet-service-arm) with the binary owned by the user "root" and the group | ||
2215 | "gnunetdns" and be SGID (2700). This way, @strong{only} | ||
2216 | "gnunet-service-dns" can change its group to "gnunetdns" and execute the | ||
2217 | helper, and the helper can then run as root (as per SUID). | ||
2218 | Access to the API offered by "gnunet-service-dns" is in turn restricted | ||
2219 | to the user "gnunet" (not the group!), which means that only | ||
2220 | "benign" services can manipulate DNS queries using "gnunet-service-dns". | ||
2221 | |||
2222 | @node Differences between "make install" and these recommendations | ||
2223 | @subsubsection Differences between "make install" and these recommendations | ||
2224 | |||
2225 | The current build system does not set all permissions automatically based | ||
2226 | on the recommendations above. In particular, it does not use the group | ||
2227 | "gnunet" at all (so setting gnunet-helpers other than the | ||
2228 | gnunet-helper-dns to be owned by group "gnunet" must be done manually). | ||
2229 | Furthermore, 'make install' will silently fail to set the DNS binaries to | ||
2230 | be owned by group "gnunetdns" unless that group already exists (!). | ||
2231 | An alternative name for the "gnunetdns" group can be specified using the | ||
2232 | @code{--with-gnunetdns=GRPNAME} configure option. | ||
2233 | |||
diff --git a/doc/documentation/chapters/keyconcepts.texi b/doc/documentation/chapters/keyconcepts.texi deleted file mode 100644 index b4a60024c..000000000 --- a/doc/documentation/chapters/keyconcepts.texi +++ /dev/null | |||
@@ -1,317 +0,0 @@ | |||
1 | |||
2 | @cindex Key Concepts | ||
3 | @node Key Concepts | ||
4 | @chapter Key Concepts | ||
5 | |||
6 | In this section, the fundamental concepts of GNUnet are explained. | ||
7 | @c FIXME: Use @uref{https://docs.gnunet.org/bib/, research papers} | ||
8 | @c once we have the new bibliography + subdomain setup. | ||
9 | Most of them are also described in our research papers. | ||
10 | First, some of the concepts used in the GNUnet framework are detailed. | ||
11 | The second part describes concepts specific to anonymous file-sharing. | ||
12 | |||
13 | @menu | ||
14 | * Authentication:: | ||
15 | * Accounting to Encourage Resource Sharing:: | ||
16 | * Confidentiality:: | ||
17 | * Anonymity:: | ||
18 | * Deniability:: | ||
19 | * Peer Identities:: | ||
20 | * Zones in the GNU Name System (GNS Zones):: | ||
21 | * Egos:: | ||
22 | @end menu | ||
23 | |||
24 | @cindex Authentication | ||
25 | @node Authentication | ||
26 | @section Authentication | ||
27 | |||
28 | Almost all peer-to-peer communications in GNUnet are between mutually | ||
29 | authenticated peers. The authentication works by using ECDHE, that is a | ||
30 | DH (Diffie---Hellman) key exchange using ephemeral elliptic curve | ||
31 | cryptography. The ephemeral ECC (Elliptic Curve Cryptography) keys are | ||
32 | signed using ECDSA (@uref{http://en.wikipedia.org/wiki/ECDSA, ECDSA}). | ||
33 | The shared secret from ECDHE is used to create a pair of session keys | ||
34 | @c FIXME: Long word for HKDF. More FIXMEs: Explain MITM etc. | ||
35 | (using HKDF) which are then used to encrypt the communication between the | ||
36 | two peers using both 256-bit AES (Advanced Encryption Standard) | ||
37 | and 256-bit Twofish (with independently derived secret keys). | ||
38 | As only the two participating hosts know the shared secret, this | ||
39 | authenticates each packet | ||
40 | without requiring signatures each time. GNUnet uses SHA-512 | ||
41 | (Secure Hash Algorithm) hash codes to verify the integrity of messages. | ||
42 | |||
43 | @c FIXME: A while back I got the feedback that I should try and integrate | ||
44 | @c explanation boxes in the long-run. So we could explain | ||
45 | @c "man-in-the-middle" and "man-in-the-middle attacks" and other words | ||
46 | @c which are not common knowledge. MITM is not common knowledge. To be | ||
47 | @c selfcontained, we should be able to explain words and concepts used in | ||
48 | @c a chapter or paragraph without hinting at Wikipedia and other online | ||
49 | @c sources which might not be available or accessible to everyone. | ||
50 | @c On the other hand we could write an introductionary chapter or book | ||
51 | @c that we could then reference in each chapter, which sound like it | ||
52 | @c could be more reusable. | ||
53 | In GNUnet, the identity of a host is its public key. For that reason, | ||
54 | man-in-the-middle attacks will not break the authentication or accounting | ||
55 | goals. Essentially, for GNUnet, the IP of the host has nothing to do with | ||
56 | the identity of the host. As the public key is the only thing that truly | ||
57 | matters, faking an IP, a port or any other property of the underlying | ||
58 | transport protocol is irrelevant. In fact, GNUnet peers can use | ||
59 | multiple IPs (IPv4 and IPv6) on multiple ports --- or even not use the | ||
60 | IP protocol at all (by running directly on layer 2). | ||
61 | @c FIXME: "IP protocol" feels wrong, but could be what people expect, as | ||
62 | @c IP is "the number" and "IP protocol" the protocol itself in general | ||
63 | @c knowledge? | ||
64 | |||
65 | @c NOTE: For consistency we will use @code{HELLO}s throughout this Manual. | ||
66 | GNUnet uses a special type of message to communicate a binding between | ||
67 | public (ECC) keys to their current network address. These messages are | ||
68 | commonly called @code{HELLO}s or @code{peer advertisements}. | ||
69 | They contain the public key of the peer and its current network | ||
70 | addresses for various transport services. | ||
71 | A transport service is a special kind of shared library that | ||
72 | provides (possibly unreliable, out-of-order) message delivery between | ||
73 | peers. | ||
74 | For the UDP and TCP transport services, a network address is an IP and a | ||
75 | port. | ||
76 | GNUnet can also use other transports (HTTP, HTTPS, WLAN, etc.) which use | ||
77 | various other forms of addresses. Note that any node can have many | ||
78 | different active transport services at the same time, | ||
79 | and each of these can have a different addresses. | ||
80 | Binding messages expire after at most a week (the timeout can be | ||
81 | shorter if the user configures the node appropriately). | ||
82 | This expiration ensures that the network will eventually get rid of | ||
83 | outdated advertisements. | ||
84 | |||
85 | For more information, refer to the following paper: | ||
86 | |||
87 | Ronaldo A. Ferreira, Christian Grothoff, and Paul Ruth. | ||
88 | A Transport Layer Abstraction for Peer-to-Peer Networks | ||
89 | Proceedings of the 3rd International Symposium on Cluster Computing | ||
90 | and the Grid (GRID 2003), 2003. | ||
91 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/transport.pdf, https://gnunet.org/git/bibliography.git/plain/docs/transport.pdf}) | ||
92 | |||
93 | @cindex Accounting to Encourage Resource Sharing | ||
94 | @node Accounting to Encourage Resource Sharing | ||
95 | @section Accounting to Encourage Resource Sharing | ||
96 | |||
97 | Most distributed P2P networks suffer from a lack of defenses or | ||
98 | precautions against attacks in the form of freeloading. | ||
99 | While the intentions of an attacker and a freeloader are different, their | ||
100 | effect on the network is the same; they both render it useless. | ||
101 | Most simple attacks on networks such as @command{Gnutella} | ||
102 | involve flooding the network with traffic, particularly | ||
103 | with queries that are, in the worst case, multiplied by the network. | ||
104 | |||
105 | In order to ensure that freeloaders or attackers have a minimal impact | ||
106 | on the network, GNUnet's file-sharing implementation (@code{FS} tries | ||
107 | to distinguish good (contributing) nodes from malicious (freeloading) | ||
108 | nodes. In GNUnet, every file-sharing node keeps track of the behavior | ||
109 | of every other node it has been in contact with. Many requests | ||
110 | (depending on the application) are transmitted with a priority (or | ||
111 | importance) level. That priority is used to establish how important | ||
112 | the sender believes this request is. If a peer responds to an | ||
113 | important request, the recipient will increase its trust in the | ||
114 | responder: the responder contributed resources. If a peer is too busy | ||
115 | to answer all requests, it needs to prioritize. For that, peers do | ||
116 | not take the priorities of the requests received at face value. | ||
117 | First, they check how much they trust the sender, and depending on | ||
118 | that amount of trust they assign the request a (possibly lower) | ||
119 | effective priority. Then, they drop the requests with the lowest | ||
120 | effective priority to satisfy their resource constraints. This way, | ||
121 | GNUnet's economic model ensures that nodes that are not currently | ||
122 | considered to have a surplus in contributions will not be served if | ||
123 | the network load is high. | ||
124 | |||
125 | For more information, refer to the following paper: | ||
126 | Christian Grothoff. An Excess-Based Economic Model for Resource | ||
127 | Allocation in Peer-to-Peer Networks. Wirtschaftsinformatik, June 2003. | ||
128 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/ebe.pdf, https://gnunet.org/git/bibliography.git/plain/docs/ebe.pdf}) | ||
129 | |||
130 | @cindex Confidentiality | ||
131 | @node Confidentiality | ||
132 | @section Confidentiality | ||
133 | |||
134 | Adversaries (malicious, bad actors) outside of GNUnet are not supposed | ||
135 | to know what kind of actions a peer is involved in. Only the specific | ||
136 | neighbor of a peer that is the corresponding sender or recipient of a | ||
137 | message may know its contents, and even then application protocols may | ||
138 | place further restrictions on that knowledge. In order to ensure | ||
139 | confidentiality, GNUnet uses link encryption, that is each message | ||
140 | exchanged between two peers is encrypted using a pair of keys only | ||
141 | known to these two peers. Encrypting traffic like this makes any kind | ||
142 | of traffic analysis much harder. Naturally, for some applications, it | ||
143 | may still be desirable if even neighbors cannot determine the concrete | ||
144 | contents of a message. In GNUnet, this problem is addressed by the | ||
145 | specific application-level protocols. See for example the following | ||
146 | sections @pxref{Anonymity}, @pxref{How file-sharing achieves Anonymity}, | ||
147 | and @pxref{Deniability}. | ||
148 | |||
149 | @cindex Anonymity | ||
150 | @node Anonymity | ||
151 | @section Anonymity | ||
152 | |||
153 | @menu | ||
154 | * How file-sharing achieves Anonymity:: | ||
155 | @end menu | ||
156 | |||
157 | Providing anonymity for users is the central goal for the anonymous | ||
158 | file-sharing application. Many other design decisions follow in the | ||
159 | footsteps of this requirement. | ||
160 | Anonymity is never absolute. While there are various | ||
161 | scientific metrics | ||
162 | (Claudia Díaz, Stefaan Seys, Joris Claessens, | ||
163 | and Bart Preneel. Towards measuring anonymity. | ||
164 | 2002. | ||
165 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/article-89.pdf, https://gnunet.org/git/bibliography.git/plain/docs/article-89.pdf})) | ||
166 | that can help quantify the level of anonymity that a given mechanism | ||
167 | provides, there is no such thing as "complete anonymity". | ||
168 | GNUnet's file-sharing implementation allows users to select for each | ||
169 | operation (publish, search, download) the desired level of anonymity. | ||
170 | The metric used is the amount of cover traffic available to hide the | ||
171 | request. | ||
172 | While this metric is not as good as, for example, the theoretical metric | ||
173 | given in scientific metrics, | ||
174 | it is probably the best metric available to a peer with a purely local | ||
175 | view of the world that does not rely on unreliable external information. | ||
176 | The default anonymity level is @code{1}, which uses anonymous routing but | ||
177 | imposes no minimal requirements on cover traffic. It is possible | ||
178 | to forego anonymity when this is not required. The anonymity level of | ||
179 | @code{0} allows GNUnet to use more efficient, non-anonymous routing. | ||
180 | |||
181 | @cindex How file-sharing achieves Anonymity | ||
182 | @node How file-sharing achieves Anonymity | ||
183 | @subsection How file-sharing achieves Anonymity | ||
184 | |||
185 | Contrary to other designs, we do not believe that users achieve strong | ||
186 | anonymity just because their requests are obfuscated by a couple of | ||
187 | indirections. This is not sufficient if the adversary uses traffic | ||
188 | analysis. | ||
189 | The threat model used for anonymous file sharing in GNUnet assumes that | ||
190 | the adversary is quite powerful. | ||
191 | In particular, we assume that the adversary can see all the traffic on | ||
192 | the Internet. And while we assume that the adversary | ||
193 | can not break our encryption, we assume that the adversary has many | ||
194 | participating nodes in the network and that it can thus see many of the | ||
195 | node-to-node interactions since it controls some of the nodes. | ||
196 | |||
197 | The system tries to achieve anonymity based on the idea that users can be | ||
198 | anonymous if they can hide their actions in the traffic created by other | ||
199 | users. | ||
200 | Hiding actions in the traffic of other users requires participating in the | ||
201 | traffic, bringing back the traditional technique of using indirection and | ||
202 | source rewriting. Source rewriting is required to gain anonymity since | ||
203 | otherwise an adversary could tell if a message originated from a host by | ||
204 | looking at the source address. If all packets look like they originate | ||
205 | from one node, the adversary can not tell which ones originate from that | ||
206 | node and which ones were routed. | ||
207 | Note that in this mindset, any node can decide to break the | ||
208 | source-rewriting paradigm without violating the protocol, as this | ||
209 | only reduces the amount of traffic that a node can hide its own traffic | ||
210 | in. | ||
211 | |||
212 | If we want to hide our actions in the traffic of other nodes, we must make | ||
213 | our traffic indistinguishable from the traffic that we route for others. | ||
214 | As our queries must have us as the receiver of the reply | ||
215 | (otherwise they would be useless), we must put ourselves as the receiver | ||
216 | of replies that actually go to other hosts; in other words, we must | ||
217 | indirect replies. | ||
218 | Unlike other systems, in anonymous file-sharing as implemented on top of | ||
219 | GNUnet we do not have to indirect the replies if we don't think we need | ||
220 | more traffic to hide our own actions. | ||
221 | |||
222 | This increases the efficiency of the network as we can indirect less under | ||
223 | higher load. | ||
224 | Refer to the following paper for more: | ||
225 | Krista Bennett and Christian Grothoff. | ||
226 | GAP --- practical anonymous networking. In Proceedings of | ||
227 | Designing Privacy Enhancing Technologies, 2003. | ||
228 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/aff.pdf, https://gnunet.org/git/bibliography.git/plain/docs/aff.pdf}) | ||
229 | |||
230 | @cindex Deniability | ||
231 | @node Deniability | ||
232 | @section Deniability | ||
233 | |||
234 | Even if the user that downloads data and the server that provides data are | ||
235 | anonymous, the intermediaries may still be targets. In particular, if the | ||
236 | intermediaries can find out which queries or which content they are | ||
237 | processing, a strong adversary could try to force them to censor | ||
238 | certain materials. | ||
239 | |||
240 | With the file-encoding used by GNUnet's anonymous file-sharing, this | ||
241 | problem does not arise. | ||
242 | The reason is that queries and replies are transmitted in | ||
243 | an encrypted format such that intermediaries cannot tell what the query | ||
244 | is for or what the content is about. Mind that this is not the same | ||
245 | encryption as the link-encryption between the nodes. GNUnet has | ||
246 | encryption on the network layer (link encryption, confidentiality, | ||
247 | authentication) and again on the application layer (provided | ||
248 | by @command{gnunet-publish}, @command{gnunet-download}, | ||
249 | @command{gnunet-search} and @command{gnunet-gtk}). | ||
250 | |||
251 | Refer to the following paper for more: | ||
252 | Christian Grothoff, Krista Grothoff, Tzvetan Horozov, | ||
253 | and Jussi T. Lindgren. | ||
254 | An Encoding for Censorship-Resistant Sharing. | ||
255 | 2009. | ||
256 | (@uref{https://gnunet.org/git/bibliography.git/plain/docs/ecrs.pdf, https://gnunet.org/git/bibliography.git/plain/docs/ecrs.pdf}) | ||
257 | |||
258 | @cindex Peer Identities | ||
259 | @node Peer Identities | ||
260 | @section Peer Identities | ||
261 | |||
262 | Peer identities are used to identify peers in the network and are unique | ||
263 | for each peer. The identity for a peer is simply its public key, which is | ||
264 | generated along with a private key the peer is started for the first time. | ||
265 | While the identity is binary data, it is often expressed as ASCII string. | ||
266 | For example, the following is a peer identity as you might see it in | ||
267 | various places: | ||
268 | |||
269 | @example | ||
270 | UAT1S6PMPITLBKSJ2DGV341JI6KF7B66AC4JVCN9811NNEGQLUN0 | ||
271 | @end example | ||
272 | |||
273 | @noindent | ||
274 | You can find your peer identity by running @command{gnunet-peerinfo -s}. | ||
275 | |||
276 | @cindex Zones in the GNU Name System (GNS Zones) | ||
277 | @node Zones in the GNU Name System (GNS Zones) | ||
278 | @section Zones in the GNU Name System (GNS Zones) | ||
279 | |||
280 | @c FIXME: Explain or link to an explanation of the concept of public keys | ||
281 | @c and private keys. | ||
282 | @c FIXME: Rewrite for the latest GNS changes. | ||
283 | GNS (Matthias Wachs, Martin Schanzenbach, and Christian Grothoff. | ||
284 | A Censorship-Resistant, Privacy-Enhancing and Fully Decentralized Name | ||
285 | System. In proceedings of 13th International Conference on Cryptology and | ||
286 | Network Security (CANS 2014). 2014. | ||
287 | @uref{https://gnunet.org/git/bibliography.git/plain/docs/gns2014wachs.pdf, https://gnunet.org/git/bibliography.git/plain/docs/gns2014wachs.pdf}) | ||
288 | zones are similar to those of DNS zones, but instead of a hierarchy of | ||
289 | authorities to governing their use, GNS zones are controlled by a private | ||
290 | key. | ||
291 | When you create a record in a DNS zone, that information is stored in your | ||
292 | nameserver. Anyone trying to resolve your domain then gets pointed | ||
293 | (hopefully) by the centralised authority to your nameserver. | ||
294 | Whereas GNS, being fully decentralized by design, stores that information | ||
295 | in DHT. The validity of the records is assured cryptographically, by | ||
296 | signing them with the private key of the respective zone. | ||
297 | |||
298 | Anyone trying to resolve records in a zone of your domain can then verify | ||
299 | the signature of the records they get from the DHT and be assured that | ||
300 | they are indeed from the respective zone. | ||
301 | To make this work, there is a 1:1 correspondence between zones and | ||
302 | their public-private key pairs. | ||
303 | So when we talk about the owner of a GNS zone, that's really the owner of | ||
304 | the private key. | ||
305 | And a user accessing a zone needs to somehow specify the corresponding | ||
306 | public key first. | ||
307 | |||
308 | @cindex Egos | ||
309 | @node Egos | ||
310 | @section Egos | ||
311 | |||
312 | @c what is the difference between peer identity and egos? It seems | ||
313 | @c like both are linked to public-private key pair. | ||
314 | Egos are your "identities" in GNUnet. Any user can assume multiple | ||
315 | identities, for example to separate their activities online. Egos can | ||
316 | correspond to "pseudonyms" or "real-world identities". Technically an | ||
317 | ego is first of all a key pair of a public- and private-key. | ||
diff --git a/doc/documentation/chapters/philosophy.texi b/doc/documentation/chapters/philosophy.texi deleted file mode 100644 index e57c20914..000000000 --- a/doc/documentation/chapters/philosophy.texi +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | @cindex Philosophy | ||
2 | @node Philosophy | ||
3 | @chapter Philosophy | ||
4 | |||
5 | @c NOTE: We should probably re-use some of the images lynX created | ||
6 | @c for secushare, showing some of the relations and functionalities | ||
7 | @c of GNUnet. | ||
8 | The primary goal of the GNUnet project is to provide a reliable, open, | ||
9 | non-discriminating and censorship-resistant system for information | ||
10 | exchange. We value free speech above state interests and intellectual | ||
11 | monopoly. GNUnet's long-term goal is to serve as a development | ||
12 | platform for the next generation of Internet protocols. | ||
13 | |||
14 | GNUnet is an anarchistic network. Participants are encouraged to | ||
15 | contribute at least as much resources (storage, bandwidth) to the network | ||
16 | as they consume, so that their participation does not have a negative | ||
17 | impact on other users. | ||
18 | |||
19 | @menu | ||
20 | * Design Principles:: | ||
21 | * Privacy and Anonymity:: | ||
22 | * Practicality:: | ||
23 | @end menu | ||
24 | |||
25 | @cindex Design Principles | ||
26 | @node Design Principles | ||
27 | @section Design Principles | ||
28 | |||
29 | These are the GNUnet design principles, in order of importance: | ||
30 | |||
31 | @itemize | ||
32 | @item GNUnet must be implemented as | ||
33 | @uref{https://www.gnu.org/philosophy/free-sw.html, Free Software} --- | ||
34 | This means that you you have the four essential freedoms: to run | ||
35 | the program, to study and change the program in source code form, | ||
36 | to redistribute exact copies, and to distribute modified versions. | ||
37 | (@uref{https://www.gnu.org/philosophy/free-sw.html}). | ||
38 | @item GNUnet must minimize the amount of personally identifiable information exposed. | ||
39 | @item GNUnet must be fully distributed and resilient to external attacks and rogue participants. | ||
40 | @item GNUnet must be self-organizing and not depend on administrators or centralized infrastructure. | ||
41 | @item GNUnet must inform the user which other participants have to be trusted when establishing private communications. | ||
42 | @item GNUnet must be open and permit new peers to join. | ||
43 | @item GNUnet must support a diverse range of applications and devices. | ||
44 | @item GNUnet must use compartmentalization to protect sensitive information. | ||
45 | @item The GNUnet architecture must be resource efficient. | ||
46 | @item GNUnet must provide incentives for peers to contribute more resources than they consume. | ||
47 | @end itemize | ||
48 | |||
49 | |||
50 | @cindex Privacy and Anonymity | ||
51 | @node Privacy and Anonymity | ||
52 | @section Privacy and Anonymity | ||
53 | |||
54 | The GNUnet protocols minimize the leakage of personally identifiable | ||
55 | information of participants and do not allow adversaries to control, | ||
56 | track, monitor or censor users activities. The GNUnet protocols also | ||
57 | make it as hard as possible to disrupt operations by participating in | ||
58 | the network with malicious intent. | ||
59 | |||
60 | Analyzing participant's activities becomes more difficult as the | ||
61 | number of peers and applications that generate traffic on the network | ||
62 | grows, even if the additional traffic generated is not related to | ||
63 | anonymous communication. This is one of the reasons why GNUnet is | ||
64 | developed as a peer-to-peer framework where many applications share | ||
65 | the lower layers of an increasingly complex protocol stack. The GNUnet | ||
66 | architecture encourages many different forms of peer-to-peer | ||
67 | applications. | ||
68 | |||
69 | @cindex Practicality | ||
70 | @node Practicality | ||
71 | @section Practicality | ||
72 | |||
73 | Whereever possible GNUnet allows the peer to adjust its operations and | ||
74 | functionalities to specific use cases. A GNUnet peer running on a | ||
75 | mobile device with limited battery for example might choose not to | ||
76 | relay traffic for other participants. | ||
77 | |||
78 | For certain applications like file-sharing GNUnet allows participants | ||
79 | to trade degrees of anonymity in exchange for increased | ||
80 | efficiency. However, it is not possible for any user's efficiency | ||
81 | requirements to compromise the anonymity of any other user. | ||
diff --git a/doc/documentation/chapters/preface.texi b/doc/documentation/chapters/preface.texi deleted file mode 100644 index 386cefa6d..000000000 --- a/doc/documentation/chapters/preface.texi +++ /dev/null | |||
@@ -1,173 +0,0 @@ | |||
1 | @node Preface | ||
2 | @chapter Preface | ||
3 | |||
4 | This collection of manuals describes how to use GNUnet, a framework | ||
5 | for secure peer-to-peer networking with the high-level goal to provide | ||
6 | a strong foundation Free Software for a global, distributed network | ||
7 | that provides security and privacy. GNUnet in that sense aims to | ||
8 | replace the current Internet protocol stack. Along with an | ||
9 | application for secure publication of files, it has grown to include | ||
10 | all kinds of basic applications for the foundation of a new Internet. | ||
11 | |||
12 | @menu | ||
13 | * About this book:: | ||
14 | * Contributing to this book:: | ||
15 | * Introduction:: | ||
16 | * Project governance:: | ||
17 | * Typography:: | ||
18 | @end menu | ||
19 | |||
20 | @node About this book | ||
21 | @section About this book | ||
22 | |||
23 | The books (described as ``book'' or ``books'' in the following) | ||
24 | bundled as the ``GNUnet Reference Manual'' are based on the historic | ||
25 | work of all contributors to GNUnet's documentation. It is our hope | ||
26 | that the content is described in a way that does not require any | ||
27 | academic background, although some concepts will require further | ||
28 | reading. | ||
29 | |||
30 | Our (long-term) goal with these books is to keep them self-contained. If | ||
31 | you see references to Wikipedia and other external sources (except for | ||
32 | our academic papers) it means that we are working on a solution to | ||
33 | describe the explanations found there which fits our use-case and licensing. | ||
34 | |||
35 | The first chapter (``Preface'') as well as the the second | ||
36 | chapter (``Philosophy'') give an introduction to GNUnet as a project, | ||
37 | what GNUnet tries to achieve. | ||
38 | |||
39 | @node Contributing to this book | ||
40 | @section Contributing to this book | ||
41 | |||
42 | The GNUnet Reference Manual is a collective work produced by various | ||
43 | people throughout the years. The version you are reading is derived | ||
44 | from many individual efforts hosted on our website. This was a failed | ||
45 | experiment, and with the conversion to Texinfo we hope to address this | ||
46 | in the longterm. Texinfo is the documentation language of the GNU project. | ||
47 | While it can be intimidating at first and look scary or complicated, | ||
48 | it is just another way to express text format instructions. We encourage | ||
49 | you to take this opportunity and learn about Texinfo, learn about GNUnet, | ||
50 | and one word at a time we will arrive at a book which explains GNUnet in | ||
51 | the least complicated way to you. Even when you don't want or can't learn | ||
52 | Texinfo, you can contribute. Send us an Email or join our IRC chat room | ||
53 | on freenode and talk with us about the documentation (the prefered way | ||
54 | to reach out is the mailinglist, since you can communicate with us | ||
55 | without waiting on someone in the chatroom). One way or another you | ||
56 | can help shape the understanding of GNUnet without the ability to read | ||
57 | and understand its sourcecode. | ||
58 | |||
59 | @node Introduction | ||
60 | @section Introduction | ||
61 | |||
62 | @c In less than 2 printed pages describe the history of GNUnet here, | ||
63 | @c what we have now and what's still missing (could be split into | ||
64 | @c subchapters). | ||
65 | |||
66 | GNUnet in its current version is the result of almost 20 years of work | ||
67 | from many contributors. So far, most contributions were made by | ||
68 | volunteers or people paid to do fundamental research. At this stage, | ||
69 | GNUnet remains an experimental system where | ||
70 | significant parts of the software lack a reasonable degree of | ||
71 | professionalism in its implementation. Furthermore, we are aware of a | ||
72 | significant number of existing bugs and critical design flaws, as some | ||
73 | unfortunate early design decisions remain to be rectified. There are | ||
74 | still known open problems; GNUnet remains an active research project. | ||
75 | |||
76 | The project was started in 2001 when some initial ideas for improving | ||
77 | Freenet's file-sharing turned out to be too radical to be easily | ||
78 | realized within the scope of the existing Freenet project. We lost | ||
79 | our first contributor on 11.9.2001 as the contributor realized that | ||
80 | privacy may help terrorists. The rest of the team concluded that it | ||
81 | was now even more important to fight for civil liberties. The first | ||
82 | release was called ``GNet'' -- already with the name GNUnet in mind, | ||
83 | but without the blessing of GNU we did not dare to call it GNUnet | ||
84 | immediately. A few months after the first release we contacted the | ||
85 | GNU project, happily agreed to their governance model and became an | ||
86 | official GNU package. | ||
87 | |||
88 | Within the first year, we created | ||
89 | @uref{https://gnu.org/s/libextractor, GNU libextractor}, a helper library | ||
90 | for meta data extraction which has been used by a few other projects | ||
91 | as well. 2003 saw the emergence of pluggable transports, the ability | ||
92 | for GNUnet to use different mechanisms for communication, starting | ||
93 | with TCP, UDP and SMTP (support for the latter was later dropped due | ||
94 | to a lack of maintenance). In 2005, the project first started to | ||
95 | evolve beyond the original file-sharing application with a first | ||
96 | simple P2P chat. In 2007, we created | ||
97 | @uref{https://gnu.org/s/libmicrohttpd, GNU libmicrohttpd} | ||
98 | to support a pluggable transport based on HTTP. In 2009, the | ||
99 | architecture was radically modularized into the multi-process system | ||
100 | that exists today. Coincidentally, the first version of the ARM | ||
101 | service (ARM: Automatic Restart Manager) | ||
102 | was implemented a day before systemd was announced. From 2009 | ||
103 | to 2014 work progressed rapidly thanks to a significant research grant | ||
104 | from the Deutsche Forschungsgesellschaft. This resulted in particular | ||
105 | in the creation of the R5N DHT, CADET, ATS and the GNU Name System. | ||
106 | In 2010, GNUnet was selected as the basis for the | ||
107 | @uref{https://secushare.org, secushare} online | ||
108 | social network, resulting in a significant growth of the core team. | ||
109 | In 2013, we launched @uref{https://taler.net, GNU Taler} to address | ||
110 | the challenge of convenient | ||
111 | and privacy-preserving online payments. In 2015, the | ||
112 | @c TODO: Maybe even markup for the E if it renders in most outputs. | ||
113 | @uref{https://pep.foundation/, pEp} (pretty Easy privacy) project | ||
114 | announced that they will use GNUnet as the technology for their | ||
115 | meta-data protection layer, ultimately resulting in GNUnet e.V. | ||
116 | entering into a formal long-term collaboration with the pEp | ||
117 | foundation. In 2016, Taler Systems SA, a first startup using GNUnet | ||
118 | technology, was founded with support from the community. | ||
119 | |||
120 | GNUnet is not merely a technical project, but also a political | ||
121 | mission: like the GNU project as a whole, we are writing software to | ||
122 | achieve political goals with a focus on the human right of | ||
123 | informational self-determination. Putting users in control of their | ||
124 | computing has been the core driver of the GNU project. With GNUnet we | ||
125 | are focusing on informational self-determination for collaborative | ||
126 | computing and communication over networks. | ||
127 | |||
128 | The Internet is shaped as much by code and protocols as it is by its | ||
129 | associated political processes (IETF, ICANN, IEEE, etc.). | ||
130 | Similarly its flaws are not limited to the protocol design. Thus, | ||
131 | technical excellence by itself will not suffice to create a better | ||
132 | network. We also need to build a community that is wise, humble and | ||
133 | has a sense of humor to achieve our goal to create a technical | ||
134 | foundation for a society we would like to live in. | ||
135 | |||
136 | |||
137 | @node Project governance | ||
138 | @section Project governance | ||
139 | |||
140 | GNUnet, like the GNU project and many other free software projects, | ||
141 | follows the governance model of a benevolent dictator. This means | ||
142 | that ultimately, the GNU project appoints the GNU maintainer and can | ||
143 | overrule decisions made by the GNUnet maintainer. Similarly, the | ||
144 | GNUnet maintainer can overrule any decisions made by individual | ||
145 | @c TODO: Should we mention if this is just about GNUnet? Other projects | ||
146 | @c TODO: in GNU seem to have rare issues (GCC, the 2018 documentation | ||
147 | @c TODO: discussion. | ||
148 | developers. Still, in practice neither has happened in the last 20 | ||
149 | years, and we hope to keep it that way. | ||
150 | |||
151 | @c TODO: Actually we are a Swiss association, or just a German association | ||
152 | @c TODO: with Swiss bylaws/Satzung? | ||
153 | @c TODO: Rewrite one of the 'GNUnet eV may also' sentences. | ||
154 | The GNUnet project is supported by GNUnet e.V., a German association | ||
155 | where any developer can become a member. GNUnet e.V. serves as a | ||
156 | legal entity to hold the copyrights to GNUnet. GNUnet e.V. may also | ||
157 | choose to pay for project resources, and can collect donations. | ||
158 | GNUnet e.V. may also choose to adjust the license of the | ||
159 | software (with the constraint that it has to remain free software). | ||
160 | In 2018 we switched from GPL3 to AGPL3, in practice these changes do | ||
161 | not happen very often. | ||
162 | |||
163 | |||
164 | @node Typography | ||
165 | @section Typography | ||
166 | |||
167 | When giving examples for commands, shell prompts are used to show if the | ||
168 | command should/can be issued as root, or if "normal" user privileges are | ||
169 | sufficient. We use a @code{#} for root's shell prompt, a | ||
170 | @code{%} for users' shell prompt, assuming they use the C-shell or tcsh | ||
171 | and a @code{$} for bourne shell and derivatives. | ||
172 | @c TODO: Really? Why the different prompts? Do we already have c-shell | ||
173 | @c TODO: examples? | ||
diff --git a/doc/documentation/chapters/user.texi b/doc/documentation/chapters/user.texi deleted file mode 100644 index 5aa3a62bf..000000000 --- a/doc/documentation/chapters/user.texi +++ /dev/null | |||
@@ -1,2293 +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 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 uncomplicated, concrete practical things that can be done | ||
10 | with the framework provided by GNUnet. | ||
11 | |||
12 | In short, this chapter of the ``GNUnet Reference Documentation'' will | ||
13 | show you how to use the various peer-to-peer applications of the | ||
14 | GNUnet system. | ||
15 | As GNUnet evolves, we will add new sections for the various | ||
16 | applications that are being created. | ||
17 | |||
18 | Comments on the content of this chapter, and extensions of it are | ||
19 | always welcome. | ||
20 | |||
21 | |||
22 | @menu | ||
23 | * Start and stop GNUnet:: | ||
24 | * First steps - Using the GNU Name System:: | ||
25 | * First steps - Using GNUnet Conversation:: | ||
26 | * First steps - Using the GNUnet VPN:: | ||
27 | * File-sharing:: | ||
28 | * The GNU Name System:: | ||
29 | * re@:claim Identity Provider:: | ||
30 | * Using the Virtual Public Network:: | ||
31 | @end menu | ||
32 | |||
33 | @node Start and stop GNUnet | ||
34 | @section Start and stop GNUnet | ||
35 | |||
36 | Previous to use any GNUnet-based application, one has to start a node: | ||
37 | |||
38 | @example | ||
39 | $ gnunet-arm -s -l gnunet.log | ||
40 | @end example | ||
41 | |||
42 | To stop GNUnet: | ||
43 | |||
44 | @example | ||
45 | $ gnunet-arm -e | ||
46 | @end example | ||
47 | |||
48 | @node First steps - Using the GNU Name System | ||
49 | @section First steps - Using the GNU Name System | ||
50 | @c %**end of header | ||
51 | |||
52 | @menu | ||
53 | * Preliminaries:: | ||
54 | * Managing Egos:: | ||
55 | * The GNS Tab:: | ||
56 | * Creating a Record:: | ||
57 | * Resolving GNS records:: | ||
58 | * Integration with Browsers:: | ||
59 | * Creating a Business Card:: | ||
60 | * Be Social:: | ||
61 | * Backup of Identities and Egos:: | ||
62 | * Revocation:: | ||
63 | * What's Next?:: | ||
64 | @end menu | ||
65 | |||
66 | @node Preliminaries | ||
67 | @subsection Preliminaries | ||
68 | @c %**end of header | ||
69 | |||
70 | ``.pin'' is a default zone which points to a zone managed by gnunet.org. | ||
71 | Use @code{gnunet-config -s gns} to view the GNS configuration, including | ||
72 | all configured zones that are operated by other users. The respective | ||
73 | configuration entry names start with a ``.'', i.e. ``.pin''. | ||
74 | |||
75 | You can configure any number of top-level domains, and point them to | ||
76 | the respective zones of your friends! For this, simply obtain the | ||
77 | respective public key (you will learn how below) and extend the | ||
78 | configuration: | ||
79 | |||
80 | @example | ||
81 | $ gnunet-config -s gns -n .myfriend -V PUBLIC_KEY | ||
82 | @end example | ||
83 | |||
84 | @node Managing Egos | ||
85 | @subsection Managing Egos | ||
86 | |||
87 | In GNUnet, identity management is about managing egos. Egos can | ||
88 | correspond to pseudonyms or real-world identities. If you value your | ||
89 | privacy, you are encouraged to use separate egos for separate | ||
90 | activities. | ||
91 | |||
92 | Technically, an ego is first of all a public-private key pair, and | ||
93 | thus egos also always correspond to a GNS zone. Egos are managed by | ||
94 | the IDENTITY service. Note that this service has nothing to do with | ||
95 | the peer identity. The IDENTITY service essentially stores the | ||
96 | private keys under human-readable names, and keeps a mapping of which | ||
97 | private key should be used for particular important system functions. | ||
98 | The existing identities can be listed using the command | ||
99 | @command{gnunet-identity -d} | ||
100 | |||
101 | @example | ||
102 | gnu - JTDVJC69NHU6GQS4B5721MV8VM7J6G2DVRGJV0ONIT6QH7OI6D50 | ||
103 | rules - GO0T87F9BPMF8NKD5A54L2AH1T0GRML539TPFSRMCEA98182QD30 | ||
104 | @end example | ||
105 | |||
106 | |||
107 | @node The GNS Tab | ||
108 | @subsection The GNS Tab | ||
109 | @c %**end of header | ||
110 | |||
111 | Maintaing your zones is through the NAMESTORE service and is discussed | ||
112 | here. You can manage your zone using @command{gnunet-identity} and | ||
113 | @command{gnunet-namestore}, or most conveniently using | ||
114 | @command{gnunet-namestore-gtk}. | ||
115 | |||
116 | We will use the GTK+ interface in this introduction. Please start | ||
117 | @command{gnunet-gkt} and switch to the GNS tab, which is the tab in | ||
118 | the middle with the letters "GNS" connected by a graph. | ||
119 | |||
120 | Next to the ``Add'' button there is a field where you can enter the | ||
121 | label (pseudonym in IDENTITY subsystem speak) of a zone you would like | ||
122 | to create. Pushing the ``Add'' button will create the zone. | ||
123 | Afterwards, you can change the label in the combo box below at any | ||
124 | time. The label will be the top-level domain that the GNU Name System | ||
125 | will resolve using your zone. For the label, you should pick | ||
126 | a name by which you would like to | ||
127 | be known by your friends (or colleagues). You should pick a label that | ||
128 | is reasonably unique within your social group. Be aware that | ||
129 | the label will be published together with every record in that zone. | ||
130 | |||
131 | Once you have created a first zone, you should see a QR code for the | ||
132 | zone on the right. Next to it is a "Copy" button to copy the public | ||
133 | key string to the clipboard. You can also save the QR code image to | ||
134 | disk. | ||
135 | |||
136 | Furthermore, you now can see the bottom part of the dialog. The | ||
137 | bottom of the window contains the existing entries in the selected zone. | ||
138 | |||
139 | @node Creating a Record | ||
140 | @subsection Creating a Record | ||
141 | @c %**end of header | ||
142 | |||
143 | We will begin by creating a simple record in your master zone. | ||
144 | To do this, click on the text "<new name>" in the table. The field is | ||
145 | editable, allowing you to enter a fresh label. Labels are restricted | ||
146 | to 63 characters and must not contain dots. For now, simply enter | ||
147 | "test", then press ENTER to confirm. This will create a new (empty) | ||
148 | record group under the label "test". Now click on "<new record>" next | ||
149 | to the new label "test". In the drop-down menu, select "A" and push | ||
150 | ENTER to confirm. Afterwards, a new dialog will pop up, asking to enter | ||
151 | details for the "A" record. | ||
152 | |||
153 | "A" records are used in the @dfn{Domain Name System} (DNS) to specify | ||
154 | IPv4 addresses. An IPv4 address is a number that is used to identify | ||
155 | and address a computer on the Internet (version 4). Please enter | ||
156 | "217.92.15.146" in the dialog below "Destination IPv4 Address" and | ||
157 | select "Record is public". Do not change any of the other options. | ||
158 | Note that as you enter a (well-formed) IPv4 address, the "Save" | ||
159 | button in the bottom right corner becomes sensitive. In general, buttons | ||
160 | in dialogs are often insensitive as long as the contents of the dialog | ||
161 | are incorrect. | ||
162 | |||
163 | Once finished, press the "Save" button. Back in the main dialog, select | ||
164 | the tiny triangle left of the "test" label. By doing so, you get to see | ||
165 | all of the records under "test". Note that you can right-click a record | ||
166 | to edit it later. | ||
167 | |||
168 | |||
169 | @node Resolving GNS records | ||
170 | @subsection Resolving GNS records | ||
171 | @c %**end of header | ||
172 | |||
173 | Next, you should try resolving your own GNS records. The method we | ||
174 | found to be the most uncomplicated is to do this by explicitly | ||
175 | resolving using @code{gnunet-gns}. For this exercise, we will assume | ||
176 | that you used the string ``gnu'' for the pseudonym (or label) of your | ||
177 | GNS zone. If you used something else, replace ``.gnu'' with your real | ||
178 | pseudonym in the examples below. | ||
179 | |||
180 | In the shell, type: | ||
181 | |||
182 | @example | ||
183 | $ gnunet-gns -u test.gnu # what follows is the reply | ||
184 | test.gnu: | ||
185 | Got `A' record: 217.92.15.146 | ||
186 | @end example | ||
187 | |||
188 | @noindent | ||
189 | That shows that resolution works, once GNS is integrated with | ||
190 | the application. | ||
191 | |||
192 | @node Integration with Browsers | ||
193 | @subsection Integration with Browsers | ||
194 | @c %**end of header | ||
195 | |||
196 | While we recommend integrating GNS using the NSS module in the | ||
197 | GNU libc Name Service Switch, you can also integrate GNS | ||
198 | directly with your browser via the @code{gnunet-gns-proxy}. | ||
199 | This method can have the advantage that the proxy can validate | ||
200 | TLS/X.509 records and thus strengthen web security; however, the proxy | ||
201 | is still a bit brittle, so expect subtle failures. We have had reasonable | ||
202 | success with Chromium, and various frustrations with Firefox in this area | ||
203 | recently. | ||
204 | |||
205 | The first step is to start the proxy. As the proxy is (usually) | ||
206 | not started by default, this is done as a unprivileged user | ||
207 | using @command{gnunet-arm -i gns-proxy}. Use @command{gnunet-arm -I} | ||
208 | as a unprivileged user to check that the proxy was actually | ||
209 | started. (The most common error for why the proxy may fail to start | ||
210 | is that you did not run @command{gnunet-gns-proxy-setup-ca} during | ||
211 | installation.) The proxy is a SOCKS5 proxy running (by default) | ||
212 | on port 7777. Thus, you need to now configure your browser to use | ||
213 | this proxy. With Chromium, you can do this by starting the browser | ||
214 | as a unprivileged user using | ||
215 | @command{chromium --proxy-server="socks5://localhost:7777"} | ||
216 | For @command{Firefox} (or @command{Icecat}), select "Edit-Preferences" | ||
217 | in the menu, and then select the "Advanced" tab in the dialog | ||
218 | and then "Network": | ||
219 | |||
220 | Here, select "Settings..." to open the proxy settings dialog. | ||
221 | Select "Manual proxy configuration" and enter @code{localhost} | ||
222 | with port 7777 under SOCKS Host. Furthermore, set the | ||
223 | checkbox ``Proxy DNS when using SOCKS v5'' at the bottom of | ||
224 | the dialog. Finally, push "OK". | ||
225 | |||
226 | You must also go to about:config and change the | ||
227 | @code{browser.fixup.alternate.enabled} option to @code{false}, | ||
228 | otherwise the browser will autoblunder an address like | ||
229 | @code{@uref{http://www.gnu/, www.gnu}} to | ||
230 | @code{@uref{http://www.gnu.com/, www.gnu.com}}. If you want | ||
231 | to resolve @@ in your own TLDs, you must additionally | ||
232 | set @code{browser.fixup.dns_first_use_for_single_words} to @code{true}. | ||
233 | |||
234 | After configuring your browser, you might want to first confirm that it | ||
235 | continues to work as before. (The proxy is still experimental and if you | ||
236 | experience "odd" failures with some webpages, you might want to disable | ||
237 | it again temporarily.) Next, test if things work by typing | ||
238 | "@uref{http://test.gnu/}" into the URL bar of your browser. | ||
239 | This currently fails with (my version of) Firefox as Firefox is | ||
240 | super-smart and tries to resolve "@uref{http://www.test.gnu/}" instead of | ||
241 | "@uref{test.gnu}". Chromium can be convinced to comply if you explicitly | ||
242 | include the "http://" prefix --- otherwise a Google search might be | ||
243 | attempted, which is not what you want. If successful, you should | ||
244 | see a simple website. | ||
245 | |||
246 | Note that while you can use GNS to access ordinary websites, this is | ||
247 | more an experimental feature and not really our primary goal at this | ||
248 | time. Still, it is a possible use-case and we welcome help with testing | ||
249 | and development. | ||
250 | |||
251 | @pindex gnunet-bcd | ||
252 | @node Creating a Business Card | ||
253 | @subsection Creating a Business Card | ||
254 | @c FIXME: Which parts of texlive are needed? Some systems offer a modular | ||
255 | @c texlive (smaller size). | ||
256 | |||
257 | Before we can really use GNS, you should create a business card. | ||
258 | Note that this requires having @command{LaTeX} installed on your system. | ||
259 | If you are using a Debian GNU/Linux based operating system, the | ||
260 | following command should install the required components. | ||
261 | Keep in mind that this @b{requires 3GB} of downloaded data and possibly | ||
262 | @b{even more} when unpacked. On a GNU Guix based system texlive 2017 has | ||
263 | returns a DAG size of 5032.4 MiB. | ||
264 | @b{We welcome any help in identifying the required components of the | ||
265 | TexLive Distribution. This way we could just state the required components | ||
266 | without pulling in the full distribution of TexLive.} | ||
267 | |||
268 | @example | ||
269 | apt-get install texlive-full | ||
270 | @end example | ||
271 | |||
272 | @noindent | ||
273 | Start creating a business card by clicking the "Copy" button | ||
274 | in @command{gnunet-gtk}'s GNS tab. Next, you should start | ||
275 | the @command{gnunet-bcd} program (in the terminal, on the command-line). | ||
276 | You do not need to pass any options, and please be not surprised if | ||
277 | there is no output: | ||
278 | |||
279 | @example | ||
280 | $ gnunet-bcd # seems to hang... | ||
281 | @end example | ||
282 | |||
283 | @noindent | ||
284 | Then, start a browser and point it to @uref{http://localhost:8888/} | ||
285 | where @code{gnunet-bcd} is running a Web server! | ||
286 | |||
287 | First, you might want to fill in the "GNS Public Key" field by | ||
288 | right-clicking and selecting "Paste", filling in the public key | ||
289 | from the copy you made in @command{gnunet-gtk}. | ||
290 | Then, fill in all of the other fields, including your @b{GNS NICKname}. | ||
291 | Adding a GPG fingerprint is optional. | ||
292 | Once finished, click "Submit Query". | ||
293 | If your @code{LaTeX} installation is incomplete, the result will be | ||
294 | disappointing. | ||
295 | Otherwise, you should get a PDF containing fancy 5x2 double-sided | ||
296 | translated business cards with a QR code containing your public key | ||
297 | and a GNUnet logo. | ||
298 | We'll explain how to use those a bit later. | ||
299 | You can now go back to the shell running @code{gnunet-bcd} and press | ||
300 | @b{CTRL-C} to shut down the Web server. | ||
301 | |||
302 | |||
303 | @node Be Social | ||
304 | @subsection Be Social | ||
305 | @c %**end of header | ||
306 | |||
307 | Next, you should print out your business card and be social. | ||
308 | Find a friend, help them install GNUnet and exchange business cards with | ||
309 | them. Or, if you're a desperate loner, you might try the next step with | ||
310 | your own card. Still, it'll be hard to have a conversation with | ||
311 | yourself later, so it would be better if you could find a friend. | ||
312 | You might also want a camera attached to your computer, so | ||
313 | you might need a trip to the store together. | ||
314 | |||
315 | Before we get started, we need to tell @code{gnunet-qr} which zone | ||
316 | it should import new records into. For this, run: | ||
317 | |||
318 | @pindex gnunet-identity | ||
319 | @example | ||
320 | $ gnunet-identity -s namestore -e NAME | ||
321 | @end example | ||
322 | where NAME is the name of the zone you want to import records | ||
323 | into. In our running example, this would be ``gnu''. | ||
324 | |||
325 | @pindex gnunet-qr | ||
326 | Henceforth, for every business card you collect, simply run: | ||
327 | @example | ||
328 | $ gnunet-qr | ||
329 | @end example | ||
330 | |||
331 | @noindent | ||
332 | to open a window showing whatever your camera points at. | ||
333 | Hold up your friend's business card and tilt it until | ||
334 | the QR code is recognized. At that point, the window should | ||
335 | automatically close. At that point, your friend's NICKname and their | ||
336 | public key should have been automatically imported into your zone. | ||
337 | |||
338 | Assuming both of your peers are properly integrated in the | ||
339 | GNUnet network at this time, you should thus be able to | ||
340 | resolve your friends names. Suppose your friend's nickname | ||
341 | is "Bob". Then, type | ||
342 | |||
343 | @pindex gnunet-gns | ||
344 | @example | ||
345 | $ gnunet-gns -u test.bob.gnu | ||
346 | @end example | ||
347 | |||
348 | @noindent | ||
349 | to check if your friend was as good at following instructions | ||
350 | as you were. | ||
351 | |||
352 | |||
353 | @node Backup of Identities and Egos | ||
354 | @subsection Backup of Identities and Egos | ||
355 | |||
356 | |||
357 | One should always backup their files, especially in these SSD days (our | ||
358 | team has suffered 3 SSD crashes over a span of 2 weeks). Backing up peer | ||
359 | identity and zones is achieved by copying the following files: | ||
360 | |||
361 | The peer identity file can be found | ||
362 | in @file{~/.local/share/gnunet/private_key.ecc} | ||
363 | |||
364 | The private keys of your egos are stored in the | ||
365 | directory @file{~/.local/share/gnunet/identity/egos/}. | ||
366 | They are stored in files whose filenames correspond to the zones' | ||
367 | ego names. These are probably the most important files you want | ||
368 | to backup from a GNUnet installation. | ||
369 | |||
370 | Note: All these files contain cryptographic keys and they are | ||
371 | stored without any encryption. So it is advisable to backup | ||
372 | encrypted copies of them. | ||
373 | |||
374 | |||
375 | @node Revocation | ||
376 | @subsection Revocation | ||
377 | |||
378 | Now, in the situation of an attacker gaining access to the private key of | ||
379 | one of your egos, the attacker can create records in the respective | ||
380 | GNS zone | ||
381 | and publish them as if you published them. Anyone resolving your | ||
382 | domain will get these new records and when they verify they seem | ||
383 | authentic because the attacker has signed them with your key. | ||
384 | |||
385 | To address this potential security issue, you can pre-compute | ||
386 | a revocation certificate corresponding to your ego. This certificate, | ||
387 | when published on the P2P network, flags your private key as invalid, | ||
388 | and all further resolutions or other checks involving the key will fail. | ||
389 | |||
390 | @pindex gnunet-revocation | ||
391 | A revocation certificate is thus a useful tool when things go out of | ||
392 | control, but at the same time it should be stored securely. | ||
393 | Generation of the revocation certificate for a zone can be done through | ||
394 | @command{gnunet-revocation}. For example, the following command (as | ||
395 | unprivileged user) generates a revocation file | ||
396 | @file{revocation.dat} for the zone @code{zone1}: | ||
397 | @command{gnunet-revocation -f revocation.dat -R zone1} | ||
398 | |||
399 | The above command only pre-computes a revocation certificate. It does | ||
400 | not revoke the given zone. Pre-computing a revocation certificate | ||
401 | involves computing a proof-of-work and hence may take up to 4 to 5 days | ||
402 | on a modern processor. Note that you can abort and resume the | ||
403 | calculation at any time. Also, even if you did not finish the | ||
404 | calculation, the resulting file will contain the signature, which is | ||
405 | sufficient to complete the revocation process even without access to | ||
406 | the private key. So instead of waiting for a few days, you can just | ||
407 | abort with CTRL-C, backup the revocation certificate and run the | ||
408 | calculation only if your key actually was compromised. This has the | ||
409 | disadvantage of revocation taking longer after the incident, but | ||
410 | the advantage of saving a significant amount of energy. So unless | ||
411 | you believe that a key compromise will need a rapid response, we | ||
412 | urge you to wait with generating the revocation certificate. | ||
413 | Also, the calculation is deliberately expensive, to deter people from | ||
414 | doing this just for fun (as the actual revocation operation is expensive | ||
415 | for the network, not for the peer performing the revocation). | ||
416 | |||
417 | |||
418 | @c FIXME: The Manual should give away the command using an example that is | ||
419 | @c very likely to never exist. | ||
420 | To avoid TL;DR ones from accidentally revocating their zones, we are not | ||
421 | giving away the command, but it is uncomplicated: the actual revocation is | ||
422 | performed by using the @command{-p} option of @command{gnunet-revocation}. | ||
423 | |||
424 | |||
425 | @node What's Next? | ||
426 | @subsection What's Next? | ||
427 | @c %**end of header | ||
428 | |||
429 | This may seem not like much of an application yet, but you have | ||
430 | just been one of the first to perform a decentralized secure name | ||
431 | lookup (where nobody could have altered the value supplied by your | ||
432 | friend) in a privacy-preserving manner (your query on the network | ||
433 | and the corresponding response were always encrypted). So what | ||
434 | can you really do with this? Well, to start with, you can publish your | ||
435 | GnuPG fingerprint in GNS as a "CERT" record and replace the public | ||
436 | web-of-trust with its complicated trust model with explicit names | ||
437 | and privacy-preserving resolution. Also, you should read the next | ||
438 | chapter of the tutorial and learn how to use GNS to have a | ||
439 | private conversation with your friend. Finally, help us | ||
440 | with the next GNUnet release for even more applications | ||
441 | using this new public key infrastructure. | ||
442 | |||
443 | @pindex gnunet-conservation-gtk | ||
444 | @node First steps - Using GNUnet Conversation | ||
445 | @section First steps - Using GNUnet Conversation | ||
446 | @c %**end of header | ||
447 | |||
448 | First, you should launch the graphical user interface. You can do | ||
449 | this from the command-line by typing | ||
450 | |||
451 | @example | ||
452 | $ gnunet-conversation-gtk | ||
453 | @end example | ||
454 | |||
455 | @menu | ||
456 | * Testing your Audio Equipment:: | ||
457 | * GNS Zones:: | ||
458 | @end menu | ||
459 | |||
460 | @node Testing your Audio Equipment | ||
461 | @subsection Testing your Audio Equipment | ||
462 | @c %**end of header | ||
463 | |||
464 | First, you should use @code{gnunet-conversation-test} to check that your | ||
465 | microphone and speaker are working correctly. You will be prompted to | ||
466 | speak for 5 seconds, and then those 5 seconds will be replayed to you. | ||
467 | The network is not involved in this test. If it fails, you should run | ||
468 | your pulse audio configuration tool to check that microphone and | ||
469 | speaker are not muted and, if you have multiple input/output devices, | ||
470 | that the correct device is being associated with GNUnet's audio tools. | ||
471 | |||
472 | @node GNS Zones | ||
473 | @subsection GNS Zones | ||
474 | @c %**end of header | ||
475 | |||
476 | @code{gnunet-conversation} uses GNS for addressing. This means that | ||
477 | you need to have a GNS zone created before using it. Information | ||
478 | about how to create GNS zones can be found here. | ||
479 | |||
480 | |||
481 | @menu | ||
482 | * Picking an Identity:: | ||
483 | * Calling somebody:: | ||
484 | @end menu | ||
485 | |||
486 | @node Picking an Identity | ||
487 | @subsubsection Picking an Identity | ||
488 | @c %**end of header | ||
489 | |||
490 | To make a call with @code{gnunet-conversation}, you first | ||
491 | need to choose an identity. This identity is both the caller ID | ||
492 | that will show up when you call somebody else, as well as the | ||
493 | GNS zone that will be used to resolve names of users that you | ||
494 | are calling. Run | ||
495 | |||
496 | @pindex gnunet-conversation | ||
497 | @example | ||
498 | gnunet-conversation -e zone-name | ||
499 | @end example | ||
500 | |||
501 | @noindent | ||
502 | to start the command-line tool. You will see a message saying | ||
503 | that your phone is now "active on line 0". You can connect | ||
504 | multiple phones on different lines at the same peer. For the | ||
505 | first phone, the line zero is of course a fine choice. | ||
506 | |||
507 | Next, you should type in @command{/help} for a list of | ||
508 | available commands. We will explain the important ones | ||
509 | during this tutorial. First, you will need to type in | ||
510 | @command{/address} to determine the address of your | ||
511 | phone. The result should look something like this: | ||
512 | |||
513 | @example | ||
514 | /address | ||
515 | 0-PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
516 | @end example | ||
517 | |||
518 | @noindent | ||
519 | Here, the "0" is your phone line, and what follows | ||
520 | after the hyphen is your peer's identity. This information will | ||
521 | need to be placed in a PHONE record of | ||
522 | your GNS master-zone so that other users can call you. | ||
523 | |||
524 | Start @code{gnunet-namestore-gtk} now (possibly from another | ||
525 | shell) and create an entry home-phone in your master zone. | ||
526 | For the record type, select PHONE. You should then see the | ||
527 | PHONE dialog: | ||
528 | |||
529 | @c image here | ||
530 | |||
531 | Note: Do not choose the expiry time to be 'Never'. If you | ||
532 | do that, you assert that this record will never change and | ||
533 | can be cached indefinitely by the DHT and the peers which | ||
534 | resolve this record. A reasonable period is 1 year. | ||
535 | |||
536 | Enter your peer identity under Peer and leave the line | ||
537 | at zero. Select the first option to make the record public. | ||
538 | If you entered your peer identity incorrectly, | ||
539 | the "Save" button will not work; you might want to use | ||
540 | copy-and-paste instead of typing in the peer identity | ||
541 | manually. Save the record. | ||
542 | |||
543 | @node Calling somebody | ||
544 | @subsubsection Calling somebody | ||
545 | @c %**end of header | ||
546 | |||
547 | Now you can call a buddy. Obviously, your buddy will have to have GNUnet | ||
548 | installed and must have performed the same steps. Also, you must have | ||
549 | your buddy in your GNS master zone, for example by having imported | ||
550 | your buddy's public key using @code{gnunet-qr}. Suppose your buddy | ||
551 | is in your zone as @code{buddy.mytld} and they also created their | ||
552 | phone using a label "home-phone". Then you can initiate a call using: | ||
553 | |||
554 | @example | ||
555 | /call home-phone.buddy.mytld | ||
556 | @end example | ||
557 | |||
558 | It may take some time for GNUnet to resolve the name and to establish | ||
559 | a link. If your buddy has your public key in their master zone, they | ||
560 | should see an incoming call with your name. If your public key is not | ||
561 | in their master zone, they will just see the public key as the caller ID. | ||
562 | |||
563 | Your buddy then can answer the call using the "/accept" command. After | ||
564 | that, (encrypted) voice data should be relayed between your two peers. | ||
565 | Either of you can end the call using @command{/cancel}. You can exit | ||
566 | @code{gnunet-conversation} using @command{/quit}. | ||
567 | |||
568 | |||
569 | @node First steps - Using the GNUnet VPN | ||
570 | @section First steps - Using the GNUnet VPN | ||
571 | @c %**end of header | ||
572 | |||
573 | |||
574 | @menu | ||
575 | * VPN Preliminaries:: | ||
576 | * GNUnet-Exit configuration:: | ||
577 | * GNS configuration:: | ||
578 | * Accessing the service:: | ||
579 | * Using a Browser:: | ||
580 | @end menu | ||
581 | |||
582 | @node VPN Preliminaries | ||
583 | @subsection VPN Preliminaries | ||
584 | @c %**end of header | ||
585 | |||
586 | To test the GNUnet VPN, we should first run a web server. | ||
587 | The easiest way to do this is to just start @code{gnunet-bcd}, | ||
588 | which will run a webserver on port @code{8888} by default. | ||
589 | Naturally, you can run some other HTTP server for our little tutorial. | ||
590 | |||
591 | If you have not done this, you should also configure your | ||
592 | Name System Service switch to use GNS. In your @code{/etc/nsswitch.conf} | ||
593 | you should fine a line like this: | ||
594 | |||
595 | @example | ||
596 | hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
597 | @end example | ||
598 | |||
599 | @noindent | ||
600 | The exact details may differ a bit, which is fine. Add the text | ||
601 | @code{gns [NOTFOUND=return]} after @code{files}: | ||
602 | |||
603 | @example | ||
604 | hosts: files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4 | ||
605 | @end example | ||
606 | |||
607 | @c TODO: outdated section, we no longer install this as part of the | ||
608 | @c TODO: standard installation procedure and should point out the manual | ||
609 | @c TODO: steps required to make it useful. | ||
610 | @noindent | ||
611 | You might want to make sure that @code{/lib/libnss_gns.so.2} exists on | ||
612 | your system, it should have been created during the installation. | ||
613 | If not, re-run | ||
614 | |||
615 | @example | ||
616 | $ configure --with-nssdir=/lib | ||
617 | $ cd src/gns/nss; sudo make install | ||
618 | @end example | ||
619 | |||
620 | @noindent | ||
621 | to install the NSS plugins in the proper location. | ||
622 | |||
623 | @node GNUnet-Exit configuration | ||
624 | @subsection GNUnet-Exit configuration | ||
625 | @c %**end of header | ||
626 | |||
627 | Stop your peer (as user @code{gnunet}, run @command{gnunet-arm -e}) and | ||
628 | run @command{gnunet-setup}. In @command{gnunet-setup}, make sure to | ||
629 | activate the @strong{EXIT} and @strong{GNS} services in the General tab. | ||
630 | Then select the Exit tab. Most of the defaults should be fine (but | ||
631 | you should check against the screenshot that they have not been modified). | ||
632 | In the bottom area, enter @code{bcd} under Identifier and change the | ||
633 | Destination to @code{169.254.86.1:8888} (if your server runs on a port | ||
634 | other than 8888, change the 8888 port accordingly). | ||
635 | |||
636 | Now exit @command{gnunet-setup} and restart your peer | ||
637 | (@command{gnunet-arm -s}). | ||
638 | |||
639 | @node GNS configuration | ||
640 | @subsection GNS configuration | ||
641 | @c %**end of header | ||
642 | |||
643 | Now, using your normal user (not the @code{gnunet} system user), run | ||
644 | @command{gnunet-gtk}. Select the GNS icon and add a new label www in your | ||
645 | master zone. For the record type, select @code{VPN}. You should then | ||
646 | see the VPN dialog: | ||
647 | |||
648 | @c insert image | ||
649 | |||
650 | Under peer, you need to supply the peer identity of your own peer. You can | ||
651 | obtain the respective string by running @command{gnunet-peerinfo -sq} | ||
652 | as the @code{gnunet} user. For the Identifier, you need to supply the same | ||
653 | identifier that we used in the Exit setup earlier, so here supply "bcd". | ||
654 | If you want others to be able to use the service, you should probably make | ||
655 | the record public. For non-public services, you should use a passphrase | ||
656 | instead of the string "bcd". Save the record and | ||
657 | exit @command{gnunet-gtk}. | ||
658 | |||
659 | @node Accessing the service | ||
660 | @subsection Accessing the service | ||
661 | @c %**end of header | ||
662 | |||
663 | You should now be able to access your webserver. Type in: | ||
664 | |||
665 | @example | ||
666 | $ wget http://www.gnu/ | ||
667 | @end example | ||
668 | |||
669 | @noindent | ||
670 | The request will resolve to the VPN record, telling the GNS resolver | ||
671 | to route it via the GNUnet VPN. The GNS resolver will ask the | ||
672 | GNUnet VPN for an IPv4 address to return to the application. The | ||
673 | VPN service will use the VPN information supplied by GNS to create | ||
674 | a tunnel (via GNUnet's MESH service) to the EXIT peer. | ||
675 | At the EXIT, the name "bcd" and destination port (80) will be mapped | ||
676 | to the specified destination IP and port. While all this is currently | ||
677 | happening on just the local machine, it should also work with other | ||
678 | peers --- naturally, they will need a way to access your GNS zone | ||
679 | first, for example by learning your public key from a QR code on | ||
680 | your business card. | ||
681 | |||
682 | @node Using a Browser | ||
683 | @subsection Using a Browser | ||
684 | @c %**end of header | ||
685 | |||
686 | Sadly, modern browsers tend to bypass the Name Services Switch and | ||
687 | attempt DNS resolution directly. You can either run | ||
688 | a @code{gnunet-dns2gns} DNS proxy, or point the browsers to an | ||
689 | HTTP proxy. When we tried it, Iceweasel did not like to connect to | ||
690 | the socks proxy for @code{.gnu} TLDs, even if we disabled its | ||
691 | autoblunder of changing @code{.gnu} to ".gnu.com". Still, | ||
692 | using the HTTP proxy with Chrome does work. | ||
693 | |||
694 | @node File-sharing | ||
695 | @section File-sharing | ||
696 | @c %**end of header | ||
697 | |||
698 | This chapter documents the GNUnet file-sharing application. The original | ||
699 | file-sharing implementation for GNUnet was designed to provide | ||
700 | @strong{anonymous} file-sharing. However, over time, we have also added | ||
701 | support for non-anonymous file-sharing (which can provide better | ||
702 | performance). Anonymous and non-anonymous file-sharing are quite | ||
703 | integrated in GNUnet and, except for routing, share most of the concepts | ||
704 | and implementation. There are three primary file-sharing operations: | ||
705 | publishing, searching and downloading. For each of these operations, | ||
706 | the user specifies an @strong{anonymity level}. If both the publisher and | ||
707 | the searcher/downloader specify "no anonymity", non-anonymous | ||
708 | file-sharing is used. If either user specifies some desired degree | ||
709 | of anonymity, anonymous file-sharing will be used. | ||
710 | |||
711 | After a short introduction, we will first look at the various concepts | ||
712 | in GNUnet's file-sharing implementation. Then, we will discuss | ||
713 | specifics as to how they impact users that publish, search or download | ||
714 | files. | ||
715 | |||
716 | |||
717 | @menu | ||
718 | * fs-Searching:: | ||
719 | * fs-Downloading:: | ||
720 | * fs-Publishing:: | ||
721 | * fs-Concepts:: | ||
722 | * Namespace Management:: | ||
723 | * File-Sharing URIs:: | ||
724 | * GTK User Interface:: | ||
725 | @end menu | ||
726 | |||
727 | @node fs-Searching | ||
728 | @subsection Searching | ||
729 | @c %**end of header | ||
730 | |||
731 | The command @command{gnunet-search} can be used to search | ||
732 | for content on GNUnet. The format is: | ||
733 | |||
734 | @example | ||
735 | $ gnunet-search [-t TIMEOUT] KEYWORD | ||
736 | @end example | ||
737 | |||
738 | @noindent | ||
739 | The @command{-t} option specifies that the query should timeout after | ||
740 | approximately TIMEOUT seconds. A value of zero (``0'') is interpreted | ||
741 | as @emph{no timeout}, which is the default. In this case, | ||
742 | @command{gnunet-search} will never terminate (unless you press | ||
743 | @command{CTRL-C}). | ||
744 | |||
745 | If multiple words are passed as keywords, they will all be | ||
746 | considered optional. Prefix keywords with a "+" to make them mandatory. | ||
747 | |||
748 | Note that searching using | ||
749 | |||
750 | @example | ||
751 | $ gnunet-search Das Kapital | ||
752 | @end example | ||
753 | |||
754 | @noindent | ||
755 | is not the same as searching for | ||
756 | |||
757 | @example | ||
758 | $ gnunet-search "Das Kapital" | ||
759 | @end example | ||
760 | |||
761 | @noindent | ||
762 | as the first will match files shared under the keywords | ||
763 | "Das" or "Kapital" whereas the second will match files | ||
764 | shared under the keyword "Das Kapital". | ||
765 | |||
766 | Search results are printed by @command{gnunet-search} like this: | ||
767 | |||
768 | @c it will be better the avoid the ellipsis altogether because I don't | ||
769 | @c understand the explanation below that | ||
770 | @c ng0: who is ``I'' and what was the complete sentence? | ||
771 | @example | ||
772 | #15: | ||
773 | gnunet-download -o "COPYING" gnunet://fs/chk/PGK8M...3EK130.75446 | ||
774 | |||
775 | @end example | ||
776 | |||
777 | @noindent | ||
778 | The whole line is the command you would have to enter to download | ||
779 | the file. The first argument passed to @code{-o} is the suggested | ||
780 | filename (you may change it to whatever you like). | ||
781 | It is followed by the key for decrypting the file, the query for | ||
782 | searching the file, a checksum (in hexadecimal) finally the size of | ||
783 | the file in bytes. | ||
784 | |||
785 | @node fs-Downloading | ||
786 | @subsection Downloading | ||
787 | @c %**end of header | ||
788 | |||
789 | In order to download a file, you need the whole line returned by | ||
790 | @command{gnunet-search}. | ||
791 | You can then use the tool @command{gnunet-download} to obtain the file: | ||
792 | |||
793 | @example | ||
794 | $ gnunet-download -o <FILENAME> <GNUNET-URL> | ||
795 | @end example | ||
796 | |||
797 | @noindent | ||
798 | FILENAME specifies the name of the file where GNUnet is supposed | ||
799 | to write the result. Existing files are overwritten. If the | ||
800 | existing file contains blocks that are identical to the | ||
801 | desired download, those blocks will not be downloaded again | ||
802 | (automatic resume). | ||
803 | |||
804 | If you want to download the GPL from the previous example, | ||
805 | you do the following: | ||
806 | |||
807 | @example | ||
808 | $ gnunet-download -o "COPYING" gnunet://fs/chk/PGK8M...3EK130.75446 | ||
809 | @end example | ||
810 | |||
811 | @noindent | ||
812 | If you ever have to abort a download, you can continue it at any time by | ||
813 | re-issuing @command{gnunet-download} with the same filename. | ||
814 | In that case, GNUnet will @strong{not} download blocks again that are | ||
815 | already present. | ||
816 | |||
817 | GNUnet's file-encoding mechanism will ensure file integrity, even if the | ||
818 | existing file was not downloaded from GNUnet in the first place. | ||
819 | |||
820 | You may want to use the @command{-V} switch to turn on verbose | ||
821 | reporting. In this case, @command{gnunet-download} will print the | ||
822 | current number of bytes downloaded whenever new data was received. | ||
823 | |||
824 | @node fs-Publishing | ||
825 | @subsection Publishing | ||
826 | @c %**end of header | ||
827 | |||
828 | The command @command{gnunet-publish} can be used to add content | ||
829 | to the network. The basic format of the command is | ||
830 | |||
831 | @example | ||
832 | $ gnunet-publish [-n] [-k KEYWORDS]* [-m TYPE:VALUE] FILENAME | ||
833 | @end example | ||
834 | |||
835 | For example | ||
836 | @example | ||
837 | $ gnunet-publish -m "description:GNU License" -k gpl -k test -m "mimetype:text/plain" COPYING | ||
838 | @end example | ||
839 | |||
840 | @menu | ||
841 | * Important command-line options:: | ||
842 | * Indexing vs. Inserting:: | ||
843 | @end menu | ||
844 | |||
845 | @node Important command-line options | ||
846 | @subsubsection Important command-line options | ||
847 | @c %**end of header | ||
848 | |||
849 | The option @code{-k} is used to specify keywords for the file that | ||
850 | should be inserted. You can supply any number of keywords, | ||
851 | and each of the keywords will be sufficient to locate and | ||
852 | retrieve the file. Please note that you must use the @code{-k} option | ||
853 | more than once -- one for each expression you use as a keyword for | ||
854 | the filename. | ||
855 | |||
856 | The -m option is used to specify meta-data, such as descriptions. | ||
857 | You can use -m multiple times. The TYPE passed must be from the | ||
858 | list of meta-data types known to libextractor. You can obtain this | ||
859 | list by running @command{extract -L}. Use quotes around the entire | ||
860 | meta-data argument if the value contains spaces. The meta-data | ||
861 | is displayed to other users when they select which files to | ||
862 | download. The meta-data and the keywords are optional and | ||
863 | may be inferred using @code{GNU libextractor}. | ||
864 | |||
865 | @command{gnunet-publish} has a few additional options to handle | ||
866 | namespaces and directories. Refer to the man-page for details: | ||
867 | |||
868 | @example | ||
869 | man gnunet-publish | ||
870 | @end example | ||
871 | |||
872 | @node Indexing vs. Inserting | ||
873 | @subsubsection Indexing vs Inserting | ||
874 | @c %**end of header | ||
875 | |||
876 | By default, GNUnet indexes a file instead of making a full copy. | ||
877 | This is much more efficient, but requires the file to stay unaltered | ||
878 | at the location where it was when it was indexed. If you intend to move, | ||
879 | delete or alter a file, consider using the option @code{-n} which will | ||
880 | force GNUnet to make a copy of the file in the database. | ||
881 | |||
882 | Since it is much less efficient, this is strongly discouraged for large | ||
883 | files. When GNUnet indexes a file (default), GNUnet does @strong{not} | ||
884 | create an additional encrypted copy of the file but just computes a | ||
885 | summary (or index) of the file. That summary is approximately two percent | ||
886 | of the size of the original file and is stored in GNUnet's database. | ||
887 | Whenever a request for a part of an indexed file reaches GNUnet, | ||
888 | this part is encrypted on-demand and send out. This way, there is no | ||
889 | need for an additional encrypted copy of the file to stay anywhere | ||
890 | on the drive. This is different from other systems, such as Freenet, | ||
891 | where each file that is put online must be in Freenet's database in | ||
892 | encrypted format, doubling the space requirements if the user wants | ||
893 | to preserve a directly accessible copy in plaintext. | ||
894 | |||
895 | Thus indexing should be used for all files where the user will keep | ||
896 | using this file (at the location given to gnunet-publish) and does | ||
897 | not want to retrieve it back from GNUnet each time. If you want to | ||
898 | remove a file that you have indexed from the local peer, use the tool | ||
899 | @command{gnunet-unindex} to un-index the file. | ||
900 | |||
901 | The option @code{-n} may be used if the user fears that the file might | ||
902 | be found on their drive (assuming the computer comes under the control | ||
903 | of an adversary). When used with the @code{-n} flag, the user has a | ||
904 | much better chance of denying knowledge of the existence of the file, | ||
905 | even if it is still (encrypted) on the drive and the adversary is | ||
906 | able to crack the encryption (e.g. by guessing the keyword. | ||
907 | |||
908 | @node fs-Concepts | ||
909 | @subsection Concepts | ||
910 | @c %**end of header | ||
911 | |||
912 | For better results with filesharing it is useful to understand the | ||
913 | following concepts. | ||
914 | In addition to anonymous routing GNUnet attempts to give users a better | ||
915 | experience in searching for content. GNUnet uses cryptography to safely | ||
916 | break content into smaller pieces that can be obtained from different | ||
917 | sources without allowing participants to corrupt files. GNUnet makes it | ||
918 | difficult for an adversary to send back bogus search results. GNUnet | ||
919 | enables content providers to group related content and to establish a | ||
920 | reputation. Furthermore, GNUnet allows updates to certain content to be | ||
921 | made available. This section is supposed to introduce users to the | ||
922 | concepts that are used to achieve these goals. | ||
923 | |||
924 | |||
925 | @menu | ||
926 | * Files:: | ||
927 | * Keywords:: | ||
928 | * Directories:: | ||
929 | * Pseudonyms:: | ||
930 | * Namespaces:: | ||
931 | * Advertisements:: | ||
932 | * Anonymity level:: | ||
933 | * Content Priority:: | ||
934 | * Replication:: | ||
935 | @end menu | ||
936 | |||
937 | @node Files | ||
938 | @subsubsection Files | ||
939 | @c %**end of header | ||
940 | |||
941 | A file in GNUnet is just a sequence of bytes. Any file-format is allowed | ||
942 | and the maximum file size is theoretically @math{2^64 - 1} bytes, except | ||
943 | that it would take an impractical amount of time to share such a file. | ||
944 | GNUnet itself never interprets the contents of shared files, except when | ||
945 | using GNU libextractor to obtain keywords. | ||
946 | |||
947 | @node Keywords | ||
948 | @subsubsection Keywords | ||
949 | @c %**end of header | ||
950 | |||
951 | Keywords are the most simple mechanism to find files on GNUnet. | ||
952 | Keywords are @strong{case-sensitive} and the search string | ||
953 | must always match @strong{exactly} the keyword used by the | ||
954 | person providing the file. Keywords are never transmitted in | ||
955 | plaintext. The only way for an adversary to determine the keyword | ||
956 | that you used to search is to guess it (which then allows the | ||
957 | adversary to produce the same search request). Since providing | ||
958 | keywords by hand for each shared file is tedious, GNUnet uses | ||
959 | GNU libextractor to help automate this process. Starting a | ||
960 | keyword search on a slow machine can take a little while since | ||
961 | the keyword search involves computing a fresh RSA key to formulate the | ||
962 | request. | ||
963 | |||
964 | @node Directories | ||
965 | @subsubsection Directories | ||
966 | @c %**end of header | ||
967 | |||
968 | A directory in GNUnet is a list of file identifiers with meta data. | ||
969 | The file identifiers provide sufficient information about the files | ||
970 | to allow downloading the contents. Once a directory has been created, | ||
971 | it cannot be changed since it is treated just like an ordinary file | ||
972 | by the network. Small files (of a few kilobytes) can be inlined in | ||
973 | the directory, so that a separate download becomes unnecessary. | ||
974 | |||
975 | Directories are shared just like ordinary files. If you download a | ||
976 | directory with @command{gnunet-download}, you can use | ||
977 | @command{gnunet-directory} to list its contents. The canonical | ||
978 | extension for GNUnet directories when stored as files in your | ||
979 | local file-system is ".gnd". The contents of a directory are URIs and | ||
980 | meta data. | ||
981 | The URIs contain all the information required by | ||
982 | @command{gnunet-download} to retrieve the file. The meta data | ||
983 | typically includes the mime-type, description, a filename and | ||
984 | other meta information, and possibly even the full original file | ||
985 | (if it was small). | ||
986 | |||
987 | @node Pseudonyms | ||
988 | @subsubsection Pseudonyms | ||
989 | @c %**end of header | ||
990 | |||
991 | @b{Please note that the text in this subsection is outdated and needs} | ||
992 | @b{to be rewritten for version 0.10!} | ||
993 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
994 | |||
995 | Pseudonyms in GNUnet are essentially public-private (RSA) key pairs | ||
996 | that allow a GNUnet user to maintain an identity (which may or may not | ||
997 | be detached from their real-life identity). GNUnet's pseudonyms are not | ||
998 | file-sharing specific --- and they will likely be used by many GNUnet | ||
999 | applications where a user identity is required. | ||
1000 | |||
1001 | Note that a pseudonym is NOT bound to a GNUnet peer. There can be multiple | ||
1002 | pseudonyms for a single user, and users could (theoretically) share the | ||
1003 | private pseudonym keys (currently only out-of-band by knowing which files | ||
1004 | to copy around). | ||
1005 | |||
1006 | @node Namespaces | ||
1007 | @subsubsection Namespaces | ||
1008 | @c %**end of header | ||
1009 | |||
1010 | @b{Please note that the text in this subsection is outdated and needs} | ||
1011 | @b{to be rewritten for version 0.10!} | ||
1012 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1013 | |||
1014 | A namespace is a set of files that were signed by the same pseudonym. | ||
1015 | Files (or directories) that have been signed and placed into a namespace | ||
1016 | can be updated. Updates are identified as authentic if the same secret | ||
1017 | key was used to sign the update. Namespaces are also useful to establish | ||
1018 | a reputation, since all of the content in the namespace comes from the | ||
1019 | same entity (which does not have to be the same person). | ||
1020 | |||
1021 | @node Advertisements | ||
1022 | @subsubsection Advertisements | ||
1023 | @c %**end of header | ||
1024 | |||
1025 | @b{Please note that the text in this subsection is outdated and needs} | ||
1026 | @b{to be rewritten for version 0.10!} | ||
1027 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1028 | |||
1029 | Advertisements are used to notify other users about the existence of a | ||
1030 | namespace. Advertisements are propagated using the normal keyword search. | ||
1031 | When an advertisement is received (in response to a search), the namespace | ||
1032 | is added to the list of namespaces available in the namespace-search | ||
1033 | dialogs of gnunet-fs-gtk and printed by @code{gnunet-identity}. Whenever a | ||
1034 | namespace is created, an appropriate advertisement can be generated. | ||
1035 | The default keyword for the advertising of namespaces is "namespace". | ||
1036 | |||
1037 | Note that GNUnet differentiates between your pseudonyms (the identities | ||
1038 | that you control) and namespaces. If you create a pseudonym, you will | ||
1039 | not automatically see the respective namespace. You first have to create | ||
1040 | an advertisement for the namespace and find it using keyword | ||
1041 | search --- even for your own namespaces. The @command{gnunet-identity} | ||
1042 | tool is currently responsible for both managing pseudonyms and namespaces. | ||
1043 | This will likely change in the future to reduce the potential for | ||
1044 | confusion. | ||
1045 | |||
1046 | @node Anonymity level | ||
1047 | @subsubsection Anonymity level | ||
1048 | @c %**end of header | ||
1049 | |||
1050 | The anonymity level determines how hard it should be for an adversary to | ||
1051 | determine the identity of the publisher or the searcher/downloader. An | ||
1052 | anonymity level of zero means that anonymity is not required. The default | ||
1053 | anonymity level of "1" means that anonymous routing is desired, but no | ||
1054 | particular amount of cover traffic is necessary. A powerful adversary | ||
1055 | might thus still be able to deduce the origin of the traffic using | ||
1056 | traffic analysis. Specifying higher anonymity levels increases the | ||
1057 | amount of cover traffic required. While this offers better privacy, | ||
1058 | it can also significantly hurt performance. | ||
1059 | |||
1060 | @node Content Priority | ||
1061 | @subsubsection Content Priority | ||
1062 | @c %**end of header | ||
1063 | |||
1064 | Depending on the peer's configuration, GNUnet peers migrate content | ||
1065 | between peers. Content in this sense are individual blocks of a file, | ||
1066 | not necessarily entire files. When peers run out of space (due to | ||
1067 | local publishing operations or due to migration of content from other | ||
1068 | peers), blocks sometimes need to be discarded. GNUnet first always | ||
1069 | discards expired blocks (typically, blocks are published with an | ||
1070 | expiration of about two years in the future; this is another option). | ||
1071 | If there is still not enough space, GNUnet discards the blocks with the | ||
1072 | lowest priority. The priority of a block is decided by its popularity | ||
1073 | (in terms of requests from peers we trust) and, in case of blocks | ||
1074 | published locally, the base-priority that was specified by the user | ||
1075 | when the block was published initially. | ||
1076 | |||
1077 | @node Replication | ||
1078 | @subsubsection Replication | ||
1079 | @c %**end of header | ||
1080 | |||
1081 | When peers migrate content to other systems, the replication level | ||
1082 | of a block is used to decide which blocks need to be migrated most | ||
1083 | urgently. GNUnet will always push the block with the highest | ||
1084 | replication level into the network, and then decrement the replication | ||
1085 | level by one. If all blocks reach replication level zero, the | ||
1086 | selection is simply random. | ||
1087 | |||
1088 | |||
1089 | @node Namespace Management | ||
1090 | @subsection Namespace Management | ||
1091 | @c %**end of header | ||
1092 | |||
1093 | @b{Please note that the text in this subsection is outdated and needs} | ||
1094 | @b{to be rewritten for version 0.10!} | ||
1095 | |||
1096 | The @code{gnunet-identity} tool can be used to create pseudonyms and | ||
1097 | to advertise namespaces. By default, @code{gnunet-identity -D} simply | ||
1098 | lists all locally available pseudonyms. | ||
1099 | |||
1100 | |||
1101 | @menu | ||
1102 | * Creating Pseudonyms:: | ||
1103 | * Deleting Pseudonyms:: | ||
1104 | * Advertising namespaces:: | ||
1105 | * Namespace names:: | ||
1106 | * Namespace root:: | ||
1107 | @end menu | ||
1108 | |||
1109 | @node Creating Pseudonyms | ||
1110 | @subsubsection Creating Pseudonyms | ||
1111 | @c %**end of header | ||
1112 | |||
1113 | @b{Please note that the text in this subsection is outdated and needs} | ||
1114 | @b{to be rewritten for version 0.10!} | ||
1115 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1116 | |||
1117 | With the @command{-C NICK} option it can also be used to | ||
1118 | create a new pseudonym. A pseudonym is the virtual identity | ||
1119 | of the entity in control of a namespace. Anyone can create | ||
1120 | any number of pseudonyms. Note that creating a pseudonym can | ||
1121 | take a few minutes depending on the performance of the machine | ||
1122 | used. | ||
1123 | |||
1124 | @node Deleting Pseudonyms | ||
1125 | @subsubsection Deleting Pseudonyms | ||
1126 | @c %**end of header | ||
1127 | |||
1128 | @b{Please note that the text in this subsection is outdated and needs} | ||
1129 | @b{to be rewritten for version 0.10!} | ||
1130 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1131 | |||
1132 | With the @command{-D NICK} option pseudonyms can be deleted. | ||
1133 | Once the pseudonym has been deleted it is impossible to add | ||
1134 | content to the corresponding namespace. Deleting the | ||
1135 | pseudonym does not make the namespace or any content in it | ||
1136 | unavailable. | ||
1137 | |||
1138 | @node Advertising namespaces | ||
1139 | @subsubsection Advertising namespaces | ||
1140 | @c %**end of header | ||
1141 | |||
1142 | @b{Please note that the text in this subsection is outdated and needs} | ||
1143 | @b{to be rewritten for version 0.10!} | ||
1144 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1145 | |||
1146 | Each namespace is associated with meta-data that describes | ||
1147 | the namespace. This meta-data is provided by the user at | ||
1148 | the time that the namespace is advertised. Advertisements | ||
1149 | are published under keywords so that they can be found using | ||
1150 | normal keyword-searches. This way, users can learn about new | ||
1151 | namespaces without relying on out-of-band communication or directories. | ||
1152 | A suggested keyword to use for all namespaces is simply "namespace". | ||
1153 | When a keyword-search finds a namespace advertisement, | ||
1154 | it is automatically stored in a local list of known namespaces. | ||
1155 | Users can then associate a rank with the namespace to remember | ||
1156 | the quality of the content found in it. | ||
1157 | |||
1158 | @node Namespace names | ||
1159 | @subsubsection Namespace names | ||
1160 | @c %**end of header | ||
1161 | |||
1162 | @b{Please note that the text in this subsection is outdated and needs} | ||
1163 | @b{to be rewritten for version 0.10!} | ||
1164 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1165 | |||
1166 | While the namespace is uniquely identified by its ID, another way | ||
1167 | to refer to the namespace is to use the NICKNAME. | ||
1168 | The NICKNAME can be freely chosen by the creator of the namespace and | ||
1169 | hence conflicts are possible. If a GNUnet client learns about more | ||
1170 | than one namespace using the same NICKNAME, the ID is appended | ||
1171 | to the NICKNAME to get a unique identifier. | ||
1172 | |||
1173 | @node Namespace root | ||
1174 | @subsubsection Namespace root | ||
1175 | @c %**end of header | ||
1176 | |||
1177 | @b{Please note that the text in this subsection is outdated and needs} | ||
1178 | @b{to be rewritten for version 0.10!} | ||
1179 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1180 | |||
1181 | An item of particular interest in the namespace advertisement is | ||
1182 | the ROOT. The ROOT is the identifier of a designated entry in the | ||
1183 | namespace. The idea is that the ROOT can be used to advertise an | ||
1184 | entry point to the content of the namespace. | ||
1185 | |||
1186 | @node File-Sharing URIs | ||
1187 | @subsection File-Sharing URIs | ||
1188 | @c %**end of header | ||
1189 | |||
1190 | GNUnet (currently) uses four different types of URIs for | ||
1191 | file-sharing. They all begin with "gnunet://fs/". | ||
1192 | This section describes the four different URI types in detail. | ||
1193 | |||
1194 | For FS URIs empty KEYWORDs are not allowed. Quotes are allowed to | ||
1195 | denote whitespace between words. Keywords must contain a balanced | ||
1196 | number of double quotes. Doubles quotes can not be used in the actual | ||
1197 | keywords. This means that the the string '""foo bar""' will be turned | ||
1198 | into two OR-ed keywords 'foo' and 'bar', not into '"foo bar"'. | ||
1199 | |||
1200 | @menu | ||
1201 | * Encoding of hash values in URIs:: | ||
1202 | * Content Hash Key (chk):: | ||
1203 | * Location identifiers (loc):: | ||
1204 | * Keyword queries (ksk):: | ||
1205 | * Namespace content (sks):: | ||
1206 | @end menu | ||
1207 | |||
1208 | @node Encoding of hash values in URIs | ||
1209 | @subsubsection Encoding of hash values in URIs | ||
1210 | @c %**end of header | ||
1211 | |||
1212 | Most URIs include some hash values. Hashes are encoded using | ||
1213 | base32hex (RFC 2938). | ||
1214 | |||
1215 | @cindex chk-uri | ||
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 | ||
1221 | and to allow peers to download the file. Files are stored in | ||
1222 | GNUnet as a tree of encrypted blocks. | ||
1223 | The chk-URI thus contains the information to download and decrypt | ||
1224 | those blocks. A chk-URI has the format | ||
1225 | "gnunet://fs/chk/KEYHASH.QUERYHASH.SIZE". Here, "SIZE" | ||
1226 | is the size of the file (which allows a peer to determine the | ||
1227 | shape of the tree), KEYHASH is the key used to decrypt the file | ||
1228 | (also the hash of the plaintext of the top block) and QUERYHASH | ||
1229 | is the query used to request the top-level block (also the hash | ||
1230 | of the encrypted block). | ||
1231 | |||
1232 | @cindex loc-uri | ||
1233 | @node Location identifiers (loc) | ||
1234 | @subsubsection Location identifiers (loc) | ||
1235 | @c %**end of header | ||
1236 | |||
1237 | For non-anonymous file-sharing, loc-URIs are used to specify which | ||
1238 | peer is offering the data (in addition to specifying all of the | ||
1239 | data from a chk-URI). Location identifiers include a digital | ||
1240 | signature of the peer to affirm that the peer is truly the | ||
1241 | origin of the data. The format is | ||
1242 | "gnunet://fs/loc/KEYHASH.QUERYHASH.SIZE.PEER.SIG.EXPTIME". | ||
1243 | Here, "PEER" is the public key of the peer (in GNUnet format in | ||
1244 | base32hex), SIG is the RSA signature (in GNUnet format in | ||
1245 | base32hex) and EXPTIME specifies when the signature expires | ||
1246 | (in milliseconds after 1970). | ||
1247 | |||
1248 | @cindex ksk-uri | ||
1249 | @node Keyword queries (ksk) | ||
1250 | @subsubsection Keyword queries (ksk) | ||
1251 | @c %**end of header | ||
1252 | |||
1253 | A keyword-URI is used to specify that the desired operation | ||
1254 | is the search using a particular keyword. The format is simply | ||
1255 | "gnunet://fs/ksk/KEYWORD". Non-ASCII characters can be specified | ||
1256 | using the typical URI-encoding (using hex values) from HTTP. | ||
1257 | "+" can be used to specify multiple keywords (which are then | ||
1258 | logically "OR"-ed in the search, results matching both keywords | ||
1259 | are given a higher rank): "gnunet://fs/ksk/KEYWORD1+KEYWORD2". | ||
1260 | ksk-URIs must not begin or end with the plus ('+') character. | ||
1261 | Furthermore they must not contain '++'. | ||
1262 | |||
1263 | @cindex sks-uri | ||
1264 | @node Namespace content (sks) | ||
1265 | @subsubsection Namespace content (sks) | ||
1266 | @c %**end of header | ||
1267 | |||
1268 | @b{Please note that the text in this subsection is outdated and needs} | ||
1269 | @b{to be rewritten for version 0.10!} | ||
1270 | @b{This especially concerns the terminology of Pseudonym/Ego/Identity.} | ||
1271 | |||
1272 | Namespaces are sets of files that have been approved by some (usually | ||
1273 | pseudonymous) user --- typically by that user publishing all of the | ||
1274 | files together. A file can be in many namespaces. A file is in a | ||
1275 | namespace if the owner of the ego (aka the namespace's private key) | ||
1276 | signs the CHK of the file cryptographically. An SKS-URI is used to | ||
1277 | search a namespace. The result is a block containing meta data, | ||
1278 | the CHK and the namespace owner's signature. The format of a sks-URI | ||
1279 | is "gnunet://fs/sks/NAMESPACE/IDENTIFIER". Here, "NAMESPACE" | ||
1280 | is the public key for the namespace. "IDENTIFIER" is a freely | ||
1281 | chosen keyword (or password!). A commonly used identifier is | ||
1282 | "root" which by convention refers to some kind of index or other | ||
1283 | entry point into the namespace. | ||
1284 | |||
1285 | @node GTK User Interface | ||
1286 | @subsection GTK User Interface | ||
1287 | This chapter describes first steps for file-sharing with GNUnet. | ||
1288 | To start, you should launch @command{gnunet-fs-gtk}. | ||
1289 | |||
1290 | As we want to be sure that the network contains the data that we are | ||
1291 | looking for for testing, we need to begin by publishing a file. | ||
1292 | |||
1293 | @menu | ||
1294 | * gtk-Publishing:: | ||
1295 | * gtk-Searching:: | ||
1296 | * gtk-Downloading:: | ||
1297 | @end menu | ||
1298 | |||
1299 | @node gtk-Publishing | ||
1300 | @subsubsection Publishing | ||
1301 | @c %**end of header | ||
1302 | |||
1303 | To publish a file, select "File Sharing" in the menu bar just below the | ||
1304 | "Statistics" icon, and then select "Publish" from the menu. | ||
1305 | |||
1306 | Afterwards, the following publishing dialog will appear: | ||
1307 | |||
1308 | @c Add image here | ||
1309 | |||
1310 | In this dialog, select the "Add File" button. This will open a | ||
1311 | file selection dialog: | ||
1312 | |||
1313 | @c Add image here | ||
1314 | |||
1315 | Now, you should select a file from your computer to be published on | ||
1316 | GNUnet. To see more of GNUnet's features later, you should pick a | ||
1317 | PNG or JPEG file this time. You can leave all of the other options | ||
1318 | in the dialog unchanged. Confirm your selection by pressing the "OK" | ||
1319 | button in the bottom right corner. Now, you will briefly see a | ||
1320 | "Messages..." dialog pop up, but most likely it will be too short for | ||
1321 | you to really read anything. That dialog is showing you progress | ||
1322 | information as GNUnet takes a first look at the selected file(s). | ||
1323 | For a normal image, this is virtually instant, but if you later | ||
1324 | import a larger directory you might be interested in the progress dialog | ||
1325 | and potential errors that might be encountered during processing. | ||
1326 | After the progress dialog automatically disappears, your file | ||
1327 | should now appear in the publishing dialog: | ||
1328 | |||
1329 | @c Add image here | ||
1330 | |||
1331 | Now, select the file (by clicking on the file name) and then click | ||
1332 | the "Edit" button. This will open the editing dialog: | ||
1333 | |||
1334 | @c Add image here | ||
1335 | |||
1336 | In this dialog, you can see many details about your file. In the | ||
1337 | top left area, you can see meta data extracted about the file, | ||
1338 | such as the original filename, the mimetype and the size of the image. | ||
1339 | In the top right, you should see a preview for the image | ||
1340 | (if GNU libextractor was installed correctly with the | ||
1341 | respective plugins). Note that if you do not see a preview, this | ||
1342 | is not a disaster, but you might still want to install more of | ||
1343 | GNU libextractor in the future. In the bottom left, the dialog contains | ||
1344 | a list of keywords. These are the keywords under which the file will be | ||
1345 | made available. The initial list will be based on the extracted meta data. | ||
1346 | Additional publishing options are in the right bottom corner. We will | ||
1347 | now add an additional keyword to the list of keywords. This is done by | ||
1348 | entering the keyword above the keyword list between the label "Keyword" | ||
1349 | and the "Add keyword" button. Enter "test" and select "Add keyword". | ||
1350 | Note that the keyword will appear at the bottom of the existing keyword | ||
1351 | list, so you might have to scroll down to see it. Afterwards, push the | ||
1352 | "OK" button at the bottom right of the dialog. | ||
1353 | |||
1354 | You should now be back at the "Publish content on GNUnet" dialog. Select | ||
1355 | "Execute" in the bottom right to close the dialog and publish your file | ||
1356 | on GNUnet! Afterwards, you should see the main dialog with a new area | ||
1357 | showing the list of published files (or ongoing publishing operations | ||
1358 | with progress indicators): | ||
1359 | |||
1360 | @c Add image here | ||
1361 | |||
1362 | @node gtk-Searching | ||
1363 | @subsubsection Searching | ||
1364 | @c %**end of header | ||
1365 | |||
1366 | Below the menu bar, there are four entry widges labeled "Namespace", | ||
1367 | "Keywords", "Anonymity" and "Mime-type" (from left to right). These | ||
1368 | widgets are used to control searching for files in GNUnet. Between the | ||
1369 | "Keywords" and "Anonymity" widgets, there is also a big "Search" button, | ||
1370 | which is used to initiate the search. We will ignore the "Namespace", | ||
1371 | "Anonymity" and "Mime-type" options in this tutorial, please leave them | ||
1372 | empty. Instead, simply enter "test" under "Keywords" and press "Search". | ||
1373 | Afterwards, you should immediately see a new tab labeled after your | ||
1374 | search term, followed by the (current) number of search | ||
1375 | results --- "(15)" in our screenshot. Note that your results may | ||
1376 | vary depending on what other users may have shared and how your | ||
1377 | peer is connected. | ||
1378 | |||
1379 | You can now select one of the search results. Once you do this, | ||
1380 | additional information about the result should be displayed on the | ||
1381 | right. If available, a preview image should appear on the top right. | ||
1382 | Meta data describing the file will be listed at the bottom right. | ||
1383 | |||
1384 | Once a file is selected, at the bottom of the search result list | ||
1385 | a little area for downloading appears. | ||
1386 | |||
1387 | @node gtk-Downloading | ||
1388 | @subsubsection Downloading | ||
1389 | @c %**end of header | ||
1390 | |||
1391 | In the downloading area, you can select the target directory (default is | ||
1392 | "Downloads") and specify the desired filename (by default the filename it | ||
1393 | taken from the meta data of the published file). Additionally, you can | ||
1394 | specify if the download should be anonymous and (for directories) if | ||
1395 | the download should be recursive. In most cases, you can simply start | ||
1396 | the download with the "Download!" button. | ||
1397 | |||
1398 | Once you selected download, the progress of the download will be | ||
1399 | displayed with the search result. You may need to resize the result | ||
1400 | list or scroll to the right. The "Status" column shows the current | ||
1401 | status of the download, and "Progress" how much has been completed. | ||
1402 | When you close the search tab (by clicking on the "X" button next to | ||
1403 | the "test" label), ongoing and completed downloads are not aborted | ||
1404 | but moved to a special "*" tab. | ||
1405 | |||
1406 | You can remove completed downloads from the "*" tab by clicking the | ||
1407 | cleanup button next to the "*". You can also abort downloads by right | ||
1408 | clicking on the respective download and selecting "Abort download" | ||
1409 | from the menu. | ||
1410 | |||
1411 | That's it, you now know the basics for file-sharing with GNUnet! | ||
1412 | |||
1413 | |||
1414 | @node The GNU Name System | ||
1415 | @section The GNU Name System | ||
1416 | @c %**end of header | ||
1417 | |||
1418 | |||
1419 | The GNU Name System (GNS) is secure and decentralized naming system. | ||
1420 | It allows its users to resolve and register names within the @code{.gnu} | ||
1421 | @dfn{top-level domain} (TLD). | ||
1422 | |||
1423 | GNS is designed to provide: | ||
1424 | @itemize @bullet | ||
1425 | @item Censorship resistance | ||
1426 | @item Query privacy | ||
1427 | @item Secure name resolution | ||
1428 | @item Compatibility with DNS | ||
1429 | @end itemize | ||
1430 | |||
1431 | For the initial configuration and population of your | ||
1432 | GNS installation, please follow the GNS setup instructions. | ||
1433 | The remainder of this chapter will provide some background on GNS | ||
1434 | and then describe how to use GNS in more detail. | ||
1435 | |||
1436 | Unlike DNS, GNS does not rely on central root zones or authorities. | ||
1437 | Instead any user administers their own root and can can create arbitrary | ||
1438 | name value mappings. Furthermore users can delegate resolution to other | ||
1439 | users' zones just like DNS NS records do. Zones are uniquely identified | ||
1440 | via public keys and resource records are signed using the corresponding | ||
1441 | public key. Delegation to another user's zone is done using special PKEY | ||
1442 | records and petnames. A petname is a name that can be freely chosen by | ||
1443 | the user. This results in non-unique name-value mappings as | ||
1444 | @code{@uref{http://www.bob.gnu/, www.bob.gnu}} to one user might be | ||
1445 | @code{@uref{http://www.friend.gnu/, www.friend.gnu}} for someone else. | ||
1446 | |||
1447 | |||
1448 | @menu | ||
1449 | * Creating a Zone:: | ||
1450 | * Maintaining your own Zones:: | ||
1451 | * Obtaining your Zone Key:: | ||
1452 | * Adding Links to Other Zones:: | ||
1453 | * Using Public Keys as Top Level Domains:: | ||
1454 | * Resource Records in GNS:: | ||
1455 | * Synchronizing with legacy DNS:: | ||
1456 | @end menu | ||
1457 | |||
1458 | |||
1459 | @node Creating a Zone | ||
1460 | @subsection Creating a Zone | ||
1461 | |||
1462 | To use GNS, you probably should create at least one zone of your own. | ||
1463 | You can create any number of zones using the gnunet-identity tool | ||
1464 | using: | ||
1465 | |||
1466 | @example | ||
1467 | $ gnunet-identity -C "myzone" | ||
1468 | @end example | ||
1469 | |||
1470 | Henceforth, on your system you control the TLD ``myzone''. | ||
1471 | |||
1472 | All of your zones can be listed (displayed) using the | ||
1473 | @command{gnunet-identity} command line tool as well: | ||
1474 | |||
1475 | @example | ||
1476 | $ gnunet-identity -d | ||
1477 | @end example | ||
1478 | |||
1479 | @node Maintaining your own Zones | ||
1480 | @subsection Maintaining your own Zones | ||
1481 | |||
1482 | @noindent | ||
1483 | Now you can add (or edit, or remove) records in your GNS zone using the | ||
1484 | @command{gnunet-namestore-gtk} GUI or using the @command{gnunet-namestore} | ||
1485 | command-line tool. | ||
1486 | In either case, your records will be stored in an SQL database under | ||
1487 | control of the @command{gnunet-service-namestore}. | ||
1488 | Note that if multiple users use one peer, the namestore database will | ||
1489 | include the combined records of all users. | ||
1490 | However, users will not be able to see each other's records | ||
1491 | if they are marked as private. | ||
1492 | |||
1493 | To provide a short example for editing your own zone, suppose you | ||
1494 | have your own web server with the IP @code{1.2.3.4}. Then you can put an | ||
1495 | @code{A} record (@code{A} records in DNS are for IPv4 IP addresses) | ||
1496 | into your local zone ``myzone'' using the command: | ||
1497 | |||
1498 | @example | ||
1499 | $ gnunet-namestore -z myzone -a -n www -t A -V 1.2.3.4 -e never | ||
1500 | @end example | ||
1501 | |||
1502 | @noindent | ||
1503 | Afterwards, you will be able to access your webpage under "www.myzone" | ||
1504 | (assuming your webserver does not use virtual hosting, if it does, | ||
1505 | please read up on setting up the GNS proxy). | ||
1506 | |||
1507 | Similar commands will work for other types of DNS and GNS records, | ||
1508 | the syntax largely depending on the type of the record. | ||
1509 | Naturally, most users may find editing the zones using the | ||
1510 | @command{gnunet-namestore-gtk} GUI to be easier. | ||
1511 | |||
1512 | @node Obtaining your Zone Key | ||
1513 | @subsection Obtaining your Zone Key | ||
1514 | |||
1515 | Each zone in GNS has a public-private key. Usually, gnunet-namestore and | ||
1516 | gnunet-setup will access your private key as necessary, so you do not | ||
1517 | have to worry about those. What is important is your public key | ||
1518 | (or rather, the hash of your public key), as you will likely want to | ||
1519 | give it to others so that they can securely link to you. | ||
1520 | |||
1521 | You can usually get the hash of your public key using | ||
1522 | |||
1523 | @example | ||
1524 | $ gnunet-identity -d $options | grep myzone | awk '@{print $3@}' | ||
1525 | @end example | ||
1526 | |||
1527 | @noindent | ||
1528 | For example, the output might be something like: | ||
1529 | |||
1530 | @example | ||
1531 | DC3SEECJORPHQNVRH965A6N74B1M37S721IG4RBQ15PJLLPJKUE0 | ||
1532 | @end example | ||
1533 | |||
1534 | @noindent | ||
1535 | Alternatively, you can obtain a QR code with your zone key AND your | ||
1536 | pseudonym from gnunet-namestore-gtk. The QR code is displayed in the | ||
1537 | main window and can be stored to disk using the ``Save as'' button | ||
1538 | next to the image. | ||
1539 | |||
1540 | @node Adding Links to Other Zones | ||
1541 | @subsection Adding Links to Other Zones | ||
1542 | |||
1543 | |||
1544 | A central operation in GNS is the ability to securely delegate to | ||
1545 | other zones. Basically, by adding a delegation you make all of the | ||
1546 | names from the other zone available to yourself. This section | ||
1547 | describes how to create delegations. | ||
1548 | |||
1549 | Suppose you have a friend who you call 'bob' who also uses GNS. | ||
1550 | You can then delegate resolution of names to Bob's zone by adding | ||
1551 | a PKEY record to their local zone: | ||
1552 | |||
1553 | @example | ||
1554 | $ gnunet-namestore -a -n bob --type PKEY -V XXXX -e never -Z myzone | ||
1555 | @end example | ||
1556 | |||
1557 | @noindent | ||
1558 | Note that ``XXXX'' in the command above must be replaced with the hash | ||
1559 | of Bob's public key (the output your friend obtained using the | ||
1560 | @command{gnunet-identity} command from the previous section and told | ||
1561 | you, for example by giving you a business card containing this | ||
1562 | information as a QR code). | ||
1563 | |||
1564 | Assuming Bob has an ``A'' record for their website under the name of | ||
1565 | ``www'' in his zone, you can then access Bob's website under | ||
1566 | ``www.bob.myzone'' --- as well as any (public) GNS record that Bob has | ||
1567 | in their zone by replacing www with the respective name of the | ||
1568 | record in Bob's zone. | ||
1569 | |||
1570 | @c themselves? themself? | ||
1571 | Furthermore, if Bob has themselves a (public) delegation to Carol's | ||
1572 | zone under "carol", you can access Carol's records under | ||
1573 | ``NAME.carol.bob.myzone'' (where ``NAME'' is the name of Carol's | ||
1574 | record you want to access). | ||
1575 | |||
1576 | |||
1577 | @node Using Public Keys as Top Level Domains | ||
1578 | @subsection Using Public Keys as Top Level Domains | ||
1579 | |||
1580 | |||
1581 | GNS also assumes responsibility for any name that uses in a | ||
1582 | well-formed public key for the TLD. Names ending this way are then | ||
1583 | resolved by querying the respective zone. Such public key TLDs are | ||
1584 | expected to be used under rare circumstances where globally unique | ||
1585 | names are required, and for integration with legacy systems. | ||
1586 | |||
1587 | @node Resource Records in GNS | ||
1588 | @subsection Resource Records in GNS | ||
1589 | |||
1590 | |||
1591 | GNS supports the majority of the DNS records as defined in | ||
1592 | @uref{http://www.ietf.org/rfc/rfc1035.txt, RFC 1035}. Additionally, | ||
1593 | GNS defines some new record types the are unique to the GNS system. | ||
1594 | For example, GNS-specific resource records are used to give petnames | ||
1595 | for zone delegation, revoke zone keys and provide some compatibility | ||
1596 | features. | ||
1597 | |||
1598 | For some DNS records, GNS does extended processing to increase their | ||
1599 | usefulness in GNS. In particular, GNS introduces special names | ||
1600 | referred to as "zone relative names". Zone relative names are allowed | ||
1601 | in some resource record types (for example, in NS and CNAME records) | ||
1602 | and can also be used in links on webpages. Zone relative names end | ||
1603 | in ".+" which indicates that the name needs to be resolved relative | ||
1604 | to the current authoritative zone. The extended processing of those | ||
1605 | names will expand the ".+" with the correct delegation chain to the | ||
1606 | authoritative zone (replacing ".+" with the name of the location | ||
1607 | where the name was encountered) and hence generate a | ||
1608 | valid GNS name. | ||
1609 | |||
1610 | GNS currently supports the following record types: | ||
1611 | |||
1612 | @menu | ||
1613 | * NICK:: | ||
1614 | * PKEY:: | ||
1615 | * BOX:: | ||
1616 | * LEHO:: | ||
1617 | * VPN:: | ||
1618 | * A AAAA and TXT:: | ||
1619 | * CNAME:: | ||
1620 | * GNS2DNS:: | ||
1621 | * SOA SRV PTR and MX:: | ||
1622 | * PLACE:: | ||
1623 | * PHONE:: | ||
1624 | * ID ATTR:: | ||
1625 | * ID TOKEN:: | ||
1626 | * ID TOKEN METADATA:: | ||
1627 | * CREDENTIAL:: | ||
1628 | * POLICY:: | ||
1629 | * ATTRIBUTE:: | ||
1630 | * ABE KEY:: | ||
1631 | * ABE MASTER:: | ||
1632 | * RECLAIM OIDC CLIENT:: | ||
1633 | * RECLAIM OIDC REDIRECT:: | ||
1634 | @end menu | ||
1635 | |||
1636 | @node NICK | ||
1637 | @subsubsection NICK | ||
1638 | |||
1639 | A NICK record is used to give a zone a name. With a NICK record, you | ||
1640 | can essentially specify how you would like to be called. GNS expects | ||
1641 | this record under the empty label ``@@'' in the zone's database | ||
1642 | (NAMESTORE); however, it will then automatically be copied into each | ||
1643 | record set, so that clients never need to do a separate lookup to | ||
1644 | discover the NICK record. Also, users do not usually have to worry | ||
1645 | about setting the NICK record: it is automatically set to the local | ||
1646 | name of the TLD. | ||
1647 | |||
1648 | @b{Example}@ | ||
1649 | |||
1650 | @example | ||
1651 | Name: @@; RRType: NICK; Value: bob | ||
1652 | @end example | ||
1653 | |||
1654 | @noindent | ||
1655 | This record in Bob's zone will tell other users that this zone wants | ||
1656 | to be referred to as 'bob'. Note that nobody is obliged to call Bob's | ||
1657 | zone 'bob' in their own zones. It can be seen as a | ||
1658 | recommendation ("Please call this zone 'bob'"). | ||
1659 | |||
1660 | @node PKEY | ||
1661 | @subsubsection PKEY | ||
1662 | |||
1663 | PKEY records are used to add delegation to other users' zones and | ||
1664 | give those zones a petname. | ||
1665 | |||
1666 | @b{Example}@ | ||
1667 | |||
1668 | Let Bob's zone be identified by the hash "ABC012". Bob is your friend | ||
1669 | so you want to give them the petname "friend". Then you add the | ||
1670 | following record to your zone: | ||
1671 | |||
1672 | @example | ||
1673 | Name: friend; RRType: PKEY; Value: ABC012; | ||
1674 | @end example | ||
1675 | |||
1676 | @noindent | ||
1677 | This will allow you to resolve records in bob's zone | ||
1678 | under "*.friend.gnu". | ||
1679 | |||
1680 | @node BOX | ||
1681 | @subsubsection BOX | ||
1682 | |||
1683 | BOX records are there to integrate information from TLSA or | ||
1684 | SRV records under the main label. In DNS, TLSA and SRV records | ||
1685 | use special names of the form @code{_port._proto.(label.)*tld} to | ||
1686 | indicate the port number and protocol (i.e. tcp or udp) for which | ||
1687 | the TLSA or SRV record is valid. This causes various problems, and | ||
1688 | is elegantly solved in GNS by integrating the protocol and port | ||
1689 | numbers together with the respective value into a "BOX" record. | ||
1690 | Note that in the GUI, you do not get to edit BOX records directly | ||
1691 | right now --- the GUI will provide the illusion of directly | ||
1692 | editing the TLSA and SRV records, even though they internally | ||
1693 | are BOXed up. | ||
1694 | |||
1695 | @node LEHO | ||
1696 | @subsubsection LEHO | ||
1697 | |||
1698 | The LEgacy HOstname of a server. Some webservers expect a specific | ||
1699 | hostname to provide a service (virtiual hosting). Also SSL | ||
1700 | certificates usually contain DNS names. To provide the expected | ||
1701 | legacy DNS name for a server, the LEHO record can be used. | ||
1702 | To mitigate the just mentioned issues the GNS proxy has to be used. | ||
1703 | The GNS proxy will use the LEHO information to apply the necessary | ||
1704 | transformations. | ||
1705 | |||
1706 | @node VPN | ||
1707 | @subsubsection VPN | ||
1708 | |||
1709 | GNS allows easy access to services provided by the GNUnet Virtual Public | ||
1710 | Network. When the GNS resolver encounters a VPN record it will contact | ||
1711 | the VPN service to try and allocate an IPv4/v6 address (if the queries | ||
1712 | record type is an IP address) that can be used to contact the service. | ||
1713 | |||
1714 | @b{Example}@ | ||
1715 | |||
1716 | I want to provide access to the VPN service "web.gnu." on port 80 on peer | ||
1717 | ABC012:@ | ||
1718 | Name: www; RRType: VPN; Value: 80 ABC012 web.gnu. | ||
1719 | |||
1720 | The peer ABC012 is configured to provide an exit point for the service | ||
1721 | "web.gnu." on port 80 to it's server running locally on port 8080 by | ||
1722 | having the following lines in the @file{gnunet.conf} configuration file: | ||
1723 | |||
1724 | @example | ||
1725 | [web.gnunet.] | ||
1726 | TCP_REDIRECTS = 80:localhost4:8080 | ||
1727 | @end example | ||
1728 | |||
1729 | @node A AAAA and TXT | ||
1730 | @subsubsection A AAAA and TXT | ||
1731 | |||
1732 | Those records work in exactly the same fashion as in traditional DNS. | ||
1733 | |||
1734 | @node CNAME | ||
1735 | @subsubsection CNAME | ||
1736 | |||
1737 | As specified in RFC 1035 whenever a CNAME is encountered the query | ||
1738 | needs to be restarted with the specified name. In GNS a CNAME | ||
1739 | can either be: | ||
1740 | |||
1741 | @itemize @bullet | ||
1742 | @item A zone relative name, | ||
1743 | @item A zkey name or | ||
1744 | @item A DNS name (in which case resolution will continue outside | ||
1745 | of GNS with the systems DNS resolver) | ||
1746 | @end itemize | ||
1747 | |||
1748 | @node GNS2DNS | ||
1749 | @subsubsection GNS2DNS | ||
1750 | |||
1751 | GNS can delegate authority to a legacy DNS zone. For this, the | ||
1752 | name of the DNS nameserver and the name of the DNS zone are | ||
1753 | specified in a GNS2DNS record. | ||
1754 | |||
1755 | @b{Example} | ||
1756 | |||
1757 | @example | ||
1758 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@a.ns.joker.com | ||
1759 | @end example | ||
1760 | |||
1761 | @noindent | ||
1762 | Any query to @code{pet.gnu} will then be delegated to the DNS server at | ||
1763 | @code{a.ns.joker.com}. For example, | ||
1764 | @code{@uref{http://www.pet.gnu/, www.pet.gnu}} will result in a DNS query | ||
1765 | for @code{@uref{http://www.gnunet.org/, www.gnunet.org}} to the server | ||
1766 | at @code{a.ns.joker.com}. Delegation to DNS via NS records in GNS can | ||
1767 | be useful if you do not want to start resolution in the DNS root zone | ||
1768 | (due to issues such as censorship or availability). | ||
1769 | |||
1770 | Note that you would typically want to use a relative name for the | ||
1771 | nameserver, i.e. | ||
1772 | |||
1773 | @example | ||
1774 | Name: pet; RRType: GNS2DNS; Value: gnunet.org@@ns-joker.+@ | ||
1775 | Name: ns-joker; RRType: A; Value: 184.172.157.218 | ||
1776 | @end example | ||
1777 | |||
1778 | @noindent | ||
1779 | This way, you can avoid involving the DNS hierarchy in the resolution of | ||
1780 | @code{a.ns.joker.com}. In the example above, the problem may not be | ||
1781 | obvious as the nameserver for "gnunet.org" is in the ".com" zone. | ||
1782 | However, imagine the nameserver was "ns.gnunet.org". In this case, | ||
1783 | delegating to "ns.gnunet.org" would mean that despite using GNS, | ||
1784 | censorship in the DNS ".org" zone would still be effective. | ||
1785 | |||
1786 | @node SOA SRV PTR and MX | ||
1787 | @subsubsection SOA SRV PTR and MX | ||
1788 | |||
1789 | The domain names in those records can, again, be either | ||
1790 | |||
1791 | @itemize @bullet | ||
1792 | @item A zone relative name, | ||
1793 | @item A zkey name or | ||
1794 | @item A DNS name | ||
1795 | @end itemize | ||
1796 | |||
1797 | The resolver will expand the zone relative name if possible. | ||
1798 | Note that when using MX records within GNS, the target mail | ||
1799 | server might still refuse to accept e-mails to the resulting | ||
1800 | domain as the name might not match. GNS-enabled mail clients | ||
1801 | should use the ZKEY zone as the destination hostname and | ||
1802 | GNS-enabled mail servers should be configured to accept | ||
1803 | e-mails to the ZKEY-zones of all local users. | ||
1804 | |||
1805 | @node PLACE | ||
1806 | @subsubsection PLACE | ||
1807 | |||
1808 | Record type for a social place. | ||
1809 | |||
1810 | @node PHONE | ||
1811 | @subsubsection PHONE | ||
1812 | |||
1813 | Record type for a phone (of CONVERSATION). | ||
1814 | |||
1815 | @node ID ATTR | ||
1816 | @subsubsection ID ATTR | ||
1817 | |||
1818 | Record type for identity attributes (of IDENTITY). | ||
1819 | |||
1820 | @node ID TOKEN | ||
1821 | @subsubsection ID TOKEN | ||
1822 | |||
1823 | Record type for an identity token (of IDENTITY-TOKEN). | ||
1824 | |||
1825 | @node ID TOKEN METADATA | ||
1826 | @subsubsection ID TOKEN METADATA | ||
1827 | |||
1828 | Record type for the private metadata of an identity token (of IDENTITY-TOKEN). | ||
1829 | |||
1830 | @node CREDENTIAL | ||
1831 | @subsubsection CREDENTIAL | ||
1832 | |||
1833 | Record type for credential. | ||
1834 | |||
1835 | @node POLICY | ||
1836 | @subsubsection POLICY | ||
1837 | |||
1838 | Record type for policies. | ||
1839 | |||
1840 | @node ATTRIBUTE | ||
1841 | @subsubsection ATTRIBUTE | ||
1842 | |||
1843 | Record type for reverse lookups. | ||
1844 | |||
1845 | @node ABE KEY | ||
1846 | @subsubsection ABE KEY | ||
1847 | |||
1848 | Record type for ABE records. | ||
1849 | |||
1850 | @node ABE MASTER | ||
1851 | @subsubsection ABE MASTER | ||
1852 | |||
1853 | Record type for ABE master keys. | ||
1854 | |||
1855 | @node RECLAIM OIDC CLIENT | ||
1856 | @subsubsection RECLAIM OIDC CLIENT | ||
1857 | |||
1858 | Record type for reclaim OIDC clients. | ||
1859 | |||
1860 | @node RECLAIM OIDC REDIRECT | ||
1861 | @subsubsection RECLAIM OIDC REDIRECT | ||
1862 | |||
1863 | Record type for reclaim OIDC redirect URIs. | ||
1864 | |||
1865 | @node Synchronizing with legacy DNS | ||
1866 | @subsection Synchronizing with legacy DNS | ||
1867 | |||
1868 | If you want to support GNS but the master database for a zone | ||
1869 | is only available and maintained in DNS, GNUnet includes the | ||
1870 | @command{gnunet-zoneimport} tool to monitor a DNS zone and | ||
1871 | automatically import records into GNS. Today, the tool does | ||
1872 | not yet support DNS AF(X)R, as we initially used it on the | ||
1873 | ``.fr'' zone which does not allow us to perform a DNS zone | ||
1874 | transfer. Instead, @command{gnunet-zoneimport} reads a list | ||
1875 | of DNS domain names from @code{stdin}, issues DNS queries for | ||
1876 | each, converts the obtained records (if possible) and stores | ||
1877 | the result in the namestore. | ||
1878 | |||
1879 | @image{images/gns,6in,, picture of DNS-GNS data flow} | ||
1880 | |||
1881 | The zonemaster service then takes the records from the namestore, | ||
1882 | publishes them into the DHT which makes the result available to the | ||
1883 | GNS resolver. In the GNS configuration, non-local zones can be | ||
1884 | configured to be intercepted by specifying ``.tld = PUBLICKEY'' in the | ||
1885 | configuration file in the ``[gns]'' section. | ||
1886 | |||
1887 | Note that the namestore by default also populates the namecache. | ||
1888 | This pre-population is cryptographically expensive. Thus, on | ||
1889 | systems that only serve to import a large (millions of records) | ||
1890 | DNS zone and that do not have a local gns service in use, it | ||
1891 | is thus advisable to disable the namecache by setting the | ||
1892 | option ``DISABLE'' to ``YES'' in section ``[namecache]''. | ||
1893 | |||
1894 | |||
1895 | @node re@:claim Identity Provider | ||
1896 | @section re@:claim Identity Provider | ||
1897 | |||
1898 | The re:claim Identity Provider (IdP) is a decentralized IdP service. | ||
1899 | It allows its users to manage and authorize third parties to access their identity attributes such as email or shipping addresses. | ||
1900 | |||
1901 | It basically mimics the concepts of centralized IdPs, such as those offered by Google or Facebook. | ||
1902 | Like other IdPs, re:claim features an (optional) OpenID-Connect 1.0-compliant protocol layer that can be used for websites to integrate re:claim as an Identity Provider with little effort. | ||
1903 | |||
1904 | @menu | ||
1905 | * Managing Attributes:: | ||
1906 | * Sharing Attributes with Third Parties:: | ||
1907 | * Revoking Authorizations of Third Parties:: | ||
1908 | * Using the OpenID-Connect IdP:: | ||
1909 | @end menu | ||
1910 | |||
1911 | @node Managing Attributes | ||
1912 | @subsection Managing Attributes | ||
1913 | |||
1914 | Before adding attributes to an identity, you must first create an ego: | ||
1915 | |||
1916 | @example | ||
1917 | $ gnunet-identity -C "username" | ||
1918 | @end example | ||
1919 | |||
1920 | Henceforth, you can manage a new user profile of the user ``username''. | ||
1921 | |||
1922 | To add an email address to your user profile, simply use the @command{gnunet-reclaim} command line tool:: | ||
1923 | |||
1924 | @example | ||
1925 | $ gnunet-reclaim -e "username" -a "email" -V "username@@example.gnunet" | ||
1926 | @end example | ||
1927 | |||
1928 | All of your attributes can be listed using the @command{gnunet-reclaim} | ||
1929 | command line tool as well: | ||
1930 | |||
1931 | @example | ||
1932 | $ gnunet-reclaim -e "username" -D | ||
1933 | @end example | ||
1934 | |||
1935 | Currently, and by default, attribute values are interpreted as plain text. | ||
1936 | In the future there might be more value types such as X.509 certificate credentials. | ||
1937 | |||
1938 | @node Sharing Attributes with Third Parties | ||
1939 | @subsection Sharing Attributes with Third Parties | ||
1940 | |||
1941 | If you want to allow a third party such as a website or friend to access to your attributes (or a subset thereof) execute: | ||
1942 | |||
1943 | @example | ||
1944 | $ gnunet-reclaim -e "username" -r "PKEY" -i "attribute1,attribute2,..." | ||
1945 | @end example | ||
1946 | |||
1947 | Where "PKEY" is the public key of the third party and "attribute1,attribute2,..." is a comma-separated list of attribute names, such as "email", that you want to share. | ||
1948 | |||
1949 | The command will return a "ticket" string. | ||
1950 | You must give this "ticket" to the requesting third party. | ||
1951 | |||
1952 | The third party can then retrieve your shared identity attributes using: | ||
1953 | |||
1954 | @example | ||
1955 | $ gnunet-reclaim -e "friend" -C "ticket" | ||
1956 | @end example | ||
1957 | |||
1958 | This will retrieve and list the shared identity attributes. | ||
1959 | The above command will also work if the user "username" is currently offline since the attributes are retrieved from GNS. | ||
1960 | Further, the "ticket" can be re-used later to retrieve up-to-date attributes in case "username" has changed the value(s). For instance, becasue his email address changed. | ||
1961 | |||
1962 | To list all given authorizations (tickets) you can execute: | ||
1963 | @example | ||
1964 | $ gnunet-reclaim -e "friend" -T (TODO there is only a REST API for this ATM) | ||
1965 | @end example | ||
1966 | |||
1967 | |||
1968 | @node Revoking Authorizations of Third Parties | ||
1969 | @subsection Revoking Authorizations of Third Parties | ||
1970 | |||
1971 | If you want to revoke the access of a third party to your attributes you can execute: | ||
1972 | |||
1973 | @example | ||
1974 | $ gnunet-reclaim -e "username" -R "ticket" | ||
1975 | @end example | ||
1976 | |||
1977 | This will prevent the third party from accessing the attribute in the future. | ||
1978 | Please note that if the third party has previously accessed the attribute, there is not way in which the system could have prevented the thiry party from storing the data. | ||
1979 | As such, only access to updated data in the future can be revoked. | ||
1980 | This behaviour is _exactly the same_ as with other IdPs. | ||
1981 | |||
1982 | @node Using the OpenID-Connect IdP | ||
1983 | @subsection Using the OpenID-Connect IdP | ||
1984 | |||
1985 | @menu | ||
1986 | * Setting up reclaim.io:: | ||
1987 | * For Users:: | ||
1988 | * For Service Providers:: | ||
1989 | @end menu | ||
1990 | |||
1991 | |||
1992 | @node Setting up reclaim.io | ||
1993 | @subsubsection Setting up reclaim.io | ||
1994 | |||
1995 | @example | ||
1996 | $ gnunet-identity -C id | ||
1997 | $ openssl genrsa -des3 -passout pass:xxxx -out server.pass.key 2048 | ||
1998 | $ openssl rsa -passin pass:xxxx -in server.pass.key -out /etc/reclaim/reclaim.id.key | ||
1999 | $ rm server.pass.key | ||
2000 | $ openssl req -new -key /etc/reclaim/reclaim.id.key -out server.csr \ | ||
2001 | -subj "/CN=reclaim.id.local" | ||
2002 | $ openssl x509 -req -days 365 -in server.csr -signkey /etc/reclaim/reclaim.id.key -out /etc/reclaim/reclaim.id.crt | ||
2003 | $ openssl x509 -in /etc/reclaim/reclaim.id.crt -out /etc/reclaim/reclaim.id.der -outform DER | ||
2004 | $ HEXCERT=`xxd -p /etc/reclaim/reclaim.id.der | tr -d '\n'` | ||
2005 | $ BOXVALUE="6 443 52 3 0 0 $HEXCERT" | ||
2006 | $ gnunet-namestore -z id -a -n reclaim -t A -V "127.0.0.1" -e 1d -p | ||
2007 | $ gnunet-namestore -z id -a -n reclaim -t LEHO -V "reclaim.id.local" -e 1d -p | ||
2008 | $ gnunet-namestore -z id -a -n reclaim -t BOX -V "$BOXVALUE" -e 1d -p | ||
2009 | @end example | ||
2010 | |||
2011 | NGINX setup: | ||
2012 | @example | ||
2013 | server @{ | ||
2014 | listen 443; | ||
2015 | server_name reclaim.id.local; | ||
2016 | ssl on; | ||
2017 | ssl_certificate /etc/reclaim/reclaim.id.crt; | ||
2018 | ssl_certificate_key /etc/reclaim/reclaim.id.key; | ||
2019 | ssl_session_timeout 30m; | ||
2020 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | ||
2021 | ssl_session_cache shared:SSL:10m; | ||
2022 | |||
2023 | location /api @{ | ||
2024 | rewrite /api/(.*) /$1 break; | ||
2025 | proxy_pass http://127.0.0.1:7776; | ||
2026 | @} | ||
2027 | @} | ||
2028 | @end example | ||
2029 | |||
2030 | This will expose the REST API of GNUnet at https://reclaim.id/api. | ||
2031 | |||
2032 | @node For Users | ||
2033 | @subsubsection For Users | ||
2034 | |||
2035 | To use the OpenID Connect Identity Provider as an end user, you must first intall the User Interface from TODOINSERTURLHERE. | ||
2036 | |||
2037 | Start the user interface using: | ||
2038 | |||
2039 | @example | ||
2040 | $ yarn run build --prod | ||
2041 | @end example | ||
2042 | |||
2043 | Now setup a webserver to serve the compiled website under "dist/". | ||
2044 | |||
2045 | Now we can add the user interfce to our NGINX configuraiton: | ||
2046 | |||
2047 | @example | ||
2048 | server @{ | ||
2049 | ... | ||
2050 | location / @{ | ||
2051 | proxy_pass http://<whereever you serve the UI>; | ||
2052 | @} | ||
2053 | @} | ||
2054 | @end example | ||
2055 | |||
2056 | You can thest your setup by accessing https://reclaim.id in your browser through the GNS proxy. | ||
2057 | |||
2058 | @node For Service Providers | ||
2059 | @subsubsection For Service Providers | ||
2060 | |||
2061 | To setup an OpenID Connect client, it must first be registered. | ||
2062 | In reclaim, client registration is done by creating a client identity and adding the redirect URI and client description into its namespace: | ||
2063 | |||
2064 | @example | ||
2065 | $ gnunet-identity -C <rp_name> | ||
2066 | $ gnunet-namestore -z <rp_name> -a -n "+" -t RECLAIM_OIDC_REDIRECT -V <redirect_uri> -e 1d -p | ||
2067 | $ gnunet-namestore -z <rp_name> -a -n "+" -t RECLAIM_OIDC_CLIENT -V "My OIDC Client" -e 1d -p | ||
2068 | @end example | ||
2069 | |||
2070 | You can now use the OpenID Connect REST endpoints exposed by reclaim. | ||
2071 | |||
2072 | To request authorization from a user, your webapplication should initiate the OpenID Connect Authorization Flow like this: | ||
2073 | @example | ||
2074 | $ https://reclaim.id/openid/authorize?redirect_uri=<redirect_uri>&client_id=<RP_PKEY>&response_type=code&nonce=1234&scope=attribute1 attribute2 ... | ||
2075 | @end example | ||
2076 | |||
2077 | You should choose a random number for the nonce parameter. The RP_KEY is the public key corresponding to the <rp_name> identity. | ||
2078 | |||
2079 | The redirect URI is the URI that you expect the user to return to within the OpenID Connect authorization code flow. | ||
2080 | |||
2081 | When the user returns to your redirect URI, you can exchange it for an access token at the OpenID Token endpoint. | ||
2082 | The authentication at the token endpoint is performed using the configured password (PSW) in the reclaim configuration (reclaim.conf). To set it execute: | ||
2083 | |||
2084 | @example | ||
2085 | $ gnunet-config -s reclaim-rest-plugin -o PSW -V <secret> | ||
2086 | @end example | ||
2087 | |||
2088 | To retrieve the access token, you can access the token endpoint through the proxy like this: | ||
2089 | |||
2090 | @example | ||
2091 | $ curl --socks5-hostname 127.0.0.1:7777 \ | ||
2092 | -X POST \ | ||
2093 | https://reclaim.id/openid/token?grant_type=authorization_code&redirect_uri=<redirect_uri>&code=<code> \ | ||
2094 | -u <RP_KEY>:<secret> | ||
2095 | @end example | ||
2096 | |||
2097 | If successful, this will return a JSON object containing an ID Token and Access Token. | ||
2098 | The Access Token can be used to access the OpenID Connect userinfo endpoint: | ||
2099 | |||
2100 | @example | ||
2101 | $ curl --socks5-hostname 127.0.0.1:7777 \ | ||
2102 | -X POST \ | ||
2103 | https://reclaim.id/openid/userinfo\ | ||
2104 | -H 'Authorization: Bearer <access_token>' | ||
2105 | @end example | ||
2106 | |||
2107 | |||
2108 | |||
2109 | @node Using the Virtual Public Network | ||
2110 | @section Using the Virtual Public Network | ||
2111 | |||
2112 | @menu | ||
2113 | * Setting up an Exit node:: | ||
2114 | * Fedora and the Firewall:: | ||
2115 | * Setting up VPN node for protocol translation and tunneling:: | ||
2116 | @end menu | ||
2117 | |||
2118 | Using the GNUnet Virtual Public Network (VPN) application you can | ||
2119 | tunnel IP traffic over GNUnet. Moreover, the VPN comes | ||
2120 | with built-in protocol translation and DNS-ALG support, enabling | ||
2121 | IPv4-to-IPv6 protocol translation (in both directions). | ||
2122 | This chapter documents how to use the GNUnet VPN. | ||
2123 | |||
2124 | The first thing to note about the GNUnet VPN is that it is a public | ||
2125 | network. All participating peers can participate and there is no | ||
2126 | secret key to control access. So unlike common virtual private | ||
2127 | networks, the GNUnet VPN is not useful as a means to provide a | ||
2128 | "private" network abstraction over the Internet. The GNUnet VPN | ||
2129 | is a virtual network in the sense that it is an overlay over the | ||
2130 | Internet, using its own routing mechanisms and can also use an | ||
2131 | internal addressing scheme. The GNUnet VPN is an Internet | ||
2132 | underlay --- TCP/IP applications run on top of it. | ||
2133 | |||
2134 | The VPN is currently only supported on GNU/Linux systems. | ||
2135 | Support for operating systems that support TUN (such as FreeBSD) | ||
2136 | should be easy to add (or might not even require any coding at | ||
2137 | all --- we just did not test this so far). Support for other | ||
2138 | operating systems would require re-writing the code to create virtual | ||
2139 | network interfaces and to intercept DNS requests. | ||
2140 | |||
2141 | The VPN does not provide good anonymity. While requests are routed | ||
2142 | over the GNUnet network, other peers can directly see the source | ||
2143 | and destination of each (encapsulated) IP packet. Finally, if you | ||
2144 | use the VPN to access Internet services, the peer sending the | ||
2145 | request to the Internet will be able to observe and even alter | ||
2146 | the IP traffic. We will discuss additional security implications | ||
2147 | of using the VPN later in this chapter. | ||
2148 | |||
2149 | @node Setting up an Exit node | ||
2150 | @subsection Setting up an Exit node | ||
2151 | |||
2152 | Any useful operation with the VPN requires the existence of an exit | ||
2153 | node in the GNUnet Peer-to-Peer network. Exit functionality can only | ||
2154 | be enabled on peers that have regular Internet access. If you want | ||
2155 | to play around with the VPN or support the network, we encourage | ||
2156 | you to setup exit nodes. This chapter documents how to setup an | ||
2157 | exit node. | ||
2158 | |||
2159 | There are four types of exit functions an exit node can provide, | ||
2160 | and using the GNUnet VPN to access the Internet will only work | ||
2161 | nicely if the first three types are provided somewhere in | ||
2162 | the network. The four exit functions are: | ||
2163 | |||
2164 | @itemize @bullet | ||
2165 | @item DNS: allow other peers to use your DNS resolver | ||
2166 | @item IPv4: allow other peers to access your IPv4 Internet connection | ||
2167 | @item IPv6: allow other peers to access your IPv6 Internet connection | ||
2168 | @item Local service: allow other peers to access a specific TCP or | ||
2169 | UDP service your peer is providing | ||
2170 | @end itemize | ||
2171 | |||
2172 | By enabling "exit" in gnunet-setup and checking the respective boxes | ||
2173 | in the "exit" tab, you can easily choose which of the above exit | ||
2174 | functions you want to support. | ||
2175 | |||
2176 | Note, however, that by supporting the first three functions you will | ||
2177 | allow arbitrary other GNUnet users to access the Internet via your | ||
2178 | system. This is somewhat similar to running a Tor exit node. The | ||
2179 | Torproject has a nice article about what to consider if you want | ||
2180 | to do this here. We believe that generally running a DNS exit node | ||
2181 | is completely harmless. | ||
2182 | |||
2183 | The exit node configuration does currently not allow you to restrict the | ||
2184 | Internet traffic that leaves your system. In particular, you cannot | ||
2185 | exclude SMTP traffic (or block port 25) or limit to HTTP traffic using | ||
2186 | the GNUnet configuration. However, you can use your host firewall to | ||
2187 | restrict outbound connections from the virtual tunnel interface. This | ||
2188 | is highly recommended. In the future, we plan to offer a wider range | ||
2189 | of configuration options for exit nodes. | ||
2190 | |||
2191 | Note that by running an exit node GNUnet will configure your kernel | ||
2192 | to perform IP-forwarding (for IPv6) and NAT (for IPv4) so that the | ||
2193 | traffic from the virtual interface can be routed to the Internet. | ||
2194 | In order to provide an IPv6-exit, you need to have a subnet routed | ||
2195 | to your host's external network interface and assign a subrange of | ||
2196 | that subnet to the GNUnet exit's TUN interface. | ||
2197 | |||
2198 | When running a local service, you should make sure that the local | ||
2199 | service is (also) bound to the IP address of your EXIT interface | ||
2200 | (i.e. 169.254.86.1). It will NOT work if your local service is | ||
2201 | just bound to loopback. You may also want to create a "VPN" record | ||
2202 | in your zone of the GNU Name System to make it easy for others to | ||
2203 | access your service via a name instead of just the full service | ||
2204 | descriptor. Note that the identifier you assign the service can | ||
2205 | serve as a passphrase or shared secret, clients connecting to the | ||
2206 | service must somehow learn the service's name. VPN records in the | ||
2207 | GNU Name System can make this easier. | ||
2208 | |||
2209 | @node Fedora and the Firewall | ||
2210 | @subsection Fedora and the Firewall | ||
2211 | |||
2212 | |||
2213 | When using an exit node on Fedora 15, the standard firewall can | ||
2214 | create trouble even when not really exiting the local system! | ||
2215 | For IPv4, the standard rules seem fine. However, for IPv6 the | ||
2216 | standard rules prohibit traffic from the network range of the | ||
2217 | virtual interface created by the exit daemon to the local IPv6 | ||
2218 | address of the same interface (which is essentially loopback | ||
2219 | traffic, so you might suspect that a standard firewall would | ||
2220 | leave this traffic alone). However, as somehow for IPv6 the | ||
2221 | traffic is not recognized as originating from the local | ||
2222 | system (and as the connection is not already "established"), | ||
2223 | the firewall drops the traffic. You should still get ICMPv6 | ||
2224 | packets back, but that's obviously not very useful. | ||
2225 | |||
2226 | Possible ways to fix this include disabling the firewall (do you | ||
2227 | have a good reason for having it on?) or disabling the firewall | ||
2228 | at least for the GNUnet exit interface (or the respective | ||
2229 | IPv4/IPv6 address range). The best way to diagnose these kinds | ||
2230 | of problems in general involves setting the firewall to REJECT | ||
2231 | instead of DROP and to watch the traffic using wireshark | ||
2232 | (or tcpdump) to see if ICMP messages are generated when running | ||
2233 | some tests that should work. | ||
2234 | |||
2235 | @node Setting up VPN node for protocol translation and tunneling | ||
2236 | @subsection Setting up VPN node for protocol translation and tunneling | ||
2237 | |||
2238 | |||
2239 | The GNUnet VPN/PT subsystem enables you to tunnel IP traffic over the | ||
2240 | VPN to an exit node, from where it can then be forwarded to the | ||
2241 | Internet. This section documents how to setup VPN/PT on a node. | ||
2242 | Note that you can enable both the VPN and an exit on the same peer. | ||
2243 | In this case, IP traffic from your system may enter your peer's VPN | ||
2244 | and leave your peer's exit. This can be useful as a means to do | ||
2245 | protocol translation. For example, you might have an application that | ||
2246 | supports only IPv4 but needs to access an IPv6-only site. In this case, | ||
2247 | GNUnet would perform 4to6 protocol translation between the VPN (IPv4) | ||
2248 | and the Exit (IPv6). Similarly, 6to4 protocol translation is also | ||
2249 | possible. However, the primary use for GNUnet would be to access | ||
2250 | an Internet service running with an IP version that is not supported | ||
2251 | by your ISP. In this case, your IP traffic would be routed via GNUnet | ||
2252 | to a peer that has access to the Internet with the desired IP version. | ||
2253 | |||
2254 | Setting up an entry node into the GNUnet VPN primarily requires you | ||
2255 | to enable the "VPN/PT" option in "gnunet-setup". This will launch the | ||
2256 | "gnunet-service-vpn", "gnunet-service-dns" and "gnunet-daemon-pt" | ||
2257 | processes. The "gnunet-service-vpn" will create a virtual interface | ||
2258 | which will be used as the target for your IP traffic that enters the | ||
2259 | VPN. Additionally, a second virtual interface will be created by | ||
2260 | the "gnunet-service-dns" for your DNS traffic. You will then need to | ||
2261 | specify which traffic you want to tunnel over GNUnet. If your ISP only | ||
2262 | provides you with IPv4 or IPv6-access, you may choose to tunnel the | ||
2263 | other IP protocol over the GNUnet VPN. If you do not have an ISP | ||
2264 | (and are connected to other GNUnet peers via WLAN), you can also | ||
2265 | choose to tunnel all IP traffic over GNUnet. This might also provide | ||
2266 | you with some anonymity. After you enable the respective options | ||
2267 | and restart your peer, your Internet traffic should be tunneled | ||
2268 | over the GNUnet VPN. | ||
2269 | |||
2270 | The GNUnet VPN uses DNS-ALG to hijack your IP traffic. Whenever an | ||
2271 | application resolves a hostname (i.e. 'gnunet.org'), the | ||
2272 | "gnunet-daemon-pt" will instruct the "gnunet-service-dns" to intercept | ||
2273 | the request (possibly route it over GNUnet as well) and replace the | ||
2274 | normal answer with an IP in the range of the VPN's interface. | ||
2275 | "gnunet-daemon-pt" will then tell "gnunet-service-vpn" to forward all | ||
2276 | traffic it receives on the TUN interface via the VPN to the original | ||
2277 | destination. | ||
2278 | |||
2279 | For applications that do not use DNS, you can also manually create | ||
2280 | such a mapping using the gnunet-vpn command-line tool. Here, you | ||
2281 | specify the desired address family of the result (i.e. "-4"), and the | ||
2282 | intended target IP on the Internet ("-i 131.159.74.67") and | ||
2283 | "gnunet-vpn" will tell you which IP address in the range of your | ||
2284 | VPN tunnel was mapped. | ||
2285 | |||
2286 | @command{gnunet-vpn} can also be used to access "internal" services | ||
2287 | offered by GNUnet nodes. So if you happen to know a peer and a | ||
2288 | service offered by that peer, you can create an IP tunnel to | ||
2289 | that peer by specifying the peer's identity, service name and | ||
2290 | protocol (--tcp or --udp) and you will again receive an IP address | ||
2291 | that will terminate at the respective peer's service. | ||
2292 | |||
2293 | |||
diff --git a/doc/documentation/chapters/vocabulary.texi b/doc/documentation/chapters/vocabulary.texi deleted file mode 100644 index 0ee472b95..000000000 --- a/doc/documentation/chapters/vocabulary.texi +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | @node Vocabulary | ||
2 | @chapter Vocabulary | ||
3 | |||
4 | @menu | ||
5 | * Definitions abbreviations and acronyms:: | ||
6 | * Words and characters:: | ||
7 | * Technical Assumptions:: | ||
8 | @end menu | ||
9 | |||
10 | Throughout this Reference Manual we will use certain words and characters | ||
11 | which are listed in this introductionary chapter. | ||
12 | |||
13 | @node Definitions abbreviations and acronyms | ||
14 | @section Definitions abbreviations and acronyms | ||
15 | |||
16 | @menu | ||
17 | * Definitions:: | ||
18 | @end menu | ||
19 | |||
20 | @node Definitions | ||
21 | @subsection Definitions | ||
22 | |||
23 | Throughout this Reference Manual, the following terms and definitions | ||
24 | apply. | ||
25 | |||
26 | @node Words and characters | ||
27 | @section Words and characters | ||
28 | |||
29 | @enumerate | ||
30 | @item | ||
31 | In chapter Installation Handbook, | ||
32 | ``@command{#}'' in example code blocks describes commands executed as root | ||
33 | |||
34 | @example | ||
35 | # echo "I am root" | ||
36 | I am root | ||
37 | @end example | ||
38 | |||
39 | @item | ||
40 | However, in the chapter GNUnet C Tutorial | ||
41 | ``@command{#}'' in example code blocks describes commands, ie comments. | ||
42 | |||
43 | @example | ||
44 | # Do the foobar thing: | ||
45 | $ make foobar | ||
46 | @end example | ||
47 | |||
48 | @item | ||
49 | Dollarsign ``@command{$}'' in example code blocks describes commands you | ||
50 | execute as unprivileged users. | ||
51 | |||
52 | @example | ||
53 | $ cd foo; ./configure --example-switch | ||
54 | @end example | ||
55 | |||
56 | @item | ||
57 | Backslash ``@command{\}'' describes linebreaks. | ||
58 | |||
59 | @example | ||
60 | ./configure --foo --bar --baz \ | ||
61 | --short-loop | ||
62 | @end example | ||
63 | |||
64 | ...expands to @code{./configure --foo --bar --baz --short-loop} | ||
65 | |||
66 | @end enumerate | ||
67 | |||
68 | @node Technical Assumptions | ||
69 | @section Technical Assumptions | ||
70 | |||
71 | @c Is it really assuming Bash (ie Bash extensions of POSIX being used)? | ||
72 | The shell on GNU systems is assumed to be Bash. | ||