[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-go] 01/01: Initial revision.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-go] 01/01: Initial revision. |
Date: |
Wed, 18 Sep 2019 17:43:36 +0200 |
This is an automated email from the git hooks/post-receive script.
bernd-fix pushed a commit to branch master
in repository gnunet-go.
commit a048e9c08195a3ed11e7f864e270d372668b129e
Author: Bernd Fix <address@hidden>
AuthorDate: Wed Sep 18 17:39:29 2019 +0200
Initial revision.
---
LICENSE | 235 ++++++
README.md | 62 ++
build.sh | 3 +
doc/raw/crypto.txt | 262 +++++++
doc/raw/protocols/core.txt | 38 +
doc/raw/protocols/hello.txt | 58 ++
doc/raw/transport.txt | 306 ++++++++
doc/specification/.gitignore | 12 +
doc/specification/chapters/messages.texi | 7 +
doc/specification/chapters/messages/transport.texi | 47 ++
doc/specification/chapters/overview.texi | 4 +
doc/specification/chapters/services.texi | 31 +
doc/specification/chapters/services/core.texi | 63 ++
.../chapters/services/services-01.dia | Bin 0 -> 2786 bytes
.../chapters/services/services-01.png | Bin 0 -> 83442 bytes
doc/specification/chapters/services/transport.texi | 25 +
doc/specification/fdl-1.3.texi | 505 +++++++++++++
doc/specification/gpl-3.0.texi | 717 ++++++++++++++++++
doc/specification/techspec.texi | 87 +++
doc/specification/versioning.texi | 4 +
src/cmd/.gitignore | 1 +
src/cmd/gnunet-service-gns-go/main.go | 83 +++
src/cmd/peer_mockup/main.go | 68 ++
src/cmd/peer_mockup/peers.go | 46 ++
src/cmd/peer_mockup/process.go | 118 +++
src/cmd/vanityid/main.go | 46 ++
src/gnunet/config/config.go | 141 ++++
src/gnunet/config/config_test.go | 22 +
src/gnunet/config/gnunet-config.json | 16 +
src/gnunet/core/peer.go | 93 +++
src/gnunet/crypto/hash.go | 24 +
src/gnunet/crypto/key_derivation.go | 31 +
src/gnunet/crypto/key_derivation_test.go | 215 ++++++
src/gnunet/crypto/key_exchange.go | 12 +
src/gnunet/crypto/key_exchange_test.go | 104 +++
src/gnunet/crypto/keys_test.go | 69 ++
src/gnunet/crypto/signature.go | 6 +
src/gnunet/crypto/symmetric.go | 59 ++
src/gnunet/enums/block.go | 22 +
src/gnunet/enums/dht.go | 12 +
src/gnunet/enums/gns.go | 287 ++++++++
src/gnunet/enums/signature.go | 34 +
src/gnunet/go.mod | 5 +
src/gnunet/go.sum | 10 +
src/gnunet/message/const.go | 37 +
src/gnunet/message/factory.go | 64 ++
src/gnunet/message/message.go | 37 +
src/gnunet/message/msg_core.go | 95 +++
src/gnunet/message/msg_dht.go | 106 +++
src/gnunet/message/msg_gns.go | 128 ++++
src/gnunet/message/msg_namecache.go | 86 +++
src/gnunet/message/msg_transport.go | 440 +++++++++++
src/gnunet/message/types.go | 817 +++++++++++++++++++++
src/gnunet/service/client.go | 59 ++
src/gnunet/service/gns/crypto.go | 41 ++
src/gnunet/service/gns/crypto_test.go | 150 ++++
src/gnunet/service/gns/gns.go | 248 +++++++
src/gnunet/service/gns/record.go | 111 +++
src/gnunet/service/service.go | 91 +++
src/gnunet/transport/channel.go | 180 +++++
src/gnunet/transport/channel_netw.go | 173 +++++
src/gnunet/transport/channel_test.go | 203 +++++
src/gnunet/transport/connection.go | 52 ++
src/gnunet/transport/session.go | 12 +
src/gnunet/util/address.go | 39 +
src/gnunet/util/array.go | 48 ++
src/gnunet/util/base32.go | 109 +++
src/gnunet/util/base32_test.go | 86 +++
src/gnunet/util/format.go | 36 +
src/gnunet/util/id.go | 10 +
src/gnunet/util/msg_queue.go | 3 +
src/gnunet/util/rnd.go | 46 ++
src/gnunet/util/time.go | 19 +
73 files changed, 7516 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0a4f9a1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,235 @@
+GNU AFFERO GENERAL PUBLIC LICENSE
+Version 3, 19 November 2007
+
+Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+
+Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
+
+ Preamble
+
+The GNU Affero General Public License is a free, copyleft license for software
and other kinds of works, specifically designed to ensure cooperation with the
community in the case of network server software.
+
+The licenses for most software and other practical works are designed to take
away your freedom to share and change the works. By contrast, our General
Public Licenses are intended to guarantee your freedom to share and change all
versions of a program--to make sure it remains free software for all its users.
+
+When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom to
distribute copies of free software (and charge for them if you wish), that you
receive source code or can get it if you want it, that you can change the
software or use pieces of it in new free programs, and that you know you can do
these things.
+
+Developers that use our General Public Licenses protect your rights with two
steps: (1) assert copyright on the software, and (2) offer you this License
which gives you legal permission to copy, distribute and/or modify the software.
+
+A secondary benefit of defending all users' freedom is that improvements made
in alternate versions of the program, if they receive widespread use, become
available for other developers to incorporate. Many developers of free
software are heartened and encouraged by the resulting cooperation. However,
in the case of software used on network servers, this result may fail to come
about. The GNU General Public License permits making a modified version and
letting the public access it on a [...]
+
+The GNU Affero General Public License is designed specifically to ensure that,
in such cases, the modified source code becomes available to the community. It
requires the operator of a network server to provide the source code of the
modified version running there to the users of that server. Therefore, public
use of a modified version, on a publicly accessible server, gives the public
access to the source code of the modified version.
+
+An older license, called the Affero General Public License and published by
Affero, was designed to accomplish similar goals. This is a different license,
not a version of the Affero GPL, but Affero has released a new version of the
Affero GPL which permits relicensing under this license.
+
+The precise terms and conditions for copying, distribution and modification
follow.
+
+ TERMS AND CONDITIONS
+
+0. Definitions.
+
+"This License" refers to version 3 of the GNU Affero General Public License.
+
+"Copyright" also means copyright-like laws that apply to other kinds of works,
such as semiconductor masks.
+
+"The Program" refers to any copyrightable work licensed under this License.
Each licensee is addressed as "you". "Licensees" and "recipients" may be
individuals or organizations.
+
+To "modify" a work means to copy from or adapt all or part of the work in a
fashion requiring copyright permission, other than the making of an exact copy.
The resulting work is called a "modified version" of the earlier work or a
work "based on" the earlier work.
+
+A "covered work" means either the unmodified Program or a work based on the
Program.
+
+To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under applicable
copyright law, except executing it on a computer or modifying a private copy.
Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as well.
+
+To "convey" a work means any kind of propagation that enables other parties to
make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
+
+An interactive user interface displays "Appropriate Legal Notices" to the
extent that it includes a convenient and prominently visible feature that (1)
displays an appropriate copyright notice, and (2) tells the user that there is
no warranty for the work (except to the extent that warranties are provided),
that licensees may convey the work under this License, and how to view a copy
of this License. If the interface presents a list of user commands or options,
such as a menu, a promine [...]
+
+1. Source Code.
+The "source code" for a work means the preferred form of the work for making
modifications to it. "Object code" means any non-source form of a work.
+
+A "Standard Interface" means an interface that either is an official standard
defined by a recognized standards body, or, in the case of interfaces specified
for a particular programming language, one that is widely used among developers
working in that language.
+
+The "System Libraries" of an executable work include anything, other than the
work as a whole, that (a) is included in the normal form of packaging a Major
Component, but which is not part of that Major Component, and (b) serves only
to enable use of the work with that Major Component, or to implement a Standard
Interface for which an implementation is available to the public in source code
form. A "Major Component", in this context, means a major essential component
(kernel, window sys [...]
+
+The "Corresponding Source" for a work in object code form means all the source
code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities.
However, it does not include the work's System Libraries, or general-purpose
tools or generally available free programs which are used unmodified in
performing those activities but which are not part of the work. For example,
Corresponding Source includes i [...]
+subprograms and other parts of the work.
+
+The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
+
+The Corresponding Source for a work in source code form is that same work.
+
+2. Basic Permissions.
+All rights granted under this License are granted for the term of copyright on
the Program, and are irrevocable provided the stated conditions are met. This
License explicitly affirms your unlimited permission to run the unmodified
Program. The output from running a covered work is covered by this License
only if the output, given its content, constitutes a covered work. This
License acknowledges your rights of fair use or other equivalent, as provided
by copyright law.
+
+You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey
covered works to others for the sole purpose of having them make modifications
exclusively for you, or provide you with facilities for running those works,
provided that you comply with the terms of this License in conveying all
material for which you do not control copyright. Those thus making or running
the covered works for you m [...]
+
+Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes it
unnecessary.
+
+3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+No covered work shall be deemed part of an effective technological measure
under any applicable law fulfilling obligations under article 11 of the WIPO
copyright treaty adopted on 20 December 1996, or similar laws prohibiting or
restricting circumvention of such measures.
+
+When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention is
effected by exercising rights under this License with respect to the covered
work, and you disclaim any intention to limit operation or modification of the
work as a means of enforcing, against the work's users, your or third parties'
legal rights to forbid circumvention of technological measures.
+
+4. Conveying Verbatim Copies.
+You may convey verbatim copies of the Program's source code as you receive it,
in any medium, provided that you conspicuously and appropriately publish on
each copy an appropriate copyright notice; keep intact all notices stating that
this License and any non-permissive terms added in accord with section 7 apply
to the code; keep intact all notices of the absence of any warranty; and give
all recipients a copy of this License along with the Program.
+
+You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
+
+5. Conveying Modified Source Versions.
+You may convey a work based on the Program, or the modifications to produce it
from the Program, in the form of source code under the terms of section 4,
provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement
modifies the requirement in section 4 to "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this License to
anyone who comes into possession of a copy. This License will therefore apply,
along with any applicable section 7 additional terms, to the whole of the work,
and all its parts, regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not invalidate
such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive interfaces
that do not display Appropriate Legal Notices, your work need not make them do
so.
+
+A compilation of a covered work with other separate and independent works,
which are not by their nature extensions of the covered work, and which are not
combined with it such as to form a larger program, in or on a volume of a
storage or distribution medium, is called an "aggregate" if the compilation and
its resulting copyright are not used to limit the access or legal rights of the
compilation's users beyond what the individual works permit. Inclusion of a
covered work in an aggrega [...]
+
+6. Conveying Non-Source Forms.
+You may convey a covered work in object code form under the terms of sections
4 and 5, provided that you also convey the machine-readable Corresponding
Source under the terms of this License, in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the Corresponding
Source fixed on a durable physical medium customarily used for software
interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a written offer,
valid for at least three years and valid for as long as you offer spare parts
or customer support for that product model, to give anyone who possesses the
object code either (1) a copy of the Corresponding Source for all the software
in the product that is covered by this License, on a durable physical medium
customarily used for software interc [...]
+
+ c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed only
occasionally and noncommercially, and only if you received the object code with
such an offer, in accord with subsection 6b.
+
+ d) Convey the object code by offering access from a designated place
(gratis or for a charge), and offer equivalent access to the Corresponding
Source in the same way through the same place at no further charge. You need
not require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the
Corresponding Source may be on a different server (operated by you or a third
party) that supports equivalent copying f [...]
+
+ e) Convey the object code using peer-to-peer transmission, provided you
inform other peers where the object code and Corresponding Source of the work
are being offered to the general public at no charge under subsection 6d.
+
+A separable portion of the object code, whose source code is excluded from the
Corresponding Source as a System Library, need not be included in conveying the
object code work.
+
+A "User Product" is either (1) a "consumer product", which means any tangible
personal property which is normally used for personal, family, or household
purposes, or (2) anything designed or sold for incorporation into a dwelling.
In determining whether a product is a consumer product, doubtful cases shall be
resolved in favor of coverage. For a particular product received by a
particular user, "normally used" refers to a typical or common use of that
class of product, regardless of t [...]
+
+"Installation Information" for a User Product means any methods, procedures,
authorization keys, or other information required to install and execute
modified versions of a covered work in that User Product from a modified
version of its Corresponding Source. The information must suffice to ensure
that the continued functioning of the modified object code is in no case
prevented or interfered with solely because modification has been made.
+
+If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as part of a
transaction in which the right of possession and use of the User Product is
transferred to the recipient in perpetuity or for a fixed term (regardless of
how the transaction is characterized), the Corresponding Source conveyed under
this section must be accompanied by the Installation Information. But this
requirement does not apply if neith [...]
+
+The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates for a
work that has been modified or installed by the recipient, or for the User
Product in which it has been modified or installed. Access to a network may be
denied when the modification itself materially and adversely affects the
operation of the network or violates the rules and protocols for communication
across the network.
+
+Corresponding Source conveyed, and Installation Information provided, in
accord with this section must be in a format that is publicly documented (and
with an implementation available to the public in source code form), and must
require no special password or key for unpacking, reading or copying.
+
+7. Additional Terms.
+"Additional permissions" are terms that supplement the terms of this License
by making exceptions from one or more of its conditions. Additional permissions
that are applicable to the entire Program shall be treated as though they were
included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part
may be used separately under those permissions, but the entire Program remains
governed by this Licens [...]
+
+When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when
you modify the work.) You may place additional permissions on material, added
by you to a covered work, for which you have or can give appropriate copyright
permission.
+
+Notwithstanding any other provision of this License, for material you add to a
covered work, you may (if authorized by the copyright holders of that material)
supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the terms
of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed by
works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in reasonable ways
as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some trade
names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that material by
anyone who conveys the material (or modified versions of it) with contractual
assumptions of liability to the recipient, for any liability that these
contractual assumptions directly impose on those licensors and authors.
+
+All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you received
it, or any part of it, contains a notice stating that it is governed by this
License along with a term that is a further restriction, you may remove that
term. If a license document contains a further restriction but permits
relicensing or conveying under this License, you may add to a covered work
material governed by the terms of that licens [...]
+
+If you add terms to a covered work in accord with this section, you must
place, in the relevant source files, a statement of the additional terms that
apply to those files, or a notice indicating where to find the applicable terms.
+
+Additional terms, permissive or non-permissive, may be stated in the form of a
separately written license, or stated as exceptions; the above requirements
apply either way.
+
+8. Termination.
+
+You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including any
patent licenses granted under the third paragraph of section 11).
+
+However, if you cease all violation of this License, then your license from a
particular copyright holder is reinstated (a) provisionally, unless and until
the copyright holder explicitly and finally terminates your license, and (b)
permanently, if the copyright holder fails to notify you of the violation by
some reasonable means prior to 60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is reinstated
permanently if the copyright holder notifies you of the violation by some
reasonable means, this is the first time you have received notice of violation
of this License (for any work) from that copyright holder, and you cure the
violation prior to 30 days after your receipt of the notice.
+
+Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License. If
your rights have been terminated and not permanently reinstated, you do not
qualify to receive new licenses for the same material under section 10.
+
+9. Acceptance Not Required for Having Copies.
+
+You are not required to accept this License in order to receive or run a copy
of the Program. Ancillary propagation of a covered work occurring solely as a
consequence of using peer-to-peer transmission to receive a copy likewise does
not require acceptance. However, nothing other than this License grants you
permission to propagate or modify any covered work. These actions infringe
copyright if you do not accept this License. Therefore, by modifying or
propagating a covered work, yo [...]
+
+10. Automatic Licensing of Downstream Recipients.
+
+Each time you convey a covered work, the recipient automatically receives a
license from the original licensors, to run, modify and propagate that work,
subject to this License. You are not responsible for enforcing compliance by
third parties with this License.
+
+An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered work
results from an entity transaction, each party to that transaction who receives
a copy of the work also receives whatever licenses to the work the party's
predecessor in interest had or could give under the previous paragraph, plus a
right to possession of the Corresponding Source [...]
+
+You may not impose any further restrictions on the exercise of the rights
granted or affirmed under this License. For example, you may not impose a
license fee, royalty, or other charge for exercise of rights granted under this
License, and you may not initiate litigation (including a cross-claim or
counterclaim in a lawsuit) alleging that any patent claim is infringed by
making, using, selling, offering for sale, or importing the Program or any
portion of it.
+
+11. Patents.
+
+A "contributor" is a copyright holder who authorizes use under this License of
the Program or a work on which the Program is based. The work thus licensed is
called the contributor's "contributor version".
+
+A contributor's "essential patent claims" are all patent claims owned or
controlled by the contributor, whether already acquired or hereafter acquired,
that would be infringed by some manner, permitted by this License, of making,
using, or selling its contributor version, but do not include claims that would
be infringed only as a consequence of further modification of the contributor
version. For purposes of this definition, "control" includes the right to
grant patent sublicenses in a [...]
+
+Each contributor grants you a non-exclusive, worldwide, royalty-free patent
license under the contributor's essential patent claims, to make, use, sell,
offer for sale, import and otherwise run, modify and propagate the contents of
its contributor version.
+
+In the following three paragraphs, a "patent license" is any express agreement
or commitment, however denominated, not to enforce a patent (such as an express
permission to practice a patent or covenant not to s ue for patent
infringement). To "grant" such a patent license to a party means to make such
an agreement or commitment not to enforce a patent against the party.
+
+If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free of
charge and under the terms of this License, through a publicly available
network server or other readily accessible means, then you must either (1)
cause the Corresponding Source to be so available, or (2) arrange to deprive
yourself of the benefit of the patent license for this particular work, or (3)
arrange, in a manner consistent w [...]
+license to downstream recipients. "Knowingly relying" means you have actual
knowledge that, but for the patent license, your conveying the covered work in
a country, or your recipient's use of the covered work in a country, would
infringe one or more identifiable patents in that country that you have reason
to believe are valid.
+
+If, pursuant to or in connection with a single transaction or arrangement, you
convey, or propagate by procuring conveyance of, a covered work, and grant a
patent license to some of the parties receiving the covered work authorizing
them to use, propagate, modify or convey a specific copy of the covered work,
then the patent license you grant is automatically extended to all recipients
of the covered work and works based on it.
+
+A patent license is "discriminatory" if it does not include within the scope
of its coverage, prohibits the exercise of, or is conditioned on the
non-exercise of one or more of the rights that are specifically granted under
this License. You may not convey a covered work if you are a party to an
arrangement with a third party that is in the business of distributing
software, under which you make payment to the third party based on the extent
of your activity of conveying the work, and u [...]
+
+Nothing in this License shall be construed as excluding or limiting any
implied license or other defenses to infringement that may otherwise be
available to you under applicable patent law.
+
+12. No Surrender of Others' Freedom.
+
+If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not excuse
you from the conditions of this License. If you cannot convey a covered work
so as to satisfy simultaneously your obligations under this License and any
other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you to
collect a royalty for further conveying from those to whom you convey the
Program, the only way you could satisfy both those terms and this License would
be to refrain entirely from conveying the Program.
+
+13. Remote Network Interaction; Use with the GNU General Public License.
+
+Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users interacting
with it remotely through a computer network (if your version supports such
interaction) an opportunity to receive the Corresponding Source of your version
by providing access to the Corresponding Source from a network server at no
charge, through some standard or customary means of facilitating copying of
software. This Corresponding Source s [...]
+
+Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU General Public License into a single combined work, and to convey the
resulting work. The terms of this License will continue to apply to the part
which is the covered work, but the work with which it is combined will remain
governed by version 3 of the GNU General Public License.
+
+14. Revised Versions of this License.
+
+The Free Software Foundation may publish revised and/or new versions of the
GNU Affero General Public License from time to time. Such new versions will be
similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU Affero General Public
License "or any later version" applies to it, you have the option of following
the terms and conditions either of that numbered version or of any later
version published by the Free Software Foundation. If the Program does not
specify a version number of the GNU Affero General Public License, you may
choose any version ever published by the Fr [...]
+
+If the Program specifies that a proxy can decide which future versions of the
GNU Affero General Public License can be used, that proxy's public statement of
acceptance of a version permanently authorizes you to choose that version for
the Program.
+
+Later license versions may give you additional or different permissions.
However, no additional obligations are imposed on any author or copyright
holder as a result of your choosing to follow a later version.
+
+15. Disclaimer of Warranty.
+
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
PROVE DEFECTIVE, YOU ASSUME TH [...]
+
+16. Limitation of Liability.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WIT [...]
+
+17. Interpretation of Sections 15 and 16.
+
+If the disclaimer of warranty and limitation of liability provided above
cannot be given local legal effect according to their terms, reviewing courts
shall apply local law that most closely approximates an absolute waiver of all
civil liability in connection with the Program, unless a warranty or assumption
of liability accompanies a copy of the Program in return for a fee.
+
+END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively state the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your option)
any later version.
+
+ This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
+
+ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If your software can interact with users remotely through a computer network,
you should also make sure that it provides a way for users to get its source.
For example, if your program is a web application, its interface could display
a "Source" link that leads users to an archive of the code. There are many
ways you could offer source, and different solutions will be better for
different programs; see section 13 for the specific requirements.
+
+You should also get your employer (if you work as a programmer) or school, if
any, to sign a "copyright disclaimer" for the program, if necessary. For more
information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d0f1b9c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,62 @@
+# GNUnet in Go
+
+This repository has two parts:
+
+* `src/` contains a Go implementation of GNUnet: It is WIP and only provides a
+very limited coverage of GNUnet. The goal is to have a complete, functionally
+equivalent implementation of the GNUnet protocol in Go.
+
+* `doc/` contains documents for an implementation-agnostic specification of the
+GNUnet P2P protocols. It focuses on the peer messages, but also provides
+information on the internal messages.
+
+## Author(s)
+ * Bernd Fix <address@hidden>
+
+All files are licensed under GNU AGPL-3.0. Copyright by the authors.
+
+## Caveat
+
+THIS IS WORK-IN-PROGRESS AT A VERY EARLY STATE. DON'T EXPECT ANY COMPLETE
+DOCUMENTATION OR COMPILABLE, RUNNABLE OR EVEN OPERATIONAL SOURCE CODE.
+
+## Source code
+
+All source code is written in Golang (version 1.11+).
+
+### Dependencies
+
+3rd party libraries are used to provide helper functionality (logging, MPI,
+Ed25519 support and other crypto-related packages). Make sure the dependent
+packages are accessible through `GOPATH`. To install the dependencies:
+
+```bash
+$ go get -u golang.org/x/crypto/...
+$ go get -u golang.org/x/text/...
+$ go get -u github.com/bfix/gospel/...
+```
+
+### ./src/cmd folder
+
+* `vanityid`: Compute GNUnet vanity peer id for a given regexp pattern.
+
+```bash
+$ vanityid "^TST[0-9]"
+```
+
+* `gnunet-service-gns-go`: Implementation of the GNS service.
+
+* `peer_mockup`: test message exchange on the lowest level (transport).
+
+### ./src/gnunet folder
+
+Packages used to implement GNUnet protocols (currently only TRANSPORT
+and GNS).
+
+## Documentation
+
+* papers: 3rd party papers on GNUnet and crypto (mostly academic)
+* raw: raw ASCII protocol definition
+* reports: findings in the GNUnet source code
+* specification: texinfo protocol definition
+
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..660ded9
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+GOPATH=$(pwd):${GOPATH} go install -v -gcflags "-N -l" ./...
diff --git a/doc/raw/crypto.txt b/doc/raw/crypto.txt
new file mode 100644
index 0000000..ef3382f
--- /dev/null
+++ b/doc/raw/crypto.txt
@@ -0,0 +1,262 @@
+
+========================================================================
+0. Intro
+========================================================================
+
+GNUnet makes use of various cryptographic mechanisms (signing, hashing,
+encrypting, ...) in various different flavors. This section will shortly
+explain these mechanisms:
+
+------------------------------------------------------------------------
+0.1. Elliptic Curve Cryptography (ECC)
+------------------------------------------------------------------------
+
+Signatures in GNUnet are based on EdDSA [1],[2]. EdDSA is a secure and
+fast ECC signature scheme based on the twisted Edwards curve Ed25519. The
+private key is a 32 byte seed value (which is used to derive an integer
+'d'); the public key is the point '[d]B' where 'B' is the base point of
+Curve25519.
+
+ Used for: - long-term signing key
+ (persistent, public key is the peer ID)
+ - short-term signing key
+ (transient, valid for ~12h)
+
+The key exchange scheme is based on ECDHE with Curve25519 key pairs.
+
+
+
+
+Long-term signing key EdDSA
+Short-term signing key ECDSA on Ed25519
+Key for key exchange ECDHE on Curve25519
+Session key(s) AES / Twofish
+
+
+
+========================================================================
+1. Initial setup
+========================================================================
+
+------------------------------------------------------------------------
+1.1. Long-term signing key
+------------------------------------------------------------------------
+
+A peer generates a long-term signing key pair for the EdDSA signature
+algorithm with the Ed25519 curve from a random seed. For further details
+see the Ed25519 paper [1] and RFC 8032 [2].
+
+------------------------------------------------------------------------
+1.2. PeerIdentity
+------------------------------------------------------------------------
+
+The PeerIdentity is the public key of the long-term signing key of a
+peer. A human-readable representation of the PeerIdentity is a custom
+Base32 encoding of the public key (see A.1 for details)
+
+========================================================================
+2. Periodically
+========================================================================
+
+------------------------------------------------------------------------
+2.1. {REKEY_FREQUENCY: 12 hrs} Ephemeral key
+------------------------------------------------------------------------
+
+A Peer generates an ephemeral signing key pair for the EdDSA signature
+algorithm with the Ed25519 curve from a random seed. It creates a
+"CORE_EPHEMERAL_KEY" message (see "CORE protocol") and signs it with the
+long-term signing key created in step 1.1
+
+This ephemeral key will be used with the ECDHE key exchange algorithm to
+establish session keys for symmetrical encryption between the peers.
+
+========================================================================
+3. On demand
+========================================================================
+
+------------------------------------------------------------------------
+2.1. {on start-up, expiration or change of TRANSPORT protocols}
+------------------------------------------------------------------------
+
+The peer constructs a new HELLO message for itself and puts it into the
+DHT (see chapter "HELLO" protocol). A HELLO message contains the identity
+of the peer and a list of available end-points where the peer accepts
+connections from other peers. Each end-point defines an expiration date
+(to handle cases where the globally-visible IP address of a peer changes
+over time like for DSL clients). The HELLO in URI format looks like:
+
+ gnunet://hello/<peerid>[+<expiration_time>+<proto>+<ip:port>](+)
+
+========================================================================
+4. Establishing a channel to a target peer
+========================================================================
+
+------------------------------------------------------------------------
+4.1. Lookup HELLO of target peer
+------------------------------------------------------------------------
+
+The peer looks up the HELLO for a target peer with a known peer identity
+from either a local list of "known" peers with non-expired lifetime or
+looks up the HELLO message of the target peer in the DHT (see chapter
+"HELLO protocol"). It selects (one or more an end-points of the target
+peer (see chapter "ATS") for a connection to the target.
+
+------------------------------------------------------------------------
+4.2. Connecting to target end-point
+------------------------------------------------------------------------
+
+The peer connects to the selected end-point(s) of the target peer thus
+establishing a uni-directional (e.g. UDP) or bi-directional (e.g. TCP)
+channel to the target.
+
+In case of a uni-directional channel the target will try to establish
+a back-channel to the peer as soon as it knows how to do so (usually
+after step 4.3.1). For simplification we assume that a bi-directional
+message exchange between peer and target exists.
+
+------------------------------------------------------------------------
+4.3. HELLO protocol to negotiate session keys for transport
+------------------------------------------------------------------------
+
+The peer
+
+========================================================================
+[5] Message exchange
+========================================================================
+
+(1) Services queue messages for a target peer
+ - message is processed immediately (if requested by service)
+ - (smaller) messages are bundled (max 64k total)
+ => raw packet:
+ [msg_1][msg_2]...[msg_n]
+
+(2) raw packet is encrypted:
+ - AES-GCM (nonce, timestamp {obsolete in future version})
+ - Twofish
+ => transport packet
+
+========================================================================
+[6] Transport
+========================================================================
+
+-------------------------------------------------
+(1) TCP:
+-------------------------------------------------
+
+ - direct message exchange (bi-directional)
+
+-------------------------------------------------
+(2) UDP:
+-------------------------------------------------
+
+ Each UDP packet has the following structure:
+ - peerid of sender (32 bytes)
+ { future extension:
+ - ephemeral key
+ - signature of payload (64 bytes)
+ - HMAC (32/64 bytes)
+ }
+ - payload (up to MTU-header size)
+
+========================================================================
+[A] Appendices
+========================================================================
+
+------------------------------------------------------------------------
+(1) Base32 conversion between binary data and string representation
+------------------------------------------------------------------------
+
+A binary array of size m is viewed as a consecutive stream of bits from
+left to right. Bytes are ordered with ascending address, while bits (in
+a byte) are ordered MSB to LSB.
+
+For encoding the stream is partitioned into 5-bit chunks; the last chunk
+is right-padded with 0's if 8*m is not divisible by 5. Each chunk (value
+between 0 and 31) is encoded into a character; the mapping for encoding
+is the same as in [3].
+
+For decoding each character is converted to a 5-bit chunk based on the
+encoder mapping (with one addition: the character 'U' maps to the value
+27). The chunks are concatenated to produce a bit stream to be stored
+in the output array.
+
+========================================================================
+B. Crypto-related constants
+========================================================================
+
+-------------------------------------------------
+B.1. Signature purpose
+-------------------------------------------------
+
++----------------------------------+-------+--------------------------------------------------------------------+
+| Name | Value | Comment
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_TEST | 0 | Only used in test cases!
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_TRANSPORT_PONG_OWN | 1 | Signature for confirming that
this peer uses a particular address. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_TRANSPORT_DISCONNECT | 2 | Signature for confirming that
this peer intends to disconnect. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_REVOCATION | 3 | Signature for confirming a key
revocation. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_NAMESPACE_ADVERTISEMENT | 4 | Signature for a
namespace/pseudonym advertisement. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_PEER_PLACEMENT | 5 | Signature by which a peer affirms
that it is providing a certain |
+| | | bit of content (used in LOCation
URIs). |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_FS_KBLOCK | 6 | Obsolete, legacy value.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_FS_SBLOCK | 7 | Obsolete, legacy value.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_FS_NBLOCK | 8 | Obsolete, legacy value.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_FS_NBLOCK_KSIG | 9 | Obsolete, legacy value.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_RESOLVER_RESPONSE | 10 | Signature of an DNS_Advertisement
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_DNS_RECORD | 11 |
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_CHAT_MESSAGE | 12 | Signature of a chat message.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_CHAT_RECEIPT | 13 | Signature of confirmation receipt
for a chat message. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_NSE_SEND | 14 | Signature of a network size
estimate message. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_GNS_RECORD_SIGN | 15 | Signature of a gnunet naming
system record block. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_ECC_KEY | 16 | Purpose is to set a session key.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG__FS_UBLOCK | 17 | UBlock Signature, done using DSS,
not ECC |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_REGEX_ACCEPT | 18 | Accept state in regex DFA. Peer
affirms that it offers the |
+| | | matching service.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_MULTICAST_MESSAGE | 19 | Signature of a multicast message
sent by the origin. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_CONVERSATION_RING | 20 | Signature of a conversation ring.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_SECRETSHARING_DKG1 | ? 22 | Signature for the first round of
distributed key generation. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_SECRETSHARING_DKG2 | ? 23 | Signature for the second round of
distributed key generation. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_SECRETSHARING_DECRYPTION | 23 | Signature for cooperative
decryption. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_MULTICAST_REQUEST | 24 | Signature of a multicast request
sent by a member. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_SENSOR_ANOMALY_REPORT | 25 | Signature for a sensor anomaly
report message. |
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_GNUID_TOKEN | 26 | Signature for a GNUid Token.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_GNUID_TICKET | 27 | Signature for a GNUid Ticket.
|
++----------------------------------+-------+--------------------------------------------------------------------+
+| SIG_CREDENTIAL | 28 | Signature for a GNUnet
credential. |
++----------------------------------+-------+--------------------------------------------------------------------+
+
+========================================================================
+[B] References
+========================================================================
+
+[1] https://tools.ietf.org/rfc/rfc8032.txt
+[2] https://ed25519.cr.yp.to/ed25519-20110926.pdf
+[3] https://www.crockford.com/wrmg/base32.html
+
diff --git a/doc/raw/protocols/core.txt b/doc/raw/protocols/core.txt
new file mode 100644
index 0000000..54efdc0
--- /dev/null
+++ b/doc/raw/protocols/core.txt
@@ -0,0 +1,38 @@
+
+
+
+========================================================================
+1. CORE Protocol
+========================================================================
+
+========================================================================
+A. Message Formats
+========================================================================
+
+------------------------------------------------------------------------
+A.1 CORE_EPHEMERAL_KEY message
+------------------------------------------------------------------------
+
++-------------+------------------+------------------------------------------+
++ Field | Size / type | Comment |
++-------------+------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++-------------+------------------+------------------------------------------+
+| type | 2 / uint16 (nbo) | Message type: CORE_EPHEMERAL_KEY (88) |
++-------------+------------------+------------------------------------------+
+| sender_stat | 4 / uint32 (nbo) | enum PeerStateMachine |
++-------------+------------------+------------------------------------------+
+| signature | 64 | EdDSA signature |
++-------------+------------------+------------------------------------------+
+| sign_length | 4 / uint32 (nbo) | Length of signed block (incl. this) |
++-------------+------------------+------------------------------------------+
+| purpose | 4 / uint32 (nbo) | Signature purpose (see chapter "CRYPTO") |
++-------------+------------------+------------------------------------------+
+| create_time | 8 / uint64 (nbo) | Time of key creation. |
++-------------+------------------+------------------------------------------+
+| expire_time | 8 / uint64 (nbo) | Time of key expiration. |
++-------------+------------------+------------------------------------------+
+| eph_key | 32 | Ephemeral EdDSA public key |
++-------------+------------------+------------------------------------------+
+| peerid | 32 | Peer identity (EdDSA public key) |
++-------------+------------------+------------------------------------------+
diff --git a/doc/raw/protocols/hello.txt b/doc/raw/protocols/hello.txt
new file mode 100644
index 0000000..e3a64d0
--- /dev/null
+++ b/doc/raw/protocols/hello.txt
@@ -0,0 +1,58 @@
+
+
+========================================================================
+1. HELLO Protocol
+========================================================================
+
+The HELLO protocol (see chapter "HELLO Protocol" for details) is a plain-
+text (unencrypted) message exchange to establish a secure (encrypted)
+message exchange between the peers after a physical connection has been
+established.
+
+4.3.1 The peer sends its HELLO message: This tells the target which
+ peer is connecting. The target retrieves the peer identity (thus
+ learning the long-term signature verification key (public EdDSA
+ key) and a list of available end-points for a possibly required
+ back-channel to the peer. If the target accepts the peer (not on
+ a black-list or filtered out) and the channel is
uni-directional,
+ the target creates a back-channel to the peer. If the target
+ does not accept the peer and the channel is bi-directional, the
+ target resets the connection.
+
+(5) peers exchange (unencrypted) and validate ephemeral keys and derive
+ a shared secret (ECDHE)
+
+(6) the shared secret is used to derive (HKDF) two session keys for
+ AES-256 and Twofish
+
+
+========================================================================
+A. Message Formats
+========================================================================
+
+------------------------------------------------------------------------
+A.1 HELLO
+------------------------------------------------------------------------
+
++-------------+------------------+--------------------------------------+
++ Field | Size / type | Comment |
++-------------+------------------+--------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++-------------+------------------+--------------------------------------+
+| type | 2 / uint16 (nbo) | GNUnet message type = HELLO (17) |
++-------------+------------------+--------------------------------------+
+| friend_only | 4 / uint32 (nbo) | = 1: do not gossip this HELLO |
++-------------+------------------+--------------------------------------+
+| peerid | 32 | EdDSA public key (long-term) |
++-------------+------------------+--------------------------------------+
+| addresses | variable | List of variable length addresses |
++-+-----------+------------------+--------------------------------------+
+ | transport | variable | Name of transport ('\0' terminated) |
+ +-----------+------------------+--------------------------------------+
+ | addr_size | 2 / uint16 (nbo) | Length of address |
+ +-----------+------------------+--------------------------------------+
+ | expire_on | 8 / uint64 (nbo) | UNIX timestamp |
+ +-----------+------------------+--------------------------------------+
+ | address | adr_size | Address (transport-dependend) |
+ +-----------+------------------+--------------------------------------+
+
diff --git a/doc/raw/transport.txt b/doc/raw/transport.txt
new file mode 100644
index 0000000..437dbad
--- /dev/null
+++ b/doc/raw/transport.txt
@@ -0,0 +1,306 @@
+
+########################################################################
+1. Establishing a GNUnet session between two peers
+########################################################################
+
+A session between two GNUnet peers enables the exchange of P2P messages
+between them. A session is a wrapper around two uni-directional channels
+(A -> B, B -> A) that in theory can even utilize two distinct transport
+mechanisms (e.g. UDP and HTTPS).
+
+The most common (and reliable) transport mechanism is TCP/IP that has
+the additional advantage of being bi-directional - it bundles channel
+and back-channel into a single transport. The following sections will
+describe how a TCP-based session between to peers A (initiator) and B
+(target) is established.
+
+After negotiating the session and a shared session key, the exchange of
+messages between A and B will be encrypted with forward secrecy (see
+chapter "Crypto" for more details).
+
+
+========================================================================
+1.1. Pre-Requisites
+========================================================================
+
+Each peer has a unique peer ID that is the public key of the long-term
+EdDSA signing key (see chapter "Crypto" for details). It is represented
+as a 32 byte binary.
+
+Each peer also has a list of end-points that can be used by other peers
+to connect to it. An end-point specifies the transport protocol (e.g.
+TCP) and an address (e.g. an IPv4 or IPv6 address and a port). The
+format of an address is of course dependent on the transport protocol;
+an HTTPS transport for example requires an URL address.
+
+We assume that the initiator A of a session knows how to connect to an
+address on target B. The bootstrap is usually done by hard-coding a
+single, reliable and available GNUnet peer identity and its addresses.
+Every peer participating in the network will "learn" about more peers
+and their addresses later in the process.
+
+
+========================================================================
+1.2. GNUnet message format
+========================================================================
+
+The communication between two peers is based on GNUnet messages. An
+individual GNUnet message cannot exceed the size of 64kB; it has at
+least a size of 4 bytes (just a header with an empty payload).
+
+All GNUnet messages have a standard header of the following form:
+
++--------+------------------+------------------------------------------+
+| Field | Size / type | Comment |
++--------+------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++--------+------------------+------------------------------------------+
+| type | 2 / uint16 (nbo) | GNUnet message type |
++--------+------------------+------------------------------------------+
+
+The annotation "(nbo)" indicates "network-byte order"; integers of that
+kind are stored in "big-endian" format (MSB first) in the message body.
+
+The field types used in messages are mostly self-explanatory and are used
+in nearly all programming languages. The following field types need an
+explanation:
+
+ string a sequence of 8-bit characters delimited by '\0'
+ (C/C++ character string)
+
+ time uint64 value of the number of microseconds since
+ midnight Jan 1st, 1970 (Unix epoch in usec)
+
+ address uint8 array of variable length (with no terminator)
+ The internal structure of an address depends on
the
+ transport protocol used (TCP and UDP addresses
for
+ example are composed of a 4 (IPv4) or 16 (IPv6)
uint8
+ array followed by the port as uint16 (nbo)).
+
+
+========================================================================
+1.3. Establishing a session between peers (TCP connection)
+========================================================================
+
+Peer A (initiator) establishes a TCP connection to an address of peer B.
+After the TCP/IP connection is built, peer A starts the message exchange
+to establish a GNUnet session with the other peer.
+
+
+------------------------------------------------------------------------
+1.3.1. Exchange TRANSPORT_TCP_WELCOME messages
+------------------------------------------------------------------------
+
+Peer A sends a TRANSPORT_TCP_WELCOME message to peer B, so that peer B
+can learn the peer identity of the initiating peer:
+
++-----------------------------------------------------------------------+
+| TRANSPORT_TCP_WELCOME |
++---------+------------------+------------------------------------------+
+| Field | Size / type | Comment |
++---------+------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++---------+------------------+------------------------------------------+
+| type | 2 / uint16 (nbo) | TRANSPORT_TCP_WELCOME (61) |
++---------+------------------+------------------------------------------+
+| peer_id | 32 | Peer ID of sender (A) |
++---------+------------------+------------------------------------------+
+
+
+Peer B replies with a TRANSPORT_TCP_WELCOME message, so that peer A can
+check it is talking to the correct target peer B (and terminate the TCP
+connection if that is not the case).
+
+Peer B can also send a TRANSPORT_SESSION_QUOTA message to inform peer A
+about a the maximum bandwidth it has assigned to this session. Only rogue
+peers ignore this request:
+
++-----------------------------------------------------------------------+
+| TRANSPORT_SESSION_QUOTA |
++---------+------------------+------------------------------------------+
+| Field | Size / type | Comment |
++---------+------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++---------+------------------+------------------------------------------+
+| quota | 4 / uint32 (nbo) | Assigned bandwith to session (B/s) |
++---------+------------------+------------------------------------------+
+
+
+Peer B can also send a TRANSPORT_SESSION_SYN message to
+
+
+EXAMPLE:
+--------
+
+A --> B 00:24:00:3d:d3:b3:ac:f3:85:0e:cc:df:82:dd:fe:45
+ 03:08:71:8c:51:aa:e6:52:bf:b6:30:e5:17:13:79:dd
+ 01:bc:89:56
+
+ = TcpWelcomeMsg{'TESTSWW51V6DZ0PXZS2G623HHH8TNSJJQYV31S8Q2DWXT0DWH5B0'}
+
+B --> A 00:24:00:3d:92:dc:bf:39:40:2d:c6:3c:97:a6:81:e0
+ fc:d8:7c:74:17:d3:a3:8c:52:fd:e0:49:bc:d0:1c:0a
+ 0b:8c:02:51
+
+ = TcpWelcomeMsg{'JBEBYEA05Q33S5X6G7GFSP3WEGBX78WCABYY0JDWT0E0M2WC098G'}
+
+B --> A 00:08:01:7b:ff:ff:ff:ff
+
+ = SessionQuotaMsg{4.000GB/s}
+
+
+------------------------------------------------------------------------
+1.3.2. Send HELLO message
+------------------------------------------------------------------------
+
+
+------------------------------------------------------------------------
+1.3.2. Send HELLO message
+------------------------------------------------------------------------
+
+Peer A sends a HELLO message to peer B to announce its peer identity
+and its list of available end-points (list of 0 or more HELLOADDR blocks):
+
++----------------------------------------------------------------------------+
+| HELLO |
++-------------+-------------------+------------------------------------------+
+| Field | Size / type | Comment |
++-------------+-------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++-------------+-------------------+------------------------------------------+
+| type | 2 / uint16 (nbo) | HELLO (17) |
++-------------+-------------------+------------------------------------------+
+| friend_only | 32 / uint32 (nbo) | =1: don't gossip HELLO |
++-------------+-------------------+------------------------------------------+
+| peer_id | 32 | Peer ID of sender |
++-------------+-------------------+------------------------------------------+
+| addr_list | * / []HELLOADDR | List of HELLO addresses (can be empty) |
++-------------+-------------------+------------------------------------------+
+
+The field 'friend_only' is either 0 (=NO) or 1 (=YES) and specifies if the
+receiving peer may gossip this HELLO message to other peers (see section
+"GOSSIP Protocol" for details).
+
+As mentioned earlier, Peer B could build a separate back-channel to peer
+A for a GNUnet connection although that is not necessary for our TCP
+connection which is bi-directional. In this case (TCP), the HELLO message
+may contain no end-point specifications (address_list is empty):
+
+If the HELLO message contains HELLOADDR blocks, these have the following
+format:
+
++----------------------------------------------------------------------------+
+| HELLOADDR |
++-------------+-------------------+------------------------------------------+
+| Field | Size / type | Comment |
++-------------+-------------------+------------------------------------------+
+| transport | * / string | Name of transport |
++-------------+-------------------+------------------------------------------+
+| addr_size | 2 / uint16 (nbo) | Size of address entry |
++-------------+-------------------+------------------------------------------+
+| expire_on | 8 / time (nbo) | Expiration date |
++-------------+-------------------+------------------------------------------+
+| address | * / address | Address specification (addr_size bytes) |
++-------------+-------------------+------------------------------------------+
+
+Peers should persistently store received HELLO messages (until the addresses
+contained in it expire).
+
+EXAMPLE:
+--------
+
+==> 00:3a:00:11:00:00:00:00:d3:b3:ac:f3:85:0e:cc:df
+ 82:dd:fe:45:03:08:71:8c:51:aa:e6:52:bf:b6:30:e5
+ 17:13:79:dd:01:bc:89:56:74:63:70:00:00:04:00:05
+ 70:c2:6b:b0:cc:92:ac:11:00:07
+
+ = HelloMsg{TESTSWW51V6DZ0PXZS2G623HHH8TNSJJQYV31S8Q2DWXT0DWH5B0,
+
0,[Address{tcp:172.17.0.7,2018-07-12T00:26:56.000434Z}]}
+
+
+------------------------------------------------------------------------
+1.3.2. PING/PONG handshake
+------------------------------------------------------------------------
+
+Peer A sends a TRANSPORT_PING message to Peer B:
+
++----------------------------------------------------------------------------+
+| TRANSPORT_PING |
++-------------+-------------------+------------------------------------------+
+| Field | Size / type | Comment |
++-------------+-------------------+------------------------------------------+
+| size | 2 / uint16 (nbo) | Total length of message (incl. size) |
++-------------+-------------------+------------------------------------------+
+| type | 2 / uint16 (nbo) | TRANSPORT_PING (372) |
++-------------+-------------------+------------------------------------------+
+| challenge | 4 / uint32 | Challenge code (to ensure fresh reply) |
++-------------+-------------------+------------------------------------------+
+| target_id | 32 | Peer ID of target peer |
++-------------+-------------------+------------------------------------------+
+| addr | * / address | Address on target peer |
++-------------+-------------------+------------------------------------------+
+
+
+Example
+==> 00:36:01:74:54:94:ab:a1:92:dc:bf:39:40:2d:c6:3c
+ 97:a6:81:e0:fc:d8:7c:74:17:d3:a3:8c:52:fd:e0:49
+ bc:d0:1c:0a:0b:8c:02:51:74:63:70:00:00:00:00:00
+ ac:11:00:05:08:26
+
+ = PingMsg{JBEBYEA05Q33S5X6G7GFSP3WEGBX78WCABYY0JDWT0E0M2WC098G,
+ Address{tcp:172.17.0.5:2086},2712376404}
+
+
+
+<== SessionQuotaMsg{4.000GB/s}
+ [0008017bffffffff]
+<== SessionSyn{2018-07-11T12:26:56.000763Z}
+ [0010017700000000000570b85cc51ddb]
+==> SessionSynAck{2018-07-11T12:26:56.000763Z}
+ [0010017800000000000570b85cc51ddb]
+<== PongMsg{?,Address{tcp:172.17.0.5:2086},2712376404}
+
[006a01755494aba1b044e5b7249257eeb177079b431aff9d225f85e14b28b2a4f2f88ac2412d6425ab58bd7d13d48be43bc7482c23e94c94519c4701ca93af2f0c32631071397f050000002200000001000570b93358c20c0000000e7463700000000000ac1100050826]
+*** PONG signature verified
+<== SessionAck{}
+ [00040179]
+
+
+========================================================================
+1.2. Peer B initiates a connection to Peer A
+========================================================================
+
+<== 00:24:00:3d:92:dc:bf:39:40:2d:c6:3c:97:a6:81:e0
+ fc:d8:7c:74:17:d3:a3:8c:52:fd:e0:49:bc:d0:1c:0a
+ 0b:8c:02:51
+
+ = TcpWelcomeMsg{'JBEBYEA05Q33S5X6G7GFSP3WEGBX78WCABYY0JDWT0E0M2WC098G'}
+
+==> 00:24:00:3d:d3:b3:ac:f3:85:0e:cc:df:82:dd:fe:45
+ 03:08:71:8c:51:aa:e6:52:bf:b6:30:e5:17:13:79:dd
+ 01:bc:89:56
+
+ = TcpWelcomeMsg{'TESTSWW51V6DZ0PXZS2G623HHH8TNSJJQYV31S8Q2DWXT0DWH5B0'}
+
+<== 00:28:00:11:00:00:00:00:92:dc:bf:39:40:2d:c6:3c
+ 97:a6:81:e0:fc:d8:7c:74:17:d3:a3:8c:52:fd:e0:49
+ bc:d0:1c:0a:0b:8c:02:51
+
+ = HelloMsg{JBEBYEA05Q33S5X6G7GFSP3WEGBX78WCABYY0JDWT0E0M2WC098G,0,[]}
+
+<==
PingMsg{TESTSWW51V6DZ0PXZS2G623HHH8TNSJJQYV31S8Q2DWXT0DWH5B0,Address{tcp:172.17.0.7:2086},279093666}
+
[00360174a2a1a210d3b3acf3850eccdf82ddfe450308718c51aae652bfb630e5171379dd01bc89567463700000000000ac1100070826]
+==> PongMsg{OK,Address{tcp:172.17.0.7:2086},279093666}
+
[006a0175a2a1a210537ed664528db72e7903f6c34f8efdeb34597a77f68b1505901b3e1ce45c24337ae00e408dfcf94d5f7caa370241bfbd3bc12dcb0e0d0d9a60d3d662454fd40f0000002200000001000570c20d3fa97e0000000e7463700000000000ac1100070826]
+<== SessionQuotaMsg{4.000GB/s}
+ [0008017bffffffff]
+<== SessionSyn{2018-07-11T12:00:31.000255Z}
+ [0010017700000000000570b7fe554827]
+==> SessionSynAck{2018-07-11T12:00:31.000255Z}
+ [0010017800000000000570b7fe554827]
+<== SessionAck{}
+ [00040179]
+*** CONNECTION etsablished with peer
'JBEBYEA05Q33S5X6G7GFSP3WEGBX78WCABYY0JDWT0E0M2WC098G'
+
+
+
+
diff --git a/doc/specification/.gitignore b/doc/specification/.gitignore
new file mode 100644
index 0000000..a6e72b2
--- /dev/null
+++ b/doc/specification/.gitignore
@@ -0,0 +1,12 @@
+*.fn
+*.fns
+*.ky
+*.pg
+*.tp
+*.vr
+*.aux
+*.cp
+*.cps
+*.log
+*.toc
+*.pdf
diff --git a/doc/specification/chapters/messages.texi
b/doc/specification/chapters/messages.texi
new file mode 100644
index 0000000..6c93ba1
--- /dev/null
+++ b/doc/specification/chapters/messages.texi
@@ -0,0 +1,7 @@
+@node Messages
+@chapter Messages
+
+@c *********************************************************************
+@include chapters/messages/transport.texi
+@c *********************************************************************
+
diff --git a/doc/specification/chapters/messages/transport.texi
b/doc/specification/chapters/messages/transport.texi
new file mode 100644
index 0000000..1a63a82
--- /dev/null
+++ b/doc/specification/chapters/messages/transport.texi
@@ -0,0 +1,47 @@
+@node Transport
+@section Transport
+
+@emph{Transport} in this chapter refers to the transport of GNUnet messages
+as sent and received by the various subsystems of GNUnet (like DHT, NSE, FS,
+GNS, ...) between peers in the P2P network. For the purpose of this chapter
+such a message `M` is treated as a binary object of size `m` (in bytes).
+
+Every node (peer) in GNUnet is identified by the hash codes of its public key.
+
+
+@table @samp
+
+@item StartMessage
+
+Message from the transport service to the library asking to check if both
+processes agree about this peers identity.
+
+@example
++--------+--------+--------+--------+--------+--------+--------+--------+
+| msg_size | msg_type | options |
++--------+--------+--------+--------+--------+--------+--------+--------+
+| |
++ +
+| |
++ peer_identity +
+| |
++ +
+| |
++--------+--------+--------+--------+--------+--------+--------+--------+
+@end example
+
+@itemize
+ @item @samp{msg_size}
+ uint16: size of the message = 40 bytes
+
+ @item @samp{msg_type}
+ uint16: message type = GNUNET_MESSAGE_TYPE_TRANSPORT_START
+
+ @item
+
+ @item @samp{peer_identity}
+ Identity we think we have. If it does not match, the receiver should
+ print out an error message and disconnect.
+@end itemize
+
+@end table
diff --git a/doc/specification/chapters/overview.texi
b/doc/specification/chapters/overview.texi
new file mode 100644
index 0000000..74a9b64
--- /dev/null
+++ b/doc/specification/chapters/overview.texi
@@ -0,0 +1,4 @@
+@node Overview
+@chapter Overview
+
+t.b.d.
diff --git a/doc/specification/chapters/services.texi
b/doc/specification/chapters/services.texi
new file mode 100644
index 0000000..4a03dc8
--- /dev/null
+++ b/doc/specification/chapters/services.texi
@@ -0,0 +1,31 @@
+@node Services
+@chapter Services
+
+A GNUnet instance running on one node is an assembly of services that exchange
+messages (see Chapter "Messages" for details) -- among themselves and with
+services running on other nodes.
+
+GNUnet services on a node usually utilize other, more basic GNUnet services
+to provide their functionality. The following graph shows the dependencies
+and message channels between the most basic GNUnet services:
+
+@float GNUnet services
+@image{chapters/services/services-01,,7cm,,.png}
+@caption{dependencies}
+@end float
+
+@node Mandatory services for a GNUnet node
+@section Mandatory services for a GNUnet node
+
+The services marked with a background color in the above figure comprise the
+smallest set of services a node must provide to be useful for the network --
+even if it is only providing a simple DHT storage service. These mandatory
+services are:
+
+@c *********************************************************************
+@include chapters/services/core.texi
+@c *********************************************************************
+
+@c *********************************************************************
+@include chapters/services/transport.texi
+@c *********************************************************************
diff --git a/doc/specification/chapters/services/core.texi
b/doc/specification/chapters/services/core.texi
new file mode 100644
index 0000000..fd1de3e
--- /dev/null
+++ b/doc/specification/chapters/services/core.texi
@@ -0,0 +1,63 @@
+
+@subsection CORE
+
+One of the most important services in GNUnet is the CORE service managing
+connections and handling encryption between peers.
+
+Every peer has a private (secret) key and an associated public key for the
+Ed25519 signature scheme (see @url{https://gnunet.org/ed25519}); this keypair
+is usually created if a GNUnet instance is started for the first time. The
+keypair is unique, so the Ed25519 public key (32 octets in standard compact
+format) serves as a GNUnet @dfn{peer identity}.
+
+A @dfn{connection} is a bi-directional channel suitable for message exchange
+between two peers. The connection uses a specific transport method (e.g.
+TCP/IP) available on both end-points. The TRANSPORT service is creating,
+processing and dropping connections to other peers on behalf of CORE.
+
+The CORE service will try to maintain a certain number of open connections to
+other peers; this number depends on the estimated size (number of participants)
+of the network as determined by the NSE service (Network Size Estimation). If
+@math{s} is the size of the network, than the number of concurrent connections
+is @math{ n = \lceil log_2\;s \rceil}.
+
+To connect to the network, a peer needs to learn about the identities of other
+peers on the network. This is done by providing a single (active) peer identity
+(and its addresses) at start-up; in the course of exchanging messages with this
+peer CORE will discover the identities of other nodes it can try connect to.
+CORE will maintain a persistent database of node identities it has discovered
+(and probably has been connected to).
+
+A node publishes its identity and addresses (initially and in case of address
+changes) in the DHT, so other nodes can look it up and connect to it if
+desired. In the same way CORE uses the DHT to lookup addresses of peers (based
+on their identity) it want to establish a connection with.
+
+After a connection is established, the peers will start exchanging messages
+over it.
+
+Out-bound GNUnet messages (originating from local GNUnet services including
+CORE itself) are queued for further processing. CORE decides if and when a
message is to be sent to
+another peer. Based on the maximum size of the out-bound transport packet
(MTU, depends
+on the transport method used), it can either bundle smaller GNUnet messages
+into a single transport packet, or create a sequence of fragments from a single
+GNUnet message, in case the GNUnet message is larger than a transport
+packet. If the GNUnet message(s) do not fill a transport packet completely,
+the transport packet is padded with random data to its maximum size. A
+transport packet is than encrypted with a session key negotiated between the
+two peers during the creation of a connection (see section on "Packet
+encryption") before leaving the peer.
+
+In-bound transport packets are first decrypted and than either split into
+multiple GNUnet messages or defragmented (reassembled) in case of a large
+GNUnet message. The received messages are either processed by CORE itself, are
+forwarded to local GNUnet services or relayed to other peers. Messages that
+cannot be handled (e.g. because a local service is temporarily unavailable)
+are simply dropped.
+
+@subsubsection Cryptographic operations
+
+@subsubsection GNUnet Anonymization Protocol
+
+The protocol governing this process is the GNUnet Anonymization Protocol (GAP)
+(see @url{https://gnunet.org/sites/default/files/aff.pdf,,paper}).
diff --git a/doc/specification/chapters/services/services-01.dia
b/doc/specification/chapters/services/services-01.dia
new file mode 100644
index 0000000..09b5bc3
Binary files /dev/null and
b/doc/specification/chapters/services/services-01.dia differ
diff --git a/doc/specification/chapters/services/services-01.png
b/doc/specification/chapters/services/services-01.png
new file mode 100644
index 0000000..776b165
Binary files /dev/null and
b/doc/specification/chapters/services/services-01.png differ
diff --git a/doc/specification/chapters/services/transport.texi
b/doc/specification/chapters/services/transport.texi
new file mode 100644
index 0000000..683b85f
--- /dev/null
+++ b/doc/specification/chapters/services/transport.texi
@@ -0,0 +1,25 @@
+
+@subsection TRANSPORT
+
+The TRANSPORT service handles all message exchanges between a local peer and
+other peers on the network. It can -- depending on the computer hardware it
+is running on -- support multiple transport methods between peers: TCP/IP,
+UDP/IP, ICMP, HTTP, Bluetooth, WiFi and others.
+
+Each transport method has its unique way of specifying a peer address; TCP/IP
+expects an IP address and a port number, while HTTP expects an URL. So a
+single peer can have multiple addresses (one for each available transport
+method). CORE links all these addresses to one peer identity. While a peer
+address can (and often do) change over time, the peer identity is fixed.
+
+The TRANSPORT service establishes, maintains, processes and drops connections
+with other peers on request of the CORE service. If a new connection to a peer
+identity is requested, the ATS (Automatic Transport Selection) decides which
+available transport method should be used. To improve performance and
+reliability, multiple channels on different transport methods can be created
+between two peers at the same time; the sender sends the next message on the
+channel with the best throughput.
+
+Connection requests from other peers can be filtered by the TRANSPORT service
+(e.g. by implementing a black-list of banned peers), all other requests are
+forwarded to the CORE service for validation and approval.
diff --git a/doc/specification/fdl-1.3.texi b/doc/specification/fdl-1.3.texi
new file mode 100644
index 0000000..cb71f05
--- /dev/null
+++ b/doc/specification/fdl-1.3.texi
@@ -0,0 +1,505 @@
+@c The GNU Free Documentation License.
+@center Version 1.3, 3 November 2008
+
+@c This file is intended to be included within another document,
+@c hence no sectioning command or @node.
+
+@display
+Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation,
Inc.
+@uref{http://fsf.org/}
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+@end display
+
+@enumerate 0
+@item
+PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document @dfn{free} in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of ``copyleft'', which means that derivative
+works of the document must themselves be free in the same sense. It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does. But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book. We recommend this License
+principally for works whose purpose is instruction or reference.
+
+@item
+APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License. Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein. The ``Document'', below,
+refers to any such manual or work. Any member of the public is a
+licensee, and is addressed as ``you''. You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A ``Modified Version'' of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A ``Secondary Section'' is a named appendix or a front-matter section
+of the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall
+subject (or to related matters) and contains nothing that could fall
+directly within that overall subject. (Thus, if the Document is in
+part a textbook of mathematics, a Secondary Section may not explain
+any mathematics.) The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The ``Invariant Sections'' are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License. If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant. The Document may contain zero
+Invariant Sections. If the Document does not identify any Invariant
+Sections then there are none.
+
+The ``Cover Texts'' are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License. A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A ``Transparent'' copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters. A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text. A copy that is not ``Transparent'' is called ``Opaque''.
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, La@TeX{} input
+format, SGML or XML using a publicly available
+DTD, and standard-conforming simple HTML,
+PostScript or PDF designed for human modification. Examples
+of transparent image formats include PNG, XCF and
+JPG. Opaque formats include proprietary formats that can be
+read and edited only by proprietary word processors, SGML or
+XML for which the DTD and/or processing tools are
+not generally available, and the machine-generated HTML,
+PostScript or PDF produced by some word processors for
+output purposes only.
+
+The ``Title Page'' means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page. For works in
+formats which do not have any title page as such, ``Title Page'' means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+The ``publisher'' means any person or entity that distributes copies
+of the Document to the public.
+
+A section ``Entitled XYZ'' means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language. (Here XYZ stands for a
+specific section name mentioned below, such as ``Acknowledgements'',
+``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
+of such a section when you modify the Document means that it remains a
+section ``Entitled XYZ'' according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document. These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+@item
+VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no other
+conditions whatsoever to those of this License. You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute. However, you may accept
+compensation in exchange for copies. If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+@item
+COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover. Both covers must also clearly and legibly identify
+you as the publisher of these copies. The front cover must present
+the full title with all words of the title equally prominent and
+visible. You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to give
+them a chance to provide you with an updated version of the Document.
+
+@item
+MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it. In addition, you must do these things in the Modified Version:
+
+@enumerate A
+@item
+Use in the Title Page (and on the covers, if any) a title distinct
+from that of the Document, and from those of previous versions
+(which should, if there were any, be listed in the History section
+of the Document). You may use the same title as a previous version
+if the original publisher of that version gives permission.
+
+@item
+List on the Title Page, as authors, one or more persons or entities
+responsible for authorship of the modifications in the Modified
+Version, together with at least five of the principal authors of the
+Document (all of its principal authors, if it has fewer than five),
+unless they release you from this requirement.
+
+@item
+State on the Title page the name of the publisher of the
+Modified Version, as the publisher.
+
+@item
+Preserve all the copyright notices of the Document.
+
+@item
+Add an appropriate copyright notice for your modifications
+adjacent to the other copyright notices.
+
+@item
+Include, immediately after the copyright notices, a license notice
+giving the public permission to use the Modified Version under the
+terms of this License, in the form shown in the Addendum below.
+
+@item
+Preserve in that license notice the full lists of Invariant Sections
+and required Cover Texts given in the Document's license notice.
+
+@item
+Include an unaltered copy of this License.
+
+@item
+Preserve the section Entitled ``History'', Preserve its Title, and add
+to it an item stating at least the title, year, new authors, and
+publisher of the Modified Version as given on the Title Page. If
+there is no section Entitled ``History'' in the Document, create one
+stating the title, year, authors, and publisher of the Document as
+given on its Title Page, then add an item describing the Modified
+Version as stated in the previous sentence.
+
+@item
+Preserve the network location, if any, given in the Document for
+public access to a Transparent copy of the Document, and likewise
+the network locations given in the Document for previous versions
+it was based on. These may be placed in the ``History'' section.
+You may omit a network location for a work that was published at
+least four years before the Document itself, or if the original
+publisher of the version it refers to gives permission.
+
+@item
+For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
+the Title of the section, and preserve in the section all the
+substance and tone of each of the contributor acknowledgements and/or
+dedications given therein.
+
+@item
+Preserve all the Invariant Sections of the Document,
+unaltered in their text and in their titles. Section numbers
+or the equivalent are not considered part of the section titles.
+
+@item
+Delete any section Entitled ``Endorsements''. Such a section
+may not be included in the Modified Version.
+
+@item
+Do not retitle any existing section to be Entitled ``Endorsements'' or
+to conflict in title with any Invariant Section.
+
+@item
+Preserve any Warranty Disclaimers.
+@end enumerate
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant. To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled ``Endorsements'', provided it contains
+nothing but endorsements of your Modified Version by various
+parties---for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version. Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity. If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+@item
+COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy. If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled ``History''
+in the various original documents, forming one section Entitled
+``History''; likewise combine any sections Entitled ``Acknowledgements'',
+and any sections Entitled ``Dedications''. You must delete all
+sections Entitled ``Endorsements.''
+
+@item
+COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other documents
+released under this License, and replace the individual copies of this
+License in the various documents with a single copy that is included in
+the collection, provided that you follow the rules of this License for
+verbatim copying of each of the documents in all other respects.
+
+You may extract a single document from such a collection, and distribute
+it individually under this License, provided you insert a copy of this
+License into the extracted document, and follow this License in all
+other respects regarding verbatim copying of that document.
+
+@item
+AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an ``aggregate'' if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+@item
+TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections. You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers. In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled ``Acknowledgements'',
+``Dedications'', or ``History'', the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+@item
+TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
+
+@item
+FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions
+of the GNU Free Documentation License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns. See
+@uref{http://www.gnu.org/copyleft/}.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License ``or any later version'' applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation. If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation. If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+@item
+RELICENSING
+
+``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works. A
+public wiki that anybody can edit is an example of such a server. A
+``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
+site means any set of copyrightable works thus published on the MMC
+site.
+
+``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+``Incorporate'' means to publish or republish a Document, in whole or
+in part, as part of another Document.
+
+An MMC is ``eligible for relicensing'' if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole
+or in part into the MMC, (1) had no cover texts or invariant sections,
+and (2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
+@end enumerate
+
+@page
+@heading ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+@smallexample
+@group
+ Copyright (C) @var{year} @var{your name}.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
+ Texts. A copy of the license is included in the section entitled ``GNU
+ Free Documentation License''.
+@end group
+@end smallexample
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the ``with@dots{}Texts.''@: line with this:
+
+@smallexample
+@group
+ with the Invariant Sections being @var{list their titles}, with
+ the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
+ being @var{list}.
+@end group
+@end smallexample
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
+
+@c Local Variables:
+@c ispell-local-pdict: "ispell-dict"
+@c End:
diff --git a/doc/specification/gpl-3.0.texi b/doc/specification/gpl-3.0.texi
new file mode 100644
index 0000000..0e2e212
--- /dev/null
+++ b/doc/specification/gpl-3.0.texi
@@ -0,0 +1,717 @@
+@c The GNU General Public License.
+@center Version 3, 29 June 2007
+
+@c This file is intended to be included within another document,
+@c hence no sectioning command or @node.
+
+@display
+Copyright @copyright{} 2007 Free Software Foundation, Inc.
@url{http://fsf.org/}
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+@end display
+
+@heading Preamble
+
+The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom
+to share and change all versions of a program---to make sure it remains
+free software for all its users. We, the Free Software Foundation,
+use the GNU General Public License for most of our software; it
+applies also to any other work released this way by its authors. You
+can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you
+have certain responsibilities if you distribute copies of the
+software, or if you modify it: responsibilities to respect the freedom
+of others.
+
+For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too,
+receive or can get the source code. And you must show them these
+terms so they know their rights.
+
+Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the
+manufacturer can do so. This is fundamentally incompatible with the
+aim of protecting users' freedom to change the software. The
+systematic pattern of such abuse occurs in the area of products for
+individuals to use, which is precisely where it is most unacceptable.
+Therefore, we have designed this version of the GPL to prohibit the
+practice for those products. If such problems arise substantially in
+other domains, we stand ready to extend this provision to those
+domains in future versions of the GPL, as needed to protect the
+freedom of users.
+
+Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish
+to avoid the special danger that patents applied to a free program
+could make it effectively proprietary. To prevent this, the GPL
+assures that patents cannot be used to render the program non-free.
+
+The precise terms and conditions for copying, distribution and
+modification follow.
+
+@heading TERMS AND CONDITIONS
+
+@enumerate 0
+@item Definitions.
+
+``This License'' refers to version 3 of the GNU General Public License.
+
+``Copyright'' also means copyright-like laws that apply to other kinds
+of works, such as semiconductor masks.
+
+``The Program'' refers to any copyrightable work licensed under this
+License. Each licensee is addressed as ``you''. ``Licensees'' and
+``recipients'' may be individuals or organizations.
+
+To ``modify'' a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of
+an exact copy. The resulting work is called a ``modified version'' of
+the earlier work or a work ``based on'' the earlier work.
+
+A ``covered work'' means either the unmodified Program or a work based
+on the Program.
+
+To ``propagate'' a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+To ``convey'' a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user
+through a computer network, with no transfer of a copy, is not
+conveying.
+
+An interactive user interface displays ``Appropriate Legal Notices'' to
+the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+@item Source Code.
+
+The ``source code'' for a work means the preferred form of the work for
+making modifications to it. ``Object code'' means any non-source form
+of a work.
+
+A ``Standard Interface'' means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+The ``System Libraries'' of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+``Major Component'', in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+The ``Corresponding Source'' for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+The Corresponding Source need not include anything that users can
+regenerate automatically from other parts of the Corresponding Source.
+
+The Corresponding Source for a work in source code form is that same
+work.
+
+@item Basic Permissions.
+
+All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+You may make, run and propagate covered works that you do not convey,
+without conditions so long as your license otherwise remains in force.
+You may convey covered works to others for the sole purpose of having
+them make modifications exclusively for you, or provide you with
+facilities for running those works, provided that you comply with the
+terms of this License in conveying all material for which you do not
+control copyright. Those thus making or running the covered works for
+you must do so exclusively on your behalf, under your direction and
+control, on terms that prohibit them from making any copies of your
+copyrighted material outside their relationship with you.
+
+Conveying under any other circumstances is permitted solely under the
+conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+@item Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such
+circumvention is effected by exercising rights under this License with
+respect to the covered work, and you disclaim any intention to limit
+operation or modification of the work as a means of enforcing, against
+the work's users, your or third parties' legal rights to forbid
+circumvention of technological measures.
+
+@item Conveying Verbatim Copies.
+
+You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+@item Conveying Modified Source Versions.
+
+You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these
+conditions:
+
+@enumerate a
+@item
+The work must carry prominent notices stating that you modified it,
+and giving a relevant date.
+
+@item
+The work must carry prominent notices stating that it is released
+under this License and any conditions added under section 7. This
+requirement modifies the requirement in section 4 to ``keep intact all
+notices''.
+
+@item
+You must license the entire work, as a whole, under this License to
+anyone who comes into possession of a copy. This License will
+therefore apply, along with any applicable section 7 additional terms,
+to the whole of the work, and all its parts, regardless of how they
+are packaged. This License gives no permission to license the work in
+any other way, but it does not invalidate such permission if you have
+separately received it.
+
+@item
+If the work has interactive user interfaces, each must display
+Appropriate Legal Notices; however, if the Program has interactive
+interfaces that do not display Appropriate Legal Notices, your work
+need not make them do so.
+@end enumerate
+
+A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+``aggregate'' if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+@item Conveying Non-Source Forms.
+
+You may convey a covered work in object code form under the terms of
+sections 4 and 5, provided that you also convey the machine-readable
+Corresponding Source under the terms of this License, in one of these
+ways:
+
+@enumerate a
+@item
+Convey the object code in, or embodied in, a physical product
+(including a physical distribution medium), accompanied by the
+Corresponding Source fixed on a durable physical medium customarily
+used for software interchange.
+
+@item
+Convey the object code in, or embodied in, a physical product
+(including a physical distribution medium), accompanied by a written
+offer, valid for at least three years and valid for as long as you
+offer spare parts or customer support for that product model, to give
+anyone who possesses the object code either (1) a copy of the
+Corresponding Source for all the software in the product that is
+covered by this License, on a durable physical medium customarily used
+for software interchange, for a price no more than your reasonable
+cost of physically performing this conveying of source, or (2) access
+to copy the Corresponding Source from a network server at no charge.
+
+@item
+Convey individual copies of the object code with a copy of the written
+offer to provide the Corresponding Source. This alternative is
+allowed only occasionally and noncommercially, and only if you
+received the object code with such an offer, in accord with subsection
+6b.
+
+@item
+Convey the object code by offering access from a designated place
+(gratis or for a charge), and offer equivalent access to the
+Corresponding Source in the same way through the same place at no
+further charge. You need not require recipients to copy the
+Corresponding Source along with the object code. If the place to copy
+the object code is a network server, the Corresponding Source may be
+on a different server (operated by you or a third party) that supports
+equivalent copying facilities, provided you maintain clear directions
+next to the object code saying where to find the Corresponding Source.
+Regardless of what server hosts the Corresponding Source, you remain
+obligated to ensure that it is available for as long as needed to
+satisfy these requirements.
+
+@item
+Convey the object code using peer-to-peer transmission, provided you
+inform other peers where the object code and Corresponding Source of
+the work are being offered to the general public at no charge under
+subsection 6d.
+
+@end enumerate
+
+A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+A ``User Product'' is either (1) a ``consumer product'', which means any
+tangible personal property which is normally used for personal,
+family, or household purposes, or (2) anything designed or sold for
+incorporation into a dwelling. In determining whether a product is a
+consumer product, doubtful cases shall be resolved in favor of
+coverage. For a particular product received by a particular user,
+``normally used'' refers to a typical or common use of that class of
+product, regardless of the status of the particular user or of the way
+in which the particular user actually uses, or expects or is expected
+to use, the product. A product is a consumer product regardless of
+whether the product has substantial commercial, industrial or
+non-consumer uses, unless such uses represent the only significant
+mode of use of the product.
+
+``Installation Information'' for a User Product means any methods,
+procedures, authorization keys, or other information required to
+install and execute modified versions of a covered work in that User
+Product from a modified version of its Corresponding Source. The
+information must suffice to ensure that the continued functioning of
+the modified object code is in no case prevented or interfered with
+solely because modification has been made.
+
+If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or
+updates for a work that has been modified or installed by the
+recipient, or for the User Product in which it has been modified or
+installed. Access to a network may be denied when the modification
+itself materially and adversely affects the operation of the network
+or violates the rules and protocols for communication across the
+network.
+
+Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+@item Additional Terms.
+
+``Additional permissions'' are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders
+of that material) supplement the terms of this License with terms:
+
+@enumerate a
+@item
+Disclaiming warranty or limiting liability differently from the terms
+of sections 15 and 16 of this License; or
+
+@item
+Requiring preservation of specified reasonable legal notices or author
+attributions in that material or in the Appropriate Legal Notices
+displayed by works containing it; or
+
+@item
+Prohibiting misrepresentation of the origin of that material, or
+requiring that modified versions of such material be marked in
+reasonable ways as different from the original version; or
+
+@item
+Limiting the use for publicity purposes of names of licensors or
+authors of the material; or
+
+@item
+Declining to grant rights under trademark law for use of some trade
+names, trademarks, or service marks; or
+
+@item
+Requiring indemnification of licensors and authors of that material by
+anyone who conveys the material (or modified versions of it) with
+contractual assumptions of liability to the recipient, for any
+liability that these contractual assumptions directly impose on those
+licensors and authors.
+@end enumerate
+
+All other non-permissive additional terms are considered ``further
+restrictions'' within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions; the
+above requirements apply either way.
+
+@item Termination.
+
+You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+@item Acceptance Not Required for Having Copies.
+
+You are not required to accept this License in order to receive or run
+a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+@item Automatic Licensing of Downstream Recipients.
+
+Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+An ``entity transaction'' is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+@item Patents.
+
+A ``contributor'' is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's ``contributor version''.
+
+A contributor's ``essential patent claims'' are all patent claims owned
+or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, ``control'' includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+In the following three paragraphs, a ``patent license'' is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To ``grant'' such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. ``Knowingly relying'' means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+A patent license is ``discriminatory'' if it does not include within the
+scope of its coverage, prohibits the exercise of, or is conditioned on
+the non-exercise of one or more of the rights that are specifically
+granted under this License. You may not convey a covered work if you
+are a party to an arrangement with a third party that is in the
+business of distributing software, under which you make payment to the
+third party based on the extent of your activity of conveying the
+work, and under which the third party grants, to any of the parties
+who would receive the covered work from you, a discriminatory patent
+license (a) in connection with copies of the covered work conveyed by
+you (or copies made from those copies), or (b) primarily for and in
+connection with specific products or compilations that contain the
+covered work, unless you entered into that arrangement, or that patent
+license was granted, prior to 28 March 2007.
+
+Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+@item No Surrender of Others' Freedom.
+
+If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey
+a covered work so as to satisfy simultaneously your obligations under
+this License and any other pertinent obligations, then as a
+consequence you may not convey it at all. For example, if you agree
+to terms that obligate you to collect a royalty for further conveying
+from those to whom you convey the Program, the only way you could
+satisfy both those terms and this License would be to refrain entirely
+from conveying the Program.
+
+@item Use with the GNU Affero General Public License.
+
+Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+@item Revised Versions of this License.
+
+The Free Software Foundation may publish revised and/or new versions
+of the GNU General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies that a certain numbered version of the GNU General Public
+License ``or any later version'' applies to it, you have the option of
+following the terms and conditions either of that numbered version or
+of any later version published by the Free Software Foundation. If
+the Program does not specify a version number of the GNU General
+Public License, you may choose any version ever published by the Free
+Software Foundation.
+
+If the Program specifies that a proxy can decide which future versions
+of the GNU General Public License can be used, that proxy's public
+statement of acceptance of a version permanently authorizes you to
+choose that version for the Program.
+
+Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+@item Disclaimer of Warranty.
+
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW@. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE@. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU@. SHOULD THE PROGRAM PROVE
+DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+CORRECTION.
+
+@item Limitation of Liability.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
+CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
+NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
+LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
+TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
+PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+@item Interpretation of Sections 15 and 16.
+
+If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+@end enumerate
+
+@heading END OF TERMS AND CONDITIONS
+
+@heading How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the ``copyright'' line and a pointer to where the full notice is found.
+
+@smallexample
+@var{one line to give the program's name and a brief idea of what it does.}
+Copyright (C) @var{year} @var{name of author}
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see @url{http://www.gnu.org/licenses/}.
+@end smallexample
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+@smallexample
+@var{program} Copyright (C) @var{year} @var{name of author}
+This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}.
+This is free software, and you are welcome to redistribute it
+under certain conditions; type @samp{show c} for details.
+@end smallexample
+
+The hypothetical commands @samp{show w} and @samp{show c} should show
+the appropriate parts of the General Public License. Of course, your
+program's commands might be different; for a GUI interface, you would
+use an ``about box''.
+
+You should also get your employer (if you work as a programmer) or school,
+if any, to sign a ``copyright disclaimer'' for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+@url{http://www.gnu.org/licenses/}.
+
+The GNU General Public License does not permit incorporating your
+program into proprietary programs. If your program is a subroutine
+library, you may consider it more useful to permit linking proprietary
+applications with the library. If this is what you want to do, use
+the GNU Lesser General Public License instead of this License. But
+first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}.
diff --git a/doc/specification/techspec.texi b/doc/specification/techspec.texi
new file mode 100644
index 0000000..26b08fc
--- /dev/null
+++ b/doc/specification/techspec.texi
@@ -0,0 +1,87 @@
+\input texinfo
+@c -*-texinfo-*-
+
+@c %**start of header
+@setfilename techspec.info
+@documentencoding UTF-8
+@settitle GNUnet Technical Specification
+@exampleindent 2
+@c %**end of header
+
+@include versioning.texi
+
+@copying
+Copyright @copyright{} 2001-2018 GNUnet e.V.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
+copy of the license is included in the section entitled ``GNU Free
+Documentation License''.
+
+A copy of the license is also available from the Free Software
+Foundation Web site at @url{http://www.gnu.org/licenses/fdl.html}.
+
+Alternately, this document is also available under the General
+Public License, version 3 or later, as published by the Free Software
+Foundation. A copy of the license is included in the section entitled
+``GNU General Public License''.
+
+A copy of the license is also available from the Free Software
+Foundation Web site at @url{http://www.gnu.org/licenses/gpl.html}.
+@end copying
+
+@titlepage
+@title GNUnet Technical Specification
+@subtitle Implementation-agnostic description of messages and processes in
GNUnet
+@author The GNUnet Developers
+
+@page
+@vskip 0pt plus 1filll
+Edition @value{EDITION} @*
+@value{UPDATED} @*
+
+@insertcopying
+@end titlepage
+
+@summarycontents
+@contents
+
+@node Top
+
+@menu
+* Overview:: Overview of GNUnet
+* Services:: Services provided by GNUnet
+* Messages:: GNUnet message formats
+* GNU Free Documentation License:: The license of this manual
+* GNU General Public License:: The license of this manual
+* References:: References to external resources
+* Index:: Index to the document
+@end menu
+
+@c *********************************************************************
+@include chapters/overview.texi
+@c *********************************************************************
+
+@c *********************************************************************
+@include chapters/services.texi
+@c *********************************************************************
+
+@c *********************************************************************
+@include chapters/messages.texi
+@c *********************************************************************
+
+@c *********************************************************************
+@node GNU Free Documentation License
+@appendix GNU Free Documentation License
+@cindex license, GNU Free Documentation License
+@include fdl-1.3.texi
+
+@c *********************************************************************
+@node GNU General Public License
+@appendix GNU General Public License
+@cindex license, GNU General Public License
+@include gpl-3.0.texi
+
+@bye
diff --git a/doc/specification/versioning.texi
b/doc/specification/versioning.texi
new file mode 100644
index 0000000..011c400
--- /dev/null
+++ b/doc/specification/versioning.texi
@@ -0,0 +1,4 @@
+@set UPDATED 13 June 2018
+@set UPDATED-MONTH June 2018
+@set EDITION 0.11.0
+@set VERSION 0.11.0
diff --git a/src/cmd/.gitignore b/src/cmd/.gitignore
new file mode 100644
index 0000000..1933786
--- /dev/null
+++ b/src/cmd/.gitignore
@@ -0,0 +1 @@
+/test/
diff --git a/src/cmd/gnunet-service-gns-go/main.go
b/src/cmd/gnunet-service-gns-go/main.go
new file mode 100644
index 0000000..ccfb5d3
--- /dev/null
+++ b/src/cmd/gnunet-service-gns-go/main.go
@@ -0,0 +1,83 @@
+package main
+
+import (
+ "flag"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+
+ "github.com/bfix/gospel/logger"
+ "gnunet/config"
+ "gnunet/service"
+ "gnunet/service/gns"
+)
+
+func main() {
+ logger.Println(logger.INFO, "[gns] Starting service...")
+ var (
+ cfgFile string
+ srvEndp string
+ err error
+ logLevel int
+ )
+ // handle command line arguments
+ flag.StringVar(&cfgFile, "c", "gnunet-config.json", "GNUnet
configuration file")
+ flag.StringVar(&srvEndp, "s", "", "GNS service end-point")
+ flag.IntVar(&logLevel, "L", logger.INFO, "GNS log level (default:
INFO)")
+ flag.Parse()
+
+ // read configuration file and set missing arguments.
+ if err = config.ParseConfig(cfgFile); err != nil {
+ logger.Printf(logger.ERROR, "[gns] Invalid configuration file:
%s\n", err.Error())
+ return
+ }
+
+ // apply configuration
+ logger.SetLogLevel(logLevel)
+ if len(srvEndp) == 0 {
+ srvEndp = config.Cfg.GNS.Endpoint
+ }
+
+ // start a new GNS service
+ gns := gns.NewGNSService()
+ srv := service.NewServiceImpl("gns", gns)
+ if err = srv.Start(srvEndp); err != nil {
+ logger.Printf(logger.ERROR, "[gns] Error: '%s'\n", err.Error())
+ return
+ }
+
+ // handle OS signals
+ sigCh := make(chan os.Signal, 5)
+ signal.Notify(sigCh)
+
+ // heart beat
+ tick := time.NewTicker(5 * time.Minute)
+
+loop:
+ for {
+ select {
+ // handle OS signals
+ case sig := <-sigCh:
+ switch sig {
+ case syscall.SIGKILL:
+ case syscall.SIGINT:
+ case syscall.SIGTERM:
+ logger.Println(logger.INFO, "[gns] Terminating
service (on signal)")
+ break loop
+ case syscall.SIGHUP:
+ logger.Println(logger.INFO, "[gns] SIGHUP")
+ default:
+ logger.Println(logger.INFO, "[gns] Unhandled
signal: "+sig.String())
+ }
+ // handle heart beat
+ case now := <-tick.C:
+ logger.Println(logger.INFO, "[gns] Heart beat at
"+now.String())
+ }
+ }
+
+ // terminating service
+ srv.Stop()
+ // wait for logger to flush last messages
+ time.Sleep(5 * time.Second)
+}
diff --git a/src/cmd/peer_mockup/main.go b/src/cmd/peer_mockup/main.go
new file mode 100644
index 0000000..59bc002
--- /dev/null
+++ b/src/cmd/peer_mockup/main.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "encoding/hex"
+ "flag"
+ "fmt"
+
+ "github.com/bfix/gospel/logger"
+ "gnunet/core"
+ "gnunet/transport"
+)
+
+var (
+ p *core.Peer // local peer (with private key)
+ t *core.Peer // remote peer
+)
+
+func main() {
+ // handle command line arguments
+ var (
+ asServer bool
+ err error
+ ch transport.Channel
+ )
+ flag.BoolVar(&asServer, "s", false, "accept incoming connections")
+ flag.Parse()
+
+ // setup peer instances from static data
+ if err = setupPeers(false); err != nil {
+ fmt.Println(err.Error())
+ return
+ }
+
+
fmt.Println("======================================================================")
+ fmt.Println("GNUnet peer mock-up (EXPERIMENTAL) (c) 2018,2019 by
Bernd Fix, >Y<")
+ fmt.Printf(" Identity '%s'\n", p.GetIDString())
+ fmt.Printf(" [%s]\n", hex.EncodeToString(p.GetID()))
+
fmt.Println("======================================================================")
+
+ if asServer {
+ // run as server
+ fmt.Println("Waiting for connections...")
+ hdlr := make(chan transport.Channel)
+ go func() {
+ for {
+ select {
+ case ch = <-hdlr:
+ mc := transport.NewMsgChannel(ch)
+ if err = process(mc, t, p); err != nil {
+ logger.Println(logger.ERROR,
err.Error())
+ }
+ }
+ }
+ }()
+ _, err = transport.NewChannelServer("tcp+0.0.0.0:2086", hdlr)
+ } else {
+ // connect to peer
+ fmt.Println("Connecting to target peer")
+ if ch, err = transport.NewChannel("tcp+172.17.0.5:2086"); err
!= nil {
+ logger.Println(logger.ERROR, err.Error())
+ }
+ mc := transport.NewMsgChannel(ch)
+ err = process(mc, p, t)
+ }
+ if err != nil {
+ fmt.Println(err)
+ }
+}
diff --git a/src/cmd/peer_mockup/peers.go b/src/cmd/peer_mockup/peers.go
new file mode 100644
index 0000000..16d3c87
--- /dev/null
+++ b/src/cmd/peer_mockup/peers.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "github.com/bfix/gospel/data"
+ "gnunet/core"
+ "gnunet/util"
+)
+
+func setupPeers(rnd bool) (err error) {
+
+ //------------------------------------------------------------------
+ // create local peer
+ //------------------------------------------------------------------
+ secret := []byte{
+ 0x78, 0xde, 0xcf, 0xc0, 0x26, 0x9e, 0x62, 0x3d,
+ 0x17, 0x24, 0xe6, 0x1b, 0x98, 0x25, 0xec, 0x2f,
+ 0x40, 0x6b, 0x1e, 0x39, 0xa5, 0x19, 0xac, 0x9b,
+ 0xb2, 0xdd, 0xf4, 0x6c, 0x12, 0x83, 0xdb, 0x86,
+ }
+ if rnd {
+ util.RndArray(secret)
+ }
+ p, err = core.NewPeer(secret, true)
+ if err != nil {
+ return
+ }
+ addr, _ := data.Marshal(util.NewIPAddress([]byte{172, 17, 0, 6}, 2086))
+ p.AddAddress(util.NewAddress("tcp", addr))
+
+ //------------------------------------------------------------------
+ // create remote peer
+ //------------------------------------------------------------------
+ id := []byte{
+ 0x92, 0xdc, 0xbf, 0x39, 0x40, 0x2d, 0xc6, 0x3c,
+ 0x97, 0xa6, 0x81, 0xe0, 0xfc, 0xd8, 0x7c, 0x74,
+ 0x17, 0xd3, 0xa3, 0x8c, 0x52, 0xfd, 0xe0, 0x49,
+ 0xbc, 0xd0, 0x1c, 0x0a, 0x0b, 0x8c, 0x02, 0x51,
+ }
+ t, err = core.NewPeer(id, false)
+ if err != nil {
+ return
+ }
+ addr, _ = data.Marshal(util.NewIPAddress([]byte{172, 17, 0, 5}, 2086))
+ t.AddAddress(util.NewAddress("tcp", addr))
+ return
+}
diff --git a/src/cmd/peer_mockup/process.go b/src/cmd/peer_mockup/process.go
new file mode 100644
index 0000000..51d4805
--- /dev/null
+++ b/src/cmd/peer_mockup/process.go
@@ -0,0 +1,118 @@
+package main
+
+import (
+ "errors"
+ "fmt"
+
+ "gnunet/core"
+ "gnunet/crypto"
+ "gnunet/message"
+ "gnunet/transport"
+ "gnunet/util"
+)
+
+func process(ch *transport.MsgChannel, from, to *core.Peer) (err error) {
+ // create a new connection instance
+ c := transport.NewConnection(ch, from, to)
+ defer c.Close()
+
+ // read and push next message
+ in := make(chan message.Message)
+ go func() {
+ for {
+ msg, err := c.Receive()
+ if err != nil {
+ fmt.Printf("Receive: %s\n", err.Error())
+ return
+ }
+ in <- msg
+ }
+ }()
+
+ // are we initiating the connection?
+ init := (from == p)
+ if init {
+ c.Send(message.NewTransportTcpWelcomeMsg(p.GetID()))
+ }
+
+ // remember peer addresses (only ONE!)
+ pAddr := p.GetAddressList()[0]
+ tAddr := t.GetAddressList()[0]
+
+ send := make(map[uint16]bool)
+ //received := make(map[uint16]bool)
+ pending := make(map[uint16]message.Message)
+
+ // process loop
+ for {
+ select {
+ case m := <-in:
+ switch msg := m.(type) {
+
+ case *message.TransportTcpWelcomeMsg:
+ if init {
+ c.Send(message.NewHelloMsg(p.GetID()))
+
c.Send(message.NewTransportPingMsg(t.GetID(), tAddr))
+ } else {
+
c.Send(message.NewTransportTcpWelcomeMsg(p.GetID()))
+ }
+
+ case *message.HelloMsg:
+
+ case *message.TransportPingMsg:
+ mOut :=
message.NewTransportPongMsg(msg.Challenge, pAddr)
+ if err := mOut.Sign(p.PrvKey()); err != nil {
+ return err
+ }
+ c.Send(mOut)
+
+ case *message.TransportPongMsg:
+ rc, err := msg.Verify(t.PubKey())
+ if err != nil {
+ return err
+ }
+ if !rc {
+ return errors.New("PONG verification
failed")
+ }
+ send[message.TRANSPORT_PONG] = true
+ if mOut, ok :=
pending[message.TRANSPORT_SESSION_SYN]; ok {
+ c.Send(mOut)
+ }
+
+ case *message.SessionSynMsg:
+ mOut :=
message.NewSessionSynAckMsg(msg.Timestamp)
+ if send[message.TRANSPORT_PONG] {
+ c.Send(mOut)
+ } else {
+ pending[message.TRANSPORT_SESSION_SYN]
= mOut
+ }
+
+ case *message.SessionQuotaMsg:
+ c.SetBandwidth(msg.Quota)
+
+ case *message.SessionAckMsg:
+
+ case *message.SessionKeepAliveMsg:
+
c.Send(message.NewSessionKeepAliveRespMsg(msg.Nonce))
+
+ case *message.EphemeralKeyMsg:
+ rc, err := msg.Verify(t.PubKey())
+ if err != nil {
+ return err
+ }
+ if !rc {
+ return errors.New("EPHKEY verification
failed")
+ }
+ t.SetEphKeyMsg(msg)
+ c.Send(p.EphKeyMsg())
+ secret := crypto.SharedSecret(p.EphPrvKey(),
t.EphKeyMsg().Public())
+ c.SharedSecret(util.Clone(secret.Bits[:]))
+
+ default:
+ fmt.Printf("!!! %v\n", msg)
+ }
+ default:
+ }
+ }
+ return nil
+}
diff --git a/src/cmd/vanityid/main.go b/src/cmd/vanityid/main.go
new file mode 100644
index 0000000..0b9fb18
--- /dev/null
+++ b/src/cmd/vanityid/main.go
@@ -0,0 +1,46 @@
+package main
+
+import (
+ "crypto/rand"
+ "encoding/hex"
+ "flag"
+ "fmt"
+ "regexp"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "gnunet/util"
+)
+
+func main() {
+ // get arguments
+ flag.Parse()
+ prefixes := flag.Args()
+ num := len(prefixes)
+ if num == 0 {
+ fmt.Println("No prefixes specified -- done.")
+ return
+ }
+
+ // pre-compile regexp
+ reg := make([]*regexp.Regexp, num)
+ for i, p := range prefixes {
+ reg[i] = regexp.MustCompile(p)
+ }
+
+ // generate new keys in a loop
+ seed := make([]byte, 32)
+ for {
+ n, err := rand.Read(seed)
+ if err != nil || n != 32 {
+ panic(err)
+ }
+ prv := ed25519.NewPrivateKeyFromSeed(seed)
+ pub := prv.Public().Bytes()
+ id := util.EncodeBinaryToString(pub)
+ for _, r := range reg {
+ if r.MatchString(id) {
+ fmt.Printf("%s [%s]\n", id,
hex.EncodeToString(seed))
+ }
+ }
+ }
+}
diff --git a/src/gnunet/config/config.go b/src/gnunet/config/config.go
new file mode 100644
index 0000000..74732ab
--- /dev/null
+++ b/src/gnunet/config/config.go
@@ -0,0 +1,141 @@
+package config
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "reflect"
+ "regexp"
+ "strings"
+
+ "github.com/bfix/gospel/logger"
+)
+
+///////////////////////////////////////////////////////////////////////
+// GNS configuration
+
+// GNSConfig
+type GNSConfig struct {
+ Endpoint string `json:"endpoint"` // end-point of GNS service
+ DHTReplLevel int `json:"dhtReplLevel"` // DHT replication level
+}
+
+///////////////////////////////////////////////////////////////////////
+// DHT configuration
+
+// DHTConfig
+type DHTConfig struct {
+ Endpoint string `json:"endpoint"` // end-point of DHT service
+}
+
+///////////////////////////////////////////////////////////////////////
+// Namecache configuration
+
+// NamecacheConfig
+type NamecacheConfig struct {
+ Endpoint string `json:"endpoint"` // end-point of Namecache service
+}
+
+///////////////////////////////////////////////////////////////////////
+
+// Environment settings
+type Environ map[string]string
+
+// Config is the aggregated configuration for GNUnet.
+type Config struct {
+ Env Environ `json:"environ"`
+ DHT *DHTConfig `json:"dht"`
+ GNS *GNSConfig `json:"gns"`
+ Namecache *NamecacheConfig `json:"namecache"`
+}
+
+var (
+ Cfg *Config
+)
+
+// Parse a JSON-encoded configuration file map it to the Config data structure.
+func ParseConfig(fileName string) (err error) {
+ // parse configuration file
+ file, err := ioutil.ReadFile(fileName)
+ if err != nil {
+ return
+ }
+ // unmarshal to Config data structure
+ Cfg = new(Config)
+ if err = json.Unmarshal(file, Cfg); err == nil {
+ // process all string-based config settings and apply
+ // string substitutions.
+ applySubstitutions(Cfg, Cfg.Env)
+ }
+ return
+}
+
+var (
+ rx = regexp.MustCompile("\\$\\{([^\\}]*)\\}")
+)
+
+func substString(s string, env map[string]string) string {
+ matches := rx.FindAllStringSubmatch(s, -1)
+ for _, m := range matches {
+ if len(m[1]) != 0 {
+ subst, ok := env[m[1]]
+ if !ok {
+ continue
+ }
+ s = strings.Replace(s, "${"+m[1]+"}", subst, -1)
+ }
+ }
+ return s
+}
+
+// applySubstitutions
+func applySubstitutions(x interface{}, env map[string]string) {
+
+ var process func(v reflect.Value)
+ process = func(v reflect.Value) {
+ for i := 0; i < v.NumField(); i++ {
+ fld := v.Field(i)
+ if fld.CanSet() {
+ switch fld.Kind() {
+ case reflect.String:
+ // check for substitution
+ s := fld.Interface().(string)
+ for {
+ s1 := substString(s, env)
+ if s1 == s {
+ break
+ }
+ logger.Printf(logger.DBG,
"[config] %s --> %s\n", s, s1)
+ fld.SetString(s1)
+ s = s1
+ }
+
+ case reflect.Struct:
+ // handle nested struct
+ process(fld)
+
+ case reflect.Ptr:
+ // handle pointer
+ e := fld.Elem()
+ if e.IsValid() {
+ process(fld.Elem())
+ } else {
+ logger.Printf(logger.ERROR,
"[config] 'nil' pointer encountered")
+ }
+ }
+ }
+ }
+ }
+
+ v := reflect.ValueOf(x)
+ switch v.Kind() {
+ case reflect.Ptr:
+ e := v.Elem()
+ if e.IsValid() {
+ process(e)
+ } else {
+ logger.Printf(logger.ERROR, "[config] 'nil' pointer
encountered")
+ }
+ case reflect.Struct:
+ process(v)
+ }
+}
diff --git a/src/gnunet/config/config_test.go b/src/gnunet/config/config_test.go
new file mode 100644
index 0000000..ec35d08
--- /dev/null
+++ b/src/gnunet/config/config_test.go
@@ -0,0 +1,22 @@
+package config
+
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/bfix/gospel/logger"
+)
+
+func TestConfigRead(t *testing.T) {
+ logger.SetLogLevel(logger.WARN)
+ if err := ParseConfig("./gnunet-config.json"); err != nil {
+ t.Fatal(err)
+ }
+ if testing.Verbose() {
+ data, err := json.Marshal(Cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Log("cfg=" + string(data))
+ }
+}
diff --git a/src/gnunet/config/gnunet-config.json
b/src/gnunet/config/gnunet-config.json
new file mode 100644
index 0000000..7ea854c
--- /dev/null
+++ b/src/gnunet/config/gnunet-config.json
@@ -0,0 +1,16 @@
+{
+ "environ": {
+ "TMP": "/tmp",
+ "RT_SYS": "${TMP}/gnunet-system-runtime"
+ },
+ "dht": {
+ "endpoint": "unix+${RT_SYS}/gnunet-service-dht.sock"
+ },
+ "gns": {
+ "endpoint":
"unix+${RT_SYS}/gnunet-service-gns-go.sock+perm=0770",
+ "dhtReplLevel": 10
+ },
+ "namecache": {
+ "endpoint": "unix+${RT_SYS}/gnunet-service-namecache.sock"
+ }
+}
diff --git a/src/gnunet/core/peer.go b/src/gnunet/core/peer.go
new file mode 100644
index 0000000..ac2d980
--- /dev/null
+++ b/src/gnunet/core/peer.go
@@ -0,0 +1,93 @@
+package core
+
+import (
+ "fmt"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "gnunet/message"
+ "gnunet/util"
+)
+
+/*
+type Peer interface {
+ GetID() []byte
+ GetIDString() string
+ GetAddressList() []*util.Address
+ Sign(msg []byte) ([]byte, error)
+ Verify(msg, sig []byte) bool
+}
+*/
+
+type Peer struct {
+ pub *ed25519.PublicKey
+ idString string
+ addrList []*util.Address
+ prv *ed25519.PrivateKey // long-term signing key
+ ephPrv *ed25519.PrivateKey // ephemeral signing key
+ ephMsg *message.EphemeralKeyMsg // ephemeral signing key message
+}
+
+func NewPeer(data []byte, local bool) (p *Peer, err error) {
+ p = new(Peer)
+ if local {
+ p.prv = ed25519.NewPrivateKeyFromSeed(data)
+ p.pub = p.prv.Public()
+ p.ephPrv, p.ephMsg, err =
message.NewEphemeralKey(p.pub.Bytes(), p.prv)
+ if err != nil {
+ return
+ }
+ } else {
+ p.prv = nil
+ p.pub = ed25519.NewPublicKeyFromBytes(data)
+ }
+ p.idString = util.EncodeBinaryToString(p.pub.Bytes())
+ p.addrList = make([]*util.Address, 0)
+ return
+}
+
+func (p *Peer) EphKeyMsg() *message.EphemeralKeyMsg {
+ return p.ephMsg
+}
+
+func (p *Peer) SetEphKeyMsg(msg *message.EphemeralKeyMsg) {
+ p.ephMsg = msg
+}
+
+func (p *Peer) EphPrvKey() *ed25519.PrivateKey {
+ return p.ephPrv
+}
+
+func (p *Peer) PrvKey() *ed25519.PrivateKey {
+ return p.prv
+}
+
+func (p *Peer) PubKey() *ed25519.PublicKey {
+ return p.pub
+}
+
+func (p *Peer) GetID() []byte {
+ return p.pub.Bytes()
+}
+
+func (p *Peer) GetIDString() string {
+ return p.idString
+}
+
+func (p *Peer) GetAddressList() []*util.Address {
+ return p.addrList
+}
+
+func (p *Peer) AddAddress(a *util.Address) {
+ p.addrList = append(p.addrList, a)
+}
+
+func (p *Peer) Sign(msg []byte) (*ed25519.EdSignature, error) {
+ if p.prv == nil {
+ return nil, fmt.Errorf("No private key")
+ }
+ return p.prv.EdSign(msg)
+}
+
+func (p *Peer) Verify(msg []byte, sig *ed25519.EdSignature) (bool, error) {
+ return p.pub.EdVerify(msg, sig)
+}
diff --git a/src/gnunet/crypto/hash.go b/src/gnunet/crypto/hash.go
new file mode 100644
index 0000000..87e3941
--- /dev/null
+++ b/src/gnunet/crypto/hash.go
@@ -0,0 +1,24 @@
+package crypto
+
+import (
+ "crypto/sha512"
+
+ "gnunet/util"
+)
+
+type HashCode struct {
+ Bits []byte `size:"64"`
+}
+
+func NewHashCode() *HashCode {
+ return &HashCode{
+ Bits: make([]byte, 64),
+ }
+}
+
+func Hash(data []byte) *HashCode {
+ val := sha512.Sum512(data)
+ return &HashCode{
+ Bits: util.Clone(val[:]),
+ }
+}
diff --git a/src/gnunet/crypto/key_derivation.go
b/src/gnunet/crypto/key_derivation.go
new file mode 100644
index 0000000..575f511
--- /dev/null
+++ b/src/gnunet/crypto/key_derivation.go
@@ -0,0 +1,31 @@
+package crypto
+
+import (
+ "crypto/sha256"
+ "crypto/sha512"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/math"
+ "golang.org/x/crypto/hkdf"
+)
+
+var (
+ ED25519_N = ed25519.GetCurve().N
+)
+
+// DeriveH derives an integer 'h' from the arguments.
+func DeriveH(pub *ed25519.PublicKey, label, context string) *math.Int {
+ prk := hkdf.Extract(sha512.New, pub.Bytes(), []byte("key-derivation"))
+ data := append([]byte(label), []byte(context)...)
+ rdr := hkdf.Expand(sha256.New, prk, data)
+ b := make([]byte, 64)
+ rdr.Read(b)
+ return math.NewIntFromBytes(b).Mod(ED25519_N)
+}
+
+// DerivePublicKey "shifts" a public key 'Q' to a new point 'P' where
+// P = h*Q with 'h' being a factor derived from the arguments.
+func DerivePublicKey(pub *ed25519.PublicKey, label string, context string)
*ed25519.PublicKey {
+ h := DeriveH(pub, label, context)
+ return pub.Mult(h)
+}
diff --git a/src/gnunet/crypto/key_derivation_test.go
b/src/gnunet/crypto/key_derivation_test.go
new file mode 100644
index 0000000..8b927d2
--- /dev/null
+++ b/src/gnunet/crypto/key_derivation_test.go
@@ -0,0 +1,215 @@
+package crypto
+
+import (
+ "bytes"
+ "crypto/sha256"
+ "crypto/sha512"
+ "encoding/hex"
+ "testing"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/math"
+ "gnunet/util"
+ "golang.org/x/crypto/hkdf"
+)
+
+func TestDeriveH(t *testing.T) {
+ var (
+ D = []byte{
+ 0x40, 0x00, 0xd4, 0xe6, 0x85, 0xa3, 0x40, 0xe2,
+ 0xa5, 0xab, 0x0f, 0xe0, 0x56, 0xbd, 0x5b, 0x93,
+ 0x6b, 0x86, 0xcd, 0x2d, 0xd2, 0xa0, 0x71, 0x4c,
+ 0x1e, 0x2b, 0x16, 0x08, 0x83, 0xaa, 0x7f, 0x88,
+ }
+ PUB = []byte{
+ 0x93, 0x34, 0x71, 0xF6, 0x99, 0x19, 0x0C, 0x62,
+ 0x85, 0xC7, 0x9B, 0x83, 0x9D, 0xCA, 0x83, 0x91,
+ 0x38, 0xFA, 0x87, 0xFB, 0xB8, 0xD4, 0xF6, 0xF0,
+ 0xF0, 0x4B, 0x7F, 0x0A, 0x48, 0xBF, 0x95, 0xF7,
+ }
+
+ ID = "JCT73XMS346651E7KE1SVJM3J4WFN1ZVQ3AFDW7G9DZGMJ5ZJQVG"
+ LABEL = "home"
+ CONTEXT = "gns"
+
+ H = []byte{
+ 0x0d, 0x4a, 0x75, 0x30, 0xfd, 0x07, 0xe1, 0x88,
+ 0xfc, 0xa0, 0xf4, 0x29, 0x52, 0x66, 0x24, 0x0f,
+ 0x1e, 0x08, 0x91, 0xb0, 0x61, 0x39, 0x46, 0xca,
+ 0xfb, 0x4c, 0xe3, 0xa8, 0x54, 0xca, 0x47, 0x7a,
+ }
+ Q = []byte{
+ 0x26, 0x84, 0x1b, 0x24, 0x35, 0xa4, 0x63, 0xe9,
+ 0xf0, 0x48, 0xae, 0x3e, 0xf7, 0xe8, 0x1b, 0xca,
+ 0x55, 0x9f, 0x4c, 0x1e, 0x16, 0x18, 0xa6, 0xd3,
+ 0x5b, 0x91, 0x0d, 0x54, 0x31, 0x6e, 0xbf, 0x97,
+ }
+
+ QUERY = []byte{
+ 0x13, 0xab, 0x16, 0x69, 0x72, 0xf5, 0x8a, 0xcf,
+ 0x21, 0x96, 0xc8, 0x19, 0x9c, 0x92, 0x46, 0x6f,
+ 0x15, 0xa2, 0x45, 0x19, 0x0a, 0x18, 0xd2, 0x3b,
+ 0x7b, 0x83, 0x21, 0x4e, 0x9d, 0x03, 0x3b, 0x81,
+ 0x7d, 0xc2, 0x23, 0xf3, 0x26, 0xe4, 0x7b, 0x43,
+ 0x52, 0xa1, 0x03, 0x59, 0x00, 0xd7, 0x2e, 0x3f,
+ 0x17, 0x0f, 0xc3, 0xb5, 0xf5, 0xcf, 0x3a, 0xdd,
+ 0xea, 0x8a, 0xc6, 0xbd, 0x2b, 0xfd, 0x50, 0x54,
+ }
+ )
+
+ // compute keypair from seed
+ prv := ed25519.NewPrivateKeyFromD(math.NewIntFromBytes(D))
+ pub := prv.Public()
+ if bytes.Compare(pub.Bytes(), PUB) != 0 {
+ t.Fatal("Wrong public key")
+ }
+ if ID != util.EncodeBinaryToString(pub.Bytes()) {
+ t.Fatal("Wrong ego ID")
+ }
+
+ hBuf := make([]byte, 32)
+ hFull := DeriveH(pub, LABEL, CONTEXT)
+ h := hFull.Mod(ED25519_N)
+ util.CopyBlock(hBuf, h.Bytes())
+ if bytes.Compare(hBuf, H) != 0 {
+ if testing.Verbose() {
+ t.Logf("H(computed) = %s\n", hex.EncodeToString(hBuf))
+ t.Logf("H(expected) = %s\n", hex.EncodeToString(H))
+ }
+ t.Fatal("H mismatch")
+ }
+
+ dpub := pub.Mult(h)
+ dpub2 := DerivePublicKey(pub, LABEL, CONTEXT)
+ if !dpub.Q.Equals(dpub2.Q) {
+ t.Fatal("Q mismatch")
+ }
+
+ q := dpub.Q.Bytes()
+ if bytes.Compare(q, Q) != 0 {
+ if testing.Verbose() {
+ t.Logf("derived_x(computed) = %s\n",
hex.EncodeToString(q))
+ t.Logf("derived_x(expected) = %s\n",
hex.EncodeToString(Q))
+ }
+ t.Fatal("x-coordinate mismatch")
+ }
+ pk1 := dpub.Bytes()
+ pk2 := DerivePublicKey(pub, LABEL, CONTEXT).Bytes()
+ if bytes.Compare(pk1, pk2) != 0 {
+ if testing.Verbose() {
+ t.Logf("derived(1) = %s\n", hex.EncodeToString(pk1))
+ t.Logf("derived(2) = %s\n", hex.EncodeToString(pk2))
+ }
+ t.Fatal("Derived key mismatch")
+ }
+
+ out := sha512.Sum512(pk1)
+ if bytes.Compare(out[:], QUERY) != 0 {
+ if testing.Verbose() {
+ t.Log("query(expected) = " + hex.EncodeToString(QUERY))
+ t.Log("query(computed) = " + hex.EncodeToString(out[:]))
+ }
+ t.Fatal("Query mismatch")
+ }
+}
+
+func TestHKDF_gnunet(t *testing.T) {
+
+ var (
+ // SALT as defined in GNUnet
+ salt = []byte("key-derivation")
+ // expected PRK (as dumped in GNUnet)
+ PRK = []byte{
+ 0xEB, 0xFE, 0x63, 0xBA, 0x68, 0x2D, 0xA5, 0x5C,
+ 0xF8, 0x37, 0xCE, 0x8F, 0x94, 0x3B, 0x01, 0x44,
+ 0x1B, 0xF9, 0x67, 0x3D, 0xFC, 0x91, 0xED, 0x61,
+ 0x79, 0x94, 0xE8, 0x2A, 0x62, 0x0A, 0xE8, 0x6E,
+ 0x59, 0xDB, 0x56, 0x63, 0x80, 0x94, 0x63, 0xAC,
+ 0x8D, 0x35, 0xE2, 0xEA, 0xBA, 0xE6, 0xF3, 0xE8,
+ 0xC1, 0x4B, 0xC9, 0x4F, 0xBD, 0xE3, 0xE6, 0x61,
+ 0x01, 0xB3, 0xB2, 0x1C, 0x6F, 0x19, 0x73, 0x8B,
+ }
+ info = []byte("master-homegns")
+ // expected result (as dumped in GNUnet)
+ OKM = []byte{
+ 0x30, 0x86, 0x34, 0x7F, 0x2E, 0x12, 0xD7, 0x65,
+ 0x35, 0x70, 0x44, 0xE2, 0xF6, 0x9B, 0x84, 0x59,
+ 0x6E, 0xE1, 0x7F, 0x62, 0x93, 0xAD, 0xAE, 0x56,
+ 0x50, 0x6A, 0xA6, 0xD6, 0x8D, 0x39, 0x39, 0x95,
+ }
+ )
+ prk := hkdf.Extract(sha512.New, pub.Bytes(), salt)
+ if testing.Verbose() {
+ t.Log("PRK(computed) = " + hex.EncodeToString(prk))
+ }
+ if bytes.Compare(prk, PRK) != 0 {
+ t.Log("PRK(expected) = " + hex.EncodeToString(PRK))
+ t.Fatal("PRK mismatch")
+ }
+
+ rdr := hkdf.Expand(sha256.New, prk, info)
+ okm := make([]byte, len(OKM))
+ rdr.Read(okm)
+ if testing.Verbose() {
+ t.Log("OKM(computed) = " + hex.EncodeToString(okm))
+ }
+ if bytes.Compare(okm, OKM) != 0 {
+ t.Log("OKM(expected) = " + hex.EncodeToString(OKM))
+ t.Fatal("OKM mismatch")
+ }
+}
+
+func TestHDKF(t *testing.T) {
+ var (
+ ikm = []byte{
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ }
+ salt = []byte{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ }
+ PRK = []byte{
+ 0x66, 0x57, 0x99, 0x82, 0x37, 0x37, 0xde, 0xd0,
+ 0x4a, 0x88, 0xe4, 0x7e, 0x54, 0xa5, 0x89, 0x0b,
+ 0xb2, 0xc3, 0xd2, 0x47, 0xc7, 0xa4, 0x25, 0x4a,
+ 0x8e, 0x61, 0x35, 0x07, 0x23, 0x59, 0x0a, 0x26,
+ 0xc3, 0x62, 0x38, 0x12, 0x7d, 0x86, 0x61, 0xb8,
+ 0x8c, 0xf8, 0x0e, 0xf8, 0x02, 0xd5, 0x7e, 0x2f,
+ 0x7c, 0xeb, 0xcf, 0x1e, 0x00, 0xe0, 0x83, 0x84,
+ 0x8b, 0xe1, 0x99, 0x29, 0xc6, 0x1b, 0x42, 0x37,
+ }
+ info = []byte{
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9,
+ }
+ OKM = []byte{
+ 0x83, 0x23, 0x90, 0x08, 0x6c, 0xda, 0x71, 0xfb,
+ 0x47, 0x62, 0x5b, 0xb5, 0xce, 0xb1, 0x68, 0xe4,
+ 0xc8, 0xe2, 0x6a, 0x1a, 0x16, 0xed, 0x34, 0xd9,
+ 0xfc, 0x7f, 0xe9, 0x2c, 0x14, 0x81, 0x57, 0x93,
+ 0x38, 0xda, 0x36, 0x2c, 0xb8, 0xd9, 0xf9, 0x25,
+ 0xd7, 0xcb,
+ }
+ )
+
+ prk := hkdf.Extract(sha512.New, ikm, salt)
+ if testing.Verbose() {
+ t.Log("PRK(computed) = " + hex.EncodeToString(prk))
+ }
+ if bytes.Compare(prk, PRK) != 0 {
+ t.Log("PRK(expected) = " + hex.EncodeToString(PRK))
+ t.Fatal("PRK mismatch")
+ }
+
+ rdr := hkdf.Expand(sha512.New, prk, info)
+ okm := make([]byte, len(OKM))
+ rdr.Read(okm)
+ if testing.Verbose() {
+ t.Log("OKM(computed) = " + hex.EncodeToString(okm))
+ }
+ if bytes.Compare(okm, OKM) != 0 {
+ t.Log("OKM(expected) = " + hex.EncodeToString(OKM))
+ t.Fatal("OKM mismatch")
+ }
+}
diff --git a/src/gnunet/crypto/key_exchange.go
b/src/gnunet/crypto/key_exchange.go
new file mode 100644
index 0000000..0efa441
--- /dev/null
+++ b/src/gnunet/crypto/key_exchange.go
@@ -0,0 +1,12 @@
+package crypto
+
+import (
+ "github.com/bfix/gospel/crypto/ed25519"
+)
+
+// SharedSecret computes a 64 byte shared secret
+// between (prvA,pubB) and (prvB,pubA).
+func SharedSecret(prv *ed25519.PrivateKey, pub *ed25519.PublicKey) *HashCode {
+ ss := pub.Mult(prv.D).Q.X().Bytes()
+ return Hash(ss)
+}
diff --git a/src/gnunet/crypto/key_exchange_test.go
b/src/gnunet/crypto/key_exchange_test.go
new file mode 100644
index 0000000..93e95a2
--- /dev/null
+++ b/src/gnunet/crypto/key_exchange_test.go
@@ -0,0 +1,104 @@
+package crypto
+
+import (
+ "bytes"
+ "crypto/sha512"
+ "encoding/hex"
+ "testing"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/math"
+)
+
+var (
+ d_1 = []byte{
+ 0x7F, 0xDE, 0x7A, 0xAA, 0xEA, 0x0D, 0xA1, 0x7A,
+ 0x7B, 0xCB, 0x4F, 0x57, 0x49, 0xCC, 0xA9, 0xBE,
+ 0xA7, 0xFB, 0x2B, 0x85, 0x77, 0xAD, 0xC9, 0x55,
+ 0xDA, 0xB2, 0x68, 0xB2, 0xB4, 0xCC, 0x24, 0x78,
+ }
+
+ d_2 = []byte{
+ 0x20, 0x3f, 0x2f, 0x8c, 0x54, 0xf4, 0x1a, 0xd3,
+ 0x01, 0x9a, 0x56, 0x92, 0x19, 0xda, 0xee, 0x4f,
+ 0xd2, 0x53, 0x55, 0xa6, 0x3c, 0xfc, 0x57, 0x40,
+ 0x8a, 0xb0, 0x86, 0x88, 0xf6, 0x86, 0xf4, 0x9c,
+ }
+
+ ss = []byte{
+ 0x0a, 0x49, 0x6e, 0x6b, 0x83, 0xca, 0x14, 0xeb,
+ 0xa5, 0x0f, 0x45, 0x49, 0x1d, 0x90, 0x7e, 0x0c,
+ 0x07, 0x56, 0x90, 0x16, 0xb2, 0x43, 0x7a, 0x0e,
+ 0x91, 0x1f, 0x73, 0xe3, 0x4f, 0xbf, 0xfd, 0x85,
+ 0x55, 0x86, 0x02, 0xc7, 0x42, 0xc0, 0x29, 0xb0,
+ 0x70, 0xe3, 0xee, 0xad, 0x41, 0x89, 0xb6, 0xc1,
+ 0x44, 0x71, 0xde, 0x2b, 0x60, 0x4e, 0x7b, 0x75,
+ 0x05, 0xbd, 0x1b, 0x85, 0xd5, 0xfd, 0x63, 0x60,
+ }
+
+ prv_1, prv_2 *ed25519.PrivateKey
+ pub_1, pub_2 *ed25519.PublicKey
+ ss_1, ss_2 []byte
+)
+
+func calcSharedSecret() bool {
+ calc := func(prv *ed25519.PrivateKey, pub *ed25519.PublicKey) []byte {
+ x := sha512.Sum512(pub.Mult(prv.D).Q.X().Bytes())
+ return x[:]
+ }
+ // compute shared secret
+ ss_1 = calc(prv_1, pub_2)
+ ss_2 = calc(prv_2, pub_1)
+ return bytes.Compare(ss_1, ss_2) == 0
+}
+
+func TestDHE(t *testing.T) {
+ // generate two key pairs
+ prv_1 = ed25519.NewPrivateKeyFromD(math.NewIntFromBytes(d_1))
+ pub_1 = prv_1.Public()
+ prv_2 = ed25519.NewPrivateKeyFromD(math.NewIntFromBytes(d_2))
+ pub_2 = prv_2.Public()
+
+ if !calcSharedSecret() {
+ t.Fatal("Shared secret mismatch")
+ }
+ if testing.Verbose() {
+ t.Logf("SS_1 = %s\n", hex.EncodeToString(ss_1))
+ t.Logf("SS_2 = %s\n", hex.EncodeToString(ss_2))
+ }
+
+ if bytes.Compare(ss_1[:], ss) != 0 {
+ t.Logf("SS(expected) = %s\n", hex.EncodeToString(ss))
+ t.Logf("SS(computed) = %s\n", hex.EncodeToString(ss_1[:]))
+ t.Fatal("Wrong shared secret:")
+ }
+
+}
+
+func TestDHERandom(t *testing.T) {
+ failed := 0
+ once := false
+ for i := 0; i < 100; i++ {
+ prv_1 = ed25519.NewPrivateKeyFromD(math.NewIntRnd(ED25519_N))
+ pub_1 = prv_1.Public()
+ prv_2 = ed25519.NewPrivateKeyFromD(math.NewIntRnd(ED25519_N))
+ pub_2 = prv_2.Public()
+
+ if !calcSharedSecret() {
+ if !once {
+ once = true
+ t.Logf("d1=%s\n",
hex.EncodeToString(prv_1.D.Bytes()))
+ t.Logf("d2=%s\n",
hex.EncodeToString(prv_2.D.Bytes()))
+ t.Logf("ss1=%s\n", hex.EncodeToString(ss_1))
+ t.Logf("ss2=%s\n", hex.EncodeToString(ss_2))
+ dd := prv_1.D.Mul(prv_2.D).Mod(ED25519_N)
+ pk :=
sha512.Sum512(ed25519.NewPrivateKeyFromD(dd).Public().Q.X().Bytes())
+ t.Logf("ss0=%s\n", hex.EncodeToString(pk[:]))
+ }
+ failed++
+ }
+ }
+ if failed > 0 {
+ t.Fatalf("Shared secret mismatches: %d/1000", failed)
+ }
+}
diff --git a/src/gnunet/crypto/keys_test.go b/src/gnunet/crypto/keys_test.go
new file mode 100644
index 0000000..69d70ca
--- /dev/null
+++ b/src/gnunet/crypto/keys_test.go
@@ -0,0 +1,69 @@
+package crypto
+
+import (
+ "bytes"
+ "encoding/hex"
+ "testing"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/math"
+ "gnunet/util"
+)
+
+var (
+ seed = []byte{
+ 0x20, 0x3f, 0x2f, 0x8c, 0x54, 0xf4, 0x1a, 0xd3,
+ 0x01, 0x9a, 0x56, 0x92, 0x19, 0xda, 0xee, 0x4f,
+ 0xd2, 0x53, 0x55, 0xa6, 0x3c, 0xfc, 0x57, 0x40,
+ 0x8a, 0xb0, 0x86, 0x88, 0xf6, 0x86, 0xf4, 0x9c,
+ }
+
+ d = []byte{
+ 0x7F, 0xDE, 0x7A, 0xAA, 0xEA, 0x0D, 0xA1, 0x7A,
+ 0x7B, 0xCB, 0x4F, 0x57, 0x49, 0xCC, 0xA9, 0xBE,
+ 0xA7, 0xFB, 0x2B, 0x85, 0x77, 0xAD, 0xC9, 0x55,
+ 0xDA, 0xB2, 0x68, 0xB2, 0xB4, 0xCC, 0x24, 0x78,
+ }
+
+ q = []byte{
+ 0x92, 0xDC, 0xBF, 0x39, 0x40, 0x2D, 0xC6, 0x3C,
+ 0x97, 0xA6, 0x81, 0xE0, 0xFC, 0xD8, 0x7C, 0x74,
+ 0x17, 0xD3, 0xA3, 0x8C, 0x52, 0xFD, 0xE0, 0x49,
+ 0xBC, 0xD0, 0x1C, 0x0A, 0x0B, 0x8C, 0x02, 0x51,
+ }
+
+ prv = ed25519.NewPrivateKeyFromSeed(seed)
+ pub = prv.Public()
+)
+
+func TestPrvKey(t *testing.T) {
+ if testing.Verbose() {
+ t.Logf("PRIVATE (seed=%s)\n", hex.EncodeToString(seed))
+ t.Logf(" d = %s\n", hex.EncodeToString(prv_1.D.Bytes()))
+ t.Logf(" ID = '%s'\n", util.EncodeBinaryToString(seed))
+ }
+
+ pubB := pub.Bytes()
+ if testing.Verbose() {
+ t.Logf("PUBLIC = %s\n", hex.EncodeToString(pubB))
+ t.Logf(" = '%s'\n", util.EncodeBinaryToString(pubB))
+ }
+
+ if !bytes.Equal(pubB, q) {
+ t.Logf("PUBLIC(computed) = %s\n", hex.EncodeToString(pubB))
+ t.Logf("PUBLIC(expected) = %s\n", hex.EncodeToString(q))
+ t.Fatal("Public key mismatch")
+ }
+
+ dVal := math.NewIntFromBytes(d)
+ if !dVal.Equals(prv.D) {
+ t.Fatal("Private exponent mismatch")
+ }
+
+ pub2 := ed25519.NewPrivateKeyFromD(dVal).Public().Bytes()
+ if !bytes.Equal(pubB, pub2) {
+ t.Logf("PUBLIC2(computed) = %s\n", hex.EncodeToString(pub2))
+ t.Logf("PUBLIC2(expected) = %s\n", hex.EncodeToString(pubB))
+ t.Fatal("Public key mismatch")
+ }
+}
diff --git a/src/gnunet/crypto/signature.go b/src/gnunet/crypto/signature.go
new file mode 100644
index 0000000..9a69b56
--- /dev/null
+++ b/src/gnunet/crypto/signature.go
@@ -0,0 +1,6 @@
+package crypto
+
+type SignaturePurpose struct {
+ Size uint32 `order:"big"` // How many bytes are signed?
+ Purpose uint32 `order:"big"` // Signature purpose
+}
diff --git a/src/gnunet/crypto/symmetric.go b/src/gnunet/crypto/symmetric.go
new file mode 100644
index 0000000..5fb2c72
--- /dev/null
+++ b/src/gnunet/crypto/symmetric.go
@@ -0,0 +1,59 @@
+package crypto
+
+import (
+ "crypto/aes"
+ "crypto/cipher"
+ "crypto/rand"
+
+ "golang.org/x/crypto/twofish"
+)
+
+type SymmetricKey struct {
+ AESKey []byte `size:"32"`
+ TwofishKey []byte `size:"32"`
+}
+
+func NewSymmetricKey() *SymmetricKey {
+ skey := &SymmetricKey{
+ AESKey: make([]byte, 32),
+ TwofishKey: make([]byte, 32),
+ }
+ rand.Read(skey.AESKey)
+ rand.Read(skey.TwofishKey)
+ return skey
+}
+
+type SymmetricIV struct {
+ AESIv []byte `size:"16"`
+ TwofishIv []byte `size:"16"`
+}
+
+func NewSymmetricIV() *SymmetricIV {
+ iv := &SymmetricIV{
+ AESIv: make([]byte, 16),
+ TwofishIv: make([]byte, 16),
+ }
+ rand.Read(iv.AESIv)
+ rand.Read(iv.TwofishIv)
+ return iv
+}
+
+func SymmetricDecrypt(data []byte, skey *SymmetricKey, iv *SymmetricIV)
([]byte, error) {
+ // Decrypt with Twofish CFB stream cipher
+ tf, err := twofish.NewCipher(skey.TwofishKey)
+ if err != nil {
+ return nil, err
+ }
+ stream := cipher.NewCFBDecrypter(tf, iv.TwofishIv)
+ out := make([]byte, len(data))
+ stream.XORKeyStream(out, data)
+
+ // Decrypt with AES CFB stream cipher
+ aes, err := aes.NewCipher(skey.AESKey)
+ if err != nil {
+ return nil, err
+ }
+ stream = cipher.NewCFBDecrypter(aes, iv.AESIv)
+ stream.XORKeyStream(out, out)
+ return out, nil
+}
diff --git a/src/gnunet/enums/block.go b/src/gnunet/enums/block.go
new file mode 100644
index 0000000..2d179a3
--- /dev/null
+++ b/src/gnunet/enums/block.go
@@ -0,0 +1,22 @@
+package enums
+
+var (
+ BLOCK_TYPE_ANY = 0 // Any type of block, used as a wildcard
when searching.
+ BLOCK_TYPE_FS_DBLOCK = 1 // Data block (leaf) in the CHK tree.
+ BLOCK_TYPE_FS_IBLOCK = 2 // Inner block in the CHK tree.
+ BLOCK_TYPE_FS_KBLOCK = 3 // Legacy type, no longer in use.
+ BLOCK_TYPE_FS_SBLOCK = 4 // Legacy type, no longer in use.
+ BLOCK_TYPE_FS_NBLOCK = 5 // Legacy type, no longer in use.
+ BLOCK_TYPE_FS_ONDEMAND = 6 // Type of a block representing a block
to be encoded on demand from disk.
+ BLOCK_TYPE_DHT_HELLO = 7 // Type of a block that contains a HELLO
for a peer
+ BLOCK_TYPE_TEST = 8 // Block for testing.
+ BLOCK_TYPE_FS_UBLOCK = 9 // Type of a block representing any type
of search result (universal).
+ BLOCK_TYPE_DNS = 10 // Block for storing DNS exit service
advertisements.
+ BLOCK_TYPE_GNS_NAMERECORD = 11 // Block for storing record data
+ BLOCK_TYPE_REVOCATION = 12 // Block type for a revocation message
by which a key is revoked.
+
+ BLOCK_TYPE_REGEX = 22 // Block to store a cadet regex state
+ BLOCK_TYPE_REGEX_ACCEPT = 23 // Block to store a cadet regex
accepting state
+ BLOCK_TYPE_SET_TEST = 24 // Block for testing set/consensus.
+ BLOCK_TYPE_CONSENSUS_ELEMENT = 25 // Block type for consensus elements.
+)
diff --git a/src/gnunet/enums/dht.go b/src/gnunet/enums/dht.go
new file mode 100644
index 0000000..87c36a3
--- /dev/null
+++ b/src/gnunet/enums/dht.go
@@ -0,0 +1,12 @@
+package enums
+
+var (
+ DHT_RO_NONE = 0 // Default. Do nothing special.
+ DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 // Each peer along the way should
look at 'enc'
+ DHT_RO_RECORD_ROUTE = 2 // keep track of the route that the
message took in the P2P network.
+ DHT_RO_FIND_PEER = 3 // This is a 'FIND-PEER' request, so
approximate results are fine.
+ DHT_RO_BART = 4 // Possible message option for query
key randomization.
+ DHT_RO_LAST_HOP = 16 // Flag given to monitors if this
was the last hop for a GET/PUT.
+
+ DHT_GNS_REPLICATION_LEVEL = 10
+)
diff --git a/src/gnunet/enums/gns.go b/src/gnunet/enums/gns.go
new file mode 100644
index 0000000..2de5048
--- /dev/null
+++ b/src/gnunet/enums/gns.go
@@ -0,0 +1,287 @@
+package enums
+
+var (
+ GNS_MAX_BLOCK_SIZE = (63 * 1024) // Maximum size of a value that can be
stored in a GNS block.
+
+ // GNS record types
+ GNS_TYPE_ANY = 0 // Record type indicating any
record/'*'
+ GNS_TYPE_DNS_A = 1 // [RFC1035] IPv4 Address record
+ GNS_TYPE_DNS_NS = 2 // [RFC1035] Name Server record
+ GNS_TYPE_DNS_CNAME = 5 // [RFC1035] Canonical Name
record
+ GNS_TYPE_DNS_SOA = 6 // [RFC2308] Start Of [a zone
of] Authority
+ GNS_TYPE_DNS_PTR = 12 // [RFC1035] Pointer record
+ GNS_TYPE_DNS_MX = 15 // [RFC7505] Mail eXchange record
+ GNS_TYPE_DNS_TXT = 16 // [RFC1035] Text record
+ GNS_TYPE_DNS_RP = 17 // [RFC1183] Responsible Person
+ GNS_TYPE_DNS_AFSDB = 18 // [RFC1183] AFS Database Record
+ GNS_TYPE_DNS_SIG = 24 // [RFC2535] Signature
+ GNS_TYPE_DNS_KEY = 25 // [RFC2930] Key record
+ GNS_TYPE_DNS_AAAA = 28 // [RFC3596] IPv6 Address record
+ GNS_TYPE_DNS_LOC = 29 // [RFC1876] Location record
+ GNS_TYPE_DNS_SRV = 33 // [RFC2782] Service locator
+ GNS_TYPE_DNS_NAPTR = 35 // [RFC3403] Naming Authority
Pointer
+ GNS_TYPE_DNS_KX = 36 // [RFC2230] Key eXchanger record
+ GNS_TYPE_DNS_CERT = 37 // [RFC4398] Certificate record
+ GNS_TYPE_DNS_DNAME = 39 // [RFC2672] Delegation Name
+ GNS_TYPE_DNS_APL = 42 // [RFC3123] Address Prefix List
+ GNS_TYPE_DNS_DS = 43 // [RFC4034] Delegation Signer
+ GNS_TYPE_DNS_SSHFP = 44 // [RFC4255] SSH public key
Fingerprint
+ GNS_TYPE_DNS_IPSECKEY = 45 // [RFC4025] IPsec Key
+ GNS_TYPE_DNS_RRSIG = 46 // [RFC4034] DNSSEC Signature
+ GNS_TYPE_DNS_NSEC = 47 // [RFC4034] Next-Secure record
+ GNS_TYPE_DNS_DNSKEY = 48 // [RFC4034] DNS Key record
+ GNS_TYPE_DNS_DHCID = 49 // [RFC4701] DHCP Identifier
+ GNS_TYPE_DNS_NSEC3 = 50 // [RFC5155] NSEC record version
3 or NSEC hashed
+ GNS_TYPE_DNS_NSEC3PARAM = 51 // [RFC5155] NSEC3 Parameters
+ GNS_TYPE_DNS_TLSA = 52 // [RFC6698] TLSA certificate
association
+ GNS_TYPE_DNS_HIP = 55 // [RFC5205] Host Identity
Protocol
+ GNS_TYPE_DNS_CDS = 59 // [RFC7344] Child DS
+ GNS_TYPE_DNS_CDNSKEY = 60 // [RFC7344] Child DNSKEY
+ GNS_TYPE_DNS_TKEY = 249 // [RFC2930] Secret Key
+ GNS_TYPE_DNS_TSIG = 250 // [RFC2845] Transaction
Signature
+ GNS_TYPE_DNS_URI = 256 // [RFC7553] Uniform Resource
Identifier
+ GNS_TYPE_DNS_CAA = 257 // [RFC6844] Certification
Authority Authorization
+ GNS_TYPE_DNS_TA = 32768 // [–] DNSSEC Trust Authorities
+ GNS_TYPE_DNS_DLV = 32769 // [RFC4431] DNSSEC Lookaside
Validation record
+ GNS_TYPE_PKEY = 65536 // Record type for GNS zone
transfer ("PKEY").
+ GNS_TYPE_NICK = 65537 // Record type for GNS nick
names ("NICK").
+ GNS_TYPE_LEHO = 65538 // Record type for GNS legacy
hostnames ("LEHO").
+ GNS_TYPE_VPN = 65539 // Record type for VPN resolution
+ GNS_TYPE_GNS2DNS = 65540 // Record type for delegation to
DNS.
+ GNS_TYPE_BOX = 65541 // Record type for a boxed
record (see TLSA/SRV handling in GNS).
+ GNS_TYPE_PLACE = 65542 // Record type for a social
place.
+ GNS_TYPE_PHONE = 65543 // Record type for a phone (of
CONVERSATION).
+ GNS_TYPE_RECLAIM_ATTR = 65544 // Record type for identity
attributes (of RECLAIM).
+ GNS_TYPE_RECLAIM_TICKET = 65545 // Record type for local ticket
references
+ GNS_TYPE_CREDENTIAL = 65547 // Record type for credential
+ GNS_TYPE_POLICY = 65548 // Record type for policies
+ GNS_TYPE_ATTRIBUTE = 65549 // Record type for reverse
lookups
+ GNS_TYPE_RECLAIM_ATTR_REF = 65550 // Record type for reclaim
records
+ GNS_TYPE_RECLAIM_MASTER = 65551 // Record type for RECLAIM master
+ GNS_TYPE_RECLAIM_OIDC_CLIENT = 65552 // Record type for reclaim OIDC
clients
+ GNS_TYPE_RECLAIM_OIDC_REDIRECT = 65553 // Record type for reclaim OIDC
redirect URIs
+
+ GNS_TYPE = map[int]string{
+ GNS_TYPE_ANY: "GNS_TYPE_ANY",
+ GNS_TYPE_DNS_A: "GNS_TYPE_DNS_A",
+ GNS_TYPE_DNS_NS: "GNS_TYPE_DNS_NS ",
+ GNS_TYPE_DNS_NS: "GNS_TYPE_DNS_NS",
+ GNS_TYPE_DNS_NS: "GNS_TYPE_DNS_NS",
+ GNS_TYPE_DNS_CNAME: "GNS_TYPE_DNS_CNAME ",
+ GNS_TYPE_DNS_NS: "GNS_TYPE_DNS_NS",
+ GNS_TYPE_DNS_CNAME: "GNS_TYPE_DNS_CNAME",
+ GNS_TYPE_DNS_CNAME: "GNS_TYPE_DNS_CNAME",
+ GNS_TYPE_DNS_SOA: "GNS_TYPE_DNS_SOA ",
+ GNS_TYPE_DNS_CNAME: "GNS_TYPE_DNS_CNAME",
+ GNS_TYPE_DNS_SOA: "GNS_TYPE_DNS_SOA",
+ GNS_TYPE_DNS_SOA: "GNS_TYPE_DNS_SOA",
+ GNS_TYPE_DNS_PTR: "GNS_TYPE_DNS_PTR ",
+ GNS_TYPE_DNS_SOA: "GNS_TYPE_DNS_SOA",
+ GNS_TYPE_DNS_PTR: "GNS_TYPE_DNS_PTR",
+ GNS_TYPE_DNS_PTR: "GNS_TYPE_DNS_PTR",
+ GNS_TYPE_DNS_MX: "GNS_TYPE_DNS_MX ",
+ GNS_TYPE_DNS_PTR: "GNS_TYPE_DNS_PTR",
+ GNS_TYPE_DNS_MX: "GNS_TYPE_DNS_MX",
+ GNS_TYPE_DNS_MX: "GNS_TYPE_DNS_MX",
+ GNS_TYPE_DNS_TXT: "GNS_TYPE_DNS_TXT ",
+ GNS_TYPE_DNS_MX: "GNS_TYPE_DNS_MX",
+ GNS_TYPE_DNS_TXT: "GNS_TYPE_DNS_TXT",
+ GNS_TYPE_DNS_TXT: "GNS_TYPE_DNS_TXT",
+ GNS_TYPE_DNS_RP: "GNS_TYPE_DNS_RP ",
+ GNS_TYPE_DNS_TXT: "GNS_TYPE_DNS_TXT",
+ GNS_TYPE_DNS_RP: "GNS_TYPE_DNS_RP",
+ GNS_TYPE_DNS_RP: "GNS_TYPE_DNS_RP",
+ GNS_TYPE_DNS_AFSDB: "GNS_TYPE_DNS_AFSDB ",
+ GNS_TYPE_DNS_RP: "GNS_TYPE_DNS_RP",
+ GNS_TYPE_DNS_AFSDB: "GNS_TYPE_DNS_AFSDB",
+ GNS_TYPE_DNS_AFSDB: "GNS_TYPE_DNS_AFSDB",
+ GNS_TYPE_DNS_SIG: "GNS_TYPE_DNS_SIG ",
+ GNS_TYPE_DNS_AFSDB: "GNS_TYPE_DNS_AFSDB",
+ GNS_TYPE_DNS_SIG: "GNS_TYPE_DNS_SIG",
+ GNS_TYPE_DNS_SIG: "GNS_TYPE_DNS_SIG",
+ GNS_TYPE_DNS_KEY: "GNS_TYPE_DNS_KEY ",
+ GNS_TYPE_DNS_SIG: "GNS_TYPE_DNS_SIG",
+ GNS_TYPE_DNS_KEY: "GNS_TYPE_DNS_KEY",
+ GNS_TYPE_DNS_KEY: "GNS_TYPE_DNS_KEY",
+ GNS_TYPE_DNS_AAAA: "GNS_TYPE_DNS_AAAA ",
+ GNS_TYPE_DNS_KEY: "GNS_TYPE_DNS_KEY",
+ GNS_TYPE_DNS_AAAA: "GNS_TYPE_DNS_AAAA",
+ GNS_TYPE_DNS_AAAA: "GNS_TYPE_DNS_AAAA",
+ GNS_TYPE_DNS_LOC: "GNS_TYPE_DNS_LOC ",
+ GNS_TYPE_DNS_AAAA: "GNS_TYPE_DNS_AAAA",
+ GNS_TYPE_DNS_LOC: "GNS_TYPE_DNS_LOC",
+ GNS_TYPE_DNS_LOC: "GNS_TYPE_DNS_LOC",
+ GNS_TYPE_DNS_SRV: "GNS_TYPE_DNS_SRV ",
+ GNS_TYPE_DNS_LOC: "GNS_TYPE_DNS_LOC",
+ GNS_TYPE_DNS_SRV: "GNS_TYPE_DNS_SRV",
+ GNS_TYPE_DNS_SRV: "GNS_TYPE_DNS_SRV",
+ GNS_TYPE_DNS_NAPTR: "GNS_TYPE_DNS_NAPTR ",
+ GNS_TYPE_DNS_SRV: "GNS_TYPE_DNS_SRV",
+ GNS_TYPE_DNS_NAPTR: "GNS_TYPE_DNS_NAPTR",
+ GNS_TYPE_DNS_NAPTR: "GNS_TYPE_DNS_NAPTR",
+ GNS_TYPE_DNS_KX: "GNS_TYPE_DNS_KX ",
+ GNS_TYPE_DNS_NAPTR: "GNS_TYPE_DNS_NAPTR",
+ GNS_TYPE_DNS_KX: "GNS_TYPE_DNS_KX",
+ GNS_TYPE_DNS_KX: "GNS_TYPE_DNS_KX",
+ GNS_TYPE_DNS_CERT: "GNS_TYPE_DNS_CERT ",
+ GNS_TYPE_DNS_KX: "GNS_TYPE_DNS_KX",
+ GNS_TYPE_DNS_CERT: "GNS_TYPE_DNS_CERT",
+ GNS_TYPE_DNS_CERT: "GNS_TYPE_DNS_CERT",
+ GNS_TYPE_DNS_DNAME: "GNS_TYPE_DNS_DNAME ",
+ GNS_TYPE_DNS_CERT: "GNS_TYPE_DNS_CERT",
+ GNS_TYPE_DNS_DNAME: "GNS_TYPE_DNS_DNAME",
+ GNS_TYPE_DNS_DNAME: "GNS_TYPE_DNS_DNAME",
+ GNS_TYPE_DNS_APL: "GNS_TYPE_DNS_APL ",
+ GNS_TYPE_DNS_DNAME: "GNS_TYPE_DNS_DNAME",
+ GNS_TYPE_DNS_APL: "GNS_TYPE_DNS_APL",
+ GNS_TYPE_DNS_APL: "GNS_TYPE_DNS_APL",
+ GNS_TYPE_DNS_DS: "GNS_TYPE_DNS_DS ",
+ GNS_TYPE_DNS_APL: "GNS_TYPE_DNS_APL",
+ GNS_TYPE_DNS_DS: "GNS_TYPE_DNS_DS",
+ GNS_TYPE_DNS_DS: "GNS_TYPE_DNS_DS",
+ GNS_TYPE_DNS_SSHFP: "GNS_TYPE_DNS_SSHFP ",
+ GNS_TYPE_DNS_DS: "GNS_TYPE_DNS_DS",
+ GNS_TYPE_DNS_SSHFP: "GNS_TYPE_DNS_SSHFP",
+ GNS_TYPE_DNS_SSHFP: "GNS_TYPE_DNS_SSHFP",
+ GNS_TYPE_DNS_IPSECKEY: "GNS_TYPE_DNS_IPSECKEY ",
+ GNS_TYPE_DNS_SSHFP: "GNS_TYPE_DNS_SSHFP",
+ GNS_TYPE_DNS_IPSECKEY: "GNS_TYPE_DNS_IPSECKEY",
+ GNS_TYPE_DNS_IPSECKEY: "GNS_TYPE_DNS_IPSECKEY",
+ GNS_TYPE_DNS_RRSIG: "GNS_TYPE_DNS_RRSIG ",
+ GNS_TYPE_DNS_IPSECKEY: "GNS_TYPE_DNS_IPSECKEY",
+ GNS_TYPE_DNS_RRSIG: "GNS_TYPE_DNS_RRSIG",
+ GNS_TYPE_DNS_RRSIG: "GNS_TYPE_DNS_RRSIG",
+ GNS_TYPE_DNS_NSEC: "GNS_TYPE_DNS_NSEC ",
+ GNS_TYPE_DNS_RRSIG: "GNS_TYPE_DNS_RRSIG",
+ GNS_TYPE_DNS_NSEC: "GNS_TYPE_DNS_NSEC",
+ GNS_TYPE_DNS_NSEC: "GNS_TYPE_DNS_NSEC",
+ GNS_TYPE_DNS_DNSKEY: "GNS_TYPE_DNS_DNSKEY ",
+ GNS_TYPE_DNS_NSEC: "GNS_TYPE_DNS_NSEC",
+ GNS_TYPE_DNS_DNSKEY: "GNS_TYPE_DNS_DNSKEY",
+ GNS_TYPE_DNS_DNSKEY: "GNS_TYPE_DNS_DNSKEY",
+ GNS_TYPE_DNS_DHCID: "GNS_TYPE_DNS_DHCID ",
+ GNS_TYPE_DNS_DNSKEY: "GNS_TYPE_DNS_DNSKEY",
+ GNS_TYPE_DNS_DHCID: "GNS_TYPE_DNS_DHCID",
+ GNS_TYPE_DNS_DHCID: "GNS_TYPE_DNS_DHCID",
+ GNS_TYPE_DNS_NSEC3: "GNS_TYPE_DNS_NSEC3 ",
+ GNS_TYPE_DNS_DHCID: "GNS_TYPE_DNS_DHCID",
+ GNS_TYPE_DNS_NSEC3: "GNS_TYPE_DNS_NSEC3",
+ GNS_TYPE_DNS_NSEC3: "GNS_TYPE_DNS_NSEC3",
+ GNS_TYPE_DNS_NSEC3PARAM: "GNS_TYPE_DNS_NSEC3PARAM ",
+ GNS_TYPE_DNS_NSEC3: "GNS_TYPE_DNS_NSEC3",
+ GNS_TYPE_DNS_NSEC3PARAM: "GNS_TYPE_DNS_NSEC3PARAM",
+ GNS_TYPE_DNS_NSEC3PARAM: "GNS_TYPE_DNS_NSEC3PARAM",
+ GNS_TYPE_DNS_TLSA: "GNS_TYPE_DNS_TLSA ",
+ GNS_TYPE_DNS_NSEC3PARAM: "GNS_TYPE_DNS_NSEC3PARAM",
+ GNS_TYPE_DNS_TLSA: "GNS_TYPE_DNS_TLSA",
+ GNS_TYPE_DNS_TLSA: "GNS_TYPE_DNS_TLSA",
+ GNS_TYPE_DNS_HIP: "GNS_TYPE_DNS_HIP ",
+ GNS_TYPE_DNS_TLSA: "GNS_TYPE_DNS_TLSA",
+ GNS_TYPE_DNS_HIP: "GNS_TYPE_DNS_HIP",
+ GNS_TYPE_DNS_HIP: "GNS_TYPE_DNS_HIP",
+ GNS_TYPE_DNS_CDS: "GNS_TYPE_DNS_CDS ",
+ GNS_TYPE_DNS_HIP: "GNS_TYPE_DNS_HIP",
+ GNS_TYPE_DNS_CDS: "GNS_TYPE_DNS_CDS",
+ GNS_TYPE_DNS_CDS: "GNS_TYPE_DNS_CDS",
+ GNS_TYPE_DNS_CDNSKEY: "GNS_TYPE_DNS_CDNSKEY ",
+ GNS_TYPE_DNS_CDS: "GNS_TYPE_DNS_CDS",
+ GNS_TYPE_DNS_CDNSKEY: "GNS_TYPE_DNS_CDNSKEY",
+ GNS_TYPE_DNS_CDNSKEY: "GNS_TYPE_DNS_CDNSKEY",
+ GNS_TYPE_DNS_TKEY: "GNS_TYPE_DNS_TKEY ",
+ GNS_TYPE_DNS_CDNSKEY: "GNS_TYPE_DNS_CDNSKEY",
+ GNS_TYPE_DNS_TKEY: "GNS_TYPE_DNS_TKEY",
+ GNS_TYPE_DNS_TKEY: "GNS_TYPE_DNS_TKEY",
+ GNS_TYPE_DNS_TSIG: "GNS_TYPE_DNS_TSIG ",
+ GNS_TYPE_DNS_TKEY: "GNS_TYPE_DNS_TKEY",
+ GNS_TYPE_DNS_TSIG: "GNS_TYPE_DNS_TSIG",
+ GNS_TYPE_DNS_TSIG: "GNS_TYPE_DNS_TSIG",
+ GNS_TYPE_DNS_URI: "GNS_TYPE_DNS_URI ",
+ GNS_TYPE_DNS_TSIG: "GNS_TYPE_DNS_TSIG",
+ GNS_TYPE_DNS_URI: "GNS_TYPE_DNS_URI",
+ GNS_TYPE_DNS_URI: "GNS_TYPE_DNS_URI",
+ GNS_TYPE_DNS_CAA: "GNS_TYPE_DNS_CAA ",
+ GNS_TYPE_DNS_URI: "GNS_TYPE_DNS_URI",
+ GNS_TYPE_DNS_CAA: "GNS_TYPE_DNS_CAA",
+ GNS_TYPE_DNS_CAA: "GNS_TYPE_DNS_CAA",
+ GNS_TYPE_DNS_TA: "GNS_TYPE_DNS_TA ",
+ GNS_TYPE_DNS_CAA: "GNS_TYPE_DNS_CAA",
+ GNS_TYPE_DNS_TA: "GNS_TYPE_DNS_TA",
+ GNS_TYPE_DNS_TA: "GNS_TYPE_DNS_TA",
+ GNS_TYPE_DNS_DLV: "GNS_TYPE_DNS_DLV ",
+ GNS_TYPE_DNS_TA: "GNS_TYPE_DNS_TA",
+ GNS_TYPE_DNS_DLV: "GNS_TYPE_DNS_DLV",
+ GNS_TYPE_DNS_DLV: "GNS_TYPE_DNS_DLV",
+ GNS_TYPE_PKEY: "GNS_TYPE_PKEY ",
+ GNS_TYPE_DNS_DLV: "GNS_TYPE_DNS_DLV",
+ GNS_TYPE_PKEY: "GNS_TYPE_PKEY",
+ GNS_TYPE_PKEY: "GNS_TYPE_PKEY",
+ GNS_TYPE_NICK: "GNS_TYPE_NICK ",
+ GNS_TYPE_PKEY: "GNS_TYPE_PKEY",
+ GNS_TYPE_NICK: "GNS_TYPE_NICK",
+ GNS_TYPE_NICK: "GNS_TYPE_NICK",
+ GNS_TYPE_LEHO: "GNS_TYPE_LEHO ",
+ GNS_TYPE_NICK: "GNS_TYPE_NICK",
+ GNS_TYPE_LEHO: "GNS_TYPE_LEHO",
+ GNS_TYPE_LEHO: "GNS_TYPE_LEHO",
+ GNS_TYPE_VPN: "GNS_TYPE_VPN ",
+ GNS_TYPE_LEHO: "GNS_TYPE_LEHO",
+ GNS_TYPE_VPN: "GNS_TYPE_VPN",
+ GNS_TYPE_VPN: "GNS_TYPE_VPN",
+ GNS_TYPE_GNS2DNS: "GNS_TYPE_GNS2DNS ",
+ GNS_TYPE_VPN: "GNS_TYPE_VPN",
+ GNS_TYPE_GNS2DNS: "GNS_TYPE_GNS2DNS",
+ GNS_TYPE_GNS2DNS: "GNS_TYPE_GNS2DNS",
+ GNS_TYPE_BOX: "GNS_TYPE_BOX ",
+ GNS_TYPE_GNS2DNS: "GNS_TYPE_GNS2DNS",
+ GNS_TYPE_BOX: "GNS_TYPE_BOX",
+ GNS_TYPE_BOX: "GNS_TYPE_BOX",
+ GNS_TYPE_PLACE: "GNS_TYPE_PLACE ",
+ GNS_TYPE_BOX: "GNS_TYPE_BOX",
+ GNS_TYPE_PLACE: "GNS_TYPE_PLACE",
+ GNS_TYPE_PLACE: "GNS_TYPE_PLACE",
+ GNS_TYPE_PHONE: "GNS_TYPE_PHONE ",
+ GNS_TYPE_PLACE: "GNS_TYPE_PLACE",
+ GNS_TYPE_PHONE: "GNS_TYPE_PHONE",
+ GNS_TYPE_PHONE: "GNS_TYPE_PHONE",
+ GNS_TYPE_RECLAIM_ATTR: "GNS_TYPE_RECLAIM_ATTR ",
+ GNS_TYPE_PHONE: "GNS_TYPE_PHONE",
+ GNS_TYPE_RECLAIM_ATTR: "GNS_TYPE_RECLAIM_ATTR",
+ GNS_TYPE_RECLAIM_ATTR: "GNS_TYPE_RECLAIM_ATTR",
+ GNS_TYPE_RECLAIM_TICKET: "GNS_TYPE_RECLAIM_TICKET ",
+ GNS_TYPE_RECLAIM_ATTR: "GNS_TYPE_RECLAIM_ATTR",
+ GNS_TYPE_RECLAIM_TICKET: "GNS_TYPE_RECLAIM_TICKET",
+ GNS_TYPE_RECLAIM_TICKET: "GNS_TYPE_RECLAIM_TICKET",
+ GNS_TYPE_CREDENTIAL: "GNS_TYPE_CREDENTIAL ",
+ GNS_TYPE_RECLAIM_TICKET: "GNS_TYPE_RECLAIM_TICKET",
+ GNS_TYPE_CREDENTIAL: "GNS_TYPE_CREDENTIAL",
+ GNS_TYPE_CREDENTIAL: "GNS_TYPE_CREDENTIAL",
+ GNS_TYPE_POLICY: "GNS_TYPE_POLICY ",
+ GNS_TYPE_CREDENTIAL: "GNS_TYPE_CREDENTIAL",
+ GNS_TYPE_POLICY: "GNS_TYPE_POLICY",
+ GNS_TYPE_POLICY: "GNS_TYPE_POLICY",
+ GNS_TYPE_ATTRIBUTE: "GNS_TYPE_ATTRIBUTE ",
+ GNS_TYPE_POLICY: "GNS_TYPE_POLICY",
+ GNS_TYPE_ATTRIBUTE: "GNS_TYPE_ATTRIBUTE",
+ GNS_TYPE_ATTRIBUTE: "GNS_TYPE_ATTRIBUTE",
+ GNS_TYPE_RECLAIM_ATTR_REF: "GNS_TYPE_RECLAIM_ATTR_REF ",
+ GNS_TYPE_ATTRIBUTE: "GNS_TYPE_ATTRIBUTE",
+ GNS_TYPE_RECLAIM_ATTR_REF: "GNS_TYPE_RECLAIM_ATTR_REF",
+ GNS_TYPE_RECLAIM_ATTR_REF: "GNS_TYPE_RECLAIM_ATTR_REF",
+ GNS_TYPE_RECLAIM_MASTER: "GNS_TYPE_RECLAIM_MASTER ",
+ GNS_TYPE_RECLAIM_ATTR_REF: "GNS_TYPE_RECLAIM_ATTR_REF",
+ GNS_TYPE_RECLAIM_MASTER: "GNS_TYPE_RECLAIM_MASTER",
+ GNS_TYPE_RECLAIM_MASTER: "GNS_TYPE_RECLAIM_MASTER",
+ GNS_TYPE_RECLAIM_OIDC_CLIENT: "GNS_TYPE_RECLAIM_OIDC_CLIENT ",
+ GNS_TYPE_RECLAIM_MASTER: "GNS_TYPE_RECLAIM_MASTER",
+ GNS_TYPE_RECLAIM_OIDC_CLIENT: "GNS_TYPE_RECLAIM_OIDC_CLIENT",
+ GNS_TYPE_RECLAIM_OIDC_CLIENT: "GNS_TYPE_RECLAIM_OIDC_CLIENT",
+ GNS_TYPE_RECLAIM_OIDC_REDIRECT: "GNS_TYPE_RECLAIM_OIDC_REDIRECT
",
+ GNS_TYPE_RECLAIM_OIDC_CLIENT: "GNS_TYPE_RECLAIM_OIDC_CLIENT",
+ GNS_TYPE_RECLAIM_OIDC_REDIRECT:
"GNS_TYPE_RECLAIM_OIDC_REDIRECT",
+ }
+
+ // GNS_LocalOptions
+ GNS_LO_DEFAULT = 0 // Defaults, look in cache, then in DHT.
+ GNS_LO_NO_DHT = 1 // Never look in the DHT, keep request to local
cache.
+ GNS_LO_LOCAL_MASTER = 2 // For the rightmost label, only look in the
cache.
+)
diff --git a/src/gnunet/enums/signature.go b/src/gnunet/enums/signature.go
new file mode 100644
index 0000000..cb60f65
--- /dev/null
+++ b/src/gnunet/enums/signature.go
@@ -0,0 +1,34 @@
+package enums
+
+// Signature purpose constants
+const (
+ SIG_TEST = iota // Only used in test cases!
+ SIG_TRANSPORT_PONG_OWN // Confirming a particular address.
+ SIG_TRANSPORT_DISCONNECT // Confirming intent to disconnect.
+ SIG_REVOCATION // Confirming a key revocation.
+ SIG_NAMESPACE_ADVERTISEMENT // Namespace/pseudonym
advertisement.
+ SIG_PEER_PLACEMENT // Affirm certain content (LOCation
URIs).
+ SIG_FS_KBLOCK // Obsolete, legacy value.
+ SIG_FS_SBLOCK // Obsolete, legacy value.
+ SIG_FS_NBLOCK // Obsolete, legacy value.
+ SIG_FS_NBLOCK_KSIG // Obsolete, legacy value.
+ SIG_RESOLVER_RESPONSE // DNS_Advertisement
+ SIG_DNS_RECORD //
+ SIG_CHAT_MESSAGE // Chat message.
+ SIG_CHAT_RECEIPT // Confirmation receipt for chat
message.
+ SIG_NSE_SEND // Network size estimate message.
+ SIG_GNS_RECORD_SIGN // GNS record block.
+ SIG_ECC_KEY // Set a session key.
+ SIG_FS_UBLOCK // UBlock Signature, done using
DSS, not ECC.
+ SIG_REGEX_ACCEPT // Accept state (affirm matching
service).
+ SIG_MULTICAST_MESSAGE // Multicast message sent by origin.
+ SIG_CONVERSATION_RING // Conversation ring.
+ SIG_SECRETSHARING_DKG1 // First round of distributed key
generation.
+ SIG_SECRETSHARING_DKG2 // Second round of distributed key
generation.
+ SIG_SECRETSHARING_DECRYPTION // Cooperative decryption.
+ SIG_MULTICAST_REQUEST // Multicast request sent by member.
+ SIG_SENSOR_ANOMALY_REPORT // Sensor anomaly report message.
+ SIG_GNUID_TOKEN // GNUid Token.
+ SIG_GNUID_TICKET // GNUid Ticket.
+ SIG_CREDENTIAL // GNUnet credential.
+)
diff --git a/src/gnunet/go.mod b/src/gnunet/go.mod
new file mode 100644
index 0000000..fce27da
--- /dev/null
+++ b/src/gnunet/go.mod
@@ -0,0 +1,5 @@
+module gnunet
+
+go 1.12
+
+require github.com/bfix/gospel v0.0.0-20190831192707-26682cc943e5
diff --git a/src/gnunet/go.sum b/src/gnunet/go.sum
new file mode 100644
index 0000000..e1de475
--- /dev/null
+++ b/src/gnunet/go.sum
@@ -0,0 +1,10 @@
+github.com/bfix/gospel v0.0.0-20190831192707-26682cc943e5
h1:vPrWvbQmjjEaWseuni9K7ffKzYLBLPbK27oHw5DvTAY=
+github.com/bfix/gospel v0.0.0-20190831192707-26682cc943e5/go.mod
h1:RQYETFV9SP+VriIsHVqCntRpSbbRvCBnNTtbUl9NAKA=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod
h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod
h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod
h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod
h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod
h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod
h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
diff --git a/src/gnunet/message/const.go b/src/gnunet/message/const.go
new file mode 100644
index 0000000..245af80
--- /dev/null
+++ b/src/gnunet/message/const.go
@@ -0,0 +1,37 @@
+package message
+
+import (
+ "time"
+)
+
+// Time constants
+var (
+ // How long is a PONG signature valid? We'll recycle a signature until
+ // 1/4 of this time is remaining. PONGs should expire so that if our
+ // external addresses change an adversary cannot replay them
indefinitely.
+ // OTOH, we don't want to spend too much time generating PONG
signatures,
+ // so they must have some lifetime to reduce our CPU usage.
+ PONG_SIGNATURE_LIFETIME = 1 * time.Hour
+
+ // After how long do we expire an address in a HELLO that we just
+ // validated? This value is also used for our own addresses when we
+ // create a HELLO.
+ HELLO_ADDRESS_EXPIRATION = 12 * time.Hour
+
+ // How often do we allow PINGing an address that we have not yet
+ // validated? This also determines how long we track an address that
+ // we cannot validate (because after this time we can destroy the
+ // validation record).
+ UNVALIDATED_PING_KEEPALIVE = 5 * time.Minute
+
+ // How often do we PING an address that we have successfully validated
+ // in the past but are not actively using? Should be (significantly)
+ // smaller than HELLO_ADDRESS_EXPIRATION.
+ VALIDATED_PING_FREQUENCY = 15 * time.Minute
+
+ // How often do we PING an address that we are currently using?
+ CONNECTED_PING_FREQUENCY = 2 * time.Minute
+
+ // How much delay is acceptable for sending the PING or PONG?
+ ACCEPTABLE_PING_DELAY = 1 * time.Second
+)
diff --git a/src/gnunet/message/factory.go b/src/gnunet/message/factory.go
new file mode 100644
index 0000000..5feb8c3
--- /dev/null
+++ b/src/gnunet/message/factory.go
@@ -0,0 +1,64 @@
+package message
+
+import (
+ "errors"
+ "fmt"
+)
+
+// NewEmptyMessage creates a new empty message object for the given type.
+func NewEmptyMessage(msgType uint16) (Message, error) {
+ switch msgType {
+ //------------------------------------------------------------------
+ // Transport
+ //------------------------------------------------------------------
+ case TRANSPORT_TCP_WELCOME:
+ return NewTransportTcpWelcomeMsg(nil), nil
+ case HELLO:
+ return NewHelloMsg(nil), nil
+ case TRANSPORT_SESSION_QUOTA:
+ return NewSessionQuotaMsg(0), nil
+ case TRANSPORT_SESSION_SYN:
+ return NewSessionSynMsg(0), nil
+ case TRANSPORT_SESSION_SYN_ACK:
+ return NewSessionSynAckMsg(0), nil
+ case TRANSPORT_SESSION_ACK:
+ return new(SessionAckMsg), nil
+ case TRANSPORT_PING:
+ return NewTransportPingMsg(nil, nil), nil
+ case TRANSPORT_PONG:
+ return NewTransportPongMsg(0, nil), nil
+ case TRANSPORT_SESSION_KEEPALIVE:
+ return NewSessionKeepAliveMsg(), nil
+
+ //------------------------------------------------------------------
+ // Core
+ //------------------------------------------------------------------
+ case CORE_EPHEMERAL_KEY:
+ return NewEphemeralKeyMsg(), nil
+
+ //------------------------------------------------------------------
+ // DHT
+ //------------------------------------------------------------------
+ case DHT_CLIENT_GET:
+ return NewDHTClientGetMsg(nil), nil
+ case DHT_CLIENT_RESULT:
+ return NewDHTClientResultMsg(nil), nil
+
+ //------------------------------------------------------------------
+ // GNS
+ //------------------------------------------------------------------
+ case GNS_LOOKUP:
+ return NewGNSLookupMsg(), nil
+ case GNS_LOOKUP_RESULT:
+ return NewGNSLookupResultMsg(0), nil
+
+ //------------------------------------------------------------------
+ // Namecache
+ //------------------------------------------------------------------
+ case NAMECACHE_LOOKUP_BLOCK:
+ return NewNamecacheLookupMsg(nil), nil
+ case NAMECACHE_LOOKUP_BLOCK_RESPONSE:
+ return NewNamecacheLookupResultMsg(), nil
+ }
+ return nil, errors.New(fmt.Sprintf("Unknown message type %d", msgType))
+}
diff --git a/src/gnunet/message/message.go b/src/gnunet/message/message.go
new file mode 100644
index 0000000..6b49a55
--- /dev/null
+++ b/src/gnunet/message/message.go
@@ -0,0 +1,37 @@
+package message
+
+import (
+ "errors"
+
+ "github.com/bfix/gospel/data"
+)
+
+var (
+ ErrMsgHeaderTooSmall = errors.New("Message header too small")
+)
+
+type Message interface {
+ Header() *MessageHeader
+}
+
+type MessageHeader struct {
+ MsgSize uint16 `order:"big"`
+ MsgType uint16 `order:"big"`
+}
+
+func (mh *MessageHeader) Size() uint16 {
+ return mh.MsgSize
+}
+
+func (mh *MessageHeader) Type() uint16 {
+ return mh.MsgType
+}
+
+func GetMsgHeader(b []byte) (mh *MessageHeader, err error) {
+ if b == nil || len(b) < 4 {
+ return nil, ErrMsgHeaderTooSmall
+ }
+ mh = new(MessageHeader)
+ err = data.Unmarshal(mh, b)
+ return
+}
diff --git a/src/gnunet/message/msg_core.go b/src/gnunet/message/msg_core.go
new file mode 100644
index 0000000..6e9b2d1
--- /dev/null
+++ b/src/gnunet/message/msg_core.go
@@ -0,0 +1,95 @@
+package message
+
+import (
+ //"encoding/hex"
+ "fmt"
+ "time"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/data"
+ "gnunet/enums"
+ "gnunet/util"
+)
+
+type EphKeyBlock struct {
+ SignSize uint32 `order:"big"` // length of signed block
+ SigPurpose uint32 `order:"big"` // signature purpose: SIG_ECC_KEY
+ CreateTime uint64 `order:"big"` // Time of key creation
+ ExpireTime uint64 `order:"big"` // Time of key expiration
+ EphemeralKey []byte `size:"32"` // Ephemeral EdDSA public key
+ PeerID []byte `size:"32"` // Peer identity (EdDSA public key)
+}
+
+type EphemeralKeyMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // CORE_EPHEMERAL_KEY (88)
+ SenderStatus uint32 `order:"big"` // enum PeerStateMachine
+ Signature []byte `size:"64"` // EdDSA signature
+ SignedBlock *EphKeyBlock
+}
+
+func NewEphemeralKeyMsg() *EphemeralKeyMsg {
+ return &EphemeralKeyMsg{
+ MsgSize: 160,
+ MsgType: CORE_EPHEMERAL_KEY,
+ SenderStatus: 1,
+ Signature: make([]byte, 64),
+ SignedBlock: &EphKeyBlock{
+ SignSize: 88,
+ SigPurpose: enums.SIG_ECC_KEY,
+ CreateTime: util.GetAbsoluteTimeNow(),
+ ExpireTime: util.GetAbsoluteTimeOffset(12 *
time.Hour),
+ EphemeralKey: make([]byte, 32),
+ PeerID: make([]byte, 32),
+ },
+ }
+}
+
+func (m *EphemeralKeyMsg) String() string {
+ return fmt.Sprintf("EphKeyMsg{%s,%s,%s,%d}",
+ util.EncodeBinaryToString(m.SignedBlock.PeerID),
+ util.EncodeBinaryToString(m.SignedBlock.EphemeralKey),
+ util.Timestamp(m.SignedBlock.ExpireTime),
+ m.SenderStatus)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *EphemeralKeyMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+func (m *EphemeralKeyMsg) Public() *ed25519.PublicKey {
+ return ed25519.NewPublicKeyFromBytes(m.SignedBlock.PeerID)
+}
+
+func (m *EphemeralKeyMsg) Verify(pub *ed25519.PublicKey) (bool, error) {
+ data, err := data.Marshal(m.SignedBlock)
+ if err != nil {
+ return false, err
+ }
+ sig, err := ed25519.NewEdSignatureFromBytes(m.Signature)
+ if err != nil {
+ return false, err
+ }
+ return pub.EdVerify(data, sig)
+}
+
+func NewEphemeralKey(peerId []byte, ltPrv *ed25519.PrivateKey)
(*ed25519.PrivateKey, *EphemeralKeyMsg, error) {
+ msg := NewEphemeralKeyMsg()
+ copy(msg.SignedBlock.PeerID, peerId)
+ seed := util.NewRndArray(32)
+ prv := ed25519.NewPrivateKeyFromSeed(seed)
+ copy(msg.SignedBlock.EphemeralKey, prv.Public().Bytes())
+
+ data, err := data.Marshal(msg.SignedBlock)
+ if err != nil {
+ return nil, nil, err
+ }
+ sig, err := ltPrv.EdSign(data)
+ if err != nil {
+ return nil, nil, err
+ }
+ copy(msg.Signature, sig.Bytes())
+
+ return prv, msg, nil
+}
diff --git a/src/gnunet/message/msg_dht.go b/src/gnunet/message/msg_dht.go
new file mode 100644
index 0000000..8b0e49c
--- /dev/null
+++ b/src/gnunet/message/msg_dht.go
@@ -0,0 +1,106 @@
+package message
+
+import (
+ "encoding/hex"
+ "fmt"
+
+ "gnunet/crypto"
+ "gnunet/enums"
+ "gnunet/util"
+)
+
+//----------------------------------------------------------------------
+// DHT_CLIENT_GET
+//----------------------------------------------------------------------
+
+// DHTClientGetMsg
+type DHTClientGetMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // DHT_CLIENT_GET (143)
+ Options uint32 `order:"big"` // Message options (DHT_RO_???)
+ ReplLevel uint32 `order:"big"` // Replication level for this
message
+ Type uint32 `order:"big"` // The type for the data for
the GET request (BLOCK_TYPE_???)
+ Key *crypto.HashCode // The key to search for
+ Id uint64 `order:"big"` // Unique ID identifying this
request
+ XQuery []byte `size:"*"` // Optional xquery
+}
+
+// NewDHTClientGetMsg creates a new default DHTClientGetMsg object.
+func NewDHTClientGetMsg(key *crypto.HashCode) *DHTClientGetMsg {
+ if key == nil {
+ key = new(crypto.HashCode)
+ }
+ return &DHTClientGetMsg{
+ MsgSize: 88,
+ MsgType: DHT_CLIENT_GET,
+ Options: uint32(enums.DHT_RO_NONE),
+ ReplLevel: 1,
+ Type: uint32(enums.BLOCK_TYPE_ANY),
+ Key: key,
+ Id: 0,
+ XQuery: make([]byte, 0),
+ }
+}
+
+// Set a (new) XQuery in this message and return previous XQuery.
+func (m *DHTClientGetMsg) SetXQuery(xq []byte) []byte {
+ prev := m.XQuery
+ m.MsgSize -= uint16(len(prev))
+ m.XQuery = util.Clone(xq)
+ m.MsgSize += uint16(len(xq))
+ return prev
+}
+
+func (m *DHTClientGetMsg) String() string {
+ return
fmt.Sprintf("DHTClientGetMsg{Id:%d,Type=%d,Options=%d,Repl=%d,Key=%s}",
+ m.Id, m.Type, m.Options, m.ReplLevel,
hex.EncodeToString(m.Key.Bits))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *DHTClientGetMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// DHT_CLIENT_RESULT
+//----------------------------------------------------------------------
+
+// DHTClientResultMsg
+type DHTClientResultMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // DHT_CLIENT_RESULT (145)
+ Type uint32 `order:"big"` // The type for the data
+ PutPathLen uint32 `order:"big"` // Number of peers recorded
in outgoing path
+ GetPathLen uint32 `order:"big"` // Number of peers recorded
from storage location
+ Id uint64 `order:"big"` // Unique ID of the matching
GET request
+ Expire uint64 `order:"big"` // Expiration time
+ Key *crypto.HashCode // The key that was searched for
+ Data []byte `size:"*"` // put path, get path and actual
data
+}
+
+// NewDHTClientResultMsg creates a new default DHTClientResultMsg object.
+func NewDHTClientResultMsg(key *crypto.HashCode) *DHTClientResultMsg {
+ if key == nil {
+ key = crypto.NewHashCode()
+ }
+ return &DHTClientResultMsg{
+ MsgSize: 64, // empty message size (no data)
+ MsgType: DHT_CLIENT_RESULT,
+ Type: 0,
+ PutPathLen: 0,
+ GetPathLen: 0,
+ Id: 0,
+ Expire: 0,
+ Key: key,
+ Data: make([]byte, 0),
+ }
+}
+
+func (m *DHTClientResultMsg) String() string {
+ return fmt.Sprintf("DHTClientResultMsg{Id:%d}", m.Id)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *DHTClientResultMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
diff --git a/src/gnunet/message/msg_gns.go b/src/gnunet/message/msg_gns.go
new file mode 100644
index 0000000..7ea7d3c
--- /dev/null
+++ b/src/gnunet/message/msg_gns.go
@@ -0,0 +1,128 @@
+package message
+
+import (
+ "fmt"
+
+ "github.com/bfix/gospel/logger"
+ "gnunet/enums"
+ "gnunet/util"
+)
+
+//----------------------------------------------------------------------
+// GNS_LOOKUP
+//----------------------------------------------------------------------
+
+// GNSLookupMsg
+type GNSLookupMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // GNS_LOOKUP (500)
+ Id uint32 `order:"big"` // Unique identifier for this request
(for key collisions).
+ Zone []byte `size:"32"` // Zone that is to be used for lookup
+ Options uint16 `order:"big"` // Local options for where to look for
results
+ Reserved uint16 `order:"big"` // Always 0
+ Type uint32 `order:"big"` // the type of record to look up
+ Name []byte `size:"*"` // zero-terminated name to look up
+}
+
+// NewGNSLookupMsg creates a new default message.
+func NewGNSLookupMsg() *GNSLookupMsg {
+ return &GNSLookupMsg{
+ MsgSize: 48, // record size with no name
+ MsgType: GNS_LOOKUP,
+ Id: 0,
+ Zone: make([]byte, 32),
+ Options: uint16(enums.GNS_LO_DEFAULT),
+ Reserved: 0,
+ Type: uint32(enums.GNS_TYPE_ANY),
+ Name: nil,
+ }
+}
+
+// SetName
+func (m *GNSLookupMsg) SetName(name string) {
+ m.Name = util.Clone(append([]byte(name), 0))
+ m.MsgSize = uint16(48 + len(m.Name))
+}
+
+// GetName
+func (m *GNSLookupMsg) GetName() string {
+ size := len(m.Name)
+ if m.Name[size-1] != 0 {
+ logger.Println(logger.WARN, "GNS_LOOKUP name not
NULL-terminated")
+ } else {
+ size -= 1
+ }
+ return string(m.Name[:size])
+}
+
+// String
+func (m *GNSLookupMsg) String() string {
+ return fmt.Sprintf(
+ "GNSLookupMsg{Id=%d,Zone=%s,Options=%d,Type=%d,Name=%s}",
+ m.Id, util.EncodeBinaryToString(m.Zone),
+ m.Options, m.Type, m.GetName())
+}
+
+// Header returns the message header in a separate instance.
+func (msg *GNSLookupMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// GNS_LOOKUP_RESULT
+//----------------------------------------------------------------------
+
+type GNSResourceRecord struct {
+ Expires uint64 `order:"big"` // Expiration time for the record
+ Size uint32 `order:"big"` // Number of bytes in 'Data'
+ Type uint32 `order:"big"` // Type of the GNS/DNS record
+ Flags uint32 `order:"big"` // Flags for the record
+ Data []byte `size:"Size"` // Record data
+}
+
+func (r *GNSResourceRecord) String() string {
+ return
fmt.Sprintf("GNSResourceRecord{Type=%s,Expire=%s,Flag=%d,Size=%d}",
+ enums.GNS_TYPE[int(r.Type)], util.Timestamp(r.Expires),
r.Flags, r.Size)
+}
+
+// GNSLookupResultMsg
+type GNSLookupResultMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // GNS_LOOKUP_RESULT (501)
+ Id uint32 `order:"big"` // Unique identifier for
this request (for key collisions).
+ Count uint32 `order:"big"` // The number of records
contained in response
+ Records []*GNSResourceRecord `size:"Count"` // GNS resource records
+}
+
+// NewGNSLookupResultMsg
+func NewGNSLookupResultMsg(id uint32) *GNSLookupResultMsg {
+ return &GNSLookupResultMsg{
+ MsgSize: 12, // Empty result (no records)
+ MsgType: GNS_LOOKUP_RESULT,
+ Id: id,
+ Count: 0,
+ Records: make([]*GNSResourceRecord, 0),
+ }
+}
+
+// AddRecord
+func (m *GNSLookupResultMsg) AddRecord(rec *GNSResourceRecord) error {
+ recSize := 20 + int(rec.Size)
+ if int(m.MsgSize)+recSize > enums.GNS_MAX_BLOCK_SIZE {
+ return fmt.Errorf("gns.AddRecord(): MAX_BLOCK_SIZE reached")
+ }
+ m.Records = append(m.Records, rec)
+ m.MsgSize += uint16(recSize)
+ m.Count++
+ return nil
+}
+
+// String
+func (m *GNSLookupResultMsg) String() string {
+ return fmt.Sprintf("GNSLookupResultMsg{Id=%d,Count=%d}", m.Id, m.Count)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *GNSLookupResultMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
diff --git a/src/gnunet/message/msg_namecache.go
b/src/gnunet/message/msg_namecache.go
new file mode 100644
index 0000000..421b625
--- /dev/null
+++ b/src/gnunet/message/msg_namecache.go
@@ -0,0 +1,86 @@
+package message
+
+import (
+ "encoding/hex"
+ "fmt"
+
+ //"github.com/bfix/gospel/logger"
+ "gnunet/crypto"
+ //"gnunet/enums"
+ "gnunet/util"
+)
+
+//----------------------------------------------------------------------
+// NAMECACHE_LOOKUP_BLOCK
+//----------------------------------------------------------------------
+
+// NamecacheLookupMsg
+type NamecacheLookupMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK (431)
+ Id uint32 `order:"big"` // Request Id
+ Query *crypto.HashCode // Query data
+}
+
+// NewNamecacheLookupMsg creates a new default message.
+func NewNamecacheLookupMsg(query *crypto.HashCode) *NamecacheLookupMsg {
+ if query == nil {
+ query = crypto.NewHashCode()
+ }
+ return &NamecacheLookupMsg{
+ MsgSize: 72,
+ MsgType: NAMECACHE_LOOKUP_BLOCK,
+ Id: 0,
+ Query: query,
+ }
+}
+
+// String
+func (m *NamecacheLookupMsg) String() string {
+ return fmt.Sprintf("NamecacheLookupMsg{Id=%d,Query=%s}",
+ m.Id, hex.EncodeToString(m.Query.Bits))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *NamecacheLookupMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// NAMECACHE_LOOKUP_BLOCK_RESPONSE
+//----------------------------------------------------------------------
+
+// NamecacheLookupResultMsg
+type NamecacheLookupResultMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK_RESPONSE (432)
+ Id uint32 `order:"big"` // Request Id
+ Expire uint64 `order:"big"` // Expiration time
+ Signature []byte `size:"64"` // ECDSA signature
+ DerivedKey []byte `size:"32"` // Derived public key
+ EncData []byte `size:"*"` // Encrypted block data
+}
+
+// NewNamecacheLookupResultMsg creates a new default message.
+func NewNamecacheLookupResultMsg() *NamecacheLookupResultMsg {
+ return &NamecacheLookupResultMsg{
+ MsgSize: 112,
+ MsgType: NAMECACHE_LOOKUP_BLOCK_RESPONSE,
+ Id: 0,
+ Expire: 0,
+ Signature: make([]byte, 64),
+ DerivedKey: make([]byte, 32),
+ EncData: make([]byte, 0),
+ }
+}
+
+// String
+func (m *NamecacheLookupResultMsg) String() string {
+ return fmt.Sprintf("NamecacheLookupResultMsg{Id=%d,Expire=%s}",
+ m.Id, util.Timestamp(m.Expire))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *NamecacheLookupResultMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
diff --git a/src/gnunet/message/msg_transport.go
b/src/gnunet/message/msg_transport.go
new file mode 100644
index 0000000..ec4e143
--- /dev/null
+++ b/src/gnunet/message/msg_transport.go
@@ -0,0 +1,440 @@
+package message
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/data"
+ "gnunet/enums"
+ "gnunet/util"
+)
+
+//----------------------------------------------------------------------
+// TRANSPORT_TCP_WELCOME
+//----------------------------------------------------------------------
+
+type TransportTcpWelcomeMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_TCP_WELCOME (61)
+ PeerID []byte `size:"32"` // Peer identity (EdDSA public key)
+}
+
+func NewTransportTcpWelcomeMsg(peerid []byte) *TransportTcpWelcomeMsg {
+ msg := &TransportTcpWelcomeMsg{
+ MsgSize: 36,
+ MsgType: TRANSPORT_TCP_WELCOME,
+ PeerID: make([]byte, 32),
+ }
+ if peerid != nil {
+ copy(msg.PeerID[:], peerid)
+ } else {
+ msg.MsgSize = 0
+ msg.MsgType = 0
+ }
+ return msg
+}
+
+func (m *TransportTcpWelcomeMsg) String() string {
+ return fmt.Sprintf("TransportTcpWelcomeMsg{'%s'}",
util.EncodeBinaryToString(m.PeerID))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *TransportTcpWelcomeMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_PONG
+//
+// Message used to validate a HELLO. The challenge is included in the
+// confirmation to make matching of replies to requests possible. The
+// signature signs our public key, an expiration time and our address.<p>
+//
+// This message is followed by our transport address that the PING tried
+// to confirm (if we liked it). The address can be empty (zero bytes)
+// if the PING had not address either (and we received the request via
+// a connection that we initiated).
+//----------------------------------------------------------------------
+
+type SignedAddress struct {
+ SignLength uint32 `order:"big"` // Length of signed block
+ Purpose uint32 `order:"big"` // SIG_TRANSPORT_PONG_OWN
+ ExpireOn uint64 `order:"big"` // usec epoch
+ AddrSize uint32 `order:"big"` // size of address
+ Address []byte `size:"AddrSize"` // address
+}
+
+func NewSignedAddress(a *util.Address) *SignedAddress {
+ // serialize address
+ addrData, _ := data.Marshal(a)
+ alen := len(addrData)
+ addr := &SignedAddress{
+ SignLength: uint32(alen + 20),
+ Purpose: enums.SIG_TRANSPORT_PONG_OWN,
+ ExpireOn: util.GetAbsoluteTimeOffset(12 * time.Hour),
+ AddrSize: uint32(alen),
+ Address: make([]byte, alen),
+ }
+ copy(addr.Address, addrData)
+ return addr
+}
+
+type TransportPongMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_PING (372)
+ Challenge uint32 // Challenge code (to ensure fresh reply)
+ Signature []byte `size:"64"` // Signature of address
+ SignedBlock *SignedAddress // signed block of data
+}
+
+func NewTransportPongMsg(challenge uint32, a *util.Address) *TransportPongMsg {
+ m := &TransportPongMsg{
+ MsgSize: 72,
+ MsgType: TRANSPORT_PONG,
+ Challenge: challenge,
+ Signature: make([]byte, 64),
+ SignedBlock: new(SignedAddress),
+ }
+ if a != nil {
+ sa := NewSignedAddress(a)
+ m.MsgSize += uint16(sa.SignLength)
+ m.SignedBlock = sa
+ }
+ return m
+}
+
+func (m *TransportPongMsg) String() string {
+ a := new(util.Address)
+ if err := data.Unmarshal(a, m.SignedBlock.Address); err == nil {
+ return fmt.Sprintf("TransportPongMsg{%s,%d}", a, m.Challenge)
+ }
+ return fmt.Sprintf("TransportPongMsg{<unkown>,%d}", m.Challenge)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *TransportPongMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+func (m *TransportPongMsg) Sign(prv *ed25519.PrivateKey) error {
+ data, err := data.Marshal(m.SignedBlock)
+ if err != nil {
+ fmt.Printf("Sign: %s\n", err)
+ return err
+ }
+ sig, err := prv.EdSign(data)
+ if err != nil {
+ fmt.Printf("Sign: %s\n", err)
+ return err
+ }
+ copy(m.Signature, sig.Bytes())
+ return nil
+}
+
+func (m *TransportPongMsg) Verify(pub *ed25519.PublicKey) (bool, error) {
+ data, err := data.Marshal(m.SignedBlock)
+ if err != nil {
+ return false, err
+ }
+ sig, err := ed25519.NewEdSignatureFromBytes(m.Signature)
+ if err != nil {
+ return false, err
+ }
+ return pub.EdVerify(data, sig)
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_PING
+//
+// Message used to ask a peer to validate receipt (to check an address
+// from a HELLO). Followed by the address we are trying to validate,
+// or an empty address if we are just sending a PING to confirm that a
+// connection which the receiver (of the PING) initiated is still valid.
+//----------------------------------------------------------------------
+
+type TransportPingMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_PING (372)
+ Challenge uint32 // Challenge code (to ensure fresh reply)
+ Target []byte `size:"32"` // EdDSA public key (long-term) of target
peer
+ Address []byte `size:"*"` // encoded address
+}
+
+func NewTransportPingMsg(target []byte, a *util.Address) *TransportPingMsg {
+ m := &TransportPingMsg{
+ MsgSize: uint16(40),
+ MsgType: TRANSPORT_PING,
+ Challenge: util.RndUInt32(),
+ Target: make([]byte, 32),
+ Address: nil,
+ }
+ if target != nil {
+ copy(m.Target, target)
+ }
+ if a != nil {
+ if addrData, err := data.Marshal(a); err == nil {
+ m.Address = addrData
+ m.MsgSize += uint16(len(addrData))
+ }
+ }
+ return m
+}
+
+func (m *TransportPingMsg) String() string {
+ a := new(util.Address)
+ data.Unmarshal(a, m.Address)
+ return fmt.Sprintf("TransportPingMsg{%s,%s,%d}",
+ util.EncodeBinaryToString(m.Target), a, m.Challenge)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *TransportPingMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// HELLO
+//
+// A HELLO message is used to exchange information about
+// transports with other peers. This struct is always
+// followed by the actual network addresses which have
+// the format:
+//
+// 1) transport-name (0-terminated)
+// 2) address-length (uint16_t, network byte order)
+// 3) address expiration
+// 4) address (address-length bytes)
+//----------------------------------------------------------------------
+
+type HelloAddress struct {
+ Transport string // Name of transport
+ AddrSize uint16 `order:"big"` // Size of address entry
+ ExpireOn uint64 `order:"big"` // Expiry date
+ Address []byte `size:"AddrSize"` // Address specification
+}
+
+func NewAddress(a *util.Address) *HelloAddress {
+ addr := &HelloAddress{
+ Transport: a.Transport,
+ AddrSize: uint16(len(a.Address)),
+ ExpireOn: util.GetAbsoluteTimeOffset(12 * time.Hour),
+ Address: make([]byte, len(a.Address)),
+ }
+ copy(addr.Address, a.Address)
+ return addr
+}
+
+func (a *HelloAddress) String() string {
+ return fmt.Sprintf("Address{%s,%s}", util.AddressString(a.Transport,
a.Address), util.Timestamp(a.ExpireOn))
+}
+
+type HelloMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // HELLO (17)
+ FriendOnly uint32 `order:"big"` // =1: do not gossip this HELLO
+ PeerID []byte `size:"32"` // EdDSA public key (long-term)
+ Addresses []*HelloAddress `size:"*"` // List of end-point addressess
+}
+
+func NewHelloMsg(peerid []byte) *HelloMsg {
+ m := &HelloMsg{
+ MsgSize: 40,
+ MsgType: HELLO,
+ FriendOnly: 0,
+ PeerID: make([]byte, 32),
+ Addresses: make([]*HelloAddress, 0),
+ }
+ if peerid != nil {
+ copy(m.PeerID, peerid)
+ }
+ return m
+}
+
+func (m *HelloMsg) String() string {
+ return fmt.Sprintf("HelloMsg{%s,%d,%v}",
util.EncodeBinaryToString(m.PeerID), m.FriendOnly, m.Addresses)
+}
+
+func (m *HelloMsg) AddAddress(a *HelloAddress) {
+ m.Addresses = append(m.Addresses, a)
+ m.MsgSize += uint16(len(a.Transport)) + a.AddrSize + 11
+}
+
+// Header returns the message header in a separate instance.
+func (msg *HelloMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_ACK
+//----------------------------------------------------------------------
+
+type SessionAckMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_ACK (377)
+}
+
+func NewSessionAckMsg() *SessionAckMsg {
+ return &SessionAckMsg{
+ MsgSize: 16,
+ MsgType: TRANSPORT_SESSION_ACK,
+ }
+}
+
+func (m *SessionAckMsg) String() string {
+ return "SessionAck{}"
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionAckMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_SYN
+//----------------------------------------------------------------------
+
+type SessionSynMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN (375)
+ Reserved uint32 `order:"big"` // reserved (=0)
+ Timestamp uint64 `order:"big"` // usec epoch
+}
+
+func NewSessionSynMsg(t uint64) *SessionSynMsg {
+ if t == 0 {
+ t = util.GetAbsoluteTimeNow()
+ }
+ return &SessionSynMsg{
+ MsgSize: 16,
+ MsgType: TRANSPORT_SESSION_SYN,
+ Reserved: 0,
+ Timestamp: t,
+ }
+}
+
+func (m *SessionSynMsg) String() string {
+ return fmt.Sprintf("SessionSyn{%s}", util.Timestamp(m.Timestamp))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionSynMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_SYN_ACK
+//----------------------------------------------------------------------
+
+type SessionSynAckMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN_ACK (376)
+ Reserved uint32 `order:"big"` // reserved (=0)
+ Timestamp uint64 `order:"big"` // usec epoch
+}
+
+func NewSessionSynAckMsg(t uint64) *SessionSynAckMsg {
+ if t == 0 {
+ t = util.GetAbsoluteTimeNow()
+ }
+ return &SessionSynAckMsg{
+ MsgSize: 16,
+ MsgType: TRANSPORT_SESSION_SYN_ACK,
+ Reserved: 0,
+ Timestamp: t,
+ }
+}
+
+func (m *SessionSynAckMsg) String() string {
+ return fmt.Sprintf("SessionSynAck{%s}", util.Timestamp(m.Timestamp))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionSynAckMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_QUOTA
+//----------------------------------------------------------------------
+
+type SessionQuotaMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_QUOTA (379)
+ Quota uint32 `order:"big"` // Quota in bytes per second
+}
+
+func NewSessionQuotaMsg(quota uint32) *SessionQuotaMsg {
+ m := new(SessionQuotaMsg)
+ if quota > 0 {
+ m.MsgSize = 8
+ m.MsgType = TRANSPORT_SESSION_QUOTA
+ m.Quota = quota
+ }
+ return m
+}
+
+func (m *SessionQuotaMsg) String() string {
+ return fmt.Sprintf("SessionQuotaMsg{%sB/s}",
util.Scale1024(uint64(m.Quota)))
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionQuotaMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_KEEPALIVE_RESPONSE
+//----------------------------------------------------------------------
+
+type SessionKeepAliveRespMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE_RESPONSE
(382)
+ Nonce uint32
+}
+
+func NewSessionKeepAliveRespMsg(nonce uint32) *SessionKeepAliveRespMsg {
+ m := &SessionKeepAliveRespMsg{
+ MsgSize: 8,
+ MsgType: TRANSPORT_SESSION_KEEPALIVE_RESPONSE,
+ Nonce: nonce,
+ }
+ return m
+}
+
+func (m *SessionKeepAliveRespMsg) String() string {
+ return fmt.Sprintf("SessionKeepAliveRespMsg{%d}", m.Nonce)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionKeepAliveRespMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
+
+//----------------------------------------------------------------------
+// TRANSPORT_SESSION_KEEPALIVE
+//----------------------------------------------------------------------
+
+type SessionKeepAliveMsg struct {
+ MsgSize uint16 `order:"big"` // total size of message
+ MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE (381)
+ Nonce uint32
+}
+
+func NewSessionKeepAliveMsg() *SessionKeepAliveMsg {
+ m := &SessionKeepAliveMsg{
+ MsgSize: 8,
+ MsgType: TRANSPORT_SESSION_KEEPALIVE,
+ Nonce: util.RndUInt32(),
+ }
+ return m
+}
+
+func (m *SessionKeepAliveMsg) String() string {
+ return fmt.Sprintf("SessionKeepAliveMsg{%d}", m.Nonce)
+}
+
+// Header returns the message header in a separate instance.
+func (msg *SessionKeepAliveMsg) Header() *MessageHeader {
+ return &MessageHeader{msg.MsgSize, msg.MsgType}
+}
diff --git a/src/gnunet/message/types.go b/src/gnunet/message/types.go
new file mode 100644
index 0000000..e3ab9b4
--- /dev/null
+++ b/src/gnunet/message/types.go
@@ -0,0 +1,817 @@
+package message
+
+// GNUnet message types
+const (
+ TEST = 1 // Test if service is online (deprecated)
+ DUMMY = 2 // Dummy messages for testing / benchmarking
+ DUMMY2 = 3 // Another dummy messages for testing / benchmarking
+
+ //------------------------------------------------------------------
+ // RESOLVER message types
+ //------------------------------------------------------------------
+
+ RESOLVER_REQUEST = 4 // Request DNS resolution
+ RESOLVER_RESPONSE = 5 // Response to a DNS resolution request
+
+ //------------------------------------------------------------------
+ // AGPL source code download
+ //------------------------------------------------------------------
+
+ REQUEST_AGPL = 6 // Message to request source code link
+ RESPONSE_AGPL = 7 // Source code link
+
+ //------------------------------------------------------------------
+ // ARM message types
+ //------------------------------------------------------------------
+
+ ARM_START = 8 // Request to ARM to start a service
+ ARM_STOP = 9 // Request to ARM to stop a service
+ ARM_RESULT = 10 // Response from ARM
+ ARM_STATUS = 11 // Status update from ARM
+ ARM_LIST = 12 // Request to ARM to list all currently running
services
+ ARM_LIST_RESULT = 13 // Response from ARM for listing currently running
services
+ ARM_MONITOR = 14 // Request to ARM to notify client of service
status changes
+ ARM_TEST = 15 // Test if ARM service is online
+
+ //------------------------------------------------------------------
+ // HELLO message types
+ //------------------------------------------------------------------
+
+ HELLO_LEGACY = 16 // Deprecated HELLO message
+ HELLO = 17 // HELLO message with friend_only flag
+
+ //------------------------------------------------------------------
+ // FRAGMENTATION message types
+ //------------------------------------------------------------------
+
+ FRAGMENT = 18 // FRAGMENT of a larger message
+ FRAGMENT_ACK = 19 // Acknowledgement of a FRAGMENT of a larger message
+
+ //------------------------------------------------------------------
+ // Transport-WLAN message types
+ //------------------------------------------------------------------
+
+ WLAN_DATA_TO_HELPER = 39 // Type of data messages from the plugin to
the gnunet-wlan-helper
+ WLAN_DATA_FROM_HELPER = 40 // Type of data messages from the
gnunet-wlan-helper to the plugin
+ WLAN_HELPER_CONTROL = 41 // Control message between the
gnunet-wlan-helper and the daemon (with the MAC)
+ WLAN_ADVERTISEMENT = 42 // Type of messages for advertisement over
wlan
+ WLAN_DATA = 43 // Type of messages for data over the wlan
+
+ //------------------------------------------------------------------
+ // Transport-DV message types
+ //------------------------------------------------------------------
+
+ DV_RECV = 44 // DV service to DV Plugin message
+ DV_SEND = 45 // DV Plugin to DV service message
+ DV_SEND_ACK = 46 // Confirmation or failure of a DV_SEND
message
+ DV_ROUTE = 47 // P2P DV message encapsulating some real
message
+ DV_START = 48 // DV Plugin to DV service message,
indicating startup.
+ DV_CONNECT = 49 // P2P DV message telling plugin that a peer
connected
+ DV_DISCONNECT = 50 // P2P DV message telling plugin that a peer
disconnected
+ DV_SEND_NACK = 51 // P2P DV message telling plugin that a
message transmission failed (negative ACK)
+ DV_DISTANCE_CHANGED = 52 // P2P DV message telling plugin that our
distance to a peer changed
+ DV_BOX = 53 // DV message box for boxing multiple
messages.
+ TRANSPORT_XU_MESSAGE = 55 // Experimental message type.
+
+ //------------------------------------------------------------------
+ // Transport-UDP message types
+ //------------------------------------------------------------------
+
+ TRANSPORT_UDP_MESSAGE = 56 // Normal UDP message type.
+ TRANSPORT_UDP_ACK = 57 // UDP ACK.
+
+ //------------------------------------------------------------------
+ // Transport-TCP message types
+ //------------------------------------------------------------------
+
+ TRANSPORT_TCP_NAT_PROBE = 60 // TCP NAT probe message
+ TRANSPORT_TCP_WELCOME = 61 // Welcome message between TCP transports.
+ TRANSPORT_ATS = 62 // Message to force transport to update
bandwidth assignment (LEGACY)
+
+ //------------------------------------------------------------------
+ // NAT message types
+ //------------------------------------------------------------------
+
+ NAT_TEST = 63 // Message to ask NAT server to perform traversal test
+
+ //------------------------------------------------------------------
+ // CORE message types
+ //------------------------------------------------------------------
+
+ CORE_INIT = 64 // Initial setup message from core
client to core.
+ CORE_INIT_REPLY = 65 // Response from core to core client to
INIT message.
+ CORE_NOTIFY_CONNECT = 67 // Notify clients about new peer-to-peer
connections (triggered after key exchange).
+ CORE_NOTIFY_DISCONNECT = 68 // Notify clients about peer
disconnecting.
+ CORE_NOTIFY_STATUS_CHANGE = 69 // Notify clients about peer status
change.
+ CORE_NOTIFY_INBOUND = 70 // Notify clients about incoming P2P
messages.
+ CORE_NOTIFY_OUTBOUND = 71 // Notify clients about outgoing P2P
transmissions.
+ CORE_SEND_REQUEST = 74 // Request from client to transmit
message.
+ CORE_SEND_READY = 75 // Confirmation from core that message
can now be sent
+ CORE_SEND = 76 // Client with message to transmit
(after SEND_READY confirmation was received).
+ CORE_MONITOR_PEERS = 78 // Request for connection monitoring
from CORE service.
+ CORE_MONITOR_NOTIFY = 79 // Reply for monitor by CORE service.
+ CORE_ENCRYPTED_MESSAGE = 82 // Encapsulation for an encrypted
message between peers.
+ CORE_PING = 83 // Check that other peer is alive
(challenge).
+ CORE_PONG = 84 // Confirmation that other peer is alive.
+ CORE_HANGUP = 85 // Request by the other peer to
terminate the connection.
+ CORE_COMPRESSED_TYPE_MAP = 86 // gzip-compressed type map of the sender
+ CORE_BINARY_TYPE_MAP = 87 // uncompressed type map of the sender
+ CORE_EPHEMERAL_KEY = 88 // Session key exchange between peers.
+ CORE_CONFIRM_TYPE_MAP = 89 // Other peer confirms having received
the type map
+
+ //------------------------------------------------------------------
+ // DATASTORE message types
+ //------------------------------------------------------------------
+
+ DATASTORE_RESERVE = 92 // Message sent by datastore client
on join.
+ DATASTORE_RELEASE_RESERVE = 93 // Message sent by datastore client
on join.
+ DATASTORE_STATUS = 94 // Message sent by datastore to
client informing about status processing a request (in response to RESERVE,
RELEASE_RESERVE, PUT, UPDATE and REMOVE requests).
+ DATASTORE_PUT = 95 // Message sent by datastore client
to store data.
+ DATASTORE_GET = 97 // Message sent by datastore client
to get data.
+ DATASTORE_GET_REPLICATION = 98 // Message sent by datastore client
to get random data.
+ DATASTORE_GET_ZERO_ANONYMITY = 99 // Message sent by datastore client
to get random data.
+ DATASTORE_DATA = 100 // Message sent by datastore to
client providing requested data (in response to GET or GET_RANDOM request).
+ DATASTORE_DATA_END = 101 // Message sent by datastore to
client signaling end of matching data. This message will also be sent for
"GET_RANDOM", even though "GET_RANDOM" returns at most one data item.
+ DATASTORE_REMOVE = 102 // Message sent by datastore client
to remove data.
+ DATASTORE_DROP = 103 // Message sent by datastore client
to drop the database.
+ DATASTORE_GET_KEY = 104 // Message sent by datastore client
to get data by key.
+
+ //------------------------------------------------------------------
+ // FS message types
+ //------------------------------------------------------------------
+
+ FS_REQUEST_LOC_SIGN = 126 // Message sent by fs client to request
LOC signature.
+ FS_REQUEST_LOC_SIGNATURE = 127 // Reply sent by fs service with LOC
signature.
+ FS_INDEX_START = 128 // Message sent by fs client to start
indexing.
+ FS_INDEX_START_OK = 129 // Affirmative response to a request for
start indexing.
+ FS_INDEX_START_FAILED = 130 // Response to a request for start
indexing that refuses.
+ FS_INDEX_LIST_GET = 131 // Request from client for list of
indexed files.
+ FS_INDEX_LIST_ENTRY = 132 // Reply to client with an indexed file
name.
+ FS_INDEX_LIST_END = 133 // Reply to client indicating end of
list.
+ FS_UNINDEX = 134 // Request from client to unindex a file.
+ FS_UNINDEX_OK = 135 // Reply to client indicating unindex
receipt.
+ FS_START_SEARCH = 136 // Client asks FS service to start a
(keyword) search.
+ FS_GET = 137 // P2P request for content (one FS to
another).
+ FS_PUT = 138 // P2P response with content or active
migration of content. Also used between the service and clients (in response
to #FS_START_SEARCH).
+ FS_MIGRATION_STOP = 139 // Peer asks us to stop migrating
content towards it for a while.
+ FS_CADET_QUERY = 140 // P2P request for content (one FS to
another via a cadet).
+ FS_CADET_REPLY = 141 // P2P answer for content (one FS to
another via a cadet).
+
+ //------------------------------------------------------------------
+ // DHT message types
+ //------------------------------------------------------------------
+
+ DHT_CLIENT_PUT = 142 // Client wants to store item in DHT.
+ DHT_CLIENT_GET = 143 // Client wants to lookup item in
DHT.
+ DHT_CLIENT_GET_STOP = 144 // Client wants to stop search in
DHT.
+ DHT_CLIENT_RESULT = 145 // Service returns result to client.
+ DHT_P2P_PUT = 146 // Peer is storing data in DHT.
+ DHT_P2P_GET = 147 // Peer tries to find data in DHT.
+ DHT_P2P_RESULT = 148 // Data is returned to peer from DHT.
+ DHT_MONITOR_GET = 149 // Receive information about
transiting GETs
+ DHT_MONITOR_GET_RESP = 150 // Receive information about
transiting GET responses
+ DHT_MONITOR_PUT = 151 // Receive information about
transiting PUTs
+ DHT_MONITOR_PUT_RESP = 152 // Receive information about
transiting PUT responses (TODO)
+ DHT_MONITOR_START = 153 // Request information about
transiting messages
+ DHT_MONITOR_STOP = 154 // Stop information about transiting
messages
+ DHT_CLIENT_GET_RESULTS_KNOWN = 156 // Certain results are already known
to the client, filter those.
+
+ //------------------------------------------------------------------
+ // HOSTLIST message types
+ //------------------------------------------------------------------
+
+ HOSTLIST_ADVERTISEMENT = 160 // Hostlist advertisement message
+
+ //------------------------------------------------------------------
+ // STATISTICS message types
+ //------------------------------------------------------------------
+
+ STATISTICS_SET = 168 // Set a statistical value.
+ STATISTICS_GET = 169 // Get a statistical value(s).
+ STATISTICS_VALUE = 170 // Response to a STATISTICS_GET
message (with value).
+ STATISTICS_END = 171 // Response to a STATISTICS_GET
message (end of value stream).
+ STATISTICS_WATCH = 172 // Watch changes to a statistical
value. Message format is the same as for GET, except that the subsystem and
entry name must be given.
+ STATISTICS_WATCH_VALUE = 173 // Changes to a watched value.
+ STATISTICS_DISCONNECT = 174 // Client is done sending service
requests and will now disconnect.
+ STATISTICS_DISCONNECT_CONFIRM = 175 // Service confirms disconnect and
that it is done processing all requests from the client.
+
+ //------------------------------------------------------------------
+ // VPN message types
+ //------------------------------------------------------------------
+
+ VPN_HELPER = 185 // Type of messages between the
gnunet-vpn-helper and the daemon
+ VPN_ICMP_TO_SERVICE = 190 // ICMP packet for a service.
+ VPN_ICMP_TO_INTERNET = 191 // ICMP packet for the Internet.
+ VPN_ICMP_TO_VPN = 192 // ICMP packet for the VPN
+ VPN_DNS_TO_INTERNET = 193 // DNS request for a DNS exit
service.
+ VPN_DNS_FROM_INTERNET = 194 // DNS reply from a DNS exit
service.
+ VPN_TCP_TO_SERVICE_START = 195 // TCP packet for a service.
+ VPN_TCP_TO_INTERNET_START = 196 // TCP packet for the Internet.
+ VPN_TCP_DATA_TO_EXIT = 197 // TCP packet of an established
connection.
+ VPN_TCP_DATA_TO_VPN = 198 // TCP packet of an established
connection.
+ VPN_UDP_TO_SERVICE = 199 // UDP packet for a service.
+ VPN_UDP_TO_INTERNET = 200 // UDP packet for the Internet.
+ VPN_UDP_REPLY = 201 // UDP packet from a remote host
+ VPN_CLIENT_REDIRECT_TO_IP = 202 // Client asks VPN service to
setup an IP to redirect traffic via an exit node to some global IP address.
+ VPN_CLIENT_REDIRECT_TO_SERVICE = 203 // Client asks VPN service to
setup an IP to redirect traffic to some peer offering a service.
+ VPN_CLIENT_USE_IP = 204 // VPN service responds to client
with an IP to use for the requested redirection.
+
+ //------------------------------------------------------------------
+ // VPN-DNS message types
+ //------------------------------------------------------------------
+
+ DNS_CLIENT_INIT = 211 // Initial message from client to DNS service
for registration.
+ DNS_CLIENT_REQUEST = 212 // Type of messages between the
gnunet-helper-dns and the service
+ DNS_CLIENT_RESPONSE = 213 // Type of messages between the
gnunet-helper-dns and the service
+ DNS_HELPER = 214 // Type of messages between the
gnunet-helper-dns and the service
+
+ //------------------------------------------------------------------
+ // CHAT message types START
+ //------------------------------------------------------------------
+
+ CHAT_JOIN_REQUEST = 300 // Message sent from client to
join a chat room.
+ CHAT_JOIN_NOTIFICATION = 301 // Message sent to client to
indicate joining of another room member.
+ CHAT_LEAVE_NOTIFICATION = 302 // Message sent to client to
indicate leaving of another room member.
+ CHAT_MESSAGE_NOTIFICATION = 303 // Notification sent by service to
client indicating that we've received a chat message.
+ CHAT_TRANSMIT_REQUEST = 304 // Request sent by client to
transmit a chat message to another room members.
+ CHAT_CONFIRMATION_RECEIPT = 305 // Receipt sent from a message
receiver to the service to confirm delivery of a chat message.
+ CHAT_CONFIRMATION_NOTIFICATION = 306 // Notification sent from the
service to the original sender to acknowledge delivery of a chat message.
+ CHAT_P2P_JOIN_NOTIFICATION = 307 // P2P message sent to indicate
joining of another room member.
+ CHAT_P2P_LEAVE_NOTIFICATION = 308 // P2P message sent to indicate
leaving of another room member.
+ CHAT_P2P_SYNC_REQUEST = 309 // P2P message sent to a newly
connected peer to request its known clients in order to synchronize room
members.
+ CHAT_P2P_MESSAGE_NOTIFICATION = 310 // Notification sent from one peer
to another to indicate that we have received a chat message.
+ CHAT_P2P_CONFIRMATION_RECEIPT = 311 // P2P receipt confirming delivery
of a chat message.
+
+ //------------------------------------------------------------------
+ // NSE (network size estimation) message types
+ //------------------------------------------------------------------
+
+ NSE_START = 321 // client->service message indicating start
+ NSE_P2P_FLOOD = 322 // P2P message sent from nearest peer
+ NSE_ESTIMATE = 323 // service->client message indicating
+
+ //------------------------------------------------------------------
+ // PEERINFO message types
+ //------------------------------------------------------------------
+
+ PEERINFO_GET = 330 // Request update and listing of a peer
+ PEERINFO_GET_ALL = 331 // Request update and listing of all peers
+ PEERINFO_INFO = 332 // Information about one of the peers
+ PEERINFO_INFO_END = 333 // End of information about other peers
+ PEERINFO_NOTIFY = 334 // Start notifying this client about changes
+
+ //------------------------------------------------------------------
+ // ATS message types
+ //------------------------------------------------------------------
+
+ ATS_START = 340 // Type of the 'struct
ClientStartMessage' sent by clients to ATS to identify the type of the client.
+ ATS_REQUEST_ADDRESS = 341 // Type of the 'struct
RequestAddressMessage' sent by clients to request an address to help connect.
+ ATS_REQUEST_ADDRESS_CANCEL = 342 // Type of the 'struct
RequestAddressMessage' sent by clients to request an address to help connect.
+ ATS_ADDRESS_UPDATE = 343 // Type of the 'struct
AddressUpdateMessage' sent by clients to ATS to inform ATS about performance
changes.
+ ATS_ADDRESS_DESTROYED = 344 // Type of the 'struct
AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address
being unavailable.
+ ATS_ADDRESS_SUGGESTION = 345 // Type of the 'struct
AddressSuggestionMessage' sent by ATS to clients to suggest switching to a
different address.
+ ATS_PEER_INFORMATION = 346 // Type of the 'struct
PeerInformationMessage' sent by ATS to clients to inform about QoS for a
particular connection.
+ ATS_RESERVATION_REQUEST = 347 // Type of the 'struct
ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth
reservations.
+ ATS_RESERVATION_RESULT = 348 // Type of the 'struct
ReservationResultMessage' sent by ATS to clients in response to a reservation
request.
+ ATS_PREFERENCE_CHANGE = 349 // Type of the 'struct
ChangePreferenceMessage' sent by clients to ATS to ask for allocation
preference changes.
+ ATS_SESSION_RELEASE = 350 // Type of the 'struct
SessionReleaseMessage' sent by ATS to client to confirm that a session ID was
destroyed.
+ ATS_ADDRESS_ADD = 353 // Type of the 'struct
AddressUpdateMessage' sent by client to ATS to add a new address
+ ATS_ADDRESSLIST_REQUEST = 354 // Type of the 'struct
AddressListRequestMessage' sent by client to ATS to request information about
addresses
+ ATS_ADDRESSLIST_RESPONSE = 355 // Type of the 'struct
AddressListResponseMessage' sent by ATS to client with information about
addresses
+ ATS_PREFERENCE_FEEDBACK = 356 // Type of the 'struct
ChangePreferenceMessage' sent by clients to ATS to ask for allocation
preference changes.
+
+ //------------------------------------------------------------------
+ // TRANSPORT message types
+ //------------------------------------------------------------------
+
+ TRANSPORT_START = 360 // Message from the core
saying that the transport server should start giving it messages. This should
automatically trigger the transmission of a HELLO message.
+ TRANSPORT_CONNECT = 361 // Message from TRANSPORT
notifying about a client that connected to us.
+ TRANSPORT_DISCONNECT = 362 // Message from TRANSPORT
notifying about a client that disconnected from us.
+ TRANSPORT_SEND = 363 // Request to TRANSPORT to
transmit a message.
+ TRANSPORT_SEND_OK = 364 // Confirmation from
TRANSPORT that message for transmission has been queued (and that the next
message to this peer can now be passed to the service). Note that this
confirmation does NOT imply that the message was fully transmitted.
+ TRANSPORT_RECV = 365 // Message from TRANSPORT
notifying about a message that was received.
+ TRANSPORT_SET_QUOTA = 366 // Message telling transport
to limit its receive rate.
+ TRANSPORT_ADDRESS_TO_STRING = 367 // Request to look addresses
of peers in server.
+ TRANSPORT_ADDRESS_TO_STRING_REPLY = 368 // Response to the address
lookup request.
+ TRANSPORT_BLACKLIST_INIT = 369 // Register a client that
wants to do blacklisting.
+ TRANSPORT_BLACKLIST_QUERY = 370 // Query to a blacklisting
client (is this peer blacklisted)?
+ TRANSPORT_BLACKLIST_REPLY = 371 // Reply from blacklisting
client (answer to blacklist query).
+ TRANSPORT_PING = 372 // Transport PING message
+ TRANSPORT_PONG = 373 // Transport PONG message
+ TRANSPORT_SESSION_SYN = 375 // Transport SYN message
exchanged between transport services to indicate that a session should be
marked as 'connected'.
+ TRANSPORT_SESSION_SYN_ACK = 376 // Transport SYN_ACK message
exchanged between transport services to indicate that a SYN message was accepted
+ TRANSPORT_SESSION_ACK = 377 // Transport ACK message
exchanged between transport services to indicate that a SYN_ACK message was
accepted
+ TRANSPORT_SESSION_DISCONNECT = 378 // Transport DISCONNECT
message exchanged between transport services to indicate that a connection
should be dropped.
+ TRANSPORT_SESSION_QUOTA = 379 // Message exchanged between
transport services to indicate that the sender should limit its transmission
rate to the indicated quota.
+ TRANSPORT_MONITOR_PEER_REQUEST = 380 // Request to monitor
addresses used by a peer or all peers.
+ TRANSPORT_SESSION_KEEPALIVE = 381 // Message send by a peer to
notify the other to keep the session alive and measure latency in a regular
interval
+ TRANSPORT_SESSION_KEEPALIVE_RESPONSE = 382 // Response to a
#TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular interval
+ TRANSPORT_MONITOR_PEER_RESPONSE = 383 // Response to
#TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addresses.
+ TRANSPORT_BROADCAST_BEACON = 384 // Message send by a peer to
notify the other to keep the session alive.
+ TRANSPORT_TRAFFIC_METRIC = 385 // Message containing
traffic metrics for transport service
+ TRANSPORT_MONITOR_PLUGIN_START = 388 // Request to start
monitoring the connection state of plugins.
+ TRANSPORT_MONITOR_PLUGIN_EVENT = 389 // Monitoring event about
the connection state of plugins, generated in response to a subscription
initiated via #TRANSPORT_MONITOR_PLUGIN_START
+ TRANSPORT_MONITOR_PLUGIN_SYNC = 390 // Monitoring event
notifying client that the initial iteration is now completed and we are in sync
with the state of the subsystem.
+ TRANSPORT_MONITOR_PEER_RESPONSE_END = 391 // terminating list of
replies.
+
+ //------------------------------------------------------------------
+ // FS-PUBLISH-HELPER IPC Messages
+ //------------------------------------------------------------------
+
+ FS_PUBLISH_HELPER_PROGRESS_FILE = 420 // Progress information from
the helper: found a file
+ FS_PUBLISH_HELPER_PROGRESS_DIRECTORY = 421 // Progress information from
the helper: found a directory
+ FS_PUBLISH_HELPER_ERROR = 422 // Error signal from the
helper.
+ FS_PUBLISH_HELPER_SKIP_FILE = 423 // Signal that helper
skipped a file.
+ FS_PUBLISH_HELPER_COUNTING_DONE = 424 // Signal that helper is
done scanning the directory tree.
+ FS_PUBLISH_HELPER_META_DATA = 425 // Extracted meta data from
the helper.
+ FS_PUBLISH_HELPER_FINISHED = 426 // Signal that helper is
done.
+
+ //------------------------------------------------------------------
+ // NAMECACHE message types
+ //------------------------------------------------------------------
+
+ NAMECACHE_LOOKUP_BLOCK = 431 // Client to service: lookup block
+ NAMECACHE_LOOKUP_BLOCK_RESPONSE = 432 // Service to client: result of
block lookup
+ NAMECACHE_BLOCK_CACHE = 433 // Client to service: cache a
block
+ NAMECACHE_BLOCK_CACHE_RESPONSE = 434 // Service to client: result of
block cache request
+
+ //------------------------------------------------------------------
+ // NAMESTORE message types
+ //------------------------------------------------------------------
+
+ NAMESTORE_RECORD_STORE = 435 // Client to service: store
records (as authority)
+ NAMESTORE_RECORD_STORE_RESPONSE = 436 // Service to client: result of
store operation.
+ NAMESTORE_RECORD_LOOKUP = 437 // Client to service: lookup
label
+ NAMESTORE_RECORD_LOOKUP_RESPONSE = 438 // Service to client: lookup
label
+ NAMESTORE_ZONE_TO_NAME = 439 // Client to service: "reverse"
lookup for zone name based on zone key
+ NAMESTORE_ZONE_TO_NAME_RESPONSE = 440 // Service to client: result of
zone-to-name lookup.
+ NAMESTORE_MONITOR_START = 441 // Client to service: start
monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" --- forever).
+ NAMESTORE_MONITOR_SYNC = 442 // Service to client: you're now
in sync.
+ NAMESTORE_RECORD_RESULT = 443 // Service to client: here is a
(plaintext) record you requested.
+ NAMESTORE_MONITOR_NEXT = 444 // Client to service: I am now
ready for the next (set of) monitor events. Monitoring equivlaent of
#NAMESTORE_ZONE_ITERATION_NEXT.
+ NAMESTORE_ZONE_ITERATION_START = 445 // Client to service: please
start iteration; receives "NAMESTORE_LOOKUP_NAME_RESPONSE" messages in return.
+ NAMESTORE_ZONE_ITERATION_NEXT = 447 // Client to service: next
record(s) in iteration please.
+ NAMESTORE_ZONE_ITERATION_STOP = 448 // Client to service: stop
iterating.
+
+ //------------------------------------------------------------------
+ // LOCKMANAGER message types
+ //------------------------------------------------------------------
+
+ LOCKMANAGER_ACQUIRE = 450 // Message to acquire Lock
+ LOCKMANAGER_RELEASE = 451 // Message to release lock
+ LOCKMANAGER_SUCCESS = 452 // SUCCESS reply from lockmanager
+
+ //------------------------------------------------------------------
+ // TESTBED message types
+ //------------------------------------------------------------------
+
+ TESTBED_INIT = 460 // Initial message from a
client to a testing control service
+ TESTBED_ADD_HOST = 461 // Message to add host
+ TESTBED_ADD_HOST_SUCCESS = 462 // Message to signal that a add
host succeeded
+ TESTBED_LINK_CONTROLLERS = 463 // Message to link delegated
controller to slave controller
+ TESTBED_CREATE_PEER = 464 // Message to create a peer at
a host
+ TESTBED_RECONFIGURE_PEER = 465 // Message to reconfigure a peer
+ TESTBED_START_PEER = 466 // Message to start a peer at a
host
+ TESTBED_STOP_PEER = 467 // Message to stop a peer at a
host
+ TESTBED_DESTROY_PEER = 468 // Message to destroy a peer
+ TESTBED_CONFIGURE_UNDERLAY_LINK = 469 // Configure underlay link
message
+ TESTBED_OVERLAY_CONNECT = 470 // Message to connect peers in
a overlay
+ TESTBED_PEER_EVENT = 471 // Message for peer events
+ TESTBED_PEER_CONNECT_EVENT = 472 // Message for peer connect
events
+ TESTBED_OPERATION_FAIL_EVENT = 473 // Message for operation events
+ TESTBED_CREATE_PEER_SUCCESS = 474 // Message to signal successful
peer creation
+ TESTBED_GENERIC_OPERATION_SUCCESS = 475 // Message to signal a generic
operation has been successful
+ TESTBED_GET_PEER_INFORMATION = 476 // Message to get a peer's
information
+ TESTBED_PEER_INFORMATION = 477 // Message containing the
peer's information
+ TESTBED_REMOTE_OVERLAY_CONNECT = 478 // Message to request a
controller to make one of its peer to connect to another peer using the
contained HELLO
+ TESTBED_GET_SLAVE_CONFIGURATION = 479 // Message to request
configuration of a slave controller
+ TESTBED_SLAVE_CONFIGURATION = 480 // Message which contains the
configuration of slave controller
+ TESTBED_LINK_CONTROLLERS_RESULT = 481 // Message to signal the result
of #TESTBED_LINK_CONTROLLERS request
+ TESTBED_SHUTDOWN_PEERS = 482 // A controller receiving this
message floods it to its directly-connected sub-controllers and then stops and
destroys all peers
+ TESTBED_MANAGE_PEER_SERVICE = 483 // Message to start/stop a
service of a peer
+ TESTBED_BARRIER_INIT = 484 // Message to initialise a
barrier. Messages of these type are flooded to all sub-controllers
+ TESTBED_BARRIER_CANCEL = 485 // Message to cancel a barrier.
This message is flooded to all sub-controllers
+ TESTBED_BARRIER_STATUS = 486 // Message for signalling
status of a barrier
+ TESTBED_BARRIER_WAIT = 487 // Message sent by a peer when
it has reached a barrier and is waiting for it to be crossed
+ TESTBED_MAX = 488 // Not really a message, but
for careful checks on the testbed messages; Should always be the maximum and
never be used to send messages with this type
+ TESTBED_HELPER_INIT = 495 // The initialization message
towards gnunet-testbed-helper
+ TESTBED_HELPER_REPLY = 496 // The reply message from
gnunet-testbed-helper
+
+ //------------------------------------------------------------------
+ // GNS.
+ //------------------------------------------------------------------
+
+ GNS_LOOKUP = 500 // Client would like to resolve a name.
+ GNS_LOOKUP_RESULT = 501 // Service response to name resolution
request from client.
+ GNS_REVERSE_LOOKUP = 502 // Reverse lookup
+ GNS_REVERSE_LOOKUP_RESULT = 503 // Response to reverse lookup
+
+ //------------------------------------------------------------------
+ // CONSENSUS message types
+ //------------------------------------------------------------------
+
+ CONSENSUS_CLIENT_JOIN = 520 // Join a consensus session.
Sent by client to service as first message.
+ CONSENSUS_CLIENT_INSERT = 521 // Insert an element. Sent by
client to service.
+ CONSENSUS_CLIENT_BEGIN = 522 // Begin accepting new elements
from other participants. Sent by client to service.
+ CONSENSUS_CLIENT_RECEIVED_ELEMENT = 523 // Sent by service when a new
element is added.
+ CONSENSUS_CLIENT_CONCLUDE = 524 // Sent by client to service in
order to start the consensus conclusion.
+ CONSENSUS_CLIENT_CONCLUDE_DONE = 525 // Sent by service to client in
order to signal a completed consensus conclusion. Last message sent in a
consensus session.
+ CONSENSUS_CLIENT_ACK = 540 // Sent by client to service,
telling whether a received element should be accepted and propagated further or
not.
+ CONSENSUS_P2P_DELTA_ESTIMATE = 541 // Strata estimator.
+ CONSENSUS_P2P_DIFFERENCE_DIGEST = 542 // IBF containing all elements
of a peer.
+ CONSENSUS_P2P_ELEMENTS = 543 // One or more elements that
are sent from peer to peer.
+ CONSENSUS_P2P_ELEMENTS_REQUEST = 544 // Elements, and requests for
further elements
+ CONSENSUS_P2P_ELEMENTS_REPORT = 545 // Elements that a peer reports
to be missing at the remote peer.
+ CONSENSUS_P2P_HELLO = 546 // Initialization message for
consensus p2p communication.
+ CONSENSUS_P2P_SYNCED = 547 // Report that the peer is
synced with the partner after successfuly decoding the invertible bloom filter.
+ CONSENSUS_P2P_FIN = 548 // Interaction os over, got
synched and reported all elements
+ CONSENSUS_P2P_ABORT = 548 // Abort a round, don't send
requested elements anymore
+ CONSENSUS_P2P_ROUND_CONTEXT = 547 // Abort a round, don't send
requested elements anymore
+
+ //------------------------------------------------------------------
+ // SET message types
+ //------------------------------------------------------------------
+
+ SET_UNION_P2P_REQUEST_FULL = 565 // Demand the whole element
from the other peer, given only the hash code.
+ SET_UNION_P2P_DEMAND = 566 // Demand the whole element
from the other peer, given only the hash code.
+ SET_UNION_P2P_INQUIRY = 567 // Tell the other peer to send
us a list of hashes that match an IBF key.
+ SET_UNION_P2P_OFFER = 568 // Tell the other peer which
hashes match a given IBF key.
+ SET_REJECT = 569 // Reject a set request.
+ SET_CANCEL = 570 // Cancel a set operation
+ SET_ITER_ACK = 571 // Acknowledge result from
iteration
+ SET_RESULT = 572 // Create an empty set
+ SET_ADD = 573 // Add element to set
+ SET_REMOVE = 574 // Remove element from set
+ SET_LISTEN = 575 // Listen for operation requests
+ SET_ACCEPT = 576 // Accept a set request
+ SET_EVALUATE = 577 // Evaluate a set operation
+ SET_CONCLUDE = 578 // Start a set operation with
the given set
+ SET_REQUEST = 579 // Notify the client of a
request from a remote peer
+ SET_CREATE = 580 // Create a new local set
+ SET_P2P_OPERATION_REQUEST = 581 // Request a set operation from
a remote peer.
+ SET_UNION_P2P_SE = 582 // Strata estimator.
+ SET_UNION_P2P_IBF = 583 // Invertible bloom filter.
+ SET_P2P_ELEMENTS = 584 // Actual set elements.
+ SET_P2P_ELEMENT_REQUESTS = 585 // Requests for the elements
with the given hashes.
+ SET_UNION_P2P_DONE = 586 // Set operation is done.
+ SET_ITER_REQUEST = 587 // Start iteration over set
elements.
+ SET_ITER_ELEMENT = 588 // Element result for the
iterating client.
+ SET_ITER_DONE = 589 // Iteration end marker for the
client.
+ SET_UNION_P2P_SEC = 590 // Compressed strata estimator.
+ SET_INTERSECTION_P2P_ELEMENT_INFO = 591 // Information about the
element count for intersection
+ SET_INTERSECTION_P2P_BF = 592 // Bloom filter message for
intersection exchange started by Bob.
+ SET_INTERSECTION_P2P_DONE = 593 // Intersection operation is
done.
+ SET_COPY_LAZY_PREPARE = 594 // Ask the set service to
prepare a copy of a set.
+ SET_COPY_LAZY_RESPONSE = 595 // Give the client an ID for
connecting to the set's copy.
+ SET_COPY_LAZY_CONNECT = 596 // Sent by the client to the
server to connect to an existing, lazily copied set.
+ SET_UNION_P2P_FULL_DONE = 597 // Request all missing elements
from the other peer, based on their sets and the elements we previously sent
with #SET_P2P_ELEMENTS.
+ SET_UNION_P2P_FULL_ELEMENT = 598 // Send a set element, not as
response to a demand but because we're sending the full set.
+ SET_UNION_P2P_OVER = 599 // Request all missing elements
from the other peer, based on their sets and the elements we previously sent
with #SET_P2P_ELEMENTS.
+
+ //------------------------------------------------------------------
+ // TESTBED LOGGER message types
+ //------------------------------------------------------------------
+
+ TESTBED_LOGGER_MSG = 600 // Message for TESTBED LOGGER
+ TESTBED_LOGGER_ACK = 601 // Message for TESTBED LOGGER acknowledgement
+
+ REGEX_ANNOUNCE = 620 // Advertise regex capability.
+ REGEX_SEARCH = 621 // Search for peer with matching capability.
+ REGEX_RESULT = 622 // Result in response to regex search.
+
+ //------------------------------------------------------------------
+ // IDENTITY message types
+ //------------------------------------------------------------------
+
+ IDENTITY_START = 624 // First message send from identity
client to service (to subscribe to updates).
+ IDENTITY_RESULT_CODE = 625 // Generic response from identity service
with success and/or error message.
+ IDENTITY_UPDATE = 626 // Update about identity status from
service to clients.
+ IDENTITY_GET_DEFAULT = 627 // Client requests to know default
identity for a subsystem.
+ IDENTITY_SET_DEFAULT = 628 // Client sets default identity; or
service informs about default identity.
+ IDENTITY_CREATE = 629 // Create new identity (client->service).
+ IDENTITY_RENAME = 630 // Rename existing identity
(client->service).
+ IDENTITY_DELETE = 631 // Delete identity (client->service).
+ IDENTITY_LOOKUP = 632
+ IDENTITY_LOOKUP_BY_NAME = 633
+
+ //------------------------------------------------------------------
+ // REVOCATION message types
+ //------------------------------------------------------------------
+
+ REVOCATION_QUERY = 636 // Client to service: was this key
revoked?
+ REVOCATION_QUERY_RESPONSE = 637 // Service to client: answer if key
was revoked!
+ REVOCATION_REVOKE = 638 // Client to service OR peer-to-peer:
revoke this key!
+ REVOCATION_REVOKE_RESPONSE = 639 // Service to client: revocation
confirmed
+
+ //------------------------------------------------------------------
+ // SCALARPRODUCT message types
+ //------------------------------------------------------------------
+
+ SCALARPRODUCT_CLIENT_TO_ALICE = 640 // Client -> Alice
+ SCALARPRODUCT_CLIENT_TO_BOB = 641 // Client -> Bob
+ SCALARPRODUCT_CLIENT_MULTIPART_ALICE = 642 // Client -> Alice
multipart
+ SCALARPRODUCT_CLIENT_MULTIPART_BOB = 643 // Client -> Bob
multipart
+ SCALARPRODUCT_SESSION_INITIALIZATION = 644 // Alice -> Bob session
initialization
+ SCALARPRODUCT_ALICE_CRYPTODATA = 645 // Alice -> Bob SP
crypto-data (after intersection)
+ SCALARPRODUCT_BOB_CRYPTODATA = 647 // Bob -> Alice SP
crypto-data
+ SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART = 648 // Bob -> Alice SP
crypto-data multipart
+ SCALARPRODUCT_RESULT = 649 // Alice/Bob -> Client
Result
+ SCALARPRODUCT_ECC_SESSION_INITIALIZATION = 650 // Alice -> Bob ECC
session initialization
+ SCALARPRODUCT_ECC_ALICE_CRYPTODATA = 651 // Alice -> Bob ECC
crypto data
+ SCALARPRODUCT_ECC_BOB_CRYPTODATA = 652 // Bob -> Alice ECC
crypto data
+
+ //------------------------------------------------------------------
+ // PSYCSTORE message types
+ //------------------------------------------------------------------
+
+ PSYCSTORE_MEMBERSHIP_STORE = 660 // Store a membership event.
+ PSYCSTORE_MEMBERSHIP_TEST = 661 // Test for membership of a member
at a particular point in time.
+ PSYCSTORE_FRAGMENT_STORE = 662 //
+ PSYCSTORE_FRAGMENT_GET = 663 //
+ PSYCSTORE_MESSAGE_GET = 664 //
+ PSYCSTORE_MESSAGE_GET_FRAGMENT = 665 //
+ PSYCSTORE_COUNTERS_GET = 666 //
+ PSYCSTORE_STATE_MODIFY = 668 //
+ PSYCSTORE_STATE_SYNC = 669 //
+ PSYCSTORE_STATE_RESET = 670 //
+ PSYCSTORE_STATE_HASH_UPDATE = 671 //
+ PSYCSTORE_STATE_GET = 672 //
+ PSYCSTORE_STATE_GET_PREFIX = 673 //
+ PSYCSTORE_RESULT_CODE = 674 // Generic response from PSYCstore
service with success and/or error message.
+ PSYCSTORE_RESULT_FRAGMENT = 675 //
+ PSYCSTORE_RESULT_COUNTERS = 676 //
+ PSYCSTORE_RESULT_STATE = 677 //
+
+ //------------------------------------------------------------------
+ // PSYC message types
+ //------------------------------------------------------------------
+
+ PSYC_RESULT_CODE = 680 // S->C: result of an operation
+ PSYC_MASTER_START = 681 // C->S: request to start a channel
as a master
+ PSYC_MASTER_START_ACK = 682 // S->C: master start
acknowledgement
+ PSYC_SLAVE_JOIN = 683 // C->S: request to join a channel
as a slave
+ PSYC_SLAVE_JOIN_ACK = 684 // S->C: slave join acknowledgement
+ PSYC_PART_REQUEST = 685 // C->S: request to part from a
channel
+ PSYC_PART_ACK = 686 // S->C: acknowledgement that a
slave of master parted from a channel
+ PSYC_JOIN_REQUEST = 687 // M->S->C: incoming join request
from multicast
+ PSYC_JOIN_DECISION = 688 // C->S->M: decision about a join
request
+ PSYC_CHANNEL_MEMBERSHIP_STORE = 689 // C->S: request to add/remove
channel slave in the membership database.
+ PSYC_MESSAGE = 691 // S<--C: PSYC message which
contains one or more message parts.
+ PSYC_MESSAGE_HEADER = 692 // M<->S<->C: PSYC message which
contains a header and one or more message parts.
+ PSYC_MESSAGE_METHOD = 693 // Message part: method
+ PSYC_MESSAGE_MODIFIER = 694 // Message part: modifier
+ PSYC_MESSAGE_MOD_CONT = 695 // Message part: modifier
continuation
+ PSYC_MESSAGE_DATA = 696 // Message part: data
+ PSYC_MESSAGE_END = 697 // Message part: end of message
+ PSYC_MESSAGE_CANCEL = 698 // Message part: message cancelled
+ PSYC_MESSAGE_ACK = 699 // S->C: message acknowledgement
+ PSYC_HISTORY_REPLAY = 701 // C->S: request channel history
replay from PSYCstore.
+ PSYC_HISTORY_RESULT = 702 // S->C: result for a channel
history request
+ PSYC_STATE_GET = 703 // C->S: request best matching
state variable from PSYCstore.
+ PSYC_STATE_GET_PREFIX = 704 // C->S: request state variables
with a given prefix from PSYCstore.
+ PSYC_STATE_RESULT = 705 // S->C: result for a state request.
+
+ //------------------------------------------------------------------
+ // CONVERSATION message types
+ //------------------------------------------------------------------
+
+ CONVERSATION_AUDIO = 730 // Message to transmit the audio
between helper and speaker/microphone library.
+ CONVERSATION_CS_PHONE_REGISTER = 731 // Client -> Server message to
register a phone.
+ CONVERSATION_CS_PHONE_PICK_UP = 732 // Client -> Server message to
reject/hangup a call
+ CONVERSATION_CS_PHONE_HANG_UP = 733 // Client -> Server message to
reject/hangup a call
+ CONVERSATION_CS_PHONE_CALL = 734 // Client <- Server message to
indicate a ringing phone
+ CONVERSATION_CS_PHONE_RING = 735 // Client <- Server message to
indicate a ringing phone
+ CONVERSATION_CS_PHONE_SUSPEND = 736 // Client <-> Server message to
suspend connection.
+ CONVERSATION_CS_PHONE_RESUME = 737 // Client <-> Server message to
resume connection.
+ CONVERSATION_CS_PHONE_PICKED_UP = 738 // Service -> Client message to
notify that phone was picked up.
+ CONVERSATION_CS_AUDIO = 739 // Client <-> Server message to
send audio data.
+ CONVERSATION_CADET_PHONE_RING = 740 // Cadet: call initiation
+ CONVERSATION_CADET_PHONE_HANG_UP = 741 // Cadet: hang up / refuse call
+ CONVERSATION_CADET_PHONE_PICK_UP = 742 // Cadet: pick up phone
(establish audio channel)
+ CONVERSATION_CADET_PHONE_SUSPEND = 743 // Cadet: phone suspended.
+ CONVERSATION_CADET_PHONE_RESUME = 744 // Cadet: phone resumed.
+ CONVERSATION_CADET_AUDIO = 745 // Cadet: audio data
+
+ //------------------------------------------------------------------
+ // MULTICAST message types
+ //------------------------------------------------------------------
+
+ MULTICAST_ORIGIN_START = 750 // C->S: Start the origin.
+ MULTICAST_MEMBER_JOIN = 751 // C->S: Join group as a member.
+ MULTICAST_JOIN_REQUEST = 752 // C<--S<->T: A peer wants to join
the group. Unicast message to the origin or another group member.
+ MULTICAST_JOIN_DECISION = 753 // C<->S<->T: Response to a join
request. Unicast message from a group member to the peer wanting to join.
+ MULTICAST_PART_REQUEST = 754 // A peer wants to part the group.
+ MULTICAST_PART_ACK = 755 // Acknowledgement sent in response
to a part request. Unicast message from a group member to the peer wanting to
part.
+ MULTICAST_GROUP_END = 756 // Group terminated.
+ MULTICAST_MESSAGE = 757 // C<->S<->T: Multicast message
from the origin to all members.
+ MULTICAST_REQUEST = 758 // C<->S<->T: Unicast request from
a group member to the origin.
+ MULTICAST_FRAGMENT_ACK = 759 // C->S: Acknowledgement of a
message or request fragment for the client.
+ MULTICAST_REPLAY_REQUEST = 760 // C<->S<->T: Replay request from a
group member to another member.
+ MULTICAST_REPLAY_RESPONSE = 761 // C<->S<->T: Replay response from
a group member to another member.
+ MULTICAST_REPLAY_RESPONSE_END = 762 // C<->S: End of replay response.
+
+ //------------------------------------------------------------------
+ // SECRETSHARING message types
+ //------------------------------------------------------------------
+
+ SECRETSHARING_CLIENT_GENERATE = 780 // Establish a new session.
+ SECRETSHARING_CLIENT_DECRYPT = 781 // Request the decryption of a
ciphertext.
+ SECRETSHARING_CLIENT_DECRYPT_DONE = 782 // The service succeeded in
decrypting a ciphertext.
+ SECRETSHARING_CLIENT_SECRET_READY = 783 // Contains the peer's share.
+
+ //------------------------------------------------------------------
+ // PEERSTORE message types
+ //------------------------------------------------------------------
+
+ PEERSTORE_STORE = 820 // Store request message
+ PEERSTORE_ITERATE = 821 // Iteration request
+ PEERSTORE_ITERATE_RECORD = 822 // Iteration record message
+ PEERSTORE_ITERATE_END = 823 // Iteration end message
+ PEERSTORE_WATCH = 824 // Watch request
+ PEERSTORE_WATCH_RECORD = 825 // Watch response
+ PEERSTORE_WATCH_CANCEL = 826 // Watch cancel request
+
+ //------------------------------------------------------------------
+ // SOCIAL message types
+ //------------------------------------------------------------------
+
+ SOCIAL_RESULT_CODE = 840 // S->C: result of an operation
+ SOCIAL_HOST_ENTER = 841 // C->S: request to enter a place as
the host
+ SOCIAL_HOST_ENTER_ACK = 842 // S->C: host enter acknowledgement
+ SOCIAL_GUEST_ENTER = 843 // C->S: request to enter a place as a
guest
+ SOCIAL_GUEST_ENTER_BY_NAME = 844 // C->S: request to enter a place as a
guest, using a GNS address
+ SOCIAL_GUEST_ENTER_ACK = 845 // S->C: guest enter acknowledgement
+ SOCIAL_ENTRY_REQUEST = 846 // P->S->C: incoming entry request
from PSYC
+ SOCIAL_ENTRY_DECISION = 847 // C->S->P: decision about an entry
request
+ SOCIAL_PLACE_LEAVE = 848 // C->S: request to leave a place
+ SOCIAL_PLACE_LEAVE_ACK = 849 // S->C: place leave acknowledgement
+ SOCIAL_ZONE_ADD_PLACE = 850 // C->S: add place to GNS zone
+ SOCIAL_ZONE_ADD_NYM = 851 // C->S: add nym to GNS zone
+ SOCIAL_APP_CONNECT = 852 // C->S: connect application
+ SOCIAL_APP_DETACH = 853 // C->S: detach a place from
application
+ SOCIAL_APP_EGO = 854 // S->C: notify about an existing ego
+ SOCIAL_APP_EGO_END = 855 // S->C: end of ego list
+ SOCIAL_APP_PLACE = 856 // S->C: notify about an existing place
+ SOCIAL_APP_PLACE_END = 857 // S->C: end of place list
+ SOCIAL_MSG_PROC_SET = 858 // C->S: set message processing flags
+ SOCIAL_MSG_PROC_CLEAR = 859 // C->S: clear message processing flags
+
+ //------------------------------------------------------------------
+ // X-VINE DHT messages
+ //------------------------------------------------------------------
+
+ XDHT_P2P_TRAIL_SETUP = 880 // Trail setup request is
received by a peer.
+ XDHT_P2P_TRAIL_SETUP_RESULT = 881 // Trail to a particular
peer is returned to this peer.
+ XDHT_P2P_VERIFY_SUCCESSOR = 882 // Verify if your
immediate successor is still your immediate successor.
+ XDHT_P2P_NOTIFY_NEW_SUCCESSOR = 883 // Notify your new
immediate successor that you are its new predecessor.
+ XDHT_P2P_VERIFY_SUCCESSOR_RESULT = 884 // Message which contains
the immediate predecessor of requested successor
+ XDHT_P2P_GET_RESULT = 885 // Message which contains
the get result.
+ XDHT_P2P_TRAIL_SETUP_REJECTION = 886 // Trail Rejection Message.
+ XDHT_P2P_TRAIL_TEARDOWN = 887 // Trail Tear down Message.
+ XDHT_P2P_ADD_TRAIL = 888 // Routing table add
message.
+ XDHT_P2P_PUT = 890 // Peer is storing the
data in DHT.
+ XDHT_P2P_GET = 891 // Peer tries to find data
in DHT.
+ XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION = 892 // Send back peer that
considers you are its successor.
+
+ DHT_ACT_MALICIOUS = 893 // Turn X-VINE DHT service malicious
+ DHT_CLIENT_ACT_MALICIOUS_OK = 894 // Acknowledge receiving ACT
MALICIOUS request
+
+ //------------------------------------------------------------------
+ // Whanau DHT messages
+ //------------------------------------------------------------------
+
+ WDHT_RANDOM_WALK = 910 // This message contains the query for
performing a random walk
+ WDHT_RANDOM_WALK_RESPONSE = 911 // This message contains the result of
a random walk
+ WDHT_TRAIL_DESTROY = 912 // This message contains a notification
for the death of a trail
+ WDHT_TRAIL_ROUTE = 913 // This message are used to route a
query to a peer
+ WDHT_SUCCESSOR_FIND = 914 // This message contains the query to
transfer successor values.
+ WDHT_GET = 915 // Message which contains the get query
+ WDHT_PUT = 916 // Message which contains the "put", a
response to #WDHT_SUCCESSOR_FIND.
+ WDHT_GET_RESULT = 917 // Message which contains the get
result, a response to #WDHT_GET.
+
+ //------------------------------------------------------------------
+ // RPS messages
+ //------------------------------------------------------------------
+
+ RPS_PP_CHECK_LIVE = 950 // RPS check liveliness message to check
liveliness of other peer
+ RPS_PP_PUSH = 951 // RPS PUSH message to push own ID to another
peer
+ RPS_PP_PULL_REQUEST = 952 // RPS PULL REQUEST message to request the
local view of another peer
+ RPS_PP_PULL_REPLY = 953 // RPS PULL REPLY message which contains the
view of the other peer
+ RPS_CS_SEED = 954 // RPS CS SEED Message for the Client to seed
peers into rps
+ RPS_ACT_MALICIOUS = 955 // Turn RPS service malicious
+ RPS_CS_SUB_START = 956 // RPS client-service message to start a sub
sampler
+ RPS_CS_SUB_STOP = 957 // RPS client-service message to stop a sub
sampler
+
+ //------------------------------------------------------------------
+ // RECLAIM messages
+ //------------------------------------------------------------------
+
+ RECLAIM_ATTRIBUTE_STORE = 961
+ RECLAIM_SUCCESS_RESPONSE = 962
+ RECLAIM_ATTRIBUTE_ITERATION_START = 963
+ RECLAIM_ATTRIBUTE_ITERATION_STOP = 964
+ RECLAIM_ATTRIBUTE_ITERATION_NEXT = 965
+ RECLAIM_ATTRIBUTE_RESULT = 966
+ RECLAIM_ISSUE_TICKET = 967
+ RECLAIM_TICKET_RESULT = 968
+ RECLAIM_REVOKE_TICKET = 969
+ RECLAIM_REVOKE_TICKET_RESULT = 970
+ RECLAIM_CONSUME_TICKET = 971
+ RECLAIM_CONSUME_TICKET_RESULT = 972
+ RECLAIM_TICKET_ITERATION_START = 973
+ RECLAIM_TICKET_ITERATION_STOP = 974
+ RECLAIM_TICKET_ITERATION_NEXT = 975
+ RECLAIM_ATTRIBUTE_DELETE = 976
+
+ //------------------------------------------------------------------
+ // CREDENTIAL messages
+ //------------------------------------------------------------------
+
+ CREDENTIAL_VERIFY = 981 //
+ CREDENTIAL_VERIFY_RESULT = 982 //
+ CREDENTIAL_COLLECT = 983 //
+ CREDENTIAL_COLLECT_RESULT = 984 //
+
+ //------------------------------------------------------------------
+ // CADET messages
+ //------------------------------------------------------------------
+
+ CADET_CONNECTION_CREATE = 1000 // Request the
creation of a connection
+ CADET_CONNECTION_CREATE_ACK = 1001 // Send origin an
ACK that the connection is complete
+ CADET_CONNECTION_BROKEN = 1002 // Notify that a
connection is no longer valid
+ CADET_CONNECTION_DESTROY = 1003 // Request the
destuction of a connection
+ CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED = 1004 // At some point,
the route will spontaneously change TODO
+ CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK = 1005 // Hop-by-hop,
connection dependent ACK. deprecated
+
+ CADET_TUNNEL_ENCRYPTED_POLL = 1006 // We do not bother with ACKs for
#CADET_TUNNEL_ENCRYPTED messages, but we instead poll for one if we got nothing
for a while and start to be worried. deprecated
+ CADET_TUNNEL_KX = 1007 // Axolotl key exchange.
+ CADET_TUNNEL_ENCRYPTED = 1008 // Axolotl encrypted data.
+ CADET_TUNNEL_KX_AUTH = 1009 // Axolotl key exchange response
with authentication.
+
+ CADET_CHANNEL_APP_DATA = 1010 // Payload data (inside an
encrypted tunnel).
+ CADET_CHANNEL_APP_DATA_ACK = 1011 // Confirm payload data
end-to-end.
+ CADET_CHANNEL_KEEPALIVE = 1012 // Announce connection is
still alive (direction sensitive).
+ CADET_CHANNEL_OPEN = 1013 // Ask the cadet service to
create a new channel.
+ CADET_CHANNEL_DESTROY = 1014 // Ask the cadet service to
destroy a channel.
+ CADET_CHANNEL_OPEN_ACK = 1015 // Confirm the creation of a
channel
+ CADET_CHANNEL_OPEN_NACK_DEPRECATED = 1016 // Reject the creation of a
channel deprecated
+
+ CADET_LOCAL_DATA = 1020 // Payload client <-> service
+ CADET_LOCAL_ACK = 1021 // Local ACK for data.
+ CADET_LOCAL_PORT_OPEN = 1022 // Start listening on a port.
+ CADET_LOCAL_PORT_CLOSE = 1023 // Stop listening on a port.
+ CADET_LOCAL_CHANNEL_CREATE = 1024 // Ask the cadet service to create a
new channel.
+ CADET_LOCAL_CHANNEL_DESTROY = 1025 // Tell client that a channel was
destroyed.
+
+ CADET_LOCAL_REQUEST_INFO_CHANNEL = 1030 // Local information about all
channels of service.
+ CADET_LOCAL_INFO_CHANNEL = 1031 // Local information of service
about a specific channel.
+ CADET_LOCAL_INFO_CHANNEL_END = 1032 // End of local information of
service about channels.
+ CADET_LOCAL_REQUEST_INFO_PEERS = 1033 // Request local information
about all peers known to the service.
+ CADET_LOCAL_INFO_PEERS = 1034 // Local information about all
peers known to the service.
+ CADET_LOCAL_INFO_PEERS_END = 1035 // End of local information
about all peers known to the service.
+ CADET_LOCAL_REQUEST_INFO_PATH = 1036 // Request local information of
service about paths to specific peer.
+ CADET_LOCAL_INFO_PATH = 1037 // Local information of service
about a specific path.
+ CADET_LOCAL_INFO_PATH_END = 1038 // End of local information of
service about a specific path.
+ CADET_LOCAL_REQUEST_INFO_TUNNELS = 1039 // Request local information
about all tunnels of service.
+ CADET_LOCAL_INFO_TUNNELS = 1040 // Local information about all
tunnels of service.
+ CADET_LOCAL_INFO_TUNNELS_END = 1041 // End of local information
about all tunnels of service.
+
+ CADET_CLI = 1059 // Traffic (net-cat style) used by the Command Line
Interface.
+
+ //------------------------------------------------------------------
+ // NAT messages
+ //------------------------------------------------------------------
+
+ NAT_REGISTER = 1060 // Message to ask NAT service
to register a client.
+ NAT_HANDLE_STUN = 1061 // Message to ask NAT service
to handle a STUN packet.
+ NAT_REQUEST_CONNECTION_REVERSAL = 1062 // Message to ask NAT service
to request connection reversal.
+ NAT_CONNECTION_REVERSAL_REQUESTED = 1063 // Message to from NAT service
notifying us that connection reversal was requested by another peer.
+ NAT_ADDRESS_CHANGE = 1064 // Message to from NAT service
notifying us that one of our addresses changed.
+ NAT_AUTO_REQUEST_CFG = 1066 // Message to ask NAT service
to request autoconfiguration.
+ NAT_AUTO_CFG_RESULT = 1065 // Message from NAT service
with the autoconfiguration result.
+
+ //------------------------------------------------------------------
+ // AUCTION messages
+ //------------------------------------------------------------------
+
+ AUCTION_CLIENT_CREATE = 1110 // Client wants to create a new auction.
+ AUCTION_CLIENT_JOIN = 1111 // Client wants to join an existing
auction.
+ AUCTION_CLIENT_OUTCOME = 1112 // Service reports the auction outcome to
the client.
+
+ //------------------------------------------------------------------
+ // RPS_DEBUG messages
+ //------------------------------------------------------------------
+
+ RPS_CS_DEBUG_VIEW_REQUEST = 1130 // Request updates of the view
+ RPS_CS_DEBUG_VIEW_REPLY = 1131 // Send update of the view
+ RPS_CS_DEBUG_VIEW_CANCEL = 1132 // Cancel getting updates of the view
+ RPS_CS_DEBUG_STREAM_REQUEST = 1133 // Request biased input stream
+ RPS_CS_DEBUG_STREAM_REPLY = 1134 // Send peer of biased stream
+ RPS_CS_DEBUG_STREAM_CANCEL = 1135 // Cancel getting biased stream
+
+ //------------------------------------------------------------------
+ // CATCH-ALL_DEBUG message
+ //------------------------------------------------------------------
+
+ ALL = 65535 // Type used to match 'all' message types.
+)
diff --git a/src/gnunet/service/client.go b/src/gnunet/service/client.go
new file mode 100644
index 0000000..2d1c3dd
--- /dev/null
+++ b/src/gnunet/service/client.go
@@ -0,0 +1,59 @@
+package service
+
+import (
+ "github.com/bfix/gospel/logger"
+ "gnunet/message"
+ "gnunet/transport"
+)
+
+// Client
+type Client struct {
+ ch *transport.MsgChannel
+}
+
+// NewClient
+func NewClient(endp string) (*Client, error) {
+ //
+ ch, err := transport.NewChannel(endp)
+ if err != nil {
+ return nil, err
+ }
+ return &Client{
+ ch: transport.NewMsgChannel(ch),
+ }, nil
+}
+
+func (c *Client) SendRequest(req message.Message) error {
+ return c.ch.Send(req)
+}
+
+func (c *Client) ReceiveResponse() (message.Message, error) {
+ return c.ch.Receive()
+}
+
+func (c *Client) Close() error {
+ return c.ch.Close()
+}
+
+func ServiceRequestResponse(caller, callee, endp string, req message.Message)
(message.Message, error) {
+ // client-connect to the service
+ logger.Printf(logger.DBG, "[%s] Connect to %s service\n", caller,
callee)
+ cl, err := NewClient(endp)
+ if err != nil {
+ return nil, err
+ }
+ // send request
+ logger.Printf(logger.DBG, "[%s] Sending request to %s service\n",
caller, callee)
+ if err = cl.SendRequest(req); err != nil {
+ return nil, err
+ }
+ // wait for a single response, then close the connection
+ logger.Printf(logger.DBG, "[%s] Waiting for response from %s
service\n", caller, callee)
+ var resp message.Message
+ if resp, err = cl.ReceiveResponse(); err != nil {
+ return nil, err
+ }
+ logger.Printf(logger.DBG, "[%s] Closing connection to %s service\n",
caller, callee)
+ cl.Close()
+ return resp, nil
+}
diff --git a/src/gnunet/service/gns/crypto.go b/src/gnunet/service/gns/crypto.go
new file mode 100644
index 0000000..f7ef111
--- /dev/null
+++ b/src/gnunet/service/gns/crypto.go
@@ -0,0 +1,41 @@
+package gns
+
+import (
+ "crypto/sha256"
+ "crypto/sha512"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "gnunet/crypto"
+ "golang.org/x/crypto/hkdf"
+)
+
+// QueryFromPublickeyDerive calculates the DHT query for a given label in a
+// given zone (identified by PKEY).
+func QueryFromPublickeyDerive(pkey *ed25519.PublicKey, label string)
*crypto.HashCode {
+ pd := crypto.DerivePublicKey(pkey, label, "gns")
+ return crypto.Hash(pd.Bytes())
+}
+
+// DecryptBlock
+func DecryptBlock(data []byte, zoneKey *ed25519.PublicKey, label string) (out
[]byte, err error) {
+ // derive key material for decryption
+ iv, skey := deriveBlockKey(label, zoneKey)
+ // perform decryption
+ return crypto.SymmetricDecrypt(data, skey, iv)
+}
+
+// Derive a symmetric key to decipher a GNS block
+func deriveBlockKey(label string, pub *ed25519.PublicKey) (iv
*crypto.SymmetricIV, skey *crypto.SymmetricKey) {
+ // generate symmetric key
+ prk := hkdf.Extract(sha512.New, []byte(label), pub.Bytes())
+ rdr := hkdf.Expand(sha256.New, prk, []byte("gns-aes-ctx-key"))
+ skey = crypto.NewSymmetricKey()
+ rdr.Read(skey.AESKey)
+ rdr.Read(skey.TwofishKey)
+ // generate initialization vector
+ rdr = hkdf.Expand(sha256.New, prk, []byte("gns-aes-ctx-iv"))
+ iv = crypto.NewSymmetricIV()
+ rdr.Read(iv.AESIv)
+ rdr.Read(iv.TwofishIv)
+ return
+}
diff --git a/src/gnunet/service/gns/crypto_test.go
b/src/gnunet/service/gns/crypto_test.go
new file mode 100644
index 0000000..2abfb99
--- /dev/null
+++ b/src/gnunet/service/gns/crypto_test.go
@@ -0,0 +1,150 @@
+package gns
+
+import (
+ "bytes"
+ "encoding/hex"
+ "testing"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+)
+
+var (
+ PUB = []byte{
+ 0x93, 0x34, 0x71, 0xF6, 0x99, 0x19, 0x0C, 0x62,
+ 0x85, 0xC7, 0x9B, 0x83, 0x9D, 0xCA, 0x83, 0x91,
+ 0x38, 0xFA, 0x87, 0xFB, 0xB8, 0xD4, 0xF6, 0xF0,
+ 0xF0, 0x4B, 0x7F, 0x0A, 0x48, 0xBF, 0x95, 0xF7,
+ }
+ LABEL = "home"
+)
+
+func TestDeriveBlockKey(t *testing.T) {
+ var (
+ SKEY = []byte{
+ 0x1D, 0x86, 0x8E, 0xF7, 0x30, 0x96, 0x3B, 0x39,
+ 0x66, 0xE6, 0x49, 0xD8, 0xF1, 0x13, 0x18, 0x39,
+ 0x8A, 0x7A, 0xB0, 0xF3, 0xDC, 0xF6, 0xE7, 0x2A,
+ 0xF6, 0x65, 0xDE, 0x86, 0x47, 0x7B, 0x20, 0x1B,
+
+ 0x21, 0xA6, 0xFA, 0x55, 0x7C, 0x29, 0xF5, 0x94,
+ 0x8E, 0x9A, 0x80, 0xB0, 0xB6, 0xD5, 0x4D, 0x38,
+ 0x0E, 0x6A, 0x0F, 0x42, 0x4B, 0x27, 0xBB, 0x6A,
+ 0x1E, 0xD1, 0x33, 0x08, 0xD6, 0x2E, 0x21, 0x8C,
+ }
+ IV = []byte{
+ 0xAC, 0x18, 0x03, 0xB7, 0x8B, 0x1E, 0x09, 0xA9,
+ 0xD0, 0x20, 0x47, 0x2B, 0x1B, 0x23, 0xE8, 0x24,
+
+ 0xC9, 0x23, 0x9E, 0x61, 0x3A, 0x8D, 0x95, 0xA9,
+ 0x3F, 0x6C, 0x1C, 0xC8, 0xCB, 0xD1, 0xBD, 0x6B,
+ }
+ )
+
+ iv, skey := deriveBlockKey(LABEL, ed25519.NewPublicKeyFromBytes(PUB))
+
+ if bytes.Compare(IV[:16], iv.AESIv) != 0 {
+ t.Logf("AES_IV(computed) = %s\n", hex.EncodeToString(iv.AESIv))
+ t.Logf("AES_IV(expected) = %s\n", hex.EncodeToString(IV[:16]))
+ t.Fatal("AES IV mismatch")
+ }
+ if bytes.Compare(IV[16:], iv.TwofishIv) != 0 {
+ t.Logf("Twofish_IV(computed) = %s\n",
hex.EncodeToString(iv.TwofishIv))
+ t.Logf("Twofish_IV(expected) = %s\n",
hex.EncodeToString(IV[16:]))
+ t.Fatal("Twofish IV mismatch")
+ }
+
+ if bytes.Compare(SKEY[:32], skey.AESKey) != 0 {
+ t.Logf("AES_KEY(computed) = %s\n",
hex.EncodeToString(skey.AESKey))
+ t.Logf("AES_KEY(expected) = %s\n",
hex.EncodeToString(SKEY[:32]))
+ t.Fatal("AES KEY mismatch")
+ }
+ if bytes.Compare(SKEY[32:], skey.TwofishKey) != 0 {
+ t.Logf("Twofish_KEY(computed) = %s\n",
hex.EncodeToString(skey.TwofishKey))
+ t.Logf("Twofish_KEY(expected) = %s\n",
hex.EncodeToString(SKEY[32:]))
+ t.Fatal("Twofish KEY mismatch")
+ }
+}
+
+func TestDecryptBlock(t *testing.T) {
+ var (
+ DATA = []byte{
+ 0xAC, 0xA5, 0x3C, 0x55, 0x63, 0x21, 0x31, 0x1F,
+ 0x11, 0x6E, 0xEF, 0x48, 0xED, 0x53, 0x46, 0x31,
+ 0x7C, 0x50, 0xFB, 0x6B, 0xA6, 0xC8, 0x6C, 0x46,
+ 0x1E, 0xE3, 0xCA, 0x45, 0xCD, 0x5B, 0xD6, 0x86,
+ 0x42, 0x87, 0xEF, 0x18, 0xCE, 0x8E, 0x83, 0x21,
+ 0x04, 0xCB, 0xCF, 0x40, 0x7E, 0x0F, 0x51, 0x54,
+ 0xE2, 0x3C, 0xDE, 0xE9, 0x22, 0x00, 0xFF, 0x40,
+ 0xBB, 0x53, 0xE3, 0x69, 0x99, 0x92, 0x47, 0x97,
+ 0xF0, 0x4E, 0x3B, 0x70,
+ }
+ OUT = []byte{
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0xAD, 0x0E,
+ 0x60, 0x28, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
+ 0x0A, 0x68, 0x6F, 0x69, 0x2D, 0x70, 0x6F, 0x6C,
+ 0x6C, 0x6F, 0x69, 0x03, 0x6F, 0x72, 0x67, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ }
+ )
+
+ out, err := DecryptBlock(DATA, ed25519.NewPublicKeyFromBytes(PUB),
LABEL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if bytes.Compare(out, OUT) != 0 {
+ t.Logf("Decrypt(computed) = %s\n", hex.EncodeToString(out))
+ t.Logf("Decrypt(expected) = %s\n", hex.EncodeToString(OUT))
+ t.Fatal("Decryptions failed")
+ }
+}
+
+func TestVerifyBlock(t *testing.T) {
+ var (
+ SIGNED = []byte{
+ 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x0f,
+ 0x00, 0x05, 0xad, 0x0e, 0x60, 0x28, 0xfe, 0x80,
+ 0xac, 0xa5, 0x3c, 0x55, 0x63, 0x21, 0x31, 0x1f,
+ 0x11, 0x6e, 0xef, 0x48, 0xed, 0x53, 0x46, 0x31,
+ 0x7c, 0x50, 0xfb, 0x6b, 0xa6, 0xc8, 0x6c, 0x46,
+ 0x1e, 0xe3, 0xca, 0x45, 0xcd, 0x5b, 0xd6, 0x86,
+ 0x42, 0x87, 0xef, 0x18, 0xce, 0x8e, 0x83, 0x21,
+ 0x04, 0xcb, 0xcf, 0x40, 0x7e, 0x0f, 0x51, 0x54,
+ 0xe2, 0x3c, 0xde, 0xe9, 0x22, 0x00, 0xff, 0x40,
+ 0xbb, 0x53, 0xe3, 0x69, 0x99, 0x92, 0x47, 0x97,
+ 0xf0, 0x4e, 0x3b, 0x70,
+ }
+ SIG = []byte{
+ 0x09, 0xc9, 0x6a, 0xda, 0x69, 0xce, 0x7c, 0x91,
+ 0xbd, 0xa4, 0x59, 0xdc, 0xc9, 0x76, 0xf4, 0x6c,
+ 0x62, 0xb7, 0x79, 0x3f, 0x94, 0xb2, 0xf6, 0xf0,
+ 0x90, 0x17, 0x4e, 0x2f, 0x68, 0x49, 0xf8, 0xcc,
+
+ 0x0b, 0x77, 0x32, 0x32, 0x28, 0x77, 0x2d, 0x2a,
+ 0x31, 0x31, 0xc1, 0x2c, 0x44, 0x18, 0xf2, 0x5f,
+ 0x1a, 0xe9, 0x8b, 0x2e, 0x65, 0xca, 0x1d, 0xe8,
+ 0x22, 0x82, 0x6a, 0x06, 0xe0, 0x6a, 0x5a, 0xe5,
+ }
+ PUB = []byte{
+ 0x26, 0x84, 0x1b, 0x24, 0x35, 0xa4, 0x63, 0xe9,
+ 0xf0, 0x48, 0xae, 0x3e, 0xf7, 0xe8, 0x1b, 0xca,
+ 0x55, 0x9f, 0x4c, 0x1e, 0x16, 0x18, 0xa6, 0xd3,
+ 0x5b, 0x91, 0x0d, 0x54, 0x31, 0x6e, 0xbf, 0x97,
+ }
+ )
+ sig, err := ed25519.NewEcSignatureFromBytes(SIG)
+ if err != nil {
+ t.Fatal(err)
+ }
+ dkey := ed25519.NewPublicKeyFromBytes(PUB)
+ ok, err := dkey.EcVerify(SIGNED, sig)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !ok {
+ t.Fatal("EcDSA verify failed")
+ }
+}
diff --git a/src/gnunet/service/gns/gns.go b/src/gnunet/service/gns/gns.go
new file mode 100644
index 0000000..4156e2a
--- /dev/null
+++ b/src/gnunet/service/gns/gns.go
@@ -0,0 +1,248 @@
+package gns
+
+import (
+ "encoding/hex"
+ "io"
+ "time"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/logger"
+ "gnunet/config"
+ "gnunet/crypto"
+ "gnunet/enums"
+ "gnunet/message"
+ "gnunet/service"
+ "gnunet/transport"
+ "gnunet/util"
+)
+
+//----------------------------------------------------------------------
+// "GNUnet Name System" service implementation
+//----------------------------------------------------------------------
+
+// GNSService
+type GNSService struct {
+}
+
+// NewGNSService
+func NewGNSService() service.Service {
+ return &GNSService{}
+}
+
+// Start the GNS service
+func (s *GNSService) Start(spec string) error {
+ return nil
+}
+
+// Stop the GNS service
+func (s *GNSService) Stop() error {
+ return nil
+}
+
+// Serve a client channel.
+func (s *GNSService) ServeClient(mc *transport.MsgChannel) {
+ for {
+ // receive next message from client
+ msg, err := mc.Receive()
+ if err != nil {
+ if err == io.EOF {
+ logger.Println(logger.INFO, "[gns] Client
channel closed.")
+ } else {
+ logger.Printf(logger.ERROR, "[gns]
Message-receive failed: %s\n", err.Error())
+ }
+ break
+ }
+ logger.Printf(logger.INFO, "[gns] Received msg: %v\n", msg)
+
+ // perform lookup
+ var resp message.Message
+ switch m := msg.(type) {
+ case *message.GNSLookupMsg:
+
//----------------------------------------------------------
+ // GNS_LOOKUP
+
//----------------------------------------------------------
+ logger.Println(logger.INFO, "[gns] Lookup request
received.")
+ respX := message.NewGNSLookupResultMsg(m.Id)
+ resp = respX
+
+ // perform lookup on block (either from Namecache or
DHT)
+ // TODO: run code in a go routine concurrently (would
need
+ // access to the message channel to send
responses)
+ block, err := s.Lookup(m)
+ if err != nil {
+ logger.Printf(logger.ERROR, "[gns] Failed to
lookup block: %s\n", err.Error())
+ break
+ }
+ // handle block
+ if block != nil {
+ logger.Printf(logger.DBG, "[gns] Received block
data: %s\n", hex.EncodeToString(block.Block.Data))
+
+ // get records from block
+ records, err := block.Records()
+ if err != nil {
+ logger.Printf(logger.ERROR, "[gns]
Failed to extract records: %s\n", err.Error())
+ break
+ }
+ if len(records) == 0 {
+ logger.Println(logger.WARN, "[gns] No
records in block")
+ break
+ }
+ // process records
+ for i, rec := range records {
+ logger.Printf(logger.DBG, "[gns] Record
#%d: %v\n", i, rec)
+
+ // is this the record type we are
looking for?
+ if rec.Type == m.Type || int(m.Type) ==
enums.GNS_TYPE_ANY {
+ // add it to the response
message
+ respX.AddRecord(rec)
+ }
+ }
+ }
+
+ default:
+
//----------------------------------------------------------
+ // UNKNOWN message type received
+
//----------------------------------------------------------
+ logger.Printf(logger.ERROR, "[gns] Unhandled message of
type (%d)\n", msg.Header().MsgType)
+ continue
+ }
+
+ // send response
+ if err := mc.Send(resp); err != nil {
+ logger.Printf(logger.ERROR, "[gns] Failed to send
response: %s\n", err.Error())
+ }
+
+ }
+ // close client connection
+ mc.Close()
+}
+
+// Lookup handles GNU_LOOKUP messages
+func (s *GNSService) Lookup(m *message.GNSLookupMsg) (block *GNSBlock, err
error) {
+ // create DHT/NAMECACHE query
+ pkey := ed25519.NewPublicKeyFromBytes(m.Zone)
+ label := m.GetName()
+ query := QueryFromPublickeyDerive(pkey, label)
+
+ // try namecache lookup first
+ if block, err = s.LookupNamecache(query, pkey, label); err != nil {
+ logger.Printf(logger.ERROR, "gns.Lookup(namecache): %s\n",
err.Error())
+ block = nil
+ return
+ }
+ if block == nil {
+ logger.Println(logger.DBG, "gns.Lookup(namecache): no block
found")
+ if int(m.Options) == enums.GNS_LO_DEFAULT {
+ // get the block from the DHT
+ if block, err = s.LookupDHT(query, pkey, label); err !=
nil || block == nil {
+ if err != nil {
+ logger.Printf(logger.ERROR,
"gns.Lookup(dht): %s\n", err.Error())
+ block = nil
+ } else {
+ logger.Println(logger.DBG,
"gns.Lookup(dht): no block found")
+ }
+ // lookup fails completely -- no result
+ }
+ }
+ }
+ return
+}
+
+// LookupNamecache
+func (s *GNSService) LookupNamecache(query *crypto.HashCode, zoneKey
*ed25519.PublicKey, label string) (block *GNSBlock, err error) {
+ logger.Printf(logger.DBG, "[gns] LookupNamecache(%s)...\n",
hex.EncodeToString(query.Bits))
+
+ // assemble Namecache request
+ req := message.NewNamecacheLookupMsg(query)
+ req.Id = uint32(util.NextID())
+ block = nil
+
+ // get response from Namecache service
+ var resp message.Message
+ if resp, err = service.ServiceRequestResponse("gns", "Namecache",
config.Cfg.Namecache.Endpoint, req); err != nil {
+ return
+ }
+
+ // handle message depending on its type
+ logger.Println(logger.DBG, "[gns] Handling response from Namecache
service")
+ switch m := resp.(type) {
+ case *message.NamecacheLookupResultMsg:
+ // check for matching IDs
+ if m.Id != req.Id {
+ logger.Println(logger.ERROR, "[gns] Got response for
unknown ID")
+ break
+ }
+ // check if block was found
+ if len(m.EncData) == 0 {
+ logger.Println(logger.DBG, "[gns] block not found in
namecache")
+ break
+ }
+ // check if record has expired
+ if m.Expire > 0 && int64(m.Expire) < time.Now().Unix() {
+ logger.Printf(logger.ERROR, "[gns] block expired at
%s\n", util.Timestamp(m.Expire))
+ break
+ }
+
+ // assemble the GNSBlock from message
+ block = new(GNSBlock)
+ block.Signature = m.Signature
+ block.DerivedKey = m.DerivedKey
+ sb := new(SignedBlockData)
+ sb.Purpose = new(crypto.SignaturePurpose)
+ sb.Purpose.Purpose = enums.SIG_GNS_RECORD_SIGN
+ sb.Purpose.Size = uint32(16 + len(m.EncData))
+ sb.Expire = m.Expire
+ sb.Data = m.EncData
+ block.Block = sb
+
+ // verify and decrypt block
+ if err = block.Verify(zoneKey, label); err != nil {
+ break
+ }
+ if err = block.Decrypt(zoneKey, label); err != nil {
+ break
+ }
+ }
+ return
+}
+
+// LookupDHT
+func (s *GNSService) LookupDHT(query *crypto.HashCode, zoneKey
*ed25519.PublicKey, label string) (block *GNSBlock, err error) {
+ logger.Printf(logger.DBG, "[gns] LookupDHT(%s)...\n",
hex.EncodeToString(query.Bits))
+
+ // assemble DHT request
+ req := message.NewDHTClientGetMsg(query)
+ req.Id = uint64(util.NextID())
+ req.ReplLevel = uint32(enums.DHT_GNS_REPLICATION_LEVEL)
+ req.Type = uint32(enums.BLOCK_TYPE_GNS_NAMERECORD)
+ req.Options = uint32(enums.DHT_RO_DEMULTIPLEX_EVERYWHERE)
+ block = nil
+
+ // get response from DHT service
+ var resp message.Message
+ if resp, err = service.ServiceRequestResponse("gns", "DHT",
config.Cfg.DHT.Endpoint, req); err != nil {
+ return
+ }
+
+ // handle message depending on its type
+ logger.Println(logger.DBG, "[gns] Handling response from DHT service")
+ switch m := resp.(type) {
+ case *message.DHTClientResultMsg:
+ // check for matching IDs
+ if m.Id != req.Id {
+ logger.Println(logger.ERROR, "[gns] Got response for
unknown ID")
+ break
+ }
+ // check if block was found
+ if len(m.Data) == 0 {
+ logger.Println(logger.DBG, "[gns] block not found in
DHT")
+ break
+ }
+ // check if record has expired
+ if m.Expire > 0 && int64(m.Expire) < time.Now().Unix() {
+ logger.Printf(logger.ERROR, "[gns] block expired at
%s\n", util.Timestamp(m.Expire))
+ break
+ }
+ }
+ return
+}
diff --git a/src/gnunet/service/gns/record.go b/src/gnunet/service/gns/record.go
new file mode 100644
index 0000000..4825432
--- /dev/null
+++ b/src/gnunet/service/gns/record.go
@@ -0,0 +1,111 @@
+package gns
+
+import (
+ "fmt"
+
+ "github.com/bfix/gospel/crypto/ed25519"
+ "github.com/bfix/gospel/data"
+ "gnunet/crypto"
+ "gnunet/message"
+)
+
+var (
+ ErrBlockNotDecrypted = fmt.Errorf("GNS block not decrypted")
+)
+
+type GNSRecordSet struct {
+ Count uint32 `order:"big"` // number of
resource records
+ Records []*message.GNSResourceRecord `size:"Count"` // list of resource
records
+ Padding []byte `size:"*"` // padding
+}
+
+func NewGNSRecordSet() *GNSRecordSet {
+ return &GNSRecordSet{
+ Count: 0,
+ Records: make([]*message.GNSResourceRecord, 0),
+ Padding: make([]byte, 0),
+ }
+}
+
+type SignedBlockData struct {
+ Purpose *crypto.SignaturePurpose // Size and purpose of signature (8
bytes)
+ Expire uint64 `order:"big"` // Expiration time of
the block.
+ Data []byte `size:"*"` // (encrypted)
GNSRecordSet
+}
+
+type GNSBlock struct {
+ Signature []byte `size:"64"` // Signature of the block.
+ DerivedKey []byte `size:"32"` // Derived key used for signing
+ Block *SignedBlockData
+
+ checked bool // block integrity checked
+ verified bool // block signature verified (internal)
+ decrypted bool // block data decrypted (internal)
+}
+
+func (b *GNSBlock) String() string {
+ return fmt.Sprintf("GNSBlock{Verified=%v,Decrypted=%v,data=[%d]}",
+ b.verified, b.decrypted, len(b.Block.Data))
+}
+
+func (b *GNSBlock) Records() ([]*message.GNSResourceRecord, error) {
+ // check if block is decrypted
+ if !b.decrypted {
+ return nil, ErrBlockNotDecrypted
+ }
+ // parse block data into record set
+ rs := NewGNSRecordSet()
+ if err := data.Unmarshal(rs, b.Block.Data); err != nil {
+ return nil, err
+ }
+ return rs.Records, nil
+}
+
+func (b *GNSBlock) Verify(zoneKey *ed25519.PublicKey, label string) (err
error) {
+ // Integrity check performed
+ b.checked = true
+
+ // verify derived key
+ dkey := ed25519.NewPublicKeyFromBytes(b.DerivedKey)
+ dkey2 := crypto.DerivePublicKey(zoneKey, label, "gns")
+ if !dkey.Q.Equals(dkey2.Q) {
+ return fmt.Errorf("Invalid signature key for GNS Block")
+ }
+ // verify signature
+ var (
+ sig *ed25519.EcSignature
+ buf []byte
+ ok bool
+ )
+ if sig, err = ed25519.NewEcSignatureFromBytes(b.Signature); err != nil {
+ return
+ }
+ if buf, err = data.Marshal(b.Block); err != nil {
+ return
+ }
+ if ok, err = dkey.EcVerify(buf, sig); err == nil && !ok {
+ err = fmt.Errorf("Signature verification failed for GNS block")
+ }
+ b.verified = true
+ return
+}
+
+func (b *GNSBlock) Decrypt(zoneKey *ed25519.PublicKey, label string) (err
error) {
+ // decrypt payload
+ b.Block.Data, err = DecryptBlock(b.Block.Data, zoneKey, label)
+ b.decrypted = true
+ return
+}
+
+func NewGNSBlock() *GNSBlock {
+ return &GNSBlock{
+ Signature: make([]byte, 64),
+ DerivedKey: make([]byte, 32),
+ Block: &SignedBlockData{
+ Data: nil,
+ },
+ checked: false,
+ verified: false,
+ decrypted: false,
+ }
+}
diff --git a/src/gnunet/service/service.go b/src/gnunet/service/service.go
new file mode 100644
index 0000000..f43c385
--- /dev/null
+++ b/src/gnunet/service/service.go
@@ -0,0 +1,91 @@
+package service
+
+import (
+ "fmt"
+
+ "github.com/bfix/gospel/logger"
+ "gnunet/transport"
+)
+
+// Service is an interface for GNUnet services. Every service has one channel
+// end-point it listens to for incoming channel requests (network-based
+// channels established by service clients). The end-point is specified in
+// Channel semantics in the specification string.
+type Service interface {
+ Start(spec string) error
+ ServeClient(ch *transport.MsgChannel)
+ Stop() error
+}
+
+// ServiceImpl is an implementation of generic service functionality.
+type ServiceImpl struct {
+ impl Service
+ hdlr chan transport.Channel
+ srvc transport.ChannelServer
+ name string
+ running bool
+}
+
+// NewServiceImpl instantiates a new ServiceImpl object.
+func NewServiceImpl(name string, srv Service) *ServiceImpl {
+ return &ServiceImpl{
+ impl: srv,
+ hdlr: make(chan transport.Channel),
+ srvc: nil,
+ name: name,
+ running: false,
+ }
+}
+
+// Start a service
+func (si *ServiceImpl) Start(spec string) (err error) {
+ // check if we are already running
+ if si.running {
+ logger.Printf(logger.ERROR, "Service '%s' already running.\n",
si.name)
+ return fmt.Errorf("service already running")
+ }
+
+ // start channel server
+ logger.Printf(logger.DBG, "[%s] Service starting.\n", si.name)
+ if si.srvc, err = transport.NewChannelServer(spec, si.hdlr); err != nil
{
+ return
+ }
+ si.running = true
+
+ // handle clients
+ go func() {
+ loop:
+ for si.running {
+ select {
+ case in := <-si.hdlr:
+ if in == nil {
+ logger.Printf(logger.DBG, "[%s]
Listener terminated.\n", si.name)
+ break loop
+ }
+ switch ch := in.(type) {
+ case transport.Channel:
+ logger.Printf(logger.DBG, "[%s] Client
connected.\n", si.name)
+ go
si.impl.ServeClient(transport.NewMsgChannel(ch))
+ }
+ default:
+ }
+ }
+ logger.Printf(logger.DBG, "[%s] Service closing.\n", si.name)
+ si.srvc.Close()
+ si.running = false
+ }()
+
+ return si.impl.Start(spec)
+}
+
+// Stop a service
+func (si *ServiceImpl) Stop() error {
+ if !si.running {
+ logger.Printf(logger.WARN, "Service '%s' not running.\n",
si.name)
+ return fmt.Errorf("service not running")
+ }
+ si.running = false
+ logger.Printf(logger.DBG, "[%s] Service terminating.\n", si.name)
+
+ return si.impl.Stop()
+}
diff --git a/src/gnunet/transport/channel.go b/src/gnunet/transport/channel.go
new file mode 100644
index 0000000..8502d8f
--- /dev/null
+++ b/src/gnunet/transport/channel.go
@@ -0,0 +1,180 @@
+package transport
+
+import (
+ "encoding/hex"
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/bfix/gospel/data"
+ "github.com/bfix/gospel/logger"
+ "gnunet/message"
+)
+
+var (
+ ErrChannelNotImplemented = fmt.Errorf("Protocol not implemented")
+ ErrChannelNotOpened = fmt.Errorf("Channel not opened")
+)
+
+////////////////////////////////////////////////////////////////////////
+// CHANNEL
+
+// Channel is an abstraction for exchanging arbitrary data over various
+// transport protocols and mechanisms. They are created by clients via
+// 'NewChannel()' or by services run via 'NewChannelServer()'.
+// A string specifies the end-point of the channel:
+// "unix+/tmp/test.sock" -- for UDS channels
+// "tcp+1.2.3.4:5" -- for TCP channels
+// "udp+1.2.3.4:5" -- for UDP channels
+type Channel interface {
+ Open(spec string) error
+ Close() error
+ Read([]byte) (int, error)
+ Write([]byte) (int, error)
+}
+
+// ChannelFactory instantiates specific Channel imülementations.
+type ChannelFactory func() Channel
+
+// Known channel implementations.
+var channelImpl = map[string]ChannelFactory{
+ "unix": NewSocketChannel,
+ "tcp": NewTCPChannel,
+ "udp": NewUDPChannel,
+}
+
+// NewChannel creates a new channel to the specified endpoint.
+// Called by a client to connect to a service.
+func NewChannel(spec string) (Channel, error) {
+ parts := strings.Split(spec, "+")
+ if fac, ok := channelImpl[parts[0]]; ok {
+ inst := fac()
+ err := inst.Open(spec)
+ return inst, err
+ }
+ return nil, ErrChannelNotImplemented
+}
+
+////////////////////////////////////////////////////////////////////////
+// CHANNEL SERVER
+
+// ChannelServer creates a listener for the specified endpoint.
+// The specification string has the same format as for Channel with slightly
+// different semantics (for TCP, and ICMP the address specifies is a mask
+// for client addresses accepted for a channel request).
+type ChannelServer interface {
+ Open(spec string, hdlr chan<- Channel) error
+ Close() error
+}
+
+// ChannelServerFactory instantiates specific ChannelServer imülementations.
+type ChannelServerFactory func() ChannelServer
+
+// Known channel server implementations.
+var channelServerImpl = map[string]ChannelServerFactory{
+ "unix": NewSocketChannelServer,
+ "tcp": NewTCPChannelServer,
+ "udp": NewUDPChannelServer,
+}
+
+// NewChannelServer
+func NewChannelServer(spec string, hdlr chan<- Channel) (ChannelServer, error)
{
+ parts := strings.Split(spec, "+")
+ if fac, ok := channelServerImpl[parts[0]]; ok {
+ inst := fac()
+ err := inst.Open(spec, hdlr)
+ return inst, err
+ }
+ return nil, ErrChannelNotImplemented
+}
+
+////////////////////////////////////////////////////////////////////////
+// MESSAGE CHANNEL
+
+// MsgChannel s a wrapper around a generic channel for GNUnet message exchange.
+type MsgChannel struct {
+ ch Channel
+ buf []byte
+}
+
+// NewMsgChannel wraps a plain Channel for GNUnet message exchange.
+func NewMsgChannel(ch Channel) *MsgChannel {
+ return &MsgChannel{
+ ch: ch,
+ buf: make([]byte, 65536),
+ }
+}
+
+// Close a MsgChannel by closing the wrapped plain Channel.
+func (c *MsgChannel) Close() error {
+ return c.ch.Close()
+}
+
+// Send a GNUnet message over a channel.
+func (c *MsgChannel) Send(msg message.Message) error {
+
+ // convert message to binary data
+ data, err := data.Marshal(msg)
+ if err != nil {
+ return err
+ }
+ logger.Printf(logger.DBG, "==> %v\n", msg)
+ logger.Printf(logger.DBG, " [%s]\n", hex.EncodeToString(data))
+
+ // check message header size and packet size
+ mh, err := message.GetMsgHeader(data)
+ if err != nil {
+ return err
+ }
+ if len(data) != int(mh.MsgSize) {
+ return errors.New("Send: message size mismatch")
+ }
+
+ // send packet
+ n, err := c.ch.Write(data)
+ if err != nil {
+ return err
+ }
+ if n != len(data) {
+ return errors.New("Incomplete send")
+ }
+ return nil
+}
+
+// Receive GNUnet messages over a plain Channel.
+func (c *MsgChannel) Receive() (message.Message, error) {
+ get := func(pos, count int) error {
+ n, err := c.ch.Read(c.buf[pos : pos+count])
+ if err != nil {
+ return err
+ }
+ if n != count {
+ return errors.New("not enough bytes on network")
+ }
+ return nil
+ }
+ if err := get(0, 4); err != nil {
+ return nil, err
+ }
+ mh, err := message.GetMsgHeader(c.buf[:4])
+ if err != nil {
+ return nil, err
+ }
+
+ if err := get(4, int(mh.MsgSize)-4); err != nil {
+ return nil, err
+ }
+ msg, err := message.NewEmptyMessage(mh.MsgType)
+ if err != nil {
+ return nil, err
+ }
+ if msg == nil {
+ return nil, fmt.Errorf("Message{%d} is nil!\n", mh.MsgType)
+ }
+ if err = data.Unmarshal(msg, c.buf[:mh.MsgSize]); err != nil {
+ return nil, err
+ }
+ logger.Printf(logger.DBG, "<== %v\n", msg)
+ logger.Printf(logger.DBG, " [%s]\n",
hex.EncodeToString(c.buf[:mh.MsgSize]))
+ return msg, nil
+}
diff --git a/src/gnunet/transport/channel_netw.go
b/src/gnunet/transport/channel_netw.go
new file mode 100644
index 0000000..69ddda5
--- /dev/null
+++ b/src/gnunet/transport/channel_netw.go
@@ -0,0 +1,173 @@
+package transport
+
+import (
+ "net"
+ "os"
+ "strconv"
+ "strings"
+
+ "github.com/bfix/gospel/logger"
+)
+
+////////////////////////////////////////////////////////////////////////
+// Generic network-based Channel
+
+// NetworkChannel
+type NetworkChannel struct {
+ network string
+ conn net.Conn
+}
+
+// NewNetworkChannel
+func NewNetworkChannel(netw string) Channel {
+ return &NetworkChannel{
+ network: netw,
+ conn: nil,
+ }
+}
+
+// Open
+func (c *NetworkChannel) Open(spec string) (err error) {
+ parts := strings.Split(spec, "+")
+ // check for correct protocol
+ if parts[0] != c.network {
+ return ErrChannelNotImplemented
+ }
+ // open connection
+ c.conn, err = net.Dial(c.network, parts[1])
+ return
+}
+
+// Close
+func (c *NetworkChannel) Close() error {
+ if c.conn != nil {
+ return c.conn.Close()
+ }
+ return ErrChannelNotOpened
+}
+
+// Read
+func (c *NetworkChannel) Read(buf []byte) (int, error) {
+ if c.conn == nil {
+ return 0, ErrChannelNotOpened
+ }
+ return c.conn.Read(buf)
+}
+
+// Write
+func (c *NetworkChannel) Write(buf []byte) (int, error) {
+ if c.conn == nil {
+ return 0, ErrChannelNotOpened
+ }
+ return c.conn.Write(buf)
+}
+
+////////////////////////////////////////////////////////////////////////
+// Generic network-based ChannelServer
+
+// NetworkChannelServer
+type NetworkChannelServer struct {
+ network string
+ listener net.Listener
+}
+
+// NewNetworkChannelServer
+func NewNetworkChannelServer(netw string) ChannelServer {
+ return &NetworkChannelServer{
+ network: netw,
+ listener: nil,
+ }
+}
+
+// Open
+func (s *NetworkChannelServer) Open(spec string, hdlr chan<- Channel) (err
error) {
+ parts := strings.Split(spec, "+")
+ // check for correct protocol
+ if parts[0] != s.network {
+ return ErrChannelNotImplemented
+ }
+ // create listener
+ if s.listener, err = net.Listen(s.network, parts[1]); err != nil {
+ return
+ }
+ // handle additional parameters ('key[=value]')
+ for _, param := range parts[2:] {
+ frag := strings.Split(param, "=")
+ switch frag[0] {
+ case "perm": // set permissions on 'unix'
+ if s.network == "unix" {
+ if perm, err := strconv.ParseInt(frag[1], 8,
32); err == nil {
+ if err := os.Chmod(parts[1],
os.FileMode(perm)); err != nil {
+ logger.Printf(
+ logger.ERROR,
+ "NetworkChannelServer:
Failed to set permissions: %s\n",
+ err.Error())
+
+ }
+ } else {
+ logger.Printf(
+ logger.ERROR,
+ "NetworkChannelServer: Invalid
permissions '%s'\n",
+ frag[1])
+ }
+ }
+ }
+ }
+ // run go routine to handle channel requests from clients
+ go func() {
+ for {
+ conn, err := s.listener.Accept()
+ if err != nil {
+ // signal failure and terminate
+ hdlr <- nil
+ break
+ }
+ // send channel to handler
+ hdlr <- &NetworkChannel{
+ network: s.network,
+ conn: conn,
+ }
+ }
+ if s.listener != nil {
+ s.listener.Close()
+ }
+ }()
+
+ return nil
+}
+
+// Close
+func (s *NetworkChannelServer) Close() error {
+ if s.listener != nil {
+ err := s.listener.Close()
+ s.listener = nil
+ return err
+ }
+ return nil
+}
+
+////////////////////////////////////////////////////////////////////////
+
+func NewSocketChannel() Channel {
+ return NewNetworkChannel("unix")
+}
+
+func NewTCPChannel() Channel {
+ return NewNetworkChannel("tcp")
+}
+
+func NewUDPChannel() Channel {
+ return NewNetworkChannel("udp")
+}
+
+func NewSocketChannelServer() ChannelServer {
+ return NewNetworkChannelServer("unix")
+}
+
+func NewTCPChannelServer() ChannelServer {
+ return NewNetworkChannelServer("tcp")
+}
+
+func NewUDPChannelServer() ChannelServer {
+ return NewNetworkChannelServer("udp")
+}
diff --git a/src/gnunet/transport/channel_test.go
b/src/gnunet/transport/channel_test.go
new file mode 100644
index 0000000..c59e3e1
--- /dev/null
+++ b/src/gnunet/transport/channel_test.go
@@ -0,0 +1,203 @@
+package transport
+
+import (
+ "bytes"
+ "fmt"
+ "testing"
+ "time"
+)
+
+const (
+ SOCK_ADDR = "/tmp/gnunet-go-test.sock"
+ TCP_ADDR_CLIENT = "gnunet.org:80"
+ TCP_ADDR_SERVER = "127.0.0.1:12086"
+)
+
+type TestChannelServer struct {
+ hdlr chan Channel
+ srvc ChannelServer
+ running bool
+}
+
+func NewTestChannelServer() *TestChannelServer {
+ return &TestChannelServer{
+ hdlr: make(chan Channel),
+ srvc: nil,
+ running: false,
+ }
+}
+
+func (s *TestChannelServer) handle(ch Channel) {
+ buf := make([]byte, 4096)
+ for {
+ n, err := ch.Read(buf)
+ if err != nil {
+ break
+ }
+ _, err = ch.Write(buf[:n])
+ if err != nil {
+ break
+ }
+ }
+ ch.Close()
+}
+
+func (s *TestChannelServer) Start(spec string) (err error) {
+ // check if we are already running
+ if s.running {
+ return fmt.Errorf("Server already running")
+ }
+
+ // start channel server
+ if s.srvc, err = NewChannelServer(spec, s.hdlr); err != nil {
+ return
+ }
+ s.running = true
+
+ // handle clients
+ go func() {
+ for s.running {
+ select {
+ case in := <-s.hdlr:
+ if in == nil {
+ break
+ }
+ switch x := in.(type) {
+ case Channel:
+ go s.handle(x)
+ }
+ }
+ }
+ s.srvc.Close()
+ s.running = false
+ }()
+ return nil
+}
+
+func (s *TestChannelServer) Stop() {
+ s.running = false
+}
+
+func TestChannelServerTCPSingle(t *testing.T) {
+ time.Sleep(time.Second)
+ s := NewTestChannelServer()
+ if err := s.Start("tcp+" + TCP_ADDR_SERVER); err != nil {
+ t.Fatal(err)
+ }
+ s.Stop()
+}
+
+func TestChannelServerTCPTwice(t *testing.T) {
+ time.Sleep(time.Second)
+ s1 := NewTestChannelServer()
+ if err := s1.Start("tcp+" + TCP_ADDR_SERVER); err != nil {
+ t.Fatal(err)
+ }
+ s2 := NewTestChannelServer()
+ if err := s2.Start("tcp+" + TCP_ADDR_SERVER); err == nil {
+ t.Fatal("SocketServer started twice!!")
+ }
+ s1.Stop()
+}
+
+func TestChannelClientTCP(t *testing.T) {
+ time.Sleep(time.Second)
+ ch, err := NewChannel("tcp+" + TCP_ADDR_CLIENT)
+ if err != nil {
+ t.Fatal(err)
+ }
+ msg := []byte("GET /\n\n")
+ n, err := ch.Write(msg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if n != len(msg) {
+ t.Fatal("Send size mismatch")
+ }
+ buf := make([]byte, 4096)
+ n = 0
+ start := time.Now().Unix()
+ for n == 0 && (time.Now().Unix()-start) < 3 {
+ if n, err = ch.Read(buf); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err = ch.Close(); err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("'%s' [%d]\n", string(buf[:n]), n)
+}
+
+func TestChannelClientServerTCP(t *testing.T) {
+ time.Sleep(time.Second)
+ s := NewTestChannelServer()
+ if err := s.Start("tcp+" + TCP_ADDR_SERVER); err != nil {
+ t.Fatal(err)
+ }
+
+ ch, err := NewChannel("tcp+" + TCP_ADDR_SERVER)
+ if err != nil {
+ t.Fatal(err)
+ }
+ msg := []byte("GET /\n\n")
+ n, err := ch.Write(msg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if n != len(msg) {
+ t.Fatal("Send size mismatch")
+ }
+ buf := make([]byte, 4096)
+ n = 0
+ start := time.Now().Unix()
+ for n == 0 && (time.Now().Unix()-start) < 3 {
+ if n, err = ch.Read(buf); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err = ch.Close(); err != nil {
+ t.Fatal(err)
+ }
+ if bytes.Compare(buf[:n], msg) != 0 {
+ t.Fatal("message send/receive mismatch")
+ }
+
+ s.Stop()
+}
+
+func TestChannelClientServerSock(t *testing.T) {
+ time.Sleep(time.Second)
+ s := NewTestChannelServer()
+ if err := s.Start("unix+" + SOCK_ADDR); err != nil {
+ t.Fatal(err)
+ }
+
+ ch, err := NewChannel("unix+" + SOCK_ADDR)
+ if err != nil {
+ t.Fatal(err)
+ }
+ msg := []byte("This is just a test -- please ignore...")
+ n, err := ch.Write(msg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if n != len(msg) {
+ t.Fatal("Send size mismatch")
+ }
+ buf := make([]byte, 4096)
+ n = 0
+ start := time.Now().Unix()
+ for n == 0 && (time.Now().Unix()-start) < 3 {
+ if n, err = ch.Read(buf); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err = ch.Close(); err != nil {
+ t.Fatal(err)
+ }
+ if bytes.Compare(buf[:n], msg) != 0 {
+ t.Fatal("message send/receive mismatch")
+ }
+
+ s.Stop()
+}
diff --git a/src/gnunet/transport/connection.go
b/src/gnunet/transport/connection.go
new file mode 100644
index 0000000..e66bec1
--- /dev/null
+++ b/src/gnunet/transport/connection.go
@@ -0,0 +1,52 @@
+package transport
+
+import (
+ "gnunet/core"
+ "gnunet/message"
+)
+
+////////////////////////////////////////////////////////////////////////
+// Connection for communicating peers
+type Connection struct {
+ from, to *core.Peer
+ ch *MsgChannel
+ buf []byte
+ bandwidth uint32
+ init bool
+ state int
+ shared []byte
+}
+
+func NewConnection(ch *MsgChannel, from, to *core.Peer) *Connection {
+ return &Connection{
+ from: from,
+ to: to,
+ state: 1,
+ ch: ch,
+ }
+}
+
+func (c *Connection) SharedSecret(secret []byte) {
+ c.shared = make([]byte, len(secret))
+ copy(c.shared, secret)
+}
+
+func (c *Connection) GetState() int {
+ return c.state
+}
+
+func (c *Connection) SetBandwidth(bw uint32) {
+ c.bandwidth = bw
+}
+
+func (c *Connection) Close() error {
+ return c.ch.Close()
+}
+
+func (c *Connection) Send(msg message.Message) error {
+ return c.ch.Send(msg)
+}
+
+func (c *Connection) Receive() (message.Message, error) {
+ return c.ch.Receive()
+}
diff --git a/src/gnunet/transport/session.go b/src/gnunet/transport/session.go
new file mode 100644
index 0000000..90e4016
--- /dev/null
+++ b/src/gnunet/transport/session.go
@@ -0,0 +1,12 @@
+package transport
+
+import ()
+
+const (
+ KX_STATE_DOWN = iota // No handshake yet.
+ KX_STATE_KEY_SENT // We've sent our session key.
+ KX_STATE_KEY_RECEIVED // We've received the other peers session
key.
+ KX_STATE_UP // Key exchange is done.
+ KX_STATE_REKEY_SENT // We're rekeying (or had a timeout).
+ KX_PEER_DISCONNECT // Last state of a KX (when it is being
terminated).
+)
diff --git a/src/gnunet/util/address.go b/src/gnunet/util/address.go
new file mode 100644
index 0000000..04e2254
--- /dev/null
+++ b/src/gnunet/util/address.go
@@ -0,0 +1,39 @@
+package util
+
+import (
+ "fmt"
+)
+
+type IPAddress struct {
+ Host []byte `size:"*-2"`
+ Port uint16 `order:"big"`
+}
+
+func NewIPAddress(host []byte, port uint16) *IPAddress {
+ ip := &IPAddress{
+ Host: make([]byte, len(host)),
+ Port: port,
+ }
+ copy(ip.Host, host)
+ return ip
+}
+
+type Address struct {
+ Transport string
+ Options uint32 `order:"big"`
+ Address []byte `size:"*"`
+}
+
+func NewAddress(transport string, addr []byte) *Address {
+ a := &Address{
+ Transport: transport,
+ Options: 0,
+ Address: make([]byte, len(addr)),
+ }
+ copy(a.Address, addr)
+ return a
+}
+
+func (a *Address) String() string {
+ return fmt.Sprintf("Address{%s}", AddressString(a.Transport, a.Address))
+}
diff --git a/src/gnunet/util/array.go b/src/gnunet/util/array.go
new file mode 100644
index 0000000..2ffb618
--- /dev/null
+++ b/src/gnunet/util/array.go
@@ -0,0 +1,48 @@
+package util
+
+import (
+ "fmt"
+)
+
+var (
+ ErrUtilArrayTooSmall = fmt.Errorf("Array to small")
+)
+
+func Clone(d []byte) []byte {
+ r := make([]byte, len(d))
+ copy(r, d)
+ return r
+}
+
+func Reverse(b []byte) []byte {
+ bl := len(b)
+ r := make([]byte, bl)
+ for i := 0; i < bl; i++ {
+ r[bl-i-1] = b[i]
+ }
+ return r
+}
+
+// CopyBlock copies 'in' to 'out' so that 'out' is filled completely.
+// - If 'in' is larger than 'out', it is left-truncated before copy
+// - If 'in' is smaller than 'out', it is left-padded with 0 before copy
+func CopyBlock(out, in []byte) {
+ count := len(in)
+ size := len(out)
+ from, to := 0, 0
+ if count > size {
+ from = count - size
+ } else if count < size {
+ to = size - count
+ for i := 0; i < to; i++ {
+ out[i] = 0
+ }
+ }
+ copy(out[to:], in[from:])
+}
+
+func Fill(b []byte, val byte) {
+ for i := 0; i < len(b); i++ {
+ b[i] = val
+ }
+}
diff --git a/src/gnunet/util/base32.go b/src/gnunet/util/base32.go
new file mode 100644
index 0000000..ff5711e
--- /dev/null
+++ b/src/gnunet/util/base32.go
@@ -0,0 +1,109 @@
+package util
+
+import (
+ "errors"
+ "strings"
+)
+
+//------------------------------------------------------------------------
+// Base32 conversion between binary data and string representation
+//------------------------------------------------------------------------
+//
+// A binary array of size m is viewed as a consecutive stream of bits
+// from left to right. Bytes are ordered with ascending address, while
+// bits (in a byte) are ordered MSB to LSB.
+
+// For encoding the stream is partitioned into 5-bit chunks; the last chunk
+// is right-padded with 0's if 8*m is not divisible by 5. Each chunk (value
+// between 0 and 31) is encoded into a character; the mapping for encoding
+// is the same as in [https://www.crockford.com/wrmg/base32.html].
+//
+// For decoding each character is converted to a 5-bit chunk based on the
+// encoder mapping (with one addition: the character 'U' maps to the value
+// 27). The chunks are concatenated to produce the bit stream to be stored
+// in the output array.
+
+// character set used for encoding/decoding
+const xlate = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
+
+var (
+ // ErrInvalidEncoding signals an invalid encoding
+ ErrInvalidEncoding = errors.New("Invalid encoding")
+ // ErrBufferTooSmall signalsa too small buffer for decoding
+ ErrBufferTooSmall = errors.New("Buffer to small")
+)
+
+// EncodeBinaryToString encodes a byte array into a string.
+func EncodeBinaryToString(data []byte) string {
+ size, pos, bits, n := len(data), 0, 0, 0
+ out := ""
+ for {
+ if n < 5 {
+ if pos < size {
+ bits = (bits << 8) | (int(data[pos]) & 0xFF)
+ pos++
+ n += 8
+ } else if n > 0 {
+ bits <<= uint(5 - n)
+ n = 5
+ } else {
+ break
+ }
+ }
+ out += string(xlate[(bits>>uint(n-5))&0x1F])
+ n -= 5
+ }
+ return out
+}
+
+// DecodeStringToBinary decodes a string into a byte array.
+// The function expects the size of the output buffer to be sepcified as an
+// argument ('num'); the function returns an error if the buffer is overrun
+// or if an invalid character is found in the encoded string. If the decoded
+// bit stream is smaller than the output buffer, it is padded with 0's.
+func DecodeStringToBinary(s string, num int) ([]byte, error) {
+ size := len(s)
+ out := make([]byte, num)
+ rpos, wpos, n, bits := 0, 0, 0, 0
+ for {
+ if n < 8 {
+ if rpos < size {
+ c := rune(s[rpos])
+ rpos++
+ v := strings.IndexRune(xlate, c)
+ if v == -1 {
+ switch c {
+ case 'O':
+ v = 0
+ case 'I', 'L':
+ v = 1
+ case 'U':
+ v = 27
+ default:
+ return nil, ErrInvalidEncoding
+ }
+ }
+ bits = (bits << 5) | (v & 0x1F)
+ n += 5
+ } else {
+ if wpos < num {
+ out[wpos] = byte(bits & ((1 <<
uint(n+1)) - 1))
+ wpos++
+ for i := wpos; i < num; i++ {
+ out[i] = 0
+ }
+ }
+ break
+ }
+ } else {
+ if wpos < num {
+ out[wpos] = byte((bits >> uint(n-8)) & 0xFF)
+ wpos++
+ n -= 8
+ } else {
+ return nil, ErrBufferTooSmall
+ }
+ }
+ }
+ return out, nil
+}
diff --git a/src/gnunet/util/base32_test.go b/src/gnunet/util/base32_test.go
new file mode 100644
index 0000000..e89109d
--- /dev/null
+++ b/src/gnunet/util/base32_test.go
@@ -0,0 +1,86 @@
+package util
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/hex"
+ "testing"
+)
+
+var (
+ tests = []struct {
+ bin []byte
+ str string
+ }{
+ {[]byte{
+ 0xD4,
+ }, "TG"},
+ {[]byte{
+ 0x78, 0xD3,
+ }, "F39G"},
+ {[]byte{
+ 0x43, 0xA4, 0x59, 0x57,
+ }, "8EJ5JNR"},
+ {[]byte{
+ 0x59, 0x40, 0xB3, 0x2D, 0xB8, 0x86, 0x61, 0xC2,
+ }, "B50B6BDRGSGW4"},
+ {[]byte{
+ 0xF9, 0x7F, 0x85, 0x6D, 0x8D, 0x8D, 0x65, 0x91,
+ 0x50, 0x3A, 0x2F, 0x36, 0x9F, 0x63, 0x01, 0x45,
+ }, "Z5ZRAVCDHNJS2M1T5WV9YRR18M"},
+ {[]byte{
+ 0x7B, 0x46, 0x0D, 0xFD, 0xC9, 0x04, 0xA6, 0x99,
+ 0x54, 0x94, 0xB0, 0xCE, 0xFE, 0x17, 0x72, 0x31,
+ 0xC8, 0x90, 0xBA, 0x9F, 0x3C, 0xD1, 0x42, 0xA1,
+ }, "FD30VZE90JK9JN4MP37FW5VJ67491EMZ7K8M588"},
+ {[]byte{
+ 0xC0, 0x78, 0x05, 0x04, 0xB8, 0xE2, 0x4A, 0xA5,
+ 0x61, 0x82, 0xCE, 0xCC, 0xE3, 0xCA, 0x53, 0x01,
+ 0x67, 0x5F, 0xA3, 0x05, 0xA9, 0x27, 0xC5, 0xE2,
+ 0x6B, 0xB5, 0xB5, 0x86, 0xAB, 0x84, 0x32, 0x6C,
+ }, "R1W0A15RW95AARC2SV6E7JJK05KNZ8R5N4KWBRKBPPTRDAW469P0"},
+ }
+)
+
+func TestBase32Preset(t *testing.T) {
+ for _, x := range tests {
+ s := EncodeBinaryToString(x.bin)
+ if testing.Verbose() {
+ t.Logf("[%s] ==> %s\n", hex.EncodeToString(x.bin), s)
+ }
+ if s != x.str {
+ t.Fatalf("Encoding mismatch: '%s' != '%s' for %s\n", s,
x.str, hex.EncodeToString(x.bin))
+ }
+ e, err := DecodeStringToBinary(x.str, len(x.bin))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if bytes.Compare(x.bin, e) != 0 {
+ t.Fatalf("Decoding mismatch: '%s' != '%s' for '%s'\n",
hex.EncodeToString(e), hex.EncodeToString(x.bin), x.str)
+ }
+ }
+}
+
+func TestBase32Random(t *testing.T) {
+ buf := make([]byte, 32)
+ for i := 0; i < 100; i++ {
+ n, err := rand.Read(buf)
+ if err != nil || n != 32 {
+ t.Fatal(err)
+ }
+ s := EncodeBinaryToString(buf)
+ r, err := DecodeStringToBinary(s, len(buf))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(buf) != len(r) {
+ x := make([]byte, len(buf))
+ n := len(buf) - len(r)
+ copy(x[n:], r)
+ r = x
+ }
+ if !bytes.Equal(buf, r) {
+ t.Fatal("Encode/Decode mismatch")
+ }
+ }
+}
diff --git a/src/gnunet/util/format.go b/src/gnunet/util/format.go
new file mode 100644
index 0000000..b52418f
--- /dev/null
+++ b/src/gnunet/util/format.go
@@ -0,0 +1,36 @@
+package util
+
+import (
+ "encoding/hex"
+ "fmt"
+ "net"
+ "time"
+)
+
+func AddressString(transport string, addr []byte) string {
+ if transport == "tcp" || transport == "udp" {
+ alen := len(addr)
+ port := uint(addr[alen-2])*256 + uint(addr[alen-1])
+ return fmt.Sprintf("%s:%s:%d", transport,
net.IP(addr[:alen-2]).String(), port)
+ }
+ return fmt.Sprintf("%s:%s", transport, hex.EncodeToString(addr))
+}
+
+func Timestamp(ts uint64) string {
+ t := time.Unix(int64(ts/(1000*1000)), int64((ts%1000)*1000))
+ return t.Format(time.RFC3339Nano)
+}
+
+var scale = " kMGTPEO"
+
+func Scale1024(n uint64) string {
+ v := float64(n)
+ var i int
+ for i = 0; v > 1024; i++ {
+ v /= 1024
+ }
+ if i == 0 {
+ return fmt.Sprintf("%d", n)
+ }
+ return fmt.Sprintf("%.3f%c", v, scale[i])
+}
diff --git a/src/gnunet/util/id.go b/src/gnunet/util/id.go
new file mode 100644
index 0000000..41bd30e
--- /dev/null
+++ b/src/gnunet/util/id.go
@@ -0,0 +1,10 @@
+package util
+
+var (
+ _id = 0
+)
+
+func NextID() int {
+ _id += 1
+ return _id
+}
diff --git a/src/gnunet/util/msg_queue.go b/src/gnunet/util/msg_queue.go
new file mode 100644
index 0000000..a4fb2eb
--- /dev/null
+++ b/src/gnunet/util/msg_queue.go
@@ -0,0 +1,3 @@
+package util
+
+import ()
diff --git a/src/gnunet/util/rnd.go b/src/gnunet/util/rnd.go
new file mode 100644
index 0000000..d3c8b2e
--- /dev/null
+++ b/src/gnunet/util/rnd.go
@@ -0,0 +1,46 @@
+package util
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+)
+
+func RndArray(b []byte) {
+ rand.Read(b)
+}
+
+func NewRndArray(size int) []byte {
+ b := make([]byte, size)
+ rand.Read(b)
+ return b
+}
+
+func RndUInt64() uint64 {
+ b := make([]byte, 8)
+ RndArray(b)
+ var v uint64
+ c := bytes.NewBuffer(b)
+ binary.Read(c, binary.BigEndian, &v)
+ return v
+}
+
+func RndInt64() int64 {
+ return int64(RndUInt64())
+}
+
+func RndUInt32() uint32 {
+ return uint32(RndUInt64())
+}
+
+func RndInt32() int32 {
+ return int32(RndUInt64())
+}
+
+func RndUInt16() uint16 {
+ return uint16(RndUInt64())
+}
+
+func RndInt16() int16 {
+ return int16(RndUInt64())
+}
diff --git a/src/gnunet/util/time.go b/src/gnunet/util/time.go
new file mode 100644
index 0000000..89109a7
--- /dev/null
+++ b/src/gnunet/util/time.go
@@ -0,0 +1,19 @@
+package util
+
+import (
+ "time"
+)
+
+func GetAbsoluteTimeNow() uint64 {
+ return getTimestamp(time.Now())
+}
+
+func GetAbsoluteTimeOffset(t time.Duration) uint64 {
+ return getTimestamp(time.Now().Add(t))
+}
+
+func getTimestamp(t time.Time) uint64 {
+ secs := t.Unix()
+ usecs := t.Nanosecond() / 1000
+ return uint64(secs*1000000) + uint64(usecs)
+}
--
To stop receiving notification emails like this one, please contact
address@hidden.