[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-go] branch master updated: Prepared for integration test.
From: |
gnunet |
Subject: |
[gnunet-go] branch master updated: Prepared for integration test. |
Date: |
Thu, 18 Aug 2022 15:02:23 +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.
The following commit(s) were added to refs/heads/master by this push:
new 5b03f75 Prepared for integration test.
5b03f75 is described below
commit 5b03f7567ad8242cc87924c3920dfc04420365ef
Author: Bernd Fix <brf@hoi-polloi.org>
AuthorDate: Thu Aug 18 14:58:34 2022 +0200
Prepared for integration test.
---
README.md | 220 ++++-
src/gnunet/cmd/gnunet-service-dht-go/main.go | 15 +-
src/gnunet/config/config.go | 11 +
src/gnunet/config/gnunet-config.json | 4 +
src/gnunet/core/core.go | 33 +-
src/gnunet/core/core_test.go | 4 +-
src/gnunet/core/event.go | 11 +-
src/gnunet/core/peer.go | 2 +-
src/gnunet/core/peer_test.go | 2 +-
src/gnunet/crypto/gns_edkey.go | 10 +-
src/gnunet/crypto/gns_pkey.go | 12 +-
src/gnunet/crypto/hash.go | 21 +-
src/gnunet/enums/dht.go | 2 +
src/gnunet/enums/dht_block_type.go | 2 +-
src/gnunet/enums/gnunet-dht.tpl | 2 +-
src/gnunet/enums/messages.go | 844 +++++++++++++++++++
src/gnunet/enums/msgtype_string.go | 1113 ++++++++++++++++++++++++++
src/gnunet/go.mod | 4 +-
src/gnunet/go.sum | 4 +-
src/gnunet/message/factory.go | 61 +-
src/gnunet/message/message.go | 25 +-
src/gnunet/message/msg_core.go | 11 +-
src/gnunet/message/msg_dht.go | 96 +--
src/gnunet/message/msg_dht_p2p.go | 166 ++--
src/gnunet/message/msg_gns.go | 65 +-
src/gnunet/message/msg_gns_test.go | 20 +-
src/gnunet/message/msg_hello.go | 18 +-
src/gnunet/message/msg_namecache.go | 63 +-
src/gnunet/message/msg_revocation.go | 58 +-
src/gnunet/message/msg_transport.go | 114 +--
src/gnunet/message/types.go | 840 -------------------
src/gnunet/service/dht/blocks/filters.go | 11 +-
src/gnunet/service/dht/blocks/generic.go | 74 +-
src/gnunet/service/dht/blocks/gns.go | 16 +-
src/gnunet/service/dht/blocks/hello.go | 46 +-
src/gnunet/service/dht/blocks/hello_test.go | 6 +-
src/gnunet/service/dht/local.go | 2 +-
src/gnunet/service/dht/messages.go | 178 ++--
src/gnunet/service/dht/messages_test.go | 73 ++
src/gnunet/service/dht/module.go | 103 +--
src/gnunet/service/dht/path/elements.go | 2 +-
src/gnunet/service/dht/path/handling.go | 2 +-
src/gnunet/service/dht/resulthandler.go | 256 ++----
src/gnunet/service/dht/routingtable.go | 58 +-
src/gnunet/service/dht/routingtable_test.go | 2 +-
src/gnunet/service/dht/service.go | 2 +-
src/gnunet/service/gns/block_handler.go | 36 +-
src/gnunet/service/gns/dns.go | 6 +-
src/gnunet/service/gns/module.go | 20 +-
src/gnunet/service/gns/service.go | 20 +-
src/gnunet/service/module.go | 5 +-
src/gnunet/service/revocation/module.go | 10 +-
src/gnunet/service/revocation/service.go | 4 +-
src/gnunet/service/store/store_dht.go | 28 +-
src/gnunet/service/store/store_dht_meta.go | 10 +-
src/gnunet/service/store/store_dht_test.go | 15 +-
src/gnunet/transport/reader_writer.go | 16 +-
src/gnunet/util/address.go | 16 +-
src/gnunet/util/array.go | 4 +-
src/gnunet/util/misc.go | 12 +
src/gnunet/util/peer.go | 12 +-
src/gnunet/util/time.go | 13 +-
62 files changed, 3070 insertions(+), 1841 deletions(-)
diff --git a/README.md b/README.md
index d4575e5..e328c66 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ go test ./...
The binaries are stored in `${GOPATH}/bin`.
-## Source code
+# Source code
All source code is written for Go v1.18+.
@@ -45,7 +45,7 @@ All source code is written for Go v1.18+.
the source code, make sure you run `go mod tidy` in the `src/gnunet` folder
to install all dependencies.
-### `./src/gnunet`
+## `./src/gnunet`
The folder `src/gnunet` contains a Go implementation of GNUnet: It is WIP
and only provides a very limited coverage of GNUnet. The goal is to have
@@ -53,12 +53,12 @@ a complete, functionally equivalent implementation of the
GNUnet protocol
in Go. Currently only some aspects of Transport, GNS, Revocation, Namecache
and DHT are implemented.
-Use `./build.sh` to build the executables (services and utilities, see
+Use `./build.sh withgen` to build the executables (services and utilities, see
below). The resulting programs are stored in `${GOPATH}/bin`.
To run the unit tests, use `./test.sh`.
-#### `./src/gnunet/enums`
+## `./src/gnunet/enums`
Changes in GANA definitions for block types, GNS record types and signature
purpose values can be imported by copying the recfiles (GNU recutils) from
@@ -71,21 +71,21 @@ GANA into this folder:
After updating the recfiles, you need to run `go generate ./...` to generate
the new source files.
-### `./src/gnunet/cmd`
+## `./src/gnunet/cmd`
-#### `gnunet-service-dht-test-go`: Implementation of the DHT core service
(testbed).
+### `gnunet-service-dht-test-go`: Implementation of the DHT core service
(testbed).
-#### `gnunet-service-gns-go`: Implementation of the GNS core service.
+### `gnunet-service-gns-go`: Implementation of the GNS core service.
Stand-alone GNS service that could be used with other GNUnet utilities and
services.
-#### `gnunet-service-revocation-go`: Implementation of the GNS revocation
service.
+### `gnunet-service-revocation-go`: Implementation of the GNS revocation
service.
Stand-alone Revocation service that could be used with other GNUnet utilities
and services.
-#### `revoke-zonekey`: Implementation of a stand-alone program to calculate
revocations.
+### `revoke-zonekey`: Implementation of a stand-alone program to calculate
revocations.
This program creates a zone key revocation block. Depending on the parameters
the calculation can take days or even weeks. The program can be interrupted
@@ -109,9 +109,9 @@ The default difficulty will create a revocation valid for
~2 years.
* **`-v`**: verbose output
-#### `peer_mockup`: test message exchange on the lowest level (transport).
+### `peer_mockup`: test message exchange on the lowest level (transport).
-#### `vanityid`: Compute GNUnet vanity peer id for a given regexp pattern.
+### `vanityid`: Compute GNUnet vanity peer id for a given regexp pattern.
N.B.: Key generation is slow at the moment, so be patient! To generate a single
matching key some 1,000,000 keys need to be generated for a four letter prefix;
@@ -141,7 +141,203 @@ For `gnunet-go` configuration files you need to paste the
result of
`echo "<hex.seed>" | xxd -r -p | base64` into the `PrivateSeed` field in the
`NodeConfig` section.
-## Using gnunet-go in your own projects
+# Testing `gnunet-go`
+
+To test the current `gnunet-go` implementation in a local GNUnet environment,
+you should follow the detailed instructions below.
+
+**N.B.**: Testing requires an up-to-date GNUnet build from source. You can
+either use your local machine (please follow the GNUnet documentation for
+setup) or you can simply use a Docker image like
+[gnunet-docker](https://github.com/bfix/gnunet-docker) for this.
+
+## Testing `R5N DHT`
+
+`gnunet-go` implements the DHT protocol specified in
+[lsd0004](https://lsd.gnunet.org/lsd0004/) and uses a custom (unencrypted)
+transport protocol not supported by the standard GNUnet. Luckily there is a
+testbed in GNUnet that allows to run the new protocol over UDP/IP.
+
+### Starting the DHTU testbed
+
+Make sure you stopped (or have not started) all GNUnet services; the testbed
+will take care of everything required.
+
+Change into `./src/dht` in the `gnunet`-Repository and start any number of
+DHTU nodes for testing:
+
+```bash
+./dhtu_testbed_deploy.sh 10
+```
+
+will start ten DHTU nodes. Nodes will listen to all available network
+addresses on port 10000+ (one node, one port).
+
+Log and configuration files can be found in `/tmp/deployment/`; they are
+named by index (starting at 0).
+
+### Running the `gnunet-go` node in the testbed
+
+#### Setting up the configuration file
+
+Copy the example `gnunet-config.json` to `dhtu-config.json` and modify the
+`network` and `local` sections to our local setup. In this example
+`172.17.0.5` is the network address for GNUnet DHTU nodes and `172.17.0.1`
+is the network address for `gnunet-go`:
+
+```json
+{
+ "network": {
+ "bootstrap": [
+ "ip+udp://127.17.0.5:10000"
+ ],
+ "numPeers": 10
+ },
+ "local": {
+ "privateSeed": "YGoe6XFH3XdvFRl+agx9gIzPTvxA229WFdkazEMdcOs=",
+ "endpoints": [
+ {
+ "id": "r5n",
+ "network": "ip+udp",
+ "address": "172.17.0.1",
+ "port": 2086,
+ "ttl": 86400
+ }
+ ]
+ }
+ :
+}
+```
+
+The above configuration will expect a network of 10 nodes and has a single
+bootstrap node (the first DHTU node in the testbed). `gnunet-go` will listen
+on port 2086.
+
+#### Running the `gnunet-go`node
+
+Run the following commands to start the `gnunet-go` node:
+
+```bash
+rm -rf /tmp/gnunet-system-runtime
+mkdir -p /tmp/gnunet-system-runtime
+${GOPATH}/bin/gnunet-service-dht-go -c dhtu-config.json 2>&1 | tee run.log
+```
+
+## Testing `GNS`
+
+You need to have (all) GNUnet services up and running.
+
+### Setting up the configuration file
+
+Copy the example `gnunet-config.json` to `gns-config.json` and modify the
+`network` and `local` sections:
+
+```json
+{
+ "network": {
+ "bootstrap": [],
+ "numPeers": 10
+ },
+ "local": {
+ "privateSeed": "YGoe6XFH3XdvFRl+agx9gIzPTvxA229WFdkazEMdcOs=",
+ "endpoints": []
+ },
+ :
+}
+```
+
+### Preparing and running the tests
+
+For test purposes you need to start the `gnunet-go` DNS service, generate
+zones and resource records for testing and run the actual test cases.
+You can use the follwing script to do it all in one go:
+
+```bash
+#!/bin/bash
+
+GNS_SOCK=/tmp/gnunet-system-runtime/gnunet-service-gns-go.sock
+[ -e ${GNS_SOCK} ] && sudo rm -f ${GNS_SOCK}
+sudo -u gnunet ../bin/gnunet-service-gns-go -L 5 &
+GOGNS=$!
+
+function get_pkey() {
+ gnunet-identity -d -e $1 | sed 's/.* - //'
+}
+
+CERT=$(openssl x509 -in <(openssl s_client -connect gnunet.org:443 </dev/null
2>/dev/null) -outform der \
+ | od -t x1 -A n \
+ | tr "\n" " " \
+ | sed "s/ //g")
+VPN="ZH7W4PR933913VA45AH45GH9QNQVP3TEM89J18549Q6RNDV75A4G secret"
+
+
+for x in zone9 private; do
+ gnunet-identity -D $x
+done
+
+ gnunet-identity -C zone9
+ gnunet-identity -C private
+
+ gnunet-namestore -a -z zone9 -n "@" -t NICK -V "zone9"
-e never
+ gnunet-namestore -a -z zone9 -n web -t A -V 131.159.74.67
-e never
+ gnunet-namestore -a -z zone9 -n web -t BOX -V "6 443 52 3 0 0
${CERT}" -e never
+ gnunet-namestore -a -z zone9 -n gn -t CNAME -V gnunet.org
-e never
+ gnunet-namestore -a -z zone9 -n sec -t VPN -V "6 ${VPN}"
-e never
+ gnunet-namestore -a -z zone9 -n prv -t PKEY -V "$(get_pkey private)"
-e never
+# gnunet-namestore -a -z zone9 -n prv -t A -V "14.15.16.17"
-e never
+ gnunet-namestore -a -z zone9 -n old -t LEHO -V "old.gnunet.org"
-e never
+ gnunet-namestore -a -z zone9 -n old -t A -V 5.6.7.8
-e never
+# gnunet-namestore -a -z zone9 -n old -t A -V 10.11.12.13
-e never
+# gnunet-namestore -a -z zone9 -n old -t TXT -V "Old version"
-e never
+
+ gnunet-namestore -a -z private -n "@" -t NICK -V "nexus9"
-e never
+ gnunet-namestore -a -z private -n name -t TXT -V "GNUnet test"
-e never
+ gnunet-namestore -d -z private -n host
+ gnunet-namestore -a -z private -n host -t GNS2DNS -V "gnunet.org@8.8.8.8"
-e never
+# gnunet-namestore -a -z private -n host -t A -V 1.2.3.4
-e never
+
+function test_gns() {
+ echo "========================"
+ echo -n "Testing '$2' for type '$1': "
+ gnunet-gns -t $1 -u $2 > plain.out
+ gnunet-gns -c gns-go.conf -t $1 -u $2 > go.out
+ rc=$(diff plain.out go.out)
+ if [ -z "$rc" ]; then
+ echo "O.K."
+ else
+ echo "FAILED!"
+ echo "---------------- GNS-C"
+ cat plain.out
+ echo "---------------- GNS-Go"
+ cat go.out
+ fi
+}
+
+# (1)
+test_gns any web.zone9
+# (2)
+test_gns any _443._tcp.web.zone9
+# (3)
+test_gns nick zone9
+# (4)
+test_gns any gn.zone9
+# (5)
+test_gns any sec.zone9
+# (6)
+test_gns pkey prv.zone9
+# (7)
+test_gns nick prv.zone9
+# (8)
+test_gns any name.prv.zone9
+# (9)
+test_gns any host.prv.zone9
+# (10)
+test_gns a host.prv.zone9
+
+kill ${GOGNS}
+```
+
+# Using gnunet-go in your own projects
`gnunet-go` is not a standard Go module for direct use (via go.mod) in other
packages, but designed as a stand-alone application. The rationale behind was
diff --git a/src/gnunet/cmd/gnunet-service-dht-go/main.go
b/src/gnunet/cmd/gnunet-service-dht-go/main.go
index 28d2100..a026cb7 100644
--- a/src/gnunet/cmd/gnunet-service-dht-go/main.go
+++ b/src/gnunet/cmd/gnunet-service-dht-go/main.go
@@ -33,6 +33,7 @@ import (
"gnunet/service"
"gnunet/service/dht"
"gnunet/service/dht/blocks"
+ "gnunet/transport"
"gnunet/util"
"github.com/bfix/gospel/logger"
@@ -44,6 +45,8 @@ func main() {
// flush last messages
logger.Flush()
}()
+ // intro
+ logger.SetLogLevel(logger.DBG)
logger.Println(logger.INFO, "[dht] Starting service...")
var (
@@ -58,7 +61,7 @@ func main() {
flag.StringVar(&cfgFile, "c", "gnunet-config.json", "GNUnet
configuration file")
flag.StringVar(&socket, "s", "", "GNS service socket")
flag.StringVar(¶m, "p", "", "socket parameters (<key>=<value>,...)")
- flag.IntVar(&logLevel, "L", logger.DBG, "DHT log level (default: DBG)")
+ flag.IntVar(&logLevel, "L", logger.INFO, "DHT log level (default:
INFO)")
flag.StringVar(&rpcEndp, "R", "", "JSON-RPC endpoint (default: none)")
flag.Parse()
@@ -69,6 +72,9 @@ func main() {
}
// apply configuration
+ if config.Cfg.Logging.Level > 0 {
+ logLevel = config.Cfg.Logging.Level
+ }
logger.SetLogLevel(logLevel)
if len(socket) == 0 {
socket = config.Cfg.DHT.Service.Socket
@@ -155,11 +161,12 @@ func main() {
}
// send HELLO to all bootstrap addresses
for _, addr := range bsList {
- if err := dhtSrv.SendHello(ctx, addr); err != nil {
- logger.Printf(logger.ERROR, "[dht] send HELLO failed:
%s", err.Error())
+ if err := dhtSrv.SendHello(ctx, addr, "bootstrap"); err != nil {
+ if err != transport.ErrEndpMaybeSent {
+ logger.Printf(logger.ERROR, "[bootstrap] send
HELLO failed: %s", err.Error())
+ }
}
}
-
// handle OS signals
sigCh := make(chan os.Signal, 5)
signal.Notify(sigCh)
diff --git a/src/gnunet/config/config.go b/src/gnunet/config/config.go
index 897926f..504ed82 100644
--- a/src/gnunet/config/config.go
+++ b/src/gnunet/config/config.go
@@ -133,6 +133,16 @@ type RevocationConfig struct {
Storage util.ParameterSet `json:"storage"` // persistence mechanism for
revocation data
}
+//----------------------------------------------------------------------
+// Logging configuration
+//----------------------------------------------------------------------
+
+// LoggingConfig defines the loglevel and logfile location
+type LoggingConfig struct {
+ Level int `json:"level"`
+ File string `json:"file"`
+}
+
//----------------------------------------------------------------------
// Combined configuration
//----------------------------------------------------------------------
@@ -150,6 +160,7 @@ type Config struct {
GNS *GNSConfig `json:"gns"`
Namecache *NamecacheConfig `json:"namecache"`
Revocation *RevocationConfig `json:"revocation"`
+ Logging *LoggingConfig `json:"logging"`
}
var (
diff --git a/src/gnunet/config/gnunet-config.json
b/src/gnunet/config/gnunet-config.json
index 2052b33..f6823d7 100644
--- a/src/gnunet/config/gnunet-config.json
+++ b/src/gnunet/config/gnunet-config.json
@@ -83,5 +83,9 @@
},
"rpc": {
"endpoint": "tcp:127.0.0.1:80"
+ },
+ "logging": {
+ "level": 4,
+ "file": "/tmp/gnunet-go/run.log"
}
}
\ No newline at end of file
diff --git a/src/gnunet/core/core.go b/src/gnunet/core/core.go
index a117643..46a53a4 100644
--- a/src/gnunet/core/core.go
+++ b/src/gnunet/core/core.go
@@ -20,7 +20,6 @@ package core
import (
"context"
- "encoding/hex"
"errors"
"gnunet/config"
"gnunet/crypto"
@@ -42,6 +41,9 @@ var (
ErrCoreNotSent = errors.New("message not sent")
)
+// CtxKey is a value-context key
+type CtxKey string
+
//----------------------------------------------------------------------
// EndpointRef is a reference to an endpoint instance managed by core.
type EndpointRef struct {
@@ -85,7 +87,7 @@ func NewCore(ctx context.Context, node *config.NodeConfig) (c
*Core, err error)
if peer, err = NewLocalPeer(node); err != nil {
return
}
- logger.Printf(logger.DBG, "[core] Local node is %s",
peer.GetID().String())
+ logger.Printf(logger.INFO, "[core] Local node is %s",
peer.GetID().Short())
// create new core instance
incoming := make(chan *transport.Message)
@@ -166,7 +168,7 @@ func (c *Core) pump(ctx context.Context) {
select {
// get (next) message from transport
case tm := <-c.incoming:
- logger.Printf(logger.DBG, "[core] Message received from
%s: %s", tm.Peer, util.Dump(tm.Msg, "json"))
+ logger.Printf(logger.DBG, "[core] Message received from
%s: %s", tm.Peer.Short(), tm.Msg)
// check if peer is already connected (has an entry in
PeerAddrist)
_, connected := c.connected.Get(tm.Peer.String(), 0)
@@ -217,6 +219,14 @@ func (c *Core) Shutdown() {
// Send is a function that allows the local peer to send a protocol
// message to a remote peer.
func (c *Core) Send(ctx context.Context, peer *util.PeerID, msg
message.Message) (err error) {
+ // assemble log label
+ label := "core"
+ if v := ctx.Value(CtxKey("label")); v != nil {
+ if s, ok := v.(string); ok && len(s) > 0 {
+ label = s
+ }
+ }
+
// TODO: select best endpoint protocol for transport; now fixed to
IP+UDP
netw := "ip+udp"
@@ -224,12 +234,12 @@ func (c *Core) Send(ctx context.Context, peer
*util.PeerID, msg message.Message)
aList := c.peers.Get(peer, netw)
maybe := false // message may be sent...
for _, addr := range aList {
- logger.Printf(logger.INFO, "[core] Trying to send to %s",
addr.URI())
+ logger.Printf(logger.INFO, "[%s] Trying to send to %s", label,
addr.URI())
// send message to address
if err = c.SendToAddr(ctx, addr, msg); err != nil {
// if it is possible that the message was not sent, try
next address
if err != transport.ErrEndpMaybeSent {
- logger.Printf(logger.WARN, "[core] Failed to
send to %s: %s", addr.URI(), err.Error())
+ logger.Printf(logger.WARN, "[%s] Failed to send
to %s: %s", label, addr.URI(), err.Error())
} else {
maybe = true
}
@@ -239,7 +249,6 @@ func (c *Core) Send(ctx context.Context, peer *util.PeerID,
msg message.Message)
return
}
if maybe {
- logger.Printf(logger.WARN, "[core] %s",
transport.ErrEndpMaybeSent.Error())
err = nil
} else {
err = ErrCoreNotSent
@@ -256,7 +265,9 @@ func (c *Core) SendToAddr(ctx context.Context, addr
*util.Address, msg message.M
}
// Learn (new) addresses for peer
-func (c *Core) Learn(ctx context.Context, peer *util.PeerID, addrs
[]*util.Address) (newPeer bool) {
+func (c *Core) Learn(ctx context.Context, peer *util.PeerID, addrs
[]*util.Address, label string) (newPeer bool) {
+ logger.Printf(logger.DBG, "[%s] Learning %v for %s", label, addrs,
peer.Short())
+
// learn all addresses for peer
newPeer = false
for _, addr := range addrs {
@@ -265,7 +276,8 @@ func (c *Core) Learn(ctx context.Context, peer
*util.PeerID, addrs []*util.Addre
continue
}
// learn address
- logger.Printf(logger.INFO, "[core] Learning %s for %s (expires
%s)", addr.URI(), peer, addr.Expires)
+ logger.Printf(logger.INFO, "[%s] Learning %s for %s (expires
%s)",
+ label, addr.URI(), peer.Short(), addr.Expire)
newPeer = (c.peers.Add(peer, addr) == 1) || newPeer
}
return
@@ -296,12 +308,10 @@ func (c *Core) PeerID() *util.PeerID {
// Sign a signable onject with private peer key
func (c *Core) Sign(obj crypto.Signable) error {
sd := obj.SignedData()
- logger.Printf(logger.DBG, "[core] Signing data '%s'",
hex.EncodeToString(sd))
sig, err := c.local.prv.EdSign(sd)
if err != nil {
return err
}
- logger.Printf(logger.DBG, "[core] --> signature '%s'",
hex.EncodeToString(sig.Bytes()))
return obj.SetSignature(util.NewPeerSignature(sig.Bytes()))
}
@@ -357,12 +367,11 @@ func (c *Core) Unregister(name string) *Listener {
// internal: dispatch event to listeners
func (c *Core) dispatch(ev *Event) {
- logger.Printf(logger.DBG, "[core] Dispatching %v...", ev)
// dispatch event to listeners
for _, l := range c.listeners {
if l.filter.CheckEvent(ev.ID) {
if ev.ID == EV_MESSAGE {
- mt := ev.Msg.Header().MsgType
+ mt := ev.Msg.Type()
if mt != 0 && !l.filter.CheckMsgType(mt) {
// skip event
return
diff --git a/src/gnunet/core/core_test.go b/src/gnunet/core/core_test.go
index f87dfef..7dabbc5 100644
--- a/src/gnunet/core/core_test.go
+++ b/src/gnunet/core/core_test.go
@@ -249,7 +249,7 @@ func (n *TestNode) Learn(ctx context.Context, peer
*util.PeerID, addr *util.Addr
label = peer.String()
}
n.t.Logf("[%d] Learning %s for %s", n.id, addr.URI(), label)
- n.core.Learn(ctx, peer, []*util.Address{addr})
+ n.core.Learn(ctx, peer, []*util.Address{addr}, label)
}
func NewTestNode(ctx context.Context, t *testing.T, cfg *config.NodeConfig)
(node *TestNode, err error) {
@@ -298,7 +298,7 @@ func NewTestNode(ctx context.Context, t *testing.T, cfg
*config.NodeConfig) (nod
case EV_DISCONNECT:
t.Logf("[%d] <<< Peer %s diconnected",
node.id, ev.Peer)
case EV_MESSAGE:
- t.Logf("[%d] <<< Msg from %s of type
%d", node.id, ev.Peer, ev.Msg.Header().MsgType)
+ t.Logf("[%d] <<< Msg from %s of type
%s", node.id, ev.Peer, ev.Msg.Type())
t.Logf("[%d] <<< --> %s", node.id,
ev.Msg.String())
wrt := new(bytes.Buffer)
if err :=
transport.WriteMessageDirect(wrt, ev.Msg); err == nil {
diff --git a/src/gnunet/core/event.go b/src/gnunet/core/event.go
index 7d7c7e1..d24352d 100644
--- a/src/gnunet/core/event.go
+++ b/src/gnunet/core/event.go
@@ -20,6 +20,7 @@ package core
import (
"fmt"
+ "gnunet/enums"
"gnunet/message"
"gnunet/transport"
"gnunet/util"
@@ -42,14 +43,14 @@ const (
// can be filtered by message type also.
type EventFilter struct {
evTypes map[int]bool
- msgTypes map[uint16]bool
+ msgTypes map[enums.MsgType]bool
}
// NewEventFilter creates a new empty filter instance.
func NewEventFilter() *EventFilter {
return &EventFilter{
evTypes: make(map[int]bool),
- msgTypes: make(map[uint16]bool),
+ msgTypes: make(map[enums.MsgType]bool),
}
}
@@ -59,7 +60,7 @@ func (f *EventFilter) AddEvent(ev int) {
}
// AddMsgType adds a message type to filter
-func (f *EventFilter) AddMsgType(mt uint16) {
+func (f *EventFilter) AddMsgType(mt enums.MsgType) {
f.evTypes[EV_MESSAGE] = true
f.msgTypes[mt] = true
}
@@ -76,7 +77,7 @@ func (f *EventFilter) CheckEvent(ev int) bool {
// CheckMsgType returns true if a message type is matched
// by the filter or the filter is empty.
-func (f *EventFilter) CheckMsgType(mt uint16) bool {
+func (f *EventFilter) CheckMsgType(mt enums.MsgType) bool {
if len(f.msgTypes) == 0 {
return true
}
@@ -103,7 +104,7 @@ func (e *Event) String() string {
}
s += fmt.Sprintf("id=%d,peer=%s", e.ID, e.Peer)
if e.Msg != nil {
- s += fmt.Sprintf(",msg=%d", e.Msg.Header().MsgType)
+ s += fmt.Sprintf(",msg=%s", e.Msg.Type())
}
return s + "}"
}
diff --git a/src/gnunet/core/peer.go b/src/gnunet/core/peer.go
index cf67272..fe171b4 100644
--- a/src/gnunet/core/peer.go
+++ b/src/gnunet/core/peer.go
@@ -103,7 +103,7 @@ func (p *Peer) HelloData(ttl time.Duration, a
[]*util.Address) (h *blocks.HelloB
// assemble HELLO data
h = new(blocks.HelloBlock)
h.PeerID = p.GetID()
- h.Expires = util.NewAbsoluteTime(time.Now().Add(ttl))
+ h.Expire_ = util.NewAbsoluteTime(time.Now().Add(ttl))
h.SetAddresses(a)
// sign data
diff --git a/src/gnunet/core/peer_test.go b/src/gnunet/core/peer_test.go
index 29fe801..c18eec3 100644
--- a/src/gnunet/core/peer_test.go
+++ b/src/gnunet/core/peer_test.go
@@ -75,7 +75,7 @@ func TestPeerHello(t *testing.T) {
t.Log(u2)
// check if HELLO data is the same
- if !h.Equals(h2) {
+ if !h.Equal(h2) {
t.Fatal("HELLO data mismatch")
}
// verify signature
diff --git a/src/gnunet/crypto/gns_edkey.go b/src/gnunet/crypto/gns_edkey.go
index 68a6444..7d4323a 100644
--- a/src/gnunet/crypto/gns_edkey.go
+++ b/src/gnunet/crypto/gns_edkey.go
@@ -132,7 +132,7 @@ func (pk *EDKEYPublicImpl) Verify(data []byte, zs
*ZoneSignature) (ok bool, err
// BlockKey return the symmetric key (and initialization vector) based on
// label and expiration time.
-func (pk *EDKEYPublicImpl) BlockKey(label string, expires util.AbsoluteTime)
(skey []byte) {
+func (pk *EDKEYPublicImpl) BlockKey(label string, expire util.AbsoluteTime)
(skey []byte) {
// generate symmetric key
skey = make([]byte, 56)
kd := pk.Bytes()
@@ -143,11 +143,11 @@ func (pk *EDKEYPublicImpl) BlockKey(label string, expires
util.AbsoluteTime) (sk
}
// assemble initialization vector
iv := &struct {
- Nonce []byte `size:"16"` // Nonce
- Expiration util.AbsoluteTime `` // Expiration time of
block
+ Nonce []byte `size:"16"` // Nonce
+ Expire util.AbsoluteTime `` // Expiration time of block
}{
- Nonce: make([]byte, 16),
- Expiration: expires,
+ Nonce: make([]byte, 16),
+ Expire: expire,
}
prk = hkdf.Extract(sha512.New, kd, []byte("gns-xsalsa-ctx-iv"))
rdr = hkdf.Expand(sha256.New, prk, []byte(label))
diff --git a/src/gnunet/crypto/gns_pkey.go b/src/gnunet/crypto/gns_pkey.go
index e9fdfb5..13925d4 100644
--- a/src/gnunet/crypto/gns_pkey.go
+++ b/src/gnunet/crypto/gns_pkey.go
@@ -121,13 +121,13 @@ func (pk *PKEYPublicImpl) BlockKey(label string, expires
util.AbsoluteTime) (ske
// assemble initialization vector
iv := &struct {
- Nonce []byte `size:"4"` // 32 bit Nonce
- Expiration util.AbsoluteTime `` // Expiration time
of block
- Counter uint32 `order:"big"` // Block counter
+ Nonce []byte `size:"4"` // 32 bit Nonce
+ Expire util.AbsoluteTime `` // Expiration time of
block
+ Counter uint32 `order:"big"` // Block counter
}{
- Nonce: make([]byte, 4),
- Expiration: expires,
- Counter: 1,
+ Nonce: make([]byte, 4),
+ Expire: expires,
+ Counter: 1,
}
prk = hkdf.Extract(sha512.New, kd, []byte("gns-aes-ctx-iv"))
rdr = hkdf.Expand(sha256.New, prk, []byte(label))
diff --git a/src/gnunet/crypto/hash.go b/src/gnunet/crypto/hash.go
index a5716a0..3b58f36 100644
--- a/src/gnunet/crypto/hash.go
+++ b/src/gnunet/crypto/hash.go
@@ -28,12 +28,12 @@ import (
// HashCode is the result of a 512-bit hash function (SHA-512)
type HashCode struct {
- Bits []byte `size:"(Size))"`
+ Data []byte `size:"(Size)"`
}
-// Equals tests if two hash results are equal.
-func (hc *HashCode) Equals(n *HashCode) bool {
- return bytes.Equal(hc.Bits, n.Bits)
+// Equal tests if two hash results are equal.
+func (hc *HashCode) Equal(n *HashCode) bool {
+ return bytes.Equal(hc.Data, n.Data)
}
// Size of binary data
@@ -44,13 +44,18 @@ func (hc *HashCode) Size() uint {
// Clone the hash code
func (hc *HashCode) Clone() *HashCode {
return &HashCode{
- Bits: util.Clone(hc.Bits),
+ Data: util.Clone(hc.Data),
}
}
// String returns a hex-representation of the hash code
func (hc *HashCode) String() string {
- return hex.EncodeToString(hc.Bits)
+ return hex.EncodeToString(hc.Data)
+}
+
+// Short returns a short key representation
+func (hc *HashCode) Short() string {
+ return util.Shorten(hc.String(), 20)
}
// NewHashCode creates a new (initialized) hash value
@@ -65,7 +70,7 @@ func NewHashCode(data []byte) *HashCode {
copy(v, data[:size])
}
}
- hc.Bits = v
+ hc.Data = v
return hc
}
@@ -73,6 +78,6 @@ func NewHashCode(data []byte) *HashCode {
func Hash(data []byte) *HashCode {
val := sha512.Sum512(data)
return &HashCode{
- Bits: util.Clone(val[:]),
+ Data: util.Clone(val[:]),
}
}
diff --git a/src/gnunet/enums/dht.go b/src/gnunet/enums/dht.go
index 040e72f..ac04244 100644
--- a/src/gnunet/enums/dht.go
+++ b/src/gnunet/enums/dht.go
@@ -26,6 +26,8 @@ const (
DHT_RO_RECORD_ROUTE = 2 // keep track of the route that the
message took in the P2P network.
DHT_RO_FIND_APPROXIMATE = 4 // Approximate results are fine.
DHT_RO_TRUNCATED = 8 // Flag if path is truncated
+
+ DHT_RO_DISCOVERY = 32768 // Peer discovery
)
//go:generate go run generate.go gnunet-dht.rec gnunet-dht.tpl
dht_block_type.go
diff --git a/src/gnunet/enums/dht_block_type.go
b/src/gnunet/enums/dht_block_type.go
index beb52dc..db2ffe9 100644
--- a/src/gnunet/enums/dht_block_type.go
+++ b/src/gnunet/enums/dht_block_type.go
@@ -3,7 +3,7 @@
//nolint:stylecheck // allow non-camel-case for constants
package enums
-type BlockType uint16
+type BlockType uint32
// DHT block types
const (
diff --git a/src/gnunet/enums/gnunet-dht.tpl b/src/gnunet/enums/gnunet-dht.tpl
index ed00e57..622ee79 100644
--- a/src/gnunet/enums/gnunet-dht.tpl
+++ b/src/gnunet/enums/gnunet-dht.tpl
@@ -3,7 +3,7 @@
//nolint:stylecheck // allow non-camel-case for constants
package enums
-type BlockType uint16
+type BlockType uint32
// DHT block types
const (
diff --git a/src/gnunet/enums/messages.go b/src/gnunet/enums/messages.go
new file mode 100644
index 0000000..af9baeb
--- /dev/null
+++ b/src/gnunet/enums/messages.go
@@ -0,0 +1,844 @@
+// This file is part of gnunet-go, a GNUnet-implementation in Golang.
+// Copyright (C) 2019-2022 Bernd Fix >Y<
+//
+// gnunet-go 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.
+//
+// gnunet-go 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/>.
+//
+// SPDX-License-Identifier: AGPL3.0-or-later
+
+//nolint:stylecheck // allow non-camel-case in constants
+package enums
+
+// MsgType for GNUnet message type identifiers
+//go:generate stringer -type=MsgType
+type MsgType uint16
+
+// GNUnet message types
+const (
+ MSG_TEST MsgType = 1 // Test if service is online (deprecated)
+ MSG_DUMMY MsgType = 2 // Dummy messages for testing / benchmarking
+ MSG_DUMMY2 MsgType = 3 // Another dummy messages for testing /
benchmarking
+
+ //------------------------------------------------------------------
+ // RESOLVER message types
+ //------------------------------------------------------------------
+
+ MSG_RESOLVER_REQUEST MsgType = 4 // Request DNS resolution
+ MSG_RESOLVER_RESPONSE MsgType = 5 // Response to a DNS resolution
request
+
+ //------------------------------------------------------------------
+ // AGPL source code download
+ //------------------------------------------------------------------
+
+ MSG_REQUEST_AGPL MsgType = 6 // Message to request source code link
+ MSG_RESPONSE_AGPL MsgType = 7 // Source code link
+
+ //------------------------------------------------------------------
+ // ARM message types
+ //------------------------------------------------------------------
+
+ MSG_ARM_START MsgType = 8 // Request to ARM to start a service
+ MSG_ARM_STOP MsgType = 9 // Request to ARM to stop a service
+ MSG_ARM_RESULT MsgType = 10 // Response from ARM
+ MSG_ARM_STATUS MsgType = 11 // Status update from ARM
+ MSG_ARM_LIST MsgType = 12 // Request to ARM to list all
currently running services
+ MSG_ARM_LIST_RESULT MsgType = 13 // Response from ARM for listing
currently running services
+ MSG_ARM_MONITOR MsgType = 14 // Request to ARM to notify client of
service status changes
+ MSG_ARM_TEST MsgType = 15 // Test if ARM service is online
+
+ //------------------------------------------------------------------
+ // HELLO message types
+ //------------------------------------------------------------------
+
+ MSG_HELLO_LEGACY MsgType = 16 // Deprecated HELLO message
+ MSG_HELLO MsgType = 17 // HELLO message with friend_only flag
+
+ //------------------------------------------------------------------
+ // FRAGMENTATION message types
+ //------------------------------------------------------------------
+
+ MSG_FRAGMENT MsgType = 18 // FRAGMENT of a larger message
+ MSG_FRAGMENT_ACK MsgType = 19 // Acknowledgement of a FRAGMENT of a
larger message
+
+ //------------------------------------------------------------------
+ // Transport-WLAN message types
+ //------------------------------------------------------------------
+
+ MSG_WLAN_DATA_TO_HELPER MsgType = 39 // Type of data messages from
the plugin to the gnunet-wlan-helper
+ MSG_WLAN_DATA_FROM_HELPER MsgType = 40 // Type of data messages from
the gnunet-wlan-helper to the plugin
+ MSG_WLAN_HELPER_CONTROL MsgType = 41 // Control message between the
gnunet-wlan-helper and the daemon (with the MAC)
+ MSG_WLAN_ADVERTISEMENT MsgType = 42 // Type of messages for
advertisement over wlan
+ MSG_WLAN_DATA MsgType = 43 // Type of messages for data
over the wlan
+
+ //------------------------------------------------------------------
+ // Transport-DV message types
+ //------------------------------------------------------------------
+
+ MSG_DV_RECV MsgType = 44 // DV service to DV Plugin message
+ MSG_DV_SEND MsgType = 45 // DV Plugin to DV service message
+ MSG_DV_SEND_ACK MsgType = 46 // Confirmation or failure of a
DV_SEND message
+ MSG_DV_ROUTE MsgType = 47 // P2P DV message encapsulating
some real message
+ MSG_DV_START MsgType = 48 // DV Plugin to DV service
message, indicating startup.
+ MSG_DV_CONNECT MsgType = 49 // P2P DV message telling plugin
that a peer connected
+ MSG_DV_DISCONNECT MsgType = 50 // P2P DV message telling plugin
that a peer disconnected
+ MSG_DV_SEND_NACK MsgType = 51 // P2P DV message telling plugin
that a message transmission failed (negative ACK)
+ MSG_DV_DISTANCE_CHANGED MsgType = 52 // P2P DV message telling plugin
that our distance to a peer changed
+ MSG_DV_BOX MsgType = 53 // DV message box for boxing
multiple messages.
+ MSG_TRANSPORT_XU_MESSAGE MsgType = 55 // Experimental message type.
+
+ //------------------------------------------------------------------
+ // Transport-UDP message types
+ //------------------------------------------------------------------
+
+ MSG_TRANSPORT_UDP_MESSAGE MsgType = 56 // Normal UDP message type.
+ MSG_TRANSPORT_UDP_ACK MsgType = 57 // UDP ACK.
+
+ //------------------------------------------------------------------
+ // Transport-TCP message types
+ //------------------------------------------------------------------
+
+ MSG_TRANSPORT_TCP_NAT_PROBE MsgType = 60 // TCP NAT probe message
+ MSG_TRANSPORT_TCP_WELCOME MsgType = 61 // Welcome message between TCP
transports.
+ MSG_TRANSPORT_ATS MsgType = 62 // Message to force transport
to update bandwidth assignment (LEGACY)
+
+ //------------------------------------------------------------------
+ // NAT message types
+ //------------------------------------------------------------------
+
+ MSG_NAT_TEST MsgType = 63 // Message to ask NAT server to perform
traversal test
+
+ //------------------------------------------------------------------
+ // CORE message types
+ //------------------------------------------------------------------
+
+ MSG_CORE_INIT MsgType = 64 // Initial setup message
from core client to core.
+ MSG_CORE_INIT_REPLY MsgType = 65 // Response from core to
core client to INIT message.
+ MSG_CORE_NOTIFY_CONNECT MsgType = 67 // Notify clients about new
peer-to-peer connections (triggered after key exchange).
+ MSG_CORE_NOTIFY_DISCONNECT MsgType = 68 // Notify clients about peer
disconnecting.
+ MSG_CORE_NOTIFY_STATUS_CHANGE MsgType = 69 // Notify clients about peer
status change.
+ MSG_CORE_NOTIFY_INBOUND MsgType = 70 // Notify clients about
incoming P2P messages.
+ MSG_CORE_NOTIFY_OUTBOUND MsgType = 71 // Notify clients about
outgoing P2P transmissions.
+ MSG_CORE_SEND_REQUEST MsgType = 74 // Request from client to
transmit message.
+ MSG_CORE_SEND_READY MsgType = 75 // Confirmation from core
that message can now be sent
+ MSG_CORE_SEND MsgType = 76 // Client with message to
transmit (after SEND_READY confirmation was received).
+ MSG_CORE_MONITOR_PEERS MsgType = 78 // Request for connection
monitoring from CORE service.
+ MSG_CORE_MONITOR_NOTIFY MsgType = 79 // Reply for monitor by CORE
service.
+ MSG_CORE_ENCRYPTED_MESSAGE MsgType = 82 // Encapsulation for an
encrypted message between peers.
+ MSG_CORE_PING MsgType = 83 // Check that other peer is
alive (challenge).
+ MSG_CORE_PONG MsgType = 84 // Confirmation that other
peer is alive.
+ MSG_CORE_HANGUP MsgType = 85 // Request by the other peer
to terminate the connection.
+ MSG_CORE_COMPRESSED_TYPE_MAP MsgType = 86 // gzip-compressed type map
of the sender
+ MSG_CORE_BINARY_TYPE_MAP MsgType = 87 // uncompressed type map of
the sender
+ MSG_CORE_EPHEMERAL_KEY MsgType = 88 // Session key exchange
between peers.
+ MSG_CORE_CONFIRM_TYPE_MAP MsgType = 89 // Other peer confirms
having received the type map
+
+ //------------------------------------------------------------------
+ // DATASTORE message types
+ //------------------------------------------------------------------
+
+ MSG_DATASTORE_RESERVE MsgType = 92 // Message sent by
datastore client on join.
+ MSG_DATASTORE_RELEASE_RESERVE MsgType = 93 // Message sent by
datastore client on join.
+ MSG_DATASTORE_STATUS MsgType = 94 // Message sent by
datastore to client informing about status processing a request (in response to
RESERVE, RELEASE_RESERVE, PUT, UPDATE and REMOVE requests).
+ MSG_DATASTORE_PUT MsgType = 95 // Message sent by
datastore client to store data.
+ MSG_DATASTORE_GET MsgType = 97 // Message sent by
datastore client to get data.
+ MSG_DATASTORE_GET_REPLICATION MsgType = 98 // Message sent by
datastore client to get random data.
+ MSG_DATASTORE_GET_ZERO_ANONYMITY MsgType = 99 // Message sent by
datastore client to get random data.
+ MSG_DATASTORE_DATA MsgType = 100 // Message sent by
datastore to client providing requested data (in response to GET or GET_RANDOM
request).
+ MSG_DATASTORE_DATA_END MsgType = 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.
+ MSG_DATASTORE_REMOVE MsgType = 102 // Message sent by
datastore client to remove data.
+ MSG_DATASTORE_DROP MsgType = 103 // Message sent by
datastore client to drop the database.
+ MSG_DATASTORE_GET_KEY MsgType = 104 // Message sent by
datastore client to get data by key.
+
+ //------------------------------------------------------------------
+ // FS message types
+ //------------------------------------------------------------------
+
+ MSG_FS_REQUEST_LOC_SIGN MsgType = 126 // Message sent by fs client
to request LOC signature.
+ MSG_FS_REQUEST_LOC_SIGNATURE MsgType = 127 // Reply sent by fs service
with LOC signature.
+ MSG_FS_INDEX_START MsgType = 128 // Message sent by fs client
to start indexing.
+ MSG_FS_INDEX_START_OK MsgType = 129 // Affirmative response to a
request for start indexing.
+ MSG_FS_INDEX_START_FAILED MsgType = 130 // Response to a request for
start indexing that refuses.
+ MSG_FS_INDEX_LIST_GET MsgType = 131 // Request from client for
list of indexed files.
+ MSG_FS_INDEX_LIST_ENTRY MsgType = 132 // Reply to client with an
indexed file name.
+ MSG_FS_INDEX_LIST_END MsgType = 133 // Reply to client
indicating end of list.
+ MSG_FS_UNINDEX MsgType = 134 // Request from client to
unindex a file.
+ MSG_FS_UNINDEX_OK MsgType = 135 // Reply to client
indicating unindex receipt.
+ MSG_FS_START_SEARCH MsgType = 136 // Client asks FS service to
start a (keyword) search.
+ MSG_FS_GET MsgType = 137 // P2P request for content
(one FS to another).
+ MSG_FS_PUT MsgType = 138 // P2P response with content
or active migration of content. Also used between the service and clients (in
response to #FS_START_SEARCH).
+ MSG_FS_MIGRATION_STOP MsgType = 139 // Peer asks us to stop
migrating content towards it for a while.
+ MSG_FS_CADET_QUERY MsgType = 140 // P2P request for content
(one FS to another via a cadet).
+ MSG_FS_CADET_REPLY MsgType = 141 // P2P answer for content
(one FS to another via a cadet).
+
+ //------------------------------------------------------------------
+ // DHT message types
+ //------------------------------------------------------------------
+
+ MSG_DHT_CLIENT_PUT MsgType = 142 // Client wants to store
item in DHT.
+ MSG_DHT_CLIENT_GET MsgType = 143 // Client wants to
lookup item in DHT.
+ MSG_DHT_CLIENT_GET_STOP MsgType = 144 // Client wants to stop
search in DHT.
+ MSG_DHT_CLIENT_RESULT MsgType = 145 // Service returns
result to client.
+ MSG_DHT_P2P_PUT MsgType = 146 // Peer is storing data
in DHT.
+ MSG_DHT_P2P_GET MsgType = 147 // Peer tries to find
data in DHT.
+ MSG_DHT_P2P_RESULT MsgType = 148 // Data is returned to
peer from DHT.
+ MSG_DHT_MONITOR_GET MsgType = 149 // Receive information
about transiting GETs
+ MSG_DHT_MONITOR_GET_RESP MsgType = 150 // Receive information
about transiting GET responses
+ MSG_DHT_MONITOR_PUT MsgType = 151 // Receive information
about transiting PUTs
+ MSG_DHT_MONITOR_PUT_RESP MsgType = 152 // Receive information
about transiting PUT responses (TODO)
+ MSG_DHT_MONITOR_START MsgType = 153 // Request information
about transiting messages
+ MSG_DHT_MONITOR_STOP MsgType = 154 // Stop information
about transiting messages
+ MSG_DHT_CLIENT_GET_RESULTS_KNOWN MsgType = 156 // Certain results are
already known to the client, filter those.
+ MSG_DHT_P2P_HELLO MsgType = 157 // HELLO advertising a
neighbours addresses.
+ MSG_DHT_CORE MsgType = 158 // Encapsulation of DHT
messages in CORE service.
+ MSG_DHT_CLIENT_HELLO_URL MsgType = 159 // HELLO URL send
between client and service (in either direction).
+ MSG_DHT_CLIENT_HELLO_GET MsgType = 161 // Client requests DHT
service's HELLO URL.
+
+ //------------------------------------------------------------------
+ // HOSTLIST message types
+ //------------------------------------------------------------------
+
+ MSG_HOSTLIST_ADVERTISEMENT MsgType = 160 // Hostlist advertisement
message
+
+ //------------------------------------------------------------------
+ // STATISTICS message types
+ //------------------------------------------------------------------
+
+ MSG_STATISTICS_SET MsgType = 168 // Set a statistical
value.
+ MSG_STATISTICS_GET MsgType = 169 // Get a statistical
value(s).
+ MSG_STATISTICS_VALUE MsgType = 170 // Response to a
STATISTICS_GET message (with value).
+ MSG_STATISTICS_END MsgType = 171 // Response to a
STATISTICS_GET message (end of value stream).
+ MSG_STATISTICS_WATCH MsgType = 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.
+ MSG_STATISTICS_WATCH_VALUE MsgType = 173 // Changes to a watched
value.
+ MSG_STATISTICS_DISCONNECT MsgType = 174 // Client is done
sending service requests and will now disconnect.
+ MSG_STATISTICS_DISCONNECT_CONFIRM MsgType = 175 // Service confirms
disconnect and that it is done processing all requests from the client.
+
+ //------------------------------------------------------------------
+ // VPN message types
+ //------------------------------------------------------------------
+
+ MSG_VPN_HELPER MsgType = 185 // Type of messages
between the gnunet-vpn-helper and the daemon
+ MSG_VPN_ICMP_TO_SERVICE MsgType = 190 // ICMP packet for a
service.
+ MSG_VPN_ICMP_TO_INTERNET MsgType = 191 // ICMP packet for the
Internet.
+ MSG_VPN_ICMP_TO_VPN MsgType = 192 // ICMP packet for the
VPN
+ MSG_VPN_DNS_TO_INTERNET MsgType = 193 // DNS request for a
DNS exit service.
+ MSG_VPN_DNS_FROM_INTERNET MsgType = 194 // DNS reply from a
DNS exit service.
+ MSG_VPN_TCP_TO_SERVICE_START MsgType = 195 // TCP packet for a
service.
+ MSG_VPN_TCP_TO_INTERNET_START MsgType = 196 // TCP packet for the
Internet.
+ MSG_VPN_TCP_DATA_TO_EXIT MsgType = 197 // TCP packet of an
established connection.
+ MSG_VPN_TCP_DATA_TO_VPN MsgType = 198 // TCP packet of an
established connection.
+ MSG_VPN_UDP_TO_SERVICE MsgType = 199 // UDP packet for a
service.
+ MSG_VPN_UDP_TO_INTERNET MsgType = 200 // UDP packet for the
Internet.
+ MSG_VPN_UDP_REPLY MsgType = 201 // UDP packet from a
remote host
+ MSG_VPN_CLIENT_REDIRECT_TO_IP MsgType = 202 // Client asks VPN
service to setup an IP to redirect traffic via an exit node to some global IP
address.
+ MSG_VPN_CLIENT_REDIRECT_TO_SERVICE MsgType = 203 // Client asks VPN
service to setup an IP to redirect traffic to some peer offering a service.
+ MSG_VPN_CLIENT_USE_IP MsgType = 204 // VPN service
responds to client with an IP to use for the requested redirection.
+
+ //------------------------------------------------------------------
+ // VPN-DNS message types
+ //------------------------------------------------------------------
+
+ MSG_DNS_CLIENT_INIT MsgType = 211 // Initial message from client to
DNS service for registration.
+ MSG_DNS_CLIENT_REQUEST MsgType = 212 // Type of messages between the
gnunet-helper-dns and the service
+ MSG_DNS_CLIENT_RESPONSE MsgType = 213 // Type of messages between the
gnunet-helper-dns and the service
+ MSG_DNS_HELPER MsgType = 214 // Type of messages between the
gnunet-helper-dns and the service
+
+ //------------------------------------------------------------------
+ // CHAT message types START
+ //------------------------------------------------------------------
+
+ MSG_CHAT_JOIN_REQUEST MsgType = 300 // Message sent from
client to join a chat room.
+ MSG_CHAT_JOIN_NOTIFICATION MsgType = 301 // Message sent to
client to indicate joining of another room member.
+ MSG_CHAT_LEAVE_NOTIFICATION MsgType = 302 // Message sent to
client to indicate leaving of another room member.
+ MSG_CHAT_MESSAGE_NOTIFICATION MsgType = 303 // Notification sent
by service to client indicating that we've received a chat message.
+ MSG_CHAT_TRANSMIT_REQUEST MsgType = 304 // Request sent by
client to transmit a chat message to another room members.
+ MSG_CHAT_CONFIRMATION_RECEIPT MsgType = 305 // Receipt sent from a
message receiver to the service to confirm delivery of a chat message.
+ MSG_CHAT_CONFIRMATION_NOTIFICATION MsgType = 306 // Notification sent
from the service to the original sender to acknowledge delivery of a chat
message.
+ MSG_CHAT_P2P_JOIN_NOTIFICATION MsgType = 307 // P2P message sent to
indicate joining of another room member.
+ MSG_CHAT_P2P_LEAVE_NOTIFICATION MsgType = 308 // P2P message sent to
indicate leaving of another room member.
+ MSG_CHAT_P2P_SYNC_REQUEST MsgType = 309 // P2P message sent to
a newly connected peer to request its known clients in order to synchronize
room members.
+ MSG_CHAT_P2P_MESSAGE_NOTIFICATION MsgType = 310 // Notification sent
from one peer to another to indicate that we have received a chat message.
+ MSG_CHAT_P2P_CONFIRMATION_RECEIPT MsgType = 311 // P2P receipt
confirming delivery of a chat message.
+
+ //------------------------------------------------------------------
+ // NSE (network size estimation) message types
+ //------------------------------------------------------------------
+
+ MSG_NSE_START MsgType = 321 // client->service message indicating
start
+ MSG_NSE_P2P_FLOOD MsgType = 322 // P2P message sent from nearest peer
+ MSG_NSE_ESTIMATE MsgType = 323 // service->client message indicating
+
+ //------------------------------------------------------------------
+ // PEERINFO message types
+ //------------------------------------------------------------------
+
+ MSG_PEERINFO_GET MsgType = 330 // Request update and listing of a
peer
+ MSG_PEERINFO_GET_ALL MsgType = 331 // Request update and listing of
all peers
+ MSG_PEERINFO_INFO MsgType = 332 // Information about one of the
peers
+ MSG_PEERINFO_INFO_END MsgType = 333 // End of information about other
peers
+ MSG_PEERINFO_NOTIFY MsgType = 334 // Start notifying this client
about changes
+
+ //------------------------------------------------------------------
+ // ATS message types
+ //------------------------------------------------------------------
+
+ MSG_ATS_START MsgType = 340 // Type of the 'struct
ClientStartMessage' sent by clients to ATS to identify the type of the client.
+ MSG_ATS_REQUEST_ADDRESS MsgType = 341 // Type of the 'struct
RequestAddressMessage' sent by clients to request an address to help connect.
+ MSG_ATS_REQUEST_ADDRESS_CANCEL MsgType = 342 // Type of the 'struct
RequestAddressMessage' sent by clients to request an address to help connect.
+ MSG_ATS_ADDRESS_UPDATE MsgType = 343 // Type of the 'struct
AddressUpdateMessage' sent by clients to ATS to inform ATS about performance
changes.
+ MSG_ATS_ADDRESS_DESTROYED MsgType = 344 // Type of the 'struct
AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address
being unavailable.
+ MSG_ATS_ADDRESS_SUGGESTION MsgType = 345 // Type of the 'struct
AddressSuggestionMessage' sent by ATS to clients to suggest switching to a
different address.
+ MSG_ATS_PEER_INFORMATION MsgType = 346 // Type of the 'struct
PeerInformationMessage' sent by ATS to clients to inform about QoS for a
particular connection.
+ MSG_ATS_RESERVATION_REQUEST MsgType = 347 // Type of the 'struct
ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth
reservations.
+ MSG_ATS_RESERVATION_RESULT MsgType = 348 // Type of the 'struct
ReservationResultMessage' sent by ATS to clients in response to a reservation
request.
+ MSG_ATS_PREFERENCE_CHANGE MsgType = 349 // Type of the 'struct
ChangePreferenceMessage' sent by clients to ATS to ask for allocation
preference changes.
+ MSG_ATS_SESSION_RELEASE MsgType = 350 // Type of the 'struct
SessionReleaseMessage' sent by ATS to client to confirm that a session ID was
destroyed.
+ MSG_ATS_ADDRESS_ADD MsgType = 353 // Type of the 'struct
AddressUpdateMessage' sent by client to ATS to add a new address
+ MSG_ATS_ADDRESSLIST_REQUEST MsgType = 354 // Type of the 'struct
AddressListRequestMessage' sent by client to ATS to request information about
addresses
+ MSG_ATS_ADDRESSLIST_RESPONSE MsgType = 355 // Type of the 'struct
AddressListResponseMessage' sent by ATS to client with information about
addresses
+ MSG_ATS_PREFERENCE_FEEDBACK MsgType = 356 // Type of the 'struct
ChangePreferenceMessage' sent by clients to ATS to ask for allocation
preference changes.
+
+ //------------------------------------------------------------------
+ // TRANSPORT message types
+ //------------------------------------------------------------------
+
+ MSG_TRANSPORT_START MsgType = 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.
+ MSG_TRANSPORT_CONNECT MsgType = 361 // Message from
TRANSPORT notifying about a client that connected to us.
+ MSG_TRANSPORT_DISCONNECT MsgType = 362 // Message from
TRANSPORT notifying about a client that disconnected from us.
+ MSG_TRANSPORT_SEND MsgType = 363 // Request to
TRANSPORT to transmit a message.
+ MSG_TRANSPORT_SEND_OK MsgType = 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.
+ MSG_TRANSPORT_RECV MsgType = 365 // Message from
TRANSPORT notifying about a message that was received.
+ MSG_TRANSPORT_SET_QUOTA MsgType = 366 // Message
telling transport to limit its receive rate.
+ MSG_TRANSPORT_ADDRESS_TO_STRING MsgType = 367 // Request to
look addresses of peers in server.
+ MSG_TRANSPORT_ADDRESS_TO_STRING_REPLY MsgType = 368 // Response to
the address lookup request.
+ MSG_TRANSPORT_BLACKLIST_INIT MsgType = 369 // Register a
client that wants to do blacklisting.
+ MSG_TRANSPORT_BLACKLIST_QUERY MsgType = 370 // Query to a
blacklisting client (is this peer blacklisted)?
+ MSG_TRANSPORT_BLACKLIST_REPLY MsgType = 371 // Reply from
blacklisting client (answer to blacklist query).
+ MSG_TRANSPORT_PING MsgType = 372 // Transport
PING message
+ MSG_TRANSPORT_PONG MsgType = 373 // Transport
PONG message
+ MSG_TRANSPORT_SESSION_SYN MsgType = 375 // Transport SYN
message exchanged between transport services to indicate that a session should
be marked as 'connected'.
+ MSG_TRANSPORT_SESSION_SYN_ACK MsgType = 376 // Transport
SYN_ACK message exchanged between transport services to indicate that a SYN
message was accepted
+ MSG_TRANSPORT_SESSION_ACK MsgType = 377 // Transport ACK
message exchanged between transport services to indicate that a SYN_ACK message
was accepted
+ MSG_TRANSPORT_SESSION_DISCONNECT MsgType = 378 // Transport
DISCONNECT message exchanged between transport services to indicate that a
connection should be dropped.
+ MSG_TRANSPORT_SESSION_QUOTA MsgType = 379 // Message
exchanged between transport services to indicate that the sender should limit
its transmission rate to the indicated quota.
+ MSG_TRANSPORT_MONITOR_PEER_REQUEST MsgType = 380 // Request to
monitor addresses used by a peer or all peers.
+ MSG_TRANSPORT_SESSION_KEEPALIVE MsgType = 381 // Message send
by a peer to notify the other to keep the session alive and measure latency in
a regular interval
+ MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE MsgType = 382 // Response to a
#TRANSPORT_SESSION_KEEPALIVE message to measure latency in a regular interval
+ MSG_TRANSPORT_MONITOR_PEER_RESPONSE MsgType = 383 // Response to
#TRANSPORT_MONITOR_PEER_REQUEST request to iterate over all known addresses.
+ MSG_TRANSPORT_BROADCAST_BEACON MsgType = 384 // Message send
by a peer to notify the other to keep the session alive.
+ MSG_TRANSPORT_TRAFFIC_METRIC MsgType = 385 // Message
containing traffic metrics for transport service
+ MSG_TRANSPORT_MONITOR_PLUGIN_START MsgType = 388 // Request to
start monitoring the connection state of plugins.
+ MSG_TRANSPORT_MONITOR_PLUGIN_EVENT MsgType = 389 // Monitoring
event about the connection state of plugins, generated in response to a
subscription initiated via #TRANSPORT_MONITOR_PLUGIN_START
+ MSG_TRANSPORT_MONITOR_PLUGIN_SYNC MsgType = 390 // Monitoring
event notifying client that the initial iteration is now completed and we are
in sync with the state of the subsystem.
+ MSG_TRANSPORT_MONITOR_PEER_RESPONSE_END MsgType = 391 // terminating
list of replies.
+
+ //------------------------------------------------------------------
+ // FS-PUBLISH-HELPER IPC Messages
+ //------------------------------------------------------------------
+
+ MSG_FS_PUBLISH_HELPER_PROGRESS_FILE MsgType = 420 // Progress
information from the helper: found a file
+ MSG_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY MsgType = 421 // Progress
information from the helper: found a directory
+ MSG_FS_PUBLISH_HELPER_ERROR MsgType = 422 // Error signal
from the helper.
+ MSG_FS_PUBLISH_HELPER_SKIP_FILE MsgType = 423 // Signal that
helper skipped a file.
+ MSG_FS_PUBLISH_HELPER_COUNTING_DONE MsgType = 424 // Signal that
helper is done scanning the directory tree.
+ MSG_FS_PUBLISH_HELPER_META_DATA MsgType = 425 // Extracted
meta data from the helper.
+ MSG_FS_PUBLISH_HELPER_FINISHED MsgType = 426 // Signal that
helper is done.
+
+ //------------------------------------------------------------------
+ // NAMECACHE message types
+ //------------------------------------------------------------------
+
+ MSG_NAMECACHE_LOOKUP_BLOCK MsgType = 431 // Client to service:
lookup block
+ MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE MsgType = 432 // Service to client:
result of block lookup
+ MSG_NAMECACHE_BLOCK_CACHE MsgType = 433 // Client to service:
cache a block
+ MSG_NAMECACHE_BLOCK_CACHE_RESPONSE MsgType = 434 // Service to client:
result of block cache request
+
+ //------------------------------------------------------------------
+ // NAMESTORE message types
+ //------------------------------------------------------------------
+
+ MSG_NAMESTORE_RECORD_STORE MsgType = 435 // Client to
service: store records (as authority)
+ MSG_NAMESTORE_RECORD_STORE_RESPONSE MsgType = 436 // Service to
client: result of store operation.
+ MSG_NAMESTORE_RECORD_LOOKUP MsgType = 437 // Client to
service: lookup label
+ MSG_NAMESTORE_RECORD_LOOKUP_RESPONSE MsgType = 438 // Service to
client: lookup label
+ MSG_NAMESTORE_ZONE_TO_NAME MsgType = 439 // Client to
service: "reverse" lookup for zone name based on zone key
+ MSG_NAMESTORE_ZONE_TO_NAME_RESPONSE MsgType = 440 // Service to
client: result of zone-to-name lookup.
+ MSG_NAMESTORE_MONITOR_START MsgType = 441 // Client to
service: start monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" ---
forever).
+ MSG_NAMESTORE_MONITOR_SYNC MsgType = 442 // Service to
client: you're now in sync.
+ MSG_NAMESTORE_RECORD_RESULT MsgType = 443 // Service to
client: here is a (plaintext) record you requested.
+ MSG_NAMESTORE_MONITOR_NEXT MsgType = 444 // Client to
service: I am now ready for the next (set of) monitor events. Monitoring
equivalent of #NAMESTORE_ZONE_ITERATION_NEXT.
+ MSG_NAMESTORE_ZONE_ITERATION_START MsgType = 445 // Client to
service: please start iteration; receives "NAMESTORE_LOOKUP_NAME_RESPONSE"
messages in return.
+ MSG_NAMESTORE_ZONE_ITERATION_NEXT MsgType = 447 // Client to
service: next record(s) in iteration please.
+ MSG_NAMESTORE_ZONE_ITERATION_STOP MsgType = 448 // Client to
service: stop iterating.
+
+ //------------------------------------------------------------------
+ // LOCKMANAGER message types
+ //------------------------------------------------------------------
+
+ MSG_LOCKMANAGER_ACQUIREMsgType = 450 // Message to acquire Lock
+ MSG_LOCKMANAGER_RELEASEMsgType = 451 // Message to release lock
+ MSG_LOCKMANAGER_SUCCESSMsgType = 452 // SUCCESS reply from lockmanager
+
+ //------------------------------------------------------------------
+ // TESTBED message types
+ //------------------------------------------------------------------
+
+ MSG_TESTBED_INIT MsgType = 460 // Initial message
from a client to a testing control service
+ MSG_TESTBED_ADD_HOST MsgType = 461 // Message to add
host
+ MSG_TESTBED_ADD_HOST_SUCCESS MsgType = 462 // Message to
signal that a add host succeeded
+ MSG_TESTBED_LINK_CONTROLLERS MsgType = 463 // Message to link
delegated controller to slave controller
+ MSG_TESTBED_CREATE_PEER MsgType = 464 // Message to
create a peer at a host
+ MSG_TESTBED_RECONFIGURE_PEER MsgType = 465 // Message to
reconfigure a peer
+ MSG_TESTBED_START_PEER MsgType = 466 // Message to start
a peer at a host
+ MSG_TESTBED_STOP_PEER MsgType = 467 // Message to stop
a peer at a host
+ MSG_TESTBED_DESTROY_PEER MsgType = 468 // Message to
destroy a peer
+ MSG_TESTBED_CONFIGURE_UNDERLAY_LINK MsgType = 469 // Configure
underlay link message
+ MSG_TESTBED_OVERLAY_CONNECT MsgType = 470 // Message to
connect peers in a overlay
+ MSG_TESTBED_PEER_EVENT MsgType = 471 // Message for peer
events
+ MSG_TESTBED_PEER_CONNECT_EVENT MsgType = 472 // Message for peer
connect events
+ MSG_TESTBED_OPERATION_FAIL_EVENT MsgType = 473 // Message for
operation events
+ MSG_TESTBED_CREATE_PEER_SUCCESS MsgType = 474 // Message to
signal successful peer creation
+ MSG_TESTBED_GENERIC_OPERATION_SUCCESS MsgType = 475 // Message to
signal a generic operation has been successful
+ MSG_TESTBED_GET_PEER_INFORMATION MsgType = 476 // Message to get a
peer's information
+ MSG_TESTBED_PEER_INFORMATION MsgType = 477 // Message
containing the peer's information
+ MSG_TESTBED_REMOTE_OVERLAY_CONNECT MsgType = 478 // Message to
request a controller to make one of its peer to connect to another peer using
the contained HELLO
+ MSG_TESTBED_GET_SLAVE_CONFIGURATION MsgType = 479 // Message to
request configuration of a slave controller
+ MSG_TESTBED_SLAVE_CONFIGURATION MsgType = 480 // Message which
contains the configuration of slave controller
+ MSG_TESTBED_LINK_CONTROLLERS_RESULT MsgType = 481 // Message to
signal the result of #TESTBED_LINK_CONTROLLERS request
+ MSG_TESTBED_SHUTDOWN_PEERS MsgType = 482 // A controller
receiving this message floods it to its directly-connected sub-controllers and
then stops and destroys all peers
+ MSG_TESTBED_MANAGE_PEER_SERVICE MsgType = 483 // Message to
start/stop a service of a peer
+ MSG_TESTBED_BARRIER_INIT MsgType = 484 // Message to
initialise a barrier. Messages of these type are flooded to all sub-controllers
+ MSG_TESTBED_BARRIER_CANCEL MsgType = 485 // Message to
cancel a barrier. This message is flooded to all sub-controllers
+ MSG_TESTBED_BARRIER_STATUS MsgType = 486 // Message for
signalling status of a barrier
+ MSG_TESTBED_BARRIER_WAIT MsgType = 487 // Message sent by
a peer when it has reached a barrier and is waiting for it to be crossed
+ MSG_TESTBED_MAX MsgType = 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
+ MSG_TESTBED_HELPER_INIT MsgType = 495 // The
initialization message towards gnunet-testbed-helper
+ MSG_TESTBED_HELPER_REPLY MsgType = 496 // The reply
message from gnunet-testbed-helper
+
+ //------------------------------------------------------------------
+ // GNS.
+ //------------------------------------------------------------------
+
+ MSG_GNS_LOOKUP MsgType = 500 // Client would like to
resolve a name.
+ MSG_GNS_LOOKUP_RESULT MsgType = 501 // Service response to name
resolution request from client.
+ MSG_GNS_REVERSE_LOOKUP MsgType = 502 // Reverse lookup
+ MSG_GNS_REVERSE_LOOKUP_RESULT MsgType = 503 // Response to reverse
lookup
+
+ //------------------------------------------------------------------
+ // CONSENSUS message types
+ //------------------------------------------------------------------
+
+ MSG_CONSENSUS_CLIENT_JOIN MsgType = 520 // Join a consensus
session. Sent by client to service as first message.
+ MSG_CONSENSUS_CLIENT_INSERT MsgType = 521 // Insert an
element. Sent by client to service.
+ MSG_CONSENSUS_CLIENT_BEGIN MsgType = 522 // Begin accepting
new elements from other participants. Sent by client to service.
+ MSG_CONSENSUS_CLIENT_RECEIVED_ELEMENT MsgType = 523 // Sent by service
when a new element is added.
+ MSG_CONSENSUS_CLIENT_CONCLUDE MsgType = 524 // Sent by client
to service in order to start the consensus conclusion.
+ MSG_CONSENSUS_CLIENT_CONCLUDE_DONE MsgType = 525 // Sent by service
to client in order to signal a completed consensus conclusion. Last message
sent in a consensus session.
+ MSG_CONSENSUS_CLIENT_ACK MsgType = 540 // Sent by client
to service, telling whether a received element should be accepted and
propagated further or not.
+ MSG_CONSENSUS_P2P_DELTA_ESTIMATE MsgType = 541 // Strata estimator.
+ MSG_CONSENSUS_P2P_DIFFERENCE_DIGEST MsgType = 542 // IBF containing
all elements of a peer.
+ MSG_CONSENSUS_P2P_ELEMENTS MsgType = 543 // One or more
elements that are sent from peer to peer.
+ MSG_CONSENSUS_P2P_ELEMENTS_REQUEST MsgType = 544 // Elements, and
requests for further elements
+ MSG_CONSENSUS_P2P_ELEMENTS_REPORT MsgType = 545 // Elements that a
peer reports to be missing at the remote peer.
+ MSG_CONSENSUS_P2P_HELLO MsgType = 546 // Initialization
message for consensus p2p communication.
+ MSG_CONSENSUS_P2P_SYNCED MsgType = 547 // Report that the
peer is synced with the partner after successfully decoding the invertible
bloom filter.
+ MSG_CONSENSUS_P2P_FIN MsgType = 548 // Interaction os
over, got synched and reported all elements
+ MSG_CONSENSUS_P2P_ABORT MsgType = 548 // Abort a round,
don't send requested elements anymore
+ MSG_CONSENSUS_P2P_ROUND_CONTEXT MsgType = 547 // Abort a round,
don't send requested elements anymore
+
+ //------------------------------------------------------------------
+ // SET message types
+ //------------------------------------------------------------------
+
+ MSG_SET_UNION_P2P_REQUEST_FULL MsgType = 565 // Demand the whole
element from the other peer, given only the hash code.
+ MSG_SET_UNION_P2P_DEMAND MsgType = 566 // Demand the whole
element from the other peer, given only the hash code.
+ MSG_SET_UNION_P2P_INQUIRY MsgType = 567 // Tell the other
peer to send us a list of hashes that match an IBF key.
+ MSG_SET_UNION_P2P_OFFER MsgType = 568 // Tell the other
peer which hashes match a given IBF key.
+ MSG_SET_REJECT MsgType = 569 // Reject a set
request.
+ MSG_SET_CANCEL MsgType = 570 // Cancel a set
operation
+ MSG_SET_ITER_ACK MsgType = 571 // Acknowledge
result from iteration
+ MSG_SET_RESULT MsgType = 572 // Create an empty
set
+ MSG_SET_ADD MsgType = 573 // Add element to
set
+ MSG_SET_REMOVE MsgType = 574 // Remove element
from set
+ MSG_SET_LISTEN MsgType = 575 // Listen for
operation requests
+ MSG_SET_ACCEPT MsgType = 576 // Accept a set
request
+ MSG_SET_EVALUATE MsgType = 577 // Evaluate a set
operation
+ MSG_SET_CONCLUDE MsgType = 578 // Start a set
operation with the given set
+ MSG_SET_REQUEST MsgType = 579 // Notify the
client of a request from a remote peer
+ MSG_SET_CREATE MsgType = 580 // Create a new
local set
+ MSG_SET_P2P_OPERATION_REQUEST MsgType = 581 // Request a set
operation from a remote peer.
+ MSG_SET_UNION_P2P_SE MsgType = 582 // Strata estimator.
+ MSG_SET_UNION_P2P_IBF MsgType = 583 // Invertible bloom
filter.
+ MSG_SET_P2P_ELEMENTS MsgType = 584 // Actual set
elements.
+ MSG_SET_P2P_ELEMENT_REQUESTS MsgType = 585 // Requests for the
elements with the given hashes.
+ MSG_SET_UNION_P2P_DONE MsgType = 586 // Set operation is
done.
+ MSG_SET_ITER_REQUEST MsgType = 587 // Start iteration
over set elements.
+ MSG_SET_ITER_ELEMENT MsgType = 588 // Element result
for the iterating client.
+ MSG_SET_ITER_DONE MsgType = 589 // Iteration end
marker for the client.
+ MSG_SET_UNION_P2P_SEC MsgType = 590 // Compressed
strata estimator.
+ MSG_SET_INTERSECTION_P2P_ELEMENT_INFO MsgType = 591 // Information
about the element count for intersection
+ MSG_SET_INTERSECTION_P2P_BF MsgType = 592 // Bloom filter
message for intersection exchange started by Bob.
+ MSG_SET_INTERSECTION_P2P_DONE MsgType = 593 // Intersection
operation is done.
+ MSG_SET_COPY_LAZY_PREPARE MsgType = 594 // Ask the set
service to prepare a copy of a set.
+ MSG_SET_COPY_LAZY_RESPONSE MsgType = 595 // Give the client
an ID for connecting to the set's copy.
+ MSG_SET_COPY_LAZY_CONNECT MsgType = 596 // Sent by the
client to the server to connect to an existing, lazily copied set.
+ MSG_SET_UNION_P2P_FULL_DONE MsgType = 597 // Request all
missing elements from the other peer, based on their sets and the elements we
previously sent with #SET_P2P_ELEMENTS.
+ MSG_SET_UNION_P2P_FULL_ELEMENT MsgType = 598 // Send a set
element, not as response to a demand but because we're sending the full set.
+ MSG_SET_UNION_P2P_OVER MsgType = 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
+ //------------------------------------------------------------------
+
+ MSG_TESTBED_LOGGER_MSG MsgType = 600 // Message for TESTBED LOGGER
+ MSG_TESTBED_LOGGER_ACK MsgType = 601 // Message for TESTBED LOGGER
acknowledgement
+
+ MSG_REGEX_ANNOUNCE MsgType = 620 // Advertise regex capability.
+ MSG_REGEX_SEARCH MsgType = 621 // Search for peer with matching
capability.
+ MSG_REGEX_RESULT MsgType = 622 // Result in response to regex search.
+
+ //------------------------------------------------------------------
+ // IDENTITY message types
+ //------------------------------------------------------------------
+
+ MSG_IDENTITY_START MsgType = 624 // First message send from
identity client to service (to subscribe to updates).
+ MSG_IDENTITY_RESULT_CODE MsgType = 625 // Generic response from
identity service with success and/or error message.
+ MSG_IDENTITY_UPDATE MsgType = 626 // Update about identity
status from service to clients.
+ MSG_IDENTITY_GET_DEFAULT MsgType = 627 // Client requests to know
default identity for a subsystem.
+ MSG_IDENTITY_SET_DEFAULT MsgType = 628 // Client sets default
identity; or service informs about default identity.
+ MSG_IDENTITY_CREATE MsgType = 629 // Create new identity
(client->service).
+ MSG_IDENTITY_RENAME MsgType = 630 // Rename existing identity
(client->service).
+ MSG_IDENTITY_DELETE MsgType = 631 // Delete identity
(client->service).
+ MSG_IDENTITY_LOOKUP MsgType = 632
+ MSG_IDENTITY_LOOKUP_BY_NAME MsgType = 633
+
+ //------------------------------------------------------------------
+ // REVOCATION message types
+ //------------------------------------------------------------------
+
+ MSG_REVOCATION_QUERY MsgType = 636 // Client to service: was
this key revoked?
+ MSG_REVOCATION_QUERY_RESPONSE MsgType = 637 // Service to client:
answer if key was revoked!
+ MSG_REVOCATION_REVOKE MsgType = 638 // Client to service OR
peer-to-peer: revoke this key!
+ MSG_REVOCATION_REVOKE_RESPONSE MsgType = 639 // Service to client:
revocation confirmed
+
+ //------------------------------------------------------------------
+ // SCALARPRODUCT message types
+ //------------------------------------------------------------------
+
+ MSG_SCALARPRODUCT_CLIENT_TO_ALICE MsgType = 640 // Client ->
Alice
+ MSG_SCALARPRODUCT_CLIENT_TO_BOB MsgType = 641 // Client ->
Bob
+ MSG_SCALARPRODUCT_CLIENT_MULTIPART_ALICE MsgType = 642 // Client ->
Alice multipart
+ MSG_SCALARPRODUCT_CLIENT_MULTIPART_BOB MsgType = 643 // Client ->
Bob multipart
+ MSG_SCALARPRODUCT_SESSION_INITIALIZATION MsgType = 644 // Alice ->
Bob session initialization
+ MSG_SCALARPRODUCT_ALICE_CRYPTODATA MsgType = 645 // Alice ->
Bob SP crypto-data (after intersection)
+ MSG_SCALARPRODUCT_BOB_CRYPTODATA MsgType = 647 // Bob ->
Alice SP crypto-data
+ MSG_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART MsgType = 648 // Bob ->
Alice SP crypto-data multipart
+ MSG_SCALARPRODUCT_RESULT MsgType = 649 // Alice/Bob
-> Client Result
+ MSG_SCALARPRODUCT_ECC_SESSION_INITIALIZATION MsgType = 650 // Alice ->
Bob ECC session initialization
+ MSG_SCALARPRODUCT_ECC_ALICE_CRYPTODATA MsgType = 651 // Alice ->
Bob ECC crypto data
+ MSG_SCALARPRODUCT_ECC_BOB_CRYPTODATA MsgType = 652 // Bob ->
Alice ECC crypto data
+
+ //------------------------------------------------------------------
+ // PSYCSTORE message types
+ //------------------------------------------------------------------
+
+ MSG_PSYCSTORE_MEMBERSHIP_STORE MsgType = 660 // Store a membership
event.
+ MSG_PSYCSTORE_MEMBERSHIP_TEST MsgType = 661 // Test for membership
of a member at a particular point in time.
+ MSG_PSYCSTORE_FRAGMENT_STORE MsgType = 662 //
+ MSG_PSYCSTORE_FRAGMENT_GET MsgType = 663 //
+ MSG_PSYCSTORE_MESSAGE_GET MsgType = 664 //
+ MSG_PSYCSTORE_MESSAGE_GET_FRAGMENT MsgType = 665 //
+ MSG_PSYCSTORE_COUNTERS_GET MsgType = 666 //
+ MSG_PSYCSTORE_STATE_MODIFY MsgType = 668 //
+ MSG_PSYCSTORE_STATE_SYNC MsgType = 669 //
+ MSG_PSYCSTORE_STATE_RESET MsgType = 670 //
+ MSG_PSYCSTORE_STATE_HASH_UPDATE MsgType = 671 //
+ MSG_PSYCSTORE_STATE_GET MsgType = 672 //
+ MSG_PSYCSTORE_STATE_GET_PREFIX MsgType = 673 //
+ MSG_PSYCSTORE_RESULT_CODE MsgType = 674 // Generic response
from PSYCstore service with success and/or error message.
+ MSG_PSYCSTORE_RESULT_FRAGMENT MsgType = 675 //
+ MSG_PSYCSTORE_RESULT_COUNTERS MsgType = 676 //
+ MSG_PSYCSTORE_RESULT_STATE MsgType = 677 //
+
+ //------------------------------------------------------------------
+ // PSYC message types
+ //------------------------------------------------------------------
+
+ MSG_PSYC_RESULT_CODE MsgType = 680 // S->C: result of an
operation
+ MSG_PSYC_MASTER_START MsgType = 681 // C->S: request to
start a channel as a master
+ MSG_PSYC_MASTER_START_ACK MsgType = 682 // S->C: master start
acknowledgement
+ MSG_PSYC_SLAVE_JOIN MsgType = 683 // C->S: request to
join a channel as a slave
+ MSG_PSYC_SLAVE_JOIN_ACK MsgType = 684 // S->C: slave join
acknowledgement
+ MSG_PSYC_PART_REQUEST MsgType = 685 // C->S: request to
part from a channel
+ MSG_PSYC_PART_ACK MsgType = 686 // S->C:
acknowledgement that a slave of master parted from a channel
+ MSG_PSYC_JOIN_REQUEST MsgType = 687 // M->S->C: incoming
join request from multicast
+ MSG_PSYC_JOIN_DECISION MsgType = 688 // C->S->M: decision
about a join request
+ MSG_PSYC_CHANNEL_MEMBERSHIP_STORE MsgType = 689 // C->S: request to
add/remove channel slave in the membership database.
+ MSG_PSYC_MESSAGE MsgType = 691 // S<--C: PSYC message
which contains one or more message parts.
+ MSG_PSYC_MESSAGE_HEADER MsgType = 692 // M<->S<->C: PSYC
message which contains a header and one or more message parts.
+ MSG_PSYC_MESSAGE_METHOD MsgType = 693 // Message part: method
+ MSG_PSYC_MESSAGE_MODIFIER MsgType = 694 // Message part:
modifier
+ MSG_PSYC_MESSAGE_MOD_CONT MsgType = 695 // Message part:
modifier continuation
+ MSG_PSYC_MESSAGE_DATA MsgType = 696 // Message part: data
+ MSG_PSYC_MESSAGE_END MsgType = 697 // Message part: end of
message
+ MSG_PSYC_MESSAGE_CANCEL MsgType = 698 // Message part:
message cancelled
+ MSG_PSYC_MESSAGE_ACK MsgType = 699 // S->C: message
acknowledgement
+ MSG_PSYC_HISTORY_REPLAY MsgType = 701 // C->S: request
channel history replay from PSYCstore.
+ MSG_PSYC_HISTORY_RESULT MsgType = 702 // S->C: result for a
channel history request
+ MSG_PSYC_STATE_GET MsgType = 703 // C->S: request best
matching state variable from PSYCstore.
+ MSG_PSYC_STATE_GET_PREFIX MsgType = 704 // C->S: request state
variables with a given prefix from PSYCstore.
+ MSG_PSYC_STATE_RESULT MsgType = 705 // S->C: result for a
state request.
+
+ //------------------------------------------------------------------
+ // CONVERSATION message types
+ //------------------------------------------------------------------
+
+ MSG_CONVERSATION_AUDIO MsgType = 730 // Message to
transmit the audio between helper and speaker/microphone library.
+ MSG_CONVERSATION_CS_PHONE_REGISTER MsgType = 731 // Client -> Server
message to register a phone.
+ MSG_CONVERSATION_CS_PHONE_PICK_UP MsgType = 732 // Client -> Server
message to reject/hangup a call
+ MSG_CONVERSATION_CS_PHONE_HANG_UP MsgType = 733 // Client -> Server
message to reject/hangup a call
+ MSG_CONVERSATION_CS_PHONE_CALL MsgType = 734 // Client <- Server
message to indicate a ringing phone
+ MSG_CONVERSATION_CS_PHONE_RING MsgType = 735 // Client <- Server
message to indicate a ringing phone
+ MSG_CONVERSATION_CS_PHONE_SUSPEND MsgType = 736 // Client <-> Server
message to suspend connection.
+ MSG_CONVERSATION_CS_PHONE_RESUME MsgType = 737 // Client <-> Server
message to resume connection.
+ MSG_CONVERSATION_CS_PHONE_PICKED_UP MsgType = 738 // Service -> Client
message to notify that phone was picked up.
+ MSG_CONVERSATION_CS_AUDIO MsgType = 739 // Client <-> Server
message to send audio data.
+ MSG_CONVERSATION_CADET_PHONE_RING MsgType = 740 // Cadet: call
initiation
+ MSG_CONVERSATION_CADET_PHONE_HANG_UP MsgType = 741 // Cadet: hang up /
refuse call
+ MSG_CONVERSATION_CADET_PHONE_PICK_UP MsgType = 742 // Cadet: pick up
phone (establish audio channel)
+ MSG_CONVERSATION_CADET_PHONE_SUSPEND MsgType = 743 // Cadet: phone
suspended.
+ MSG_CONVERSATION_CADET_PHONE_RESUME MsgType = 744 // Cadet: phone
resumed.
+ MSG_CONVERSATION_CADET_AUDIO MsgType = 745 // Cadet: audio data
+
+ //------------------------------------------------------------------
+ // MULTICAST message types
+ //------------------------------------------------------------------
+
+ MSG_MULTICAST_ORIGIN_START MsgType = 750 // C->S: Start the
origin.
+ MSG_MULTICAST_MEMBER_JOIN MsgType = 751 // C->S: Join group as
a member.
+ MSG_MULTICAST_JOIN_REQUEST MsgType = 752 // C<--S<->T: A peer
wants to join the group. Unicast message to the origin or another group member.
+ MSG_MULTICAST_JOIN_DECISION MsgType = 753 // C<->S<->T: Response
to a join request. Unicast message from a group member to the peer wanting to
join.
+ MSG_MULTICAST_PART_REQUEST MsgType = 754 // A peer wants to part
the group.
+ MSG_MULTICAST_PART_ACK MsgType = 755 // Acknowledgement sent
in response to a part request. Unicast message from a group member to the peer
wanting to part.
+ MSG_MULTICAST_GROUP_END MsgType = 756 // Group terminated.
+ MSG_MULTICAST_MESSAGE MsgType = 757 // C<->S<->T: Multicast
message from the origin to all members.
+ MSG_MULTICAST_REQUEST MsgType = 758 // C<->S<->T: Unicast
request from a group member to the origin.
+ MSG_MULTICAST_FRAGMENT_ACK MsgType = 759 // C->S:
Acknowledgement of a message or request fragment for the client.
+ MSG_MULTICAST_REPLAY_REQUEST MsgType = 760 // C<->S<->T: Replay
request from a group member to another member.
+ MSG_MULTICAST_REPLAY_RESPONSE MsgType = 761 // C<->S<->T: Replay
response from a group member to another member.
+ MSG_MULTICAST_REPLAY_RESPONSE_END MsgType = 762 // C<->S: End of replay
response.
+
+ //------------------------------------------------------------------
+ // SECRETSHARING message types
+ //------------------------------------------------------------------
+
+ MSG_SECRETSHARING_CLIENT_GENERATE MsgType = 780 // Establish a new
session.
+ MSG_SECRETSHARING_CLIENT_DECRYPT MsgType = 781 // Request the
decryption of a ciphertext.
+ MSG_SECRETSHARING_CLIENT_DECRYPT_DONE MsgType = 782 // The service
succeeded in decrypting a ciphertext.
+ MSG_SECRETSHARING_CLIENT_SECRET_READY MsgType = 783 // Contains the
peer's share.
+
+ //------------------------------------------------------------------
+ // PEERSTORE message types
+ //------------------------------------------------------------------
+
+ MSG_PEERSTORE_STORE MsgType = 820 // Store request message
+ MSG_PEERSTORE_ITERATE MsgType = 821 // Iteration request
+ MSG_PEERSTORE_ITERATE_RECORD MsgType = 822 // Iteration record message
+ MSG_PEERSTORE_ITERATE_END MsgType = 823 // Iteration end message
+ MSG_PEERSTORE_WATCH MsgType = 824 // Watch request
+ MSG_PEERSTORE_WATCH_RECORD MsgType = 825 // Watch response
+ MSG_PEERSTORE_WATCH_CANCEL MsgType = 826 // Watch cancel request
+
+ //------------------------------------------------------------------
+ // SOCIAL message types
+ //------------------------------------------------------------------
+
+ MSG_SOCIAL_RESULT_CODE MsgType = 840 // S->C: result of an
operation
+ MSG_SOCIAL_HOST_ENTER MsgType = 841 // C->S: request to enter
a place as the host
+ MSG_SOCIAL_HOST_ENTER_ACK MsgType = 842 // S->C: host enter
acknowledgement
+ MSG_SOCIAL_GUEST_ENTER MsgType = 843 // C->S: request to enter
a place as a guest
+ MSG_SOCIAL_GUEST_ENTER_BY_NAME MsgType = 844 // C->S: request to enter
a place as a guest, using a GNS address
+ MSG_SOCIAL_GUEST_ENTER_ACK MsgType = 845 // S->C: guest enter
acknowledgement
+ MSG_SOCIAL_ENTRY_REQUEST MsgType = 846 // P->S->C: incoming entry
request from PSYC
+ MSG_SOCIAL_ENTRY_DECISION MsgType = 847 // C->S->P: decision about
an entry request
+ MSG_SOCIAL_PLACE_LEAVE MsgType = 848 // C->S: request to leave
a place
+ MSG_SOCIAL_PLACE_LEAVE_ACK MsgType = 849 // S->C: place leave
acknowledgement
+ MSG_SOCIAL_ZONE_ADD_PLACE MsgType = 850 // C->S: add place to GNS
zone
+ MSG_SOCIAL_ZONE_ADD_NYM MsgType = 851 // C->S: add nym to GNS
zone
+ MSG_SOCIAL_APP_CONNECT MsgType = 852 // C->S: connect
application
+ MSG_SOCIAL_APP_DETACH MsgType = 853 // C->S: detach a place
from application
+ MSG_SOCIAL_APP_EGO MsgType = 854 // S->C: notify about an
existing ego
+ MSG_SOCIAL_APP_EGO_END MsgType = 855 // S->C: end of ego list
+ MSG_SOCIAL_APP_PLACE MsgType = 856 // S->C: notify about an
existing place
+ MSG_SOCIAL_APP_PLACE_END MsgType = 857 // S->C: end of place list
+ MSG_SOCIAL_MSG_PROC_SET MsgType = 858 // C->S: set message
processing flags
+ MSG_SOCIAL_MSG_PROC_CLEAR MsgType = 859 // C->S: clear message
processing flags
+
+ //------------------------------------------------------------------
+ // X-VINE DHT messages
+ //------------------------------------------------------------------
+
+ MSG_XDHT_P2P_TRAIL_SETUP MsgType = 880 // Trail setup
request is received by a peer.
+ MSG_XDHT_P2P_TRAIL_SETUP_RESULT MsgType = 881 // Trail to a
particular peer is returned to this peer.
+ MSG_XDHT_P2P_VERIFY_SUCCESSOR MsgType = 882 // Verify if
your immediate successor is still your immediate successor.
+ MSG_XDHT_P2P_NOTIFY_NEW_SUCCESSOR MsgType = 883 // Notify your
new immediate successor that you are its new predecessor.
+ MSG_XDHT_P2P_VERIFY_SUCCESSOR_RESULT MsgType = 884 // Message
which contains the immediate predecessor of requested successor
+ MSG_XDHT_P2P_GET_RESULT MsgType = 885 // Message
which contains the get result.
+ MSG_XDHT_P2P_TRAIL_SETUP_REJECTION MsgType = 886 // Trail
Rejection Message.
+ MSG_XDHT_P2P_TRAIL_TEARDOWN MsgType = 887 // Trail Tear
down Message.
+ MSG_XDHT_P2P_ADD_TRAIL MsgType = 888 // Routing
table add message.
+ MSG_XDHT_P2P_PUT MsgType = 890 // Peer is
storing the data in DHT.
+ MSG_XDHT_P2P_GET MsgType = 891 // Peer tries
to find data in DHT.
+ MSG_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION MsgType = 892 // Send back
peer that considers you are its successor.
+
+ MSG_DHT_ACT_MALICIOUS MsgType = 893 // Turn X-VINE DHT
service malicious
+ MSG_DHT_CLIENT_ACT_MALICIOUS_OK MsgType = 894 // Acknowledge receiving
ACT MALICIOUS request
+
+ //------------------------------------------------------------------
+ // Whanau DHT messages
+ //------------------------------------------------------------------
+
+ MSG_WDHT_RANDOM_WALK MsgType = 910 // This message contains
the query for performing a random walk
+ MSG_WDHT_RANDOM_WALK_RESPONSE MsgType = 911 // This message contains
the result of a random walk
+ MSG_WDHT_TRAIL_DESTROY MsgType = 912 // This message contains a
notification for the death of a trail
+ MSG_WDHT_TRAIL_ROUTE MsgType = 913 // This message are used to
route a query to a peer
+ MSG_WDHT_SUCCESSOR_FIND MsgType = 914 // This message contains
the query to transfer successor values.
+ MSG_WDHT_GET MsgType = 915 // Message which contains
the get query
+ MSG_WDHT_PUT MsgType = 916 // Message which contains
the "put", a response to #WDHT_SUCCESSOR_FIND.
+ MSG_WDHT_GET_RESULT MsgType = 917 // Message which contains
the get result, a response to #WDHT_GET.
+
+ //------------------------------------------------------------------
+ // RPS messages
+ //------------------------------------------------------------------
+
+ MSG_RPS_PP_CHECK_LIVE MsgType = 950 // RPS check liveliness message
to check liveliness of other peer
+ MSG_RPS_PP_PUSH MsgType = 951 // RPS PUSH message to push own
ID to another peer
+ MSG_RPS_PP_PULL_REQUEST MsgType = 952 // RPS PULL REQUEST message to
request the local view of another peer
+ MSG_RPS_PP_PULL_REPLY MsgType = 953 // RPS PULL REPLY message which
contains the view of the other peer
+ MSG_RPS_CS_SEED MsgType = 954 // RPS CS SEED Message for the
Client to seed peers into rps
+ MSG_RPS_ACT_MALICIOUS MsgType = 955 // Turn RPS service malicious
+ MSG_RPS_CS_SUB_START MsgType = 956 // RPS client-service message to
start a sub sampler
+ MSG_RPS_CS_SUB_STOP MsgType = 957 // RPS client-service message to
stop a sub sampler
+
+ //------------------------------------------------------------------
+ // RECLAIM messages
+ //------------------------------------------------------------------
+
+ MSG_RECLAIM_ATTRIBUTE_STORE MsgType = 961
+ MSG_RECLAIM_SUCCESS_RESPONSE MsgType = 962
+ MSG_RECLAIM_ATTRIBUTE_ITERATION_START MsgType = 963
+ MSG_RECLAIM_ATTRIBUTE_ITERATION_STOP MsgType = 964
+ MSG_RECLAIM_ATTRIBUTE_ITERATION_NEXT MsgType = 965
+ MSG_RECLAIM_ATTRIBUTE_RESULT MsgType = 966
+ MSG_RECLAIM_ISSUE_TICKET MsgType = 967
+ MSG_RECLAIM_TICKET_RESULT MsgType = 968
+ MSG_RECLAIM_REVOKE_TICKET MsgType = 969
+ MSG_RECLAIM_REVOKE_TICKET_RESULT MsgType = 970
+ MSG_RECLAIM_CONSUME_TICKET MsgType = 971
+ MSG_RECLAIM_CONSUME_TICKET_RESULT MsgType = 972
+ MSG_RECLAIM_TICKET_ITERATION_START MsgType = 973
+ MSG_RECLAIM_TICKET_ITERATION_STOP MsgType = 974
+ MSG_RECLAIM_TICKET_ITERATION_NEXT MsgType = 975
+ MSG_RECLAIM_ATTRIBUTE_DELETE MsgType = 976
+
+ //------------------------------------------------------------------
+ // CREDENTIAL messages
+ //------------------------------------------------------------------
+
+ MSG_CREDENTIAL_VERIFY MsgType = 981 //
+ MSG_CREDENTIAL_VERIFY_RESULT MsgType = 982 //
+ MSG_CREDENTIAL_COLLECT MsgType = 983 //
+ MSG_CREDENTIAL_COLLECT_RESULT MsgType = 984 //
+
+ //------------------------------------------------------------------
+ // CADET messages
+ //------------------------------------------------------------------
+
+ MSG_CADET_CONNECTION_CREATE MsgType = 1000 //
Request the creation of a connection
+ MSG_CADET_CONNECTION_CREATE_ACK MsgType = 1001 // Send
origin an ACK that the connection is complete
+ MSG_CADET_CONNECTION_BROKEN MsgType = 1002 //
Notify that a connection is no longer valid
+ MSG_CADET_CONNECTION_DESTROY MsgType = 1003 //
Request the destuction of a connection
+ MSG_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED MsgType = 1004 // At
some point, the route will spontaneously change TODO
+ MSG_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK MsgType = 1005 //
Hop-by-hop, connection dependent ACK. deprecated
+
+ MSG_CADET_TUNNEL_ENCRYPTED_POLL MsgType = 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
+ MSG_CADET_TUNNEL_KX MsgType = 1007 // Axolotl key exchange.
+ MSG_CADET_TUNNEL_ENCRYPTED MsgType = 1008 // Axolotl encrypted
data.
+ MSG_CADET_TUNNEL_KX_AUTH MsgType = 1009 // Axolotl key exchange
response with authentication.
+
+ MSG_CADET_CHANNEL_APP_DATA MsgType = 1010 // Payload data
(inside an encrypted tunnel).
+ MSG_CADET_CHANNEL_APP_DATA_ACK MsgType = 1011 // Confirm
payload data end-to-end.
+ MSG_CADET_CHANNEL_KEEPALIVE MsgType = 1012 // Announce
connection is still alive (direction sensitive).
+ MSG_CADET_CHANNEL_OPEN MsgType = 1013 // Ask the cadet
service to create a new channel.
+ MSG_CADET_CHANNEL_DESTROY MsgType = 1014 // Ask the cadet
service to destroy a channel.
+ MSG_CADET_CHANNEL_OPEN_ACK MsgType = 1015 // Confirm the
creation of a channel
+ MSG_CADET_CHANNEL_OPEN_NACK_DEPRECATED MsgType = 1016 // Reject the
creation of a channel deprecated
+
+ MSG_CADET_LOCAL_DATA MsgType = 1020 // Payload client <->
service
+ MSG_CADET_LOCAL_ACK MsgType = 1021 // Local ACK for data.
+ MSG_CADET_LOCAL_PORT_OPEN MsgType = 1022 // Start listening on a
port.
+ MSG_CADET_LOCAL_PORT_CLOSE MsgType = 1023 // Stop listening on a
port.
+ MSG_CADET_LOCAL_CHANNEL_CREATE MsgType = 1024 // Ask the cadet service
to create a new channel.
+ MSG_CADET_LOCAL_CHANNEL_DESTROY MsgType = 1025 // Tell client that a
channel was destroyed.
+
+ MSG_CADET_LOCAL_REQUEST_INFO_CHANNEL MsgType = 1030 // Local
information about all channels of service.
+ MSG_CADET_LOCAL_INFO_CHANNEL MsgType = 1031 // Local
information of service about a specific channel.
+ MSG_CADET_LOCAL_INFO_CHANNEL_END MsgType = 1032 // End of local
information of service about channels.
+ MSG_CADET_LOCAL_REQUEST_INFO_PEERS MsgType = 1033 // Request local
information about all peers known to the service.
+ MSG_CADET_LOCAL_INFO_PEERS MsgType = 1034 // Local
information about all peers known to the service.
+ MSG_CADET_LOCAL_INFO_PEERS_END MsgType = 1035 // End of local
information about all peers known to the service.
+ MSG_CADET_LOCAL_REQUEST_INFO_PATH MsgType = 1036 // Request local
information of service about paths to specific peer.
+ MSG_CADET_LOCAL_INFO_PATH MsgType = 1037 // Local
information of service about a specific path.
+ MSG_CADET_LOCAL_INFO_PATH_END MsgType = 1038 // End of local
information of service about a specific path.
+ MSG_CADET_LOCAL_REQUEST_INFO_TUNNELS MsgType = 1039 // Request local
information about all tunnels of service.
+ MSG_CADET_LOCAL_INFO_TUNNELS MsgType = 1040 // Local
information about all tunnels of service.
+ MSG_CADET_LOCAL_INFO_TUNNELS_END MsgType = 1041 // End of local
information about all tunnels of service.
+
+ MSG_CADET_CLI MsgType = 1059 // Traffic (net-cat style) used by the
Command Line Interface.
+
+ //------------------------------------------------------------------
+ // NAT messages
+ //------------------------------------------------------------------
+
+ MSG_NAT_REGISTER MsgType = 1060 // Message to ask
NAT service to register a client.
+ MSG_NAT_HANDLE_STUN MsgType = 1061 // Message to ask
NAT service to handle a STUN packet.
+ MSG_NAT_REQUEST_CONNECTION_REVERSAL MsgType = 1062 // Message to ask
NAT service to request connection reversal.
+ MSG_NAT_CONNECTION_REVERSAL_REQUESTED MsgType = 1063 // Message to from
NAT service notifying us that connection reversal was requested by another peer.
+ MSG_NAT_ADDRESS_CHANGE MsgType = 1064 // Message to from
NAT service notifying us that one of our addresses changed.
+ MSG_NAT_AUTO_REQUEST_CFG MsgType = 1066 // Message to ask
NAT service to request autoconfiguration.
+ MSG_NAT_AUTO_CFG_RESULT MsgType = 1065 // Message from
NAT service with the autoconfiguration result.
+
+ //------------------------------------------------------------------
+ // AUCTION messages
+ //------------------------------------------------------------------
+
+ MSG_AUCTION_CLIENT_CREATE MsgType = 1110 // Client wants to create a
new auction.
+ MSG_AUCTION_CLIENT_JOIN MsgType = 1111 // Client wants to join an
existing auction.
+ MSG_AUCTION_CLIENT_OUTCOME MsgType = 1112 // Service reports the
auction outcome to the client.
+
+ //------------------------------------------------------------------
+ // RPS_DEBUG messages
+ //------------------------------------------------------------------
+
+ MSG_RPS_CS_DEBUG_VIEW_REQUEST MsgType = 1130 // Request updates of
the view
+ MSG_RPS_CS_DEBUG_VIEW_REPLY MsgType = 1131 // Send update of the
view
+ MSG_RPS_CS_DEBUG_VIEW_CANCEL MsgType = 1132 // Cancel getting
updates of the view
+ MSG_RPS_CS_DEBUG_STREAM_REQUEST MsgType = 1133 // Request biased input
stream
+ MSG_RPS_CS_DEBUG_STREAM_REPLY MsgType = 1134 // Send peer of biased
stream
+ MSG_RPS_CS_DEBUG_STREAM_CANCEL MsgType = 1135 // Cancel getting biased
stream
+
+ //------------------------------------------------------------------
+ // CATCH-ALL_DEBUG message
+ //------------------------------------------------------------------
+
+ MSG_ALL MsgType = 65535 // Type used to match 'all' message types.
+)
diff --git a/src/gnunet/enums/msgtype_string.go
b/src/gnunet/enums/msgtype_string.go
new file mode 100644
index 0000000..bab1e22
--- /dev/null
+++ b/src/gnunet/enums/msgtype_string.go
@@ -0,0 +1,1113 @@
+// Code generated by "stringer -type=MsgType"; DO NOT EDIT.
+
+package enums
+
+import "strconv"
+
+func _() {
+ // An "invalid array index" compiler error signifies that the constant
values have changed.
+ // Re-run the stringer command to generate them again.
+ var x [1]struct{}
+ _ = x[MSG_TEST-1]
+ _ = x[MSG_DUMMY-2]
+ _ = x[MSG_DUMMY2-3]
+ _ = x[MSG_RESOLVER_REQUEST-4]
+ _ = x[MSG_RESOLVER_RESPONSE-5]
+ _ = x[MSG_REQUEST_AGPL-6]
+ _ = x[MSG_RESPONSE_AGPL-7]
+ _ = x[MSG_ARM_START-8]
+ _ = x[MSG_ARM_STOP-9]
+ _ = x[MSG_ARM_RESULT-10]
+ _ = x[MSG_ARM_STATUS-11]
+ _ = x[MSG_ARM_LIST-12]
+ _ = x[MSG_ARM_LIST_RESULT-13]
+ _ = x[MSG_ARM_MONITOR-14]
+ _ = x[MSG_ARM_TEST-15]
+ _ = x[MSG_HELLO_LEGACY-16]
+ _ = x[MSG_HELLO-17]
+ _ = x[MSG_FRAGMENT-18]
+ _ = x[MSG_FRAGMENT_ACK-19]
+ _ = x[MSG_WLAN_DATA_TO_HELPER-39]
+ _ = x[MSG_WLAN_DATA_FROM_HELPER-40]
+ _ = x[MSG_WLAN_HELPER_CONTROL-41]
+ _ = x[MSG_WLAN_ADVERTISEMENT-42]
+ _ = x[MSG_WLAN_DATA-43]
+ _ = x[MSG_DV_RECV-44]
+ _ = x[MSG_DV_SEND-45]
+ _ = x[MSG_DV_SEND_ACK-46]
+ _ = x[MSG_DV_ROUTE-47]
+ _ = x[MSG_DV_START-48]
+ _ = x[MSG_DV_CONNECT-49]
+ _ = x[MSG_DV_DISCONNECT-50]
+ _ = x[MSG_DV_SEND_NACK-51]
+ _ = x[MSG_DV_DISTANCE_CHANGED-52]
+ _ = x[MSG_DV_BOX-53]
+ _ = x[MSG_TRANSPORT_XU_MESSAGE-55]
+ _ = x[MSG_TRANSPORT_UDP_MESSAGE-56]
+ _ = x[MSG_TRANSPORT_UDP_ACK-57]
+ _ = x[MSG_TRANSPORT_TCP_NAT_PROBE-60]
+ _ = x[MSG_TRANSPORT_TCP_WELCOME-61]
+ _ = x[MSG_TRANSPORT_ATS-62]
+ _ = x[MSG_NAT_TEST-63]
+ _ = x[MSG_CORE_INIT-64]
+ _ = x[MSG_CORE_INIT_REPLY-65]
+ _ = x[MSG_CORE_NOTIFY_CONNECT-67]
+ _ = x[MSG_CORE_NOTIFY_DISCONNECT-68]
+ _ = x[MSG_CORE_NOTIFY_STATUS_CHANGE-69]
+ _ = x[MSG_CORE_NOTIFY_INBOUND-70]
+ _ = x[MSG_CORE_NOTIFY_OUTBOUND-71]
+ _ = x[MSG_CORE_SEND_REQUEST-74]
+ _ = x[MSG_CORE_SEND_READY-75]
+ _ = x[MSG_CORE_SEND-76]
+ _ = x[MSG_CORE_MONITOR_PEERS-78]
+ _ = x[MSG_CORE_MONITOR_NOTIFY-79]
+ _ = x[MSG_CORE_ENCRYPTED_MESSAGE-82]
+ _ = x[MSG_CORE_PING-83]
+ _ = x[MSG_CORE_PONG-84]
+ _ = x[MSG_CORE_HANGUP-85]
+ _ = x[MSG_CORE_COMPRESSED_TYPE_MAP-86]
+ _ = x[MSG_CORE_BINARY_TYPE_MAP-87]
+ _ = x[MSG_CORE_EPHEMERAL_KEY-88]
+ _ = x[MSG_CORE_CONFIRM_TYPE_MAP-89]
+ _ = x[MSG_DATASTORE_RESERVE-92]
+ _ = x[MSG_DATASTORE_RELEASE_RESERVE-93]
+ _ = x[MSG_DATASTORE_STATUS-94]
+ _ = x[MSG_DATASTORE_PUT-95]
+ _ = x[MSG_DATASTORE_GET-97]
+ _ = x[MSG_DATASTORE_GET_REPLICATION-98]
+ _ = x[MSG_DATASTORE_GET_ZERO_ANONYMITY-99]
+ _ = x[MSG_DATASTORE_DATA-100]
+ _ = x[MSG_DATASTORE_DATA_END-101]
+ _ = x[MSG_DATASTORE_REMOVE-102]
+ _ = x[MSG_DATASTORE_DROP-103]
+ _ = x[MSG_DATASTORE_GET_KEY-104]
+ _ = x[MSG_FS_REQUEST_LOC_SIGN-126]
+ _ = x[MSG_FS_REQUEST_LOC_SIGNATURE-127]
+ _ = x[MSG_FS_INDEX_START-128]
+ _ = x[MSG_FS_INDEX_START_OK-129]
+ _ = x[MSG_FS_INDEX_START_FAILED-130]
+ _ = x[MSG_FS_INDEX_LIST_GET-131]
+ _ = x[MSG_FS_INDEX_LIST_ENTRY-132]
+ _ = x[MSG_FS_INDEX_LIST_END-133]
+ _ = x[MSG_FS_UNINDEX-134]
+ _ = x[MSG_FS_UNINDEX_OK-135]
+ _ = x[MSG_FS_START_SEARCH-136]
+ _ = x[MSG_FS_GET-137]
+ _ = x[MSG_FS_PUT-138]
+ _ = x[MSG_FS_MIGRATION_STOP-139]
+ _ = x[MSG_FS_CADET_QUERY-140]
+ _ = x[MSG_FS_CADET_REPLY-141]
+ _ = x[MSG_DHT_CLIENT_PUT-142]
+ _ = x[MSG_DHT_CLIENT_GET-143]
+ _ = x[MSG_DHT_CLIENT_GET_STOP-144]
+ _ = x[MSG_DHT_CLIENT_RESULT-145]
+ _ = x[MSG_DHT_P2P_PUT-146]
+ _ = x[MSG_DHT_P2P_GET-147]
+ _ = x[MSG_DHT_P2P_RESULT-148]
+ _ = x[MSG_DHT_MONITOR_GET-149]
+ _ = x[MSG_DHT_MONITOR_GET_RESP-150]
+ _ = x[MSG_DHT_MONITOR_PUT-151]
+ _ = x[MSG_DHT_MONITOR_PUT_RESP-152]
+ _ = x[MSG_DHT_MONITOR_START-153]
+ _ = x[MSG_DHT_MONITOR_STOP-154]
+ _ = x[MSG_DHT_CLIENT_GET_RESULTS_KNOWN-156]
+ _ = x[MSG_DHT_P2P_HELLO-157]
+ _ = x[MSG_DHT_CORE-158]
+ _ = x[MSG_DHT_CLIENT_HELLO_URL-159]
+ _ = x[MSG_DHT_CLIENT_HELLO_GET-161]
+ _ = x[MSG_HOSTLIST_ADVERTISEMENT-160]
+ _ = x[MSG_STATISTICS_SET-168]
+ _ = x[MSG_STATISTICS_GET-169]
+ _ = x[MSG_STATISTICS_VALUE-170]
+ _ = x[MSG_STATISTICS_END-171]
+ _ = x[MSG_STATISTICS_WATCH-172]
+ _ = x[MSG_STATISTICS_WATCH_VALUE-173]
+ _ = x[MSG_STATISTICS_DISCONNECT-174]
+ _ = x[MSG_STATISTICS_DISCONNECT_CONFIRM-175]
+ _ = x[MSG_VPN_HELPER-185]
+ _ = x[MSG_VPN_ICMP_TO_SERVICE-190]
+ _ = x[MSG_VPN_ICMP_TO_INTERNET-191]
+ _ = x[MSG_VPN_ICMP_TO_VPN-192]
+ _ = x[MSG_VPN_DNS_TO_INTERNET-193]
+ _ = x[MSG_VPN_DNS_FROM_INTERNET-194]
+ _ = x[MSG_VPN_TCP_TO_SERVICE_START-195]
+ _ = x[MSG_VPN_TCP_TO_INTERNET_START-196]
+ _ = x[MSG_VPN_TCP_DATA_TO_EXIT-197]
+ _ = x[MSG_VPN_TCP_DATA_TO_VPN-198]
+ _ = x[MSG_VPN_UDP_TO_SERVICE-199]
+ _ = x[MSG_VPN_UDP_TO_INTERNET-200]
+ _ = x[MSG_VPN_UDP_REPLY-201]
+ _ = x[MSG_VPN_CLIENT_REDIRECT_TO_IP-202]
+ _ = x[MSG_VPN_CLIENT_REDIRECT_TO_SERVICE-203]
+ _ = x[MSG_VPN_CLIENT_USE_IP-204]
+ _ = x[MSG_DNS_CLIENT_INIT-211]
+ _ = x[MSG_DNS_CLIENT_REQUEST-212]
+ _ = x[MSG_DNS_CLIENT_RESPONSE-213]
+ _ = x[MSG_DNS_HELPER-214]
+ _ = x[MSG_CHAT_JOIN_REQUEST-300]
+ _ = x[MSG_CHAT_JOIN_NOTIFICATION-301]
+ _ = x[MSG_CHAT_LEAVE_NOTIFICATION-302]
+ _ = x[MSG_CHAT_MESSAGE_NOTIFICATION-303]
+ _ = x[MSG_CHAT_TRANSMIT_REQUEST-304]
+ _ = x[MSG_CHAT_CONFIRMATION_RECEIPT-305]
+ _ = x[MSG_CHAT_CONFIRMATION_NOTIFICATION-306]
+ _ = x[MSG_CHAT_P2P_JOIN_NOTIFICATION-307]
+ _ = x[MSG_CHAT_P2P_LEAVE_NOTIFICATION-308]
+ _ = x[MSG_CHAT_P2P_SYNC_REQUEST-309]
+ _ = x[MSG_CHAT_P2P_MESSAGE_NOTIFICATION-310]
+ _ = x[MSG_CHAT_P2P_CONFIRMATION_RECEIPT-311]
+ _ = x[MSG_NSE_START-321]
+ _ = x[MSG_NSE_P2P_FLOOD-322]
+ _ = x[MSG_NSE_ESTIMATE-323]
+ _ = x[MSG_PEERINFO_GET-330]
+ _ = x[MSG_PEERINFO_GET_ALL-331]
+ _ = x[MSG_PEERINFO_INFO-332]
+ _ = x[MSG_PEERINFO_INFO_END-333]
+ _ = x[MSG_PEERINFO_NOTIFY-334]
+ _ = x[MSG_ATS_START-340]
+ _ = x[MSG_ATS_REQUEST_ADDRESS-341]
+ _ = x[MSG_ATS_REQUEST_ADDRESS_CANCEL-342]
+ _ = x[MSG_ATS_ADDRESS_UPDATE-343]
+ _ = x[MSG_ATS_ADDRESS_DESTROYED-344]
+ _ = x[MSG_ATS_ADDRESS_SUGGESTION-345]
+ _ = x[MSG_ATS_PEER_INFORMATION-346]
+ _ = x[MSG_ATS_RESERVATION_REQUEST-347]
+ _ = x[MSG_ATS_RESERVATION_RESULT-348]
+ _ = x[MSG_ATS_PREFERENCE_CHANGE-349]
+ _ = x[MSG_ATS_SESSION_RELEASE-350]
+ _ = x[MSG_ATS_ADDRESS_ADD-353]
+ _ = x[MSG_ATS_ADDRESSLIST_REQUEST-354]
+ _ = x[MSG_ATS_ADDRESSLIST_RESPONSE-355]
+ _ = x[MSG_ATS_PREFERENCE_FEEDBACK-356]
+ _ = x[MSG_TRANSPORT_START-360]
+ _ = x[MSG_TRANSPORT_CONNECT-361]
+ _ = x[MSG_TRANSPORT_DISCONNECT-362]
+ _ = x[MSG_TRANSPORT_SEND-363]
+ _ = x[MSG_TRANSPORT_SEND_OK-364]
+ _ = x[MSG_TRANSPORT_RECV-365]
+ _ = x[MSG_TRANSPORT_SET_QUOTA-366]
+ _ = x[MSG_TRANSPORT_ADDRESS_TO_STRING-367]
+ _ = x[MSG_TRANSPORT_ADDRESS_TO_STRING_REPLY-368]
+ _ = x[MSG_TRANSPORT_BLACKLIST_INIT-369]
+ _ = x[MSG_TRANSPORT_BLACKLIST_QUERY-370]
+ _ = x[MSG_TRANSPORT_BLACKLIST_REPLY-371]
+ _ = x[MSG_TRANSPORT_PING-372]
+ _ = x[MSG_TRANSPORT_PONG-373]
+ _ = x[MSG_TRANSPORT_SESSION_SYN-375]
+ _ = x[MSG_TRANSPORT_SESSION_SYN_ACK-376]
+ _ = x[MSG_TRANSPORT_SESSION_ACK-377]
+ _ = x[MSG_TRANSPORT_SESSION_DISCONNECT-378]
+ _ = x[MSG_TRANSPORT_SESSION_QUOTA-379]
+ _ = x[MSG_TRANSPORT_MONITOR_PEER_REQUEST-380]
+ _ = x[MSG_TRANSPORT_SESSION_KEEPALIVE-381]
+ _ = x[MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE-382]
+ _ = x[MSG_TRANSPORT_MONITOR_PEER_RESPONSE-383]
+ _ = x[MSG_TRANSPORT_BROADCAST_BEACON-384]
+ _ = x[MSG_TRANSPORT_TRAFFIC_METRIC-385]
+ _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_START-388]
+ _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_EVENT-389]
+ _ = x[MSG_TRANSPORT_MONITOR_PLUGIN_SYNC-390]
+ _ = x[MSG_TRANSPORT_MONITOR_PEER_RESPONSE_END-391]
+ _ = x[MSG_FS_PUBLISH_HELPER_PROGRESS_FILE-420]
+ _ = x[MSG_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY-421]
+ _ = x[MSG_FS_PUBLISH_HELPER_ERROR-422]
+ _ = x[MSG_FS_PUBLISH_HELPER_SKIP_FILE-423]
+ _ = x[MSG_FS_PUBLISH_HELPER_COUNTING_DONE-424]
+ _ = x[MSG_FS_PUBLISH_HELPER_META_DATA-425]
+ _ = x[MSG_FS_PUBLISH_HELPER_FINISHED-426]
+ _ = x[MSG_NAMECACHE_LOOKUP_BLOCK-431]
+ _ = x[MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE-432]
+ _ = x[MSG_NAMECACHE_BLOCK_CACHE-433]
+ _ = x[MSG_NAMECACHE_BLOCK_CACHE_RESPONSE-434]
+ _ = x[MSG_NAMESTORE_RECORD_STORE-435]
+ _ = x[MSG_NAMESTORE_RECORD_STORE_RESPONSE-436]
+ _ = x[MSG_NAMESTORE_RECORD_LOOKUP-437]
+ _ = x[MSG_NAMESTORE_RECORD_LOOKUP_RESPONSE-438]
+ _ = x[MSG_NAMESTORE_ZONE_TO_NAME-439]
+ _ = x[MSG_NAMESTORE_ZONE_TO_NAME_RESPONSE-440]
+ _ = x[MSG_NAMESTORE_MONITOR_START-441]
+ _ = x[MSG_NAMESTORE_MONITOR_SYNC-442]
+ _ = x[MSG_NAMESTORE_RECORD_RESULT-443]
+ _ = x[MSG_NAMESTORE_MONITOR_NEXT-444]
+ _ = x[MSG_NAMESTORE_ZONE_ITERATION_START-445]
+ _ = x[MSG_NAMESTORE_ZONE_ITERATION_NEXT-447]
+ _ = x[MSG_NAMESTORE_ZONE_ITERATION_STOP-448]
+ _ = x[MSG_TESTBED_INIT-460]
+ _ = x[MSG_TESTBED_ADD_HOST-461]
+ _ = x[MSG_TESTBED_ADD_HOST_SUCCESS-462]
+ _ = x[MSG_TESTBED_LINK_CONTROLLERS-463]
+ _ = x[MSG_TESTBED_CREATE_PEER-464]
+ _ = x[MSG_TESTBED_RECONFIGURE_PEER-465]
+ _ = x[MSG_TESTBED_START_PEER-466]
+ _ = x[MSG_TESTBED_STOP_PEER-467]
+ _ = x[MSG_TESTBED_DESTROY_PEER-468]
+ _ = x[MSG_TESTBED_CONFIGURE_UNDERLAY_LINK-469]
+ _ = x[MSG_TESTBED_OVERLAY_CONNECT-470]
+ _ = x[MSG_TESTBED_PEER_EVENT-471]
+ _ = x[MSG_TESTBED_PEER_CONNECT_EVENT-472]
+ _ = x[MSG_TESTBED_OPERATION_FAIL_EVENT-473]
+ _ = x[MSG_TESTBED_CREATE_PEER_SUCCESS-474]
+ _ = x[MSG_TESTBED_GENERIC_OPERATION_SUCCESS-475]
+ _ = x[MSG_TESTBED_GET_PEER_INFORMATION-476]
+ _ = x[MSG_TESTBED_PEER_INFORMATION-477]
+ _ = x[MSG_TESTBED_REMOTE_OVERLAY_CONNECT-478]
+ _ = x[MSG_TESTBED_GET_SLAVE_CONFIGURATION-479]
+ _ = x[MSG_TESTBED_SLAVE_CONFIGURATION-480]
+ _ = x[MSG_TESTBED_LINK_CONTROLLERS_RESULT-481]
+ _ = x[MSG_TESTBED_SHUTDOWN_PEERS-482]
+ _ = x[MSG_TESTBED_MANAGE_PEER_SERVICE-483]
+ _ = x[MSG_TESTBED_BARRIER_INIT-484]
+ _ = x[MSG_TESTBED_BARRIER_CANCEL-485]
+ _ = x[MSG_TESTBED_BARRIER_STATUS-486]
+ _ = x[MSG_TESTBED_BARRIER_WAIT-487]
+ _ = x[MSG_TESTBED_MAX-488]
+ _ = x[MSG_TESTBED_HELPER_INIT-495]
+ _ = x[MSG_TESTBED_HELPER_REPLY-496]
+ _ = x[MSG_GNS_LOOKUP-500]
+ _ = x[MSG_GNS_LOOKUP_RESULT-501]
+ _ = x[MSG_GNS_REVERSE_LOOKUP-502]
+ _ = x[MSG_GNS_REVERSE_LOOKUP_RESULT-503]
+ _ = x[MSG_CONSENSUS_CLIENT_JOIN-520]
+ _ = x[MSG_CONSENSUS_CLIENT_INSERT-521]
+ _ = x[MSG_CONSENSUS_CLIENT_BEGIN-522]
+ _ = x[MSG_CONSENSUS_CLIENT_RECEIVED_ELEMENT-523]
+ _ = x[MSG_CONSENSUS_CLIENT_CONCLUDE-524]
+ _ = x[MSG_CONSENSUS_CLIENT_CONCLUDE_DONE-525]
+ _ = x[MSG_CONSENSUS_CLIENT_ACK-540]
+ _ = x[MSG_CONSENSUS_P2P_DELTA_ESTIMATE-541]
+ _ = x[MSG_CONSENSUS_P2P_DIFFERENCE_DIGEST-542]
+ _ = x[MSG_CONSENSUS_P2P_ELEMENTS-543]
+ _ = x[MSG_CONSENSUS_P2P_ELEMENTS_REQUEST-544]
+ _ = x[MSG_CONSENSUS_P2P_ELEMENTS_REPORT-545]
+ _ = x[MSG_CONSENSUS_P2P_HELLO-546]
+ _ = x[MSG_CONSENSUS_P2P_SYNCED-547]
+ _ = x[MSG_CONSENSUS_P2P_FIN-548]
+ _ = x[MSG_CONSENSUS_P2P_ABORT-548]
+ _ = x[MSG_CONSENSUS_P2P_ROUND_CONTEXT-547]
+ _ = x[MSG_SET_UNION_P2P_REQUEST_FULL-565]
+ _ = x[MSG_SET_UNION_P2P_DEMAND-566]
+ _ = x[MSG_SET_UNION_P2P_INQUIRY-567]
+ _ = x[MSG_SET_UNION_P2P_OFFER-568]
+ _ = x[MSG_SET_REJECT-569]
+ _ = x[MSG_SET_CANCEL-570]
+ _ = x[MSG_SET_ITER_ACK-571]
+ _ = x[MSG_SET_RESULT-572]
+ _ = x[MSG_SET_ADD-573]
+ _ = x[MSG_SET_REMOVE-574]
+ _ = x[MSG_SET_LISTEN-575]
+ _ = x[MSG_SET_ACCEPT-576]
+ _ = x[MSG_SET_EVALUATE-577]
+ _ = x[MSG_SET_CONCLUDE-578]
+ _ = x[MSG_SET_REQUEST-579]
+ _ = x[MSG_SET_CREATE-580]
+ _ = x[MSG_SET_P2P_OPERATION_REQUEST-581]
+ _ = x[MSG_SET_UNION_P2P_SE-582]
+ _ = x[MSG_SET_UNION_P2P_IBF-583]
+ _ = x[MSG_SET_P2P_ELEMENTS-584]
+ _ = x[MSG_SET_P2P_ELEMENT_REQUESTS-585]
+ _ = x[MSG_SET_UNION_P2P_DONE-586]
+ _ = x[MSG_SET_ITER_REQUEST-587]
+ _ = x[MSG_SET_ITER_ELEMENT-588]
+ _ = x[MSG_SET_ITER_DONE-589]
+ _ = x[MSG_SET_UNION_P2P_SEC-590]
+ _ = x[MSG_SET_INTERSECTION_P2P_ELEMENT_INFO-591]
+ _ = x[MSG_SET_INTERSECTION_P2P_BF-592]
+ _ = x[MSG_SET_INTERSECTION_P2P_DONE-593]
+ _ = x[MSG_SET_COPY_LAZY_PREPARE-594]
+ _ = x[MSG_SET_COPY_LAZY_RESPONSE-595]
+ _ = x[MSG_SET_COPY_LAZY_CONNECT-596]
+ _ = x[MSG_SET_UNION_P2P_FULL_DONE-597]
+ _ = x[MSG_SET_UNION_P2P_FULL_ELEMENT-598]
+ _ = x[MSG_SET_UNION_P2P_OVER-599]
+ _ = x[MSG_TESTBED_LOGGER_MSG-600]
+ _ = x[MSG_TESTBED_LOGGER_ACK-601]
+ _ = x[MSG_REGEX_ANNOUNCE-620]
+ _ = x[MSG_REGEX_SEARCH-621]
+ _ = x[MSG_REGEX_RESULT-622]
+ _ = x[MSG_IDENTITY_START-624]
+ _ = x[MSG_IDENTITY_RESULT_CODE-625]
+ _ = x[MSG_IDENTITY_UPDATE-626]
+ _ = x[MSG_IDENTITY_GET_DEFAULT-627]
+ _ = x[MSG_IDENTITY_SET_DEFAULT-628]
+ _ = x[MSG_IDENTITY_CREATE-629]
+ _ = x[MSG_IDENTITY_RENAME-630]
+ _ = x[MSG_IDENTITY_DELETE-631]
+ _ = x[MSG_IDENTITY_LOOKUP-632]
+ _ = x[MSG_IDENTITY_LOOKUP_BY_NAME-633]
+ _ = x[MSG_REVOCATION_QUERY-636]
+ _ = x[MSG_REVOCATION_QUERY_RESPONSE-637]
+ _ = x[MSG_REVOCATION_REVOKE-638]
+ _ = x[MSG_REVOCATION_REVOKE_RESPONSE-639]
+ _ = x[MSG_SCALARPRODUCT_CLIENT_TO_ALICE-640]
+ _ = x[MSG_SCALARPRODUCT_CLIENT_TO_BOB-641]
+ _ = x[MSG_SCALARPRODUCT_CLIENT_MULTIPART_ALICE-642]
+ _ = x[MSG_SCALARPRODUCT_CLIENT_MULTIPART_BOB-643]
+ _ = x[MSG_SCALARPRODUCT_SESSION_INITIALIZATION-644]
+ _ = x[MSG_SCALARPRODUCT_ALICE_CRYPTODATA-645]
+ _ = x[MSG_SCALARPRODUCT_BOB_CRYPTODATA-647]
+ _ = x[MSG_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART-648]
+ _ = x[MSG_SCALARPRODUCT_RESULT-649]
+ _ = x[MSG_SCALARPRODUCT_ECC_SESSION_INITIALIZATION-650]
+ _ = x[MSG_SCALARPRODUCT_ECC_ALICE_CRYPTODATA-651]
+ _ = x[MSG_SCALARPRODUCT_ECC_BOB_CRYPTODATA-652]
+ _ = x[MSG_PSYCSTORE_MEMBERSHIP_STORE-660]
+ _ = x[MSG_PSYCSTORE_MEMBERSHIP_TEST-661]
+ _ = x[MSG_PSYCSTORE_FRAGMENT_STORE-662]
+ _ = x[MSG_PSYCSTORE_FRAGMENT_GET-663]
+ _ = x[MSG_PSYCSTORE_MESSAGE_GET-664]
+ _ = x[MSG_PSYCSTORE_MESSAGE_GET_FRAGMENT-665]
+ _ = x[MSG_PSYCSTORE_COUNTERS_GET-666]
+ _ = x[MSG_PSYCSTORE_STATE_MODIFY-668]
+ _ = x[MSG_PSYCSTORE_STATE_SYNC-669]
+ _ = x[MSG_PSYCSTORE_STATE_RESET-670]
+ _ = x[MSG_PSYCSTORE_STATE_HASH_UPDATE-671]
+ _ = x[MSG_PSYCSTORE_STATE_GET-672]
+ _ = x[MSG_PSYCSTORE_STATE_GET_PREFIX-673]
+ _ = x[MSG_PSYCSTORE_RESULT_CODE-674]
+ _ = x[MSG_PSYCSTORE_RESULT_FRAGMENT-675]
+ _ = x[MSG_PSYCSTORE_RESULT_COUNTERS-676]
+ _ = x[MSG_PSYCSTORE_RESULT_STATE-677]
+ _ = x[MSG_PSYC_RESULT_CODE-680]
+ _ = x[MSG_PSYC_MASTER_START-681]
+ _ = x[MSG_PSYC_MASTER_START_ACK-682]
+ _ = x[MSG_PSYC_SLAVE_JOIN-683]
+ _ = x[MSG_PSYC_SLAVE_JOIN_ACK-684]
+ _ = x[MSG_PSYC_PART_REQUEST-685]
+ _ = x[MSG_PSYC_PART_ACK-686]
+ _ = x[MSG_PSYC_JOIN_REQUEST-687]
+ _ = x[MSG_PSYC_JOIN_DECISION-688]
+ _ = x[MSG_PSYC_CHANNEL_MEMBERSHIP_STORE-689]
+ _ = x[MSG_PSYC_MESSAGE-691]
+ _ = x[MSG_PSYC_MESSAGE_HEADER-692]
+ _ = x[MSG_PSYC_MESSAGE_METHOD-693]
+ _ = x[MSG_PSYC_MESSAGE_MODIFIER-694]
+ _ = x[MSG_PSYC_MESSAGE_MOD_CONT-695]
+ _ = x[MSG_PSYC_MESSAGE_DATA-696]
+ _ = x[MSG_PSYC_MESSAGE_END-697]
+ _ = x[MSG_PSYC_MESSAGE_CANCEL-698]
+ _ = x[MSG_PSYC_MESSAGE_ACK-699]
+ _ = x[MSG_PSYC_HISTORY_REPLAY-701]
+ _ = x[MSG_PSYC_HISTORY_RESULT-702]
+ _ = x[MSG_PSYC_STATE_GET-703]
+ _ = x[MSG_PSYC_STATE_GET_PREFIX-704]
+ _ = x[MSG_PSYC_STATE_RESULT-705]
+ _ = x[MSG_CONVERSATION_AUDIO-730]
+ _ = x[MSG_CONVERSATION_CS_PHONE_REGISTER-731]
+ _ = x[MSG_CONVERSATION_CS_PHONE_PICK_UP-732]
+ _ = x[MSG_CONVERSATION_CS_PHONE_HANG_UP-733]
+ _ = x[MSG_CONVERSATION_CS_PHONE_CALL-734]
+ _ = x[MSG_CONVERSATION_CS_PHONE_RING-735]
+ _ = x[MSG_CONVERSATION_CS_PHONE_SUSPEND-736]
+ _ = x[MSG_CONVERSATION_CS_PHONE_RESUME-737]
+ _ = x[MSG_CONVERSATION_CS_PHONE_PICKED_UP-738]
+ _ = x[MSG_CONVERSATION_CS_AUDIO-739]
+ _ = x[MSG_CONVERSATION_CADET_PHONE_RING-740]
+ _ = x[MSG_CONVERSATION_CADET_PHONE_HANG_UP-741]
+ _ = x[MSG_CONVERSATION_CADET_PHONE_PICK_UP-742]
+ _ = x[MSG_CONVERSATION_CADET_PHONE_SUSPEND-743]
+ _ = x[MSG_CONVERSATION_CADET_PHONE_RESUME-744]
+ _ = x[MSG_CONVERSATION_CADET_AUDIO-745]
+ _ = x[MSG_MULTICAST_ORIGIN_START-750]
+ _ = x[MSG_MULTICAST_MEMBER_JOIN-751]
+ _ = x[MSG_MULTICAST_JOIN_REQUEST-752]
+ _ = x[MSG_MULTICAST_JOIN_DECISION-753]
+ _ = x[MSG_MULTICAST_PART_REQUEST-754]
+ _ = x[MSG_MULTICAST_PART_ACK-755]
+ _ = x[MSG_MULTICAST_GROUP_END-756]
+ _ = x[MSG_MULTICAST_MESSAGE-757]
+ _ = x[MSG_MULTICAST_REQUEST-758]
+ _ = x[MSG_MULTICAST_FRAGMENT_ACK-759]
+ _ = x[MSG_MULTICAST_REPLAY_REQUEST-760]
+ _ = x[MSG_MULTICAST_REPLAY_RESPONSE-761]
+ _ = x[MSG_MULTICAST_REPLAY_RESPONSE_END-762]
+ _ = x[MSG_SECRETSHARING_CLIENT_GENERATE-780]
+ _ = x[MSG_SECRETSHARING_CLIENT_DECRYPT-781]
+ _ = x[MSG_SECRETSHARING_CLIENT_DECRYPT_DONE-782]
+ _ = x[MSG_SECRETSHARING_CLIENT_SECRET_READY-783]
+ _ = x[MSG_PEERSTORE_STORE-820]
+ _ = x[MSG_PEERSTORE_ITERATE-821]
+ _ = x[MSG_PEERSTORE_ITERATE_RECORD-822]
+ _ = x[MSG_PEERSTORE_ITERATE_END-823]
+ _ = x[MSG_PEERSTORE_WATCH-824]
+ _ = x[MSG_PEERSTORE_WATCH_RECORD-825]
+ _ = x[MSG_PEERSTORE_WATCH_CANCEL-826]
+ _ = x[MSG_SOCIAL_RESULT_CODE-840]
+ _ = x[MSG_SOCIAL_HOST_ENTER-841]
+ _ = x[MSG_SOCIAL_HOST_ENTER_ACK-842]
+ _ = x[MSG_SOCIAL_GUEST_ENTER-843]
+ _ = x[MSG_SOCIAL_GUEST_ENTER_BY_NAME-844]
+ _ = x[MSG_SOCIAL_GUEST_ENTER_ACK-845]
+ _ = x[MSG_SOCIAL_ENTRY_REQUEST-846]
+ _ = x[MSG_SOCIAL_ENTRY_DECISION-847]
+ _ = x[MSG_SOCIAL_PLACE_LEAVE-848]
+ _ = x[MSG_SOCIAL_PLACE_LEAVE_ACK-849]
+ _ = x[MSG_SOCIAL_ZONE_ADD_PLACE-850]
+ _ = x[MSG_SOCIAL_ZONE_ADD_NYM-851]
+ _ = x[MSG_SOCIAL_APP_CONNECT-852]
+ _ = x[MSG_SOCIAL_APP_DETACH-853]
+ _ = x[MSG_SOCIAL_APP_EGO-854]
+ _ = x[MSG_SOCIAL_APP_EGO_END-855]
+ _ = x[MSG_SOCIAL_APP_PLACE-856]
+ _ = x[MSG_SOCIAL_APP_PLACE_END-857]
+ _ = x[MSG_SOCIAL_MSG_PROC_SET-858]
+ _ = x[MSG_SOCIAL_MSG_PROC_CLEAR-859]
+ _ = x[MSG_XDHT_P2P_TRAIL_SETUP-880]
+ _ = x[MSG_XDHT_P2P_TRAIL_SETUP_RESULT-881]
+ _ = x[MSG_XDHT_P2P_VERIFY_SUCCESSOR-882]
+ _ = x[MSG_XDHT_P2P_NOTIFY_NEW_SUCCESSOR-883]
+ _ = x[MSG_XDHT_P2P_VERIFY_SUCCESSOR_RESULT-884]
+ _ = x[MSG_XDHT_P2P_GET_RESULT-885]
+ _ = x[MSG_XDHT_P2P_TRAIL_SETUP_REJECTION-886]
+ _ = x[MSG_XDHT_P2P_TRAIL_TEARDOWN-887]
+ _ = x[MSG_XDHT_P2P_ADD_TRAIL-888]
+ _ = x[MSG_XDHT_P2P_PUT-890]
+ _ = x[MSG_XDHT_P2P_GET-891]
+ _ = x[MSG_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION-892]
+ _ = x[MSG_DHT_ACT_MALICIOUS-893]
+ _ = x[MSG_DHT_CLIENT_ACT_MALICIOUS_OK-894]
+ _ = x[MSG_WDHT_RANDOM_WALK-910]
+ _ = x[MSG_WDHT_RANDOM_WALK_RESPONSE-911]
+ _ = x[MSG_WDHT_TRAIL_DESTROY-912]
+ _ = x[MSG_WDHT_TRAIL_ROUTE-913]
+ _ = x[MSG_WDHT_SUCCESSOR_FIND-914]
+ _ = x[MSG_WDHT_GET-915]
+ _ = x[MSG_WDHT_PUT-916]
+ _ = x[MSG_WDHT_GET_RESULT-917]
+ _ = x[MSG_RPS_PP_CHECK_LIVE-950]
+ _ = x[MSG_RPS_PP_PUSH-951]
+ _ = x[MSG_RPS_PP_PULL_REQUEST-952]
+ _ = x[MSG_RPS_PP_PULL_REPLY-953]
+ _ = x[MSG_RPS_CS_SEED-954]
+ _ = x[MSG_RPS_ACT_MALICIOUS-955]
+ _ = x[MSG_RPS_CS_SUB_START-956]
+ _ = x[MSG_RPS_CS_SUB_STOP-957]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_STORE-961]
+ _ = x[MSG_RECLAIM_SUCCESS_RESPONSE-962]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_START-963]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_STOP-964]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_ITERATION_NEXT-965]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_RESULT-966]
+ _ = x[MSG_RECLAIM_ISSUE_TICKET-967]
+ _ = x[MSG_RECLAIM_TICKET_RESULT-968]
+ _ = x[MSG_RECLAIM_REVOKE_TICKET-969]
+ _ = x[MSG_RECLAIM_REVOKE_TICKET_RESULT-970]
+ _ = x[MSG_RECLAIM_CONSUME_TICKET-971]
+ _ = x[MSG_RECLAIM_CONSUME_TICKET_RESULT-972]
+ _ = x[MSG_RECLAIM_TICKET_ITERATION_START-973]
+ _ = x[MSG_RECLAIM_TICKET_ITERATION_STOP-974]
+ _ = x[MSG_RECLAIM_TICKET_ITERATION_NEXT-975]
+ _ = x[MSG_RECLAIM_ATTRIBUTE_DELETE-976]
+ _ = x[MSG_CREDENTIAL_VERIFY-981]
+ _ = x[MSG_CREDENTIAL_VERIFY_RESULT-982]
+ _ = x[MSG_CREDENTIAL_COLLECT-983]
+ _ = x[MSG_CREDENTIAL_COLLECT_RESULT-984]
+ _ = x[MSG_CADET_CONNECTION_CREATE-1000]
+ _ = x[MSG_CADET_CONNECTION_CREATE_ACK-1001]
+ _ = x[MSG_CADET_CONNECTION_BROKEN-1002]
+ _ = x[MSG_CADET_CONNECTION_DESTROY-1003]
+ _ = x[MSG_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED-1004]
+ _ = x[MSG_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK-1005]
+ _ = x[MSG_CADET_TUNNEL_ENCRYPTED_POLL-1006]
+ _ = x[MSG_CADET_TUNNEL_KX-1007]
+ _ = x[MSG_CADET_TUNNEL_ENCRYPTED-1008]
+ _ = x[MSG_CADET_TUNNEL_KX_AUTH-1009]
+ _ = x[MSG_CADET_CHANNEL_APP_DATA-1010]
+ _ = x[MSG_CADET_CHANNEL_APP_DATA_ACK-1011]
+ _ = x[MSG_CADET_CHANNEL_KEEPALIVE-1012]
+ _ = x[MSG_CADET_CHANNEL_OPEN-1013]
+ _ = x[MSG_CADET_CHANNEL_DESTROY-1014]
+ _ = x[MSG_CADET_CHANNEL_OPEN_ACK-1015]
+ _ = x[MSG_CADET_CHANNEL_OPEN_NACK_DEPRECATED-1016]
+ _ = x[MSG_CADET_LOCAL_DATA-1020]
+ _ = x[MSG_CADET_LOCAL_ACK-1021]
+ _ = x[MSG_CADET_LOCAL_PORT_OPEN-1022]
+ _ = x[MSG_CADET_LOCAL_PORT_CLOSE-1023]
+ _ = x[MSG_CADET_LOCAL_CHANNEL_CREATE-1024]
+ _ = x[MSG_CADET_LOCAL_CHANNEL_DESTROY-1025]
+ _ = x[MSG_CADET_LOCAL_REQUEST_INFO_CHANNEL-1030]
+ _ = x[MSG_CADET_LOCAL_INFO_CHANNEL-1031]
+ _ = x[MSG_CADET_LOCAL_INFO_CHANNEL_END-1032]
+ _ = x[MSG_CADET_LOCAL_REQUEST_INFO_PEERS-1033]
+ _ = x[MSG_CADET_LOCAL_INFO_PEERS-1034]
+ _ = x[MSG_CADET_LOCAL_INFO_PEERS_END-1035]
+ _ = x[MSG_CADET_LOCAL_REQUEST_INFO_PATH-1036]
+ _ = x[MSG_CADET_LOCAL_INFO_PATH-1037]
+ _ = x[MSG_CADET_LOCAL_INFO_PATH_END-1038]
+ _ = x[MSG_CADET_LOCAL_REQUEST_INFO_TUNNELS-1039]
+ _ = x[MSG_CADET_LOCAL_INFO_TUNNELS-1040]
+ _ = x[MSG_CADET_LOCAL_INFO_TUNNELS_END-1041]
+ _ = x[MSG_CADET_CLI-1059]
+ _ = x[MSG_NAT_REGISTER-1060]
+ _ = x[MSG_NAT_HANDLE_STUN-1061]
+ _ = x[MSG_NAT_REQUEST_CONNECTION_REVERSAL-1062]
+ _ = x[MSG_NAT_CONNECTION_REVERSAL_REQUESTED-1063]
+ _ = x[MSG_NAT_ADDRESS_CHANGE-1064]
+ _ = x[MSG_NAT_AUTO_REQUEST_CFG-1066]
+ _ = x[MSG_NAT_AUTO_CFG_RESULT-1065]
+ _ = x[MSG_AUCTION_CLIENT_CREATE-1110]
+ _ = x[MSG_AUCTION_CLIENT_JOIN-1111]
+ _ = x[MSG_AUCTION_CLIENT_OUTCOME-1112]
+ _ = x[MSG_RPS_CS_DEBUG_VIEW_REQUEST-1130]
+ _ = x[MSG_RPS_CS_DEBUG_VIEW_REPLY-1131]
+ _ = x[MSG_RPS_CS_DEBUG_VIEW_CANCEL-1132]
+ _ = x[MSG_RPS_CS_DEBUG_STREAM_REQUEST-1133]
+ _ = x[MSG_RPS_CS_DEBUG_STREAM_REPLY-1134]
+ _ = x[MSG_RPS_CS_DEBUG_STREAM_CANCEL-1135]
+ _ = x[MSG_ALL-65535]
+}
+
+const _MsgType_name =
"MSG_TESTMSG_DUMMYMSG_DUMMY2MSG_RESOLVER_REQUESTMSG_RESOLVER_RESPONSEMSG_REQUEST_AGPLMSG_RESPONSE_AGPLMSG_ARM_STARTMSG_ARM_STOPMSG_ARM_RESULTMSG_ARM_STATUSMSG_ARM_LISTMSG_ARM_LIST_RESULTMSG_ARM_MONITORMSG_ARM_TESTMSG_HELLO_LEGACYMSG_HELLOMSG_FRAGMENTMSG_FRAGMENT_ACKMSG_WLAN_DATA_TO_HELPERMSG_WLAN_DATA_FROM_HELPERMSG_WLAN_HELPER_CONTROLMSG_WLAN_ADVERTISEMENTMSG_WLAN_DATAMSG_DV_RECVMSG_DV_SENDMSG_DV_SEND_ACKMSG_DV_ROUTEMSG_DV_STARTMSG_DV_CONNECTMSG_DV_DISCONNECTMSG_DV
[...]
+
+var _MsgType_map = map[MsgType]string{
+ 1: _MsgType_name[0:8],
+ 2: _MsgType_name[8:17],
+ 3: _MsgType_name[17:27],
+ 4: _MsgType_name[27:47],
+ 5: _MsgType_name[47:68],
+ 6: _MsgType_name[68:84],
+ 7: _MsgType_name[84:101],
+ 8: _MsgType_name[101:114],
+ 9: _MsgType_name[114:126],
+ 10: _MsgType_name[126:140],
+ 11: _MsgType_name[140:154],
+ 12: _MsgType_name[154:166],
+ 13: _MsgType_name[166:185],
+ 14: _MsgType_name[185:200],
+ 15: _MsgType_name[200:212],
+ 16: _MsgType_name[212:228],
+ 17: _MsgType_name[228:237],
+ 18: _MsgType_name[237:249],
+ 19: _MsgType_name[249:265],
+ 39: _MsgType_name[265:288],
+ 40: _MsgType_name[288:313],
+ 41: _MsgType_name[313:336],
+ 42: _MsgType_name[336:358],
+ 43: _MsgType_name[358:371],
+ 44: _MsgType_name[371:382],
+ 45: _MsgType_name[382:393],
+ 46: _MsgType_name[393:408],
+ 47: _MsgType_name[408:420],
+ 48: _MsgType_name[420:432],
+ 49: _MsgType_name[432:446],
+ 50: _MsgType_name[446:463],
+ 51: _MsgType_name[463:479],
+ 52: _MsgType_name[479:502],
+ 53: _MsgType_name[502:512],
+ 55: _MsgType_name[512:536],
+ 56: _MsgType_name[536:561],
+ 57: _MsgType_name[561:582],
+ 60: _MsgType_name[582:609],
+ 61: _MsgType_name[609:634],
+ 62: _MsgType_name[634:651],
+ 63: _MsgType_name[651:663],
+ 64: _MsgType_name[663:676],
+ 65: _MsgType_name[676:695],
+ 67: _MsgType_name[695:718],
+ 68: _MsgType_name[718:744],
+ 69: _MsgType_name[744:773],
+ 70: _MsgType_name[773:796],
+ 71: _MsgType_name[796:820],
+ 74: _MsgType_name[820:841],
+ 75: _MsgType_name[841:860],
+ 76: _MsgType_name[860:873],
+ 78: _MsgType_name[873:895],
+ 79: _MsgType_name[895:918],
+ 82: _MsgType_name[918:944],
+ 83: _MsgType_name[944:957],
+ 84: _MsgType_name[957:970],
+ 85: _MsgType_name[970:985],
+ 86: _MsgType_name[985:1013],
+ 87: _MsgType_name[1013:1037],
+ 88: _MsgType_name[1037:1059],
+ 89: _MsgType_name[1059:1084],
+ 92: _MsgType_name[1084:1105],
+ 93: _MsgType_name[1105:1134],
+ 94: _MsgType_name[1134:1154],
+ 95: _MsgType_name[1154:1171],
+ 97: _MsgType_name[1171:1188],
+ 98: _MsgType_name[1188:1217],
+ 99: _MsgType_name[1217:1249],
+ 100: _MsgType_name[1249:1267],
+ 101: _MsgType_name[1267:1289],
+ 102: _MsgType_name[1289:1309],
+ 103: _MsgType_name[1309:1327],
+ 104: _MsgType_name[1327:1348],
+ 126: _MsgType_name[1348:1371],
+ 127: _MsgType_name[1371:1399],
+ 128: _MsgType_name[1399:1417],
+ 129: _MsgType_name[1417:1438],
+ 130: _MsgType_name[1438:1463],
+ 131: _MsgType_name[1463:1484],
+ 132: _MsgType_name[1484:1507],
+ 133: _MsgType_name[1507:1528],
+ 134: _MsgType_name[1528:1542],
+ 135: _MsgType_name[1542:1559],
+ 136: _MsgType_name[1559:1578],
+ 137: _MsgType_name[1578:1588],
+ 138: _MsgType_name[1588:1598],
+ 139: _MsgType_name[1598:1619],
+ 140: _MsgType_name[1619:1637],
+ 141: _MsgType_name[1637:1655],
+ 142: _MsgType_name[1655:1673],
+ 143: _MsgType_name[1673:1691],
+ 144: _MsgType_name[1691:1714],
+ 145: _MsgType_name[1714:1735],
+ 146: _MsgType_name[1735:1750],
+ 147: _MsgType_name[1750:1765],
+ 148: _MsgType_name[1765:1783],
+ 149: _MsgType_name[1783:1802],
+ 150: _MsgType_name[1802:1826],
+ 151: _MsgType_name[1826:1845],
+ 152: _MsgType_name[1845:1869],
+ 153: _MsgType_name[1869:1890],
+ 154: _MsgType_name[1890:1910],
+ 156: _MsgType_name[1910:1942],
+ 157: _MsgType_name[1942:1959],
+ 158: _MsgType_name[1959:1971],
+ 159: _MsgType_name[1971:1995],
+ 160: _MsgType_name[1995:2021],
+ 161: _MsgType_name[2021:2045],
+ 168: _MsgType_name[2045:2063],
+ 169: _MsgType_name[2063:2081],
+ 170: _MsgType_name[2081:2101],
+ 171: _MsgType_name[2101:2119],
+ 172: _MsgType_name[2119:2139],
+ 173: _MsgType_name[2139:2165],
+ 174: _MsgType_name[2165:2190],
+ 175: _MsgType_name[2190:2223],
+ 185: _MsgType_name[2223:2237],
+ 190: _MsgType_name[2237:2260],
+ 191: _MsgType_name[2260:2284],
+ 192: _MsgType_name[2284:2303],
+ 193: _MsgType_name[2303:2326],
+ 194: _MsgType_name[2326:2351],
+ 195: _MsgType_name[2351:2379],
+ 196: _MsgType_name[2379:2408],
+ 197: _MsgType_name[2408:2432],
+ 198: _MsgType_name[2432:2455],
+ 199: _MsgType_name[2455:2477],
+ 200: _MsgType_name[2477:2500],
+ 201: _MsgType_name[2500:2517],
+ 202: _MsgType_name[2517:2546],
+ 203: _MsgType_name[2546:2580],
+ 204: _MsgType_name[2580:2601],
+ 211: _MsgType_name[2601:2620],
+ 212: _MsgType_name[2620:2642],
+ 213: _MsgType_name[2642:2665],
+ 214: _MsgType_name[2665:2679],
+ 300: _MsgType_name[2679:2700],
+ 301: _MsgType_name[2700:2726],
+ 302: _MsgType_name[2726:2753],
+ 303: _MsgType_name[2753:2782],
+ 304: _MsgType_name[2782:2807],
+ 305: _MsgType_name[2807:2836],
+ 306: _MsgType_name[2836:2870],
+ 307: _MsgType_name[2870:2900],
+ 308: _MsgType_name[2900:2931],
+ 309: _MsgType_name[2931:2956],
+ 310: _MsgType_name[2956:2989],
+ 311: _MsgType_name[2989:3022],
+ 321: _MsgType_name[3022:3035],
+ 322: _MsgType_name[3035:3052],
+ 323: _MsgType_name[3052:3068],
+ 330: _MsgType_name[3068:3084],
+ 331: _MsgType_name[3084:3104],
+ 332: _MsgType_name[3104:3121],
+ 333: _MsgType_name[3121:3142],
+ 334: _MsgType_name[3142:3161],
+ 340: _MsgType_name[3161:3174],
+ 341: _MsgType_name[3174:3197],
+ 342: _MsgType_name[3197:3227],
+ 343: _MsgType_name[3227:3249],
+ 344: _MsgType_name[3249:3274],
+ 345: _MsgType_name[3274:3300],
+ 346: _MsgType_name[3300:3324],
+ 347: _MsgType_name[3324:3351],
+ 348: _MsgType_name[3351:3377],
+ 349: _MsgType_name[3377:3402],
+ 350: _MsgType_name[3402:3425],
+ 353: _MsgType_name[3425:3444],
+ 354: _MsgType_name[3444:3471],
+ 355: _MsgType_name[3471:3499],
+ 356: _MsgType_name[3499:3526],
+ 360: _MsgType_name[3526:3545],
+ 361: _MsgType_name[3545:3566],
+ 362: _MsgType_name[3566:3590],
+ 363: _MsgType_name[3590:3608],
+ 364: _MsgType_name[3608:3629],
+ 365: _MsgType_name[3629:3647],
+ 366: _MsgType_name[3647:3670],
+ 367: _MsgType_name[3670:3701],
+ 368: _MsgType_name[3701:3738],
+ 369: _MsgType_name[3738:3766],
+ 370: _MsgType_name[3766:3795],
+ 371: _MsgType_name[3795:3824],
+ 372: _MsgType_name[3824:3842],
+ 373: _MsgType_name[3842:3860],
+ 375: _MsgType_name[3860:3885],
+ 376: _MsgType_name[3885:3914],
+ 377: _MsgType_name[3914:3939],
+ 378: _MsgType_name[3939:3971],
+ 379: _MsgType_name[3971:3998],
+ 380: _MsgType_name[3998:4032],
+ 381: _MsgType_name[4032:4063],
+ 382: _MsgType_name[4063:4103],
+ 383: _MsgType_name[4103:4138],
+ 384: _MsgType_name[4138:4168],
+ 385: _MsgType_name[4168:4196],
+ 388: _MsgType_name[4196:4230],
+ 389: _MsgType_name[4230:4264],
+ 390: _MsgType_name[4264:4297],
+ 391: _MsgType_name[4297:4336],
+ 420: _MsgType_name[4336:4371],
+ 421: _MsgType_name[4371:4411],
+ 422: _MsgType_name[4411:4438],
+ 423: _MsgType_name[4438:4469],
+ 424: _MsgType_name[4469:4504],
+ 425: _MsgType_name[4504:4535],
+ 426: _MsgType_name[4535:4565],
+ 431: _MsgType_name[4565:4591],
+ 432: _MsgType_name[4591:4626],
+ 433: _MsgType_name[4626:4651],
+ 434: _MsgType_name[4651:4685],
+ 435: _MsgType_name[4685:4711],
+ 436: _MsgType_name[4711:4746],
+ 437: _MsgType_name[4746:4773],
+ 438: _MsgType_name[4773:4809],
+ 439: _MsgType_name[4809:4835],
+ 440: _MsgType_name[4835:4870],
+ 441: _MsgType_name[4870:4897],
+ 442: _MsgType_name[4897:4923],
+ 443: _MsgType_name[4923:4950],
+ 444: _MsgType_name[4950:4976],
+ 445: _MsgType_name[4976:5010],
+ 447: _MsgType_name[5010:5043],
+ 448: _MsgType_name[5043:5076],
+ 460: _MsgType_name[5076:5092],
+ 461: _MsgType_name[5092:5112],
+ 462: _MsgType_name[5112:5140],
+ 463: _MsgType_name[5140:5168],
+ 464: _MsgType_name[5168:5191],
+ 465: _MsgType_name[5191:5219],
+ 466: _MsgType_name[5219:5241],
+ 467: _MsgType_name[5241:5262],
+ 468: _MsgType_name[5262:5286],
+ 469: _MsgType_name[5286:5321],
+ 470: _MsgType_name[5321:5348],
+ 471: _MsgType_name[5348:5370],
+ 472: _MsgType_name[5370:5400],
+ 473: _MsgType_name[5400:5432],
+ 474: _MsgType_name[5432:5463],
+ 475: _MsgType_name[5463:5500],
+ 476: _MsgType_name[5500:5532],
+ 477: _MsgType_name[5532:5560],
+ 478: _MsgType_name[5560:5594],
+ 479: _MsgType_name[5594:5629],
+ 480: _MsgType_name[5629:5660],
+ 481: _MsgType_name[5660:5695],
+ 482: _MsgType_name[5695:5721],
+ 483: _MsgType_name[5721:5752],
+ 484: _MsgType_name[5752:5776],
+ 485: _MsgType_name[5776:5802],
+ 486: _MsgType_name[5802:5828],
+ 487: _MsgType_name[5828:5852],
+ 488: _MsgType_name[5852:5867],
+ 495: _MsgType_name[5867:5890],
+ 496: _MsgType_name[5890:5914],
+ 500: _MsgType_name[5914:5928],
+ 501: _MsgType_name[5928:5949],
+ 502: _MsgType_name[5949:5971],
+ 503: _MsgType_name[5971:6000],
+ 520: _MsgType_name[6000:6025],
+ 521: _MsgType_name[6025:6052],
+ 522: _MsgType_name[6052:6078],
+ 523: _MsgType_name[6078:6115],
+ 524: _MsgType_name[6115:6144],
+ 525: _MsgType_name[6144:6178],
+ 540: _MsgType_name[6178:6202],
+ 541: _MsgType_name[6202:6234],
+ 542: _MsgType_name[6234:6269],
+ 543: _MsgType_name[6269:6295],
+ 544: _MsgType_name[6295:6329],
+ 545: _MsgType_name[6329:6362],
+ 546: _MsgType_name[6362:6385],
+ 547: _MsgType_name[6385:6409],
+ 548: _MsgType_name[6409:6430],
+ 565: _MsgType_name[6430:6460],
+ 566: _MsgType_name[6460:6484],
+ 567: _MsgType_name[6484:6509],
+ 568: _MsgType_name[6509:6532],
+ 569: _MsgType_name[6532:6546],
+ 570: _MsgType_name[6546:6560],
+ 571: _MsgType_name[6560:6576],
+ 572: _MsgType_name[6576:6590],
+ 573: _MsgType_name[6590:6601],
+ 574: _MsgType_name[6601:6615],
+ 575: _MsgType_name[6615:6629],
+ 576: _MsgType_name[6629:6643],
+ 577: _MsgType_name[6643:6659],
+ 578: _MsgType_name[6659:6675],
+ 579: _MsgType_name[6675:6690],
+ 580: _MsgType_name[6690:6704],
+ 581: _MsgType_name[6704:6733],
+ 582: _MsgType_name[6733:6753],
+ 583: _MsgType_name[6753:6774],
+ 584: _MsgType_name[6774:6794],
+ 585: _MsgType_name[6794:6822],
+ 586: _MsgType_name[6822:6844],
+ 587: _MsgType_name[6844:6864],
+ 588: _MsgType_name[6864:6884],
+ 589: _MsgType_name[6884:6901],
+ 590: _MsgType_name[6901:6922],
+ 591: _MsgType_name[6922:6959],
+ 592: _MsgType_name[6959:6986],
+ 593: _MsgType_name[6986:7015],
+ 594: _MsgType_name[7015:7040],
+ 595: _MsgType_name[7040:7066],
+ 596: _MsgType_name[7066:7091],
+ 597: _MsgType_name[7091:7118],
+ 598: _MsgType_name[7118:7148],
+ 599: _MsgType_name[7148:7170],
+ 600: _MsgType_name[7170:7192],
+ 601: _MsgType_name[7192:7214],
+ 620: _MsgType_name[7214:7232],
+ 621: _MsgType_name[7232:7248],
+ 622: _MsgType_name[7248:7264],
+ 624: _MsgType_name[7264:7282],
+ 625: _MsgType_name[7282:7306],
+ 626: _MsgType_name[7306:7325],
+ 627: _MsgType_name[7325:7349],
+ 628: _MsgType_name[7349:7373],
+ 629: _MsgType_name[7373:7392],
+ 630: _MsgType_name[7392:7411],
+ 631: _MsgType_name[7411:7430],
+ 632: _MsgType_name[7430:7449],
+ 633: _MsgType_name[7449:7476],
+ 636: _MsgType_name[7476:7496],
+ 637: _MsgType_name[7496:7525],
+ 638: _MsgType_name[7525:7546],
+ 639: _MsgType_name[7546:7576],
+ 640: _MsgType_name[7576:7609],
+ 641: _MsgType_name[7609:7640],
+ 642: _MsgType_name[7640:7680],
+ 643: _MsgType_name[7680:7718],
+ 644: _MsgType_name[7718:7758],
+ 645: _MsgType_name[7758:7792],
+ 647: _MsgType_name[7792:7824],
+ 648: _MsgType_name[7824:7866],
+ 649: _MsgType_name[7866:7890],
+ 650: _MsgType_name[7890:7934],
+ 651: _MsgType_name[7934:7972],
+ 652: _MsgType_name[7972:8008],
+ 660: _MsgType_name[8008:8038],
+ 661: _MsgType_name[8038:8067],
+ 662: _MsgType_name[8067:8095],
+ 663: _MsgType_name[8095:8121],
+ 664: _MsgType_name[8121:8146],
+ 665: _MsgType_name[8146:8180],
+ 666: _MsgType_name[8180:8206],
+ 668: _MsgType_name[8206:8232],
+ 669: _MsgType_name[8232:8256],
+ 670: _MsgType_name[8256:8281],
+ 671: _MsgType_name[8281:8312],
+ 672: _MsgType_name[8312:8335],
+ 673: _MsgType_name[8335:8365],
+ 674: _MsgType_name[8365:8390],
+ 675: _MsgType_name[8390:8419],
+ 676: _MsgType_name[8419:8448],
+ 677: _MsgType_name[8448:8474],
+ 680: _MsgType_name[8474:8494],
+ 681: _MsgType_name[8494:8515],
+ 682: _MsgType_name[8515:8540],
+ 683: _MsgType_name[8540:8559],
+ 684: _MsgType_name[8559:8582],
+ 685: _MsgType_name[8582:8603],
+ 686: _MsgType_name[8603:8620],
+ 687: _MsgType_name[8620:8641],
+ 688: _MsgType_name[8641:8663],
+ 689: _MsgType_name[8663:8696],
+ 691: _MsgType_name[8696:8712],
+ 692: _MsgType_name[8712:8735],
+ 693: _MsgType_name[8735:8758],
+ 694: _MsgType_name[8758:8783],
+ 695: _MsgType_name[8783:8808],
+ 696: _MsgType_name[8808:8829],
+ 697: _MsgType_name[8829:8849],
+ 698: _MsgType_name[8849:8872],
+ 699: _MsgType_name[8872:8892],
+ 701: _MsgType_name[8892:8915],
+ 702: _MsgType_name[8915:8938],
+ 703: _MsgType_name[8938:8956],
+ 704: _MsgType_name[8956:8981],
+ 705: _MsgType_name[8981:9002],
+ 730: _MsgType_name[9002:9024],
+ 731: _MsgType_name[9024:9058],
+ 732: _MsgType_name[9058:9091],
+ 733: _MsgType_name[9091:9124],
+ 734: _MsgType_name[9124:9154],
+ 735: _MsgType_name[9154:9184],
+ 736: _MsgType_name[9184:9217],
+ 737: _MsgType_name[9217:9249],
+ 738: _MsgType_name[9249:9284],
+ 739: _MsgType_name[9284:9309],
+ 740: _MsgType_name[9309:9342],
+ 741: _MsgType_name[9342:9378],
+ 742: _MsgType_name[9378:9414],
+ 743: _MsgType_name[9414:9450],
+ 744: _MsgType_name[9450:9485],
+ 745: _MsgType_name[9485:9513],
+ 750: _MsgType_name[9513:9539],
+ 751: _MsgType_name[9539:9564],
+ 752: _MsgType_name[9564:9590],
+ 753: _MsgType_name[9590:9617],
+ 754: _MsgType_name[9617:9643],
+ 755: _MsgType_name[9643:9665],
+ 756: _MsgType_name[9665:9688],
+ 757: _MsgType_name[9688:9709],
+ 758: _MsgType_name[9709:9730],
+ 759: _MsgType_name[9730:9756],
+ 760: _MsgType_name[9756:9784],
+ 761: _MsgType_name[9784:9813],
+ 762: _MsgType_name[9813:9846],
+ 780: _MsgType_name[9846:9879],
+ 781: _MsgType_name[9879:9911],
+ 782: _MsgType_name[9911:9948],
+ 783: _MsgType_name[9948:9985],
+ 820: _MsgType_name[9985:10004],
+ 821: _MsgType_name[10004:10025],
+ 822: _MsgType_name[10025:10053],
+ 823: _MsgType_name[10053:10078],
+ 824: _MsgType_name[10078:10097],
+ 825: _MsgType_name[10097:10123],
+ 826: _MsgType_name[10123:10149],
+ 840: _MsgType_name[10149:10171],
+ 841: _MsgType_name[10171:10192],
+ 842: _MsgType_name[10192:10217],
+ 843: _MsgType_name[10217:10239],
+ 844: _MsgType_name[10239:10269],
+ 845: _MsgType_name[10269:10295],
+ 846: _MsgType_name[10295:10319],
+ 847: _MsgType_name[10319:10344],
+ 848: _MsgType_name[10344:10366],
+ 849: _MsgType_name[10366:10392],
+ 850: _MsgType_name[10392:10417],
+ 851: _MsgType_name[10417:10440],
+ 852: _MsgType_name[10440:10462],
+ 853: _MsgType_name[10462:10483],
+ 854: _MsgType_name[10483:10501],
+ 855: _MsgType_name[10501:10523],
+ 856: _MsgType_name[10523:10543],
+ 857: _MsgType_name[10543:10567],
+ 858: _MsgType_name[10567:10590],
+ 859: _MsgType_name[10590:10615],
+ 880: _MsgType_name[10615:10639],
+ 881: _MsgType_name[10639:10670],
+ 882: _MsgType_name[10670:10699],
+ 883: _MsgType_name[10699:10732],
+ 884: _MsgType_name[10732:10768],
+ 885: _MsgType_name[10768:10791],
+ 886: _MsgType_name[10791:10825],
+ 887: _MsgType_name[10825:10852],
+ 888: _MsgType_name[10852:10874],
+ 890: _MsgType_name[10874:10890],
+ 891: _MsgType_name[10890:10906],
+ 892: _MsgType_name[10906:10948],
+ 893: _MsgType_name[10948:10969],
+ 894: _MsgType_name[10969:11000],
+ 910: _MsgType_name[11000:11020],
+ 911: _MsgType_name[11020:11049],
+ 912: _MsgType_name[11049:11071],
+ 913: _MsgType_name[11071:11091],
+ 914: _MsgType_name[11091:11114],
+ 915: _MsgType_name[11114:11126],
+ 916: _MsgType_name[11126:11138],
+ 917: _MsgType_name[11138:11157],
+ 950: _MsgType_name[11157:11178],
+ 951: _MsgType_name[11178:11193],
+ 952: _MsgType_name[11193:11216],
+ 953: _MsgType_name[11216:11237],
+ 954: _MsgType_name[11237:11252],
+ 955: _MsgType_name[11252:11273],
+ 956: _MsgType_name[11273:11293],
+ 957: _MsgType_name[11293:11312],
+ 961: _MsgType_name[11312:11339],
+ 962: _MsgType_name[11339:11367],
+ 963: _MsgType_name[11367:11404],
+ 964: _MsgType_name[11404:11440],
+ 965: _MsgType_name[11440:11476],
+ 966: _MsgType_name[11476:11504],
+ 967: _MsgType_name[11504:11528],
+ 968: _MsgType_name[11528:11553],
+ 969: _MsgType_name[11553:11578],
+ 970: _MsgType_name[11578:11610],
+ 971: _MsgType_name[11610:11636],
+ 972: _MsgType_name[11636:11669],
+ 973: _MsgType_name[11669:11703],
+ 974: _MsgType_name[11703:11736],
+ 975: _MsgType_name[11736:11769],
+ 976: _MsgType_name[11769:11797],
+ 981: _MsgType_name[11797:11818],
+ 982: _MsgType_name[11818:11846],
+ 983: _MsgType_name[11846:11868],
+ 984: _MsgType_name[11868:11897],
+ 1000: _MsgType_name[11897:11924],
+ 1001: _MsgType_name[11924:11955],
+ 1002: _MsgType_name[11955:11982],
+ 1003: _MsgType_name[11982:12010],
+ 1004: _MsgType_name[12010:12057],
+ 1005: _MsgType_name[12057:12102],
+ 1006: _MsgType_name[12102:12133],
+ 1007: _MsgType_name[12133:12152],
+ 1008: _MsgType_name[12152:12178],
+ 1009: _MsgType_name[12178:12202],
+ 1010: _MsgType_name[12202:12228],
+ 1011: _MsgType_name[12228:12258],
+ 1012: _MsgType_name[12258:12285],
+ 1013: _MsgType_name[12285:12307],
+ 1014: _MsgType_name[12307:12332],
+ 1015: _MsgType_name[12332:12358],
+ 1016: _MsgType_name[12358:12396],
+ 1020: _MsgType_name[12396:12416],
+ 1021: _MsgType_name[12416:12435],
+ 1022: _MsgType_name[12435:12460],
+ 1023: _MsgType_name[12460:12486],
+ 1024: _MsgType_name[12486:12516],
+ 1025: _MsgType_name[12516:12547],
+ 1030: _MsgType_name[12547:12583],
+ 1031: _MsgType_name[12583:12611],
+ 1032: _MsgType_name[12611:12643],
+ 1033: _MsgType_name[12643:12677],
+ 1034: _MsgType_name[12677:12703],
+ 1035: _MsgType_name[12703:12733],
+ 1036: _MsgType_name[12733:12766],
+ 1037: _MsgType_name[12766:12791],
+ 1038: _MsgType_name[12791:12820],
+ 1039: _MsgType_name[12820:12856],
+ 1040: _MsgType_name[12856:12884],
+ 1041: _MsgType_name[12884:12916],
+ 1059: _MsgType_name[12916:12929],
+ 1060: _MsgType_name[12929:12945],
+ 1061: _MsgType_name[12945:12964],
+ 1062: _MsgType_name[12964:12999],
+ 1063: _MsgType_name[12999:13036],
+ 1064: _MsgType_name[13036:13058],
+ 1065: _MsgType_name[13058:13081],
+ 1066: _MsgType_name[13081:13105],
+ 1110: _MsgType_name[13105:13130],
+ 1111: _MsgType_name[13130:13153],
+ 1112: _MsgType_name[13153:13179],
+ 1130: _MsgType_name[13179:13208],
+ 1131: _MsgType_name[13208:13235],
+ 1132: _MsgType_name[13235:13263],
+ 1133: _MsgType_name[13263:13294],
+ 1134: _MsgType_name[13294:13323],
+ 1135: _MsgType_name[13323:13353],
+ 65535: _MsgType_name[13353:13360],
+}
+
+func (i MsgType) String() string {
+ if str, ok := _MsgType_map[i]; ok {
+ return str
+ }
+ return "MsgType(" + strconv.FormatInt(int64(i), 10) + ")"
+}
diff --git a/src/gnunet/go.mod b/src/gnunet/go.mod
index 9e01d7c..26f0e38 100644
--- a/src/gnunet/go.mod
+++ b/src/gnunet/go.mod
@@ -3,7 +3,7 @@ module gnunet
go 1.18
require (
- github.com/bfix/gospel v1.2.18
+ github.com/bfix/gospel v1.2.19
github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.6.0
github.com/gorilla/mux v1.8.0
@@ -24,4 +24,4 @@ require (
golang.org/x/tools v0.1.11 // indirect
)
-//replace github.com/bfix/gospel v1.2.18 => ../gospel
+// replace github.com/bfix/gospel v1.2.19 => ../gospel
diff --git a/src/gnunet/go.sum b/src/gnunet/go.sum
index 2a2a36a..a1c014b 100644
--- a/src/gnunet/go.sum
+++ b/src/gnunet/go.sum
@@ -1,5 +1,5 @@
-github.com/bfix/gospel v1.2.18 h1:X9hYudt5dvjYTGGmKC4T7qcLdb7ORblVD4kAC/ZYXdU=
-github.com/bfix/gospel v1.2.18/go.mod
h1:cdu63bA9ZdfeDoqZ+vnWOcbY9Puwdzmf5DMxMGMznRI=
+github.com/bfix/gospel v1.2.19 h1:B57L5CMjKPeRPtVxt1JcSx42AKwD+SpN32QaF0DxXFM=
+github.com/bfix/gospel v1.2.19/go.mod
h1:cdu63bA9ZdfeDoqZ+vnWOcbY9Puwdzmf5DMxMGMznRI=
github.com/cespare/xxhash/v2 v2.1.2
h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod
h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
diff --git a/src/gnunet/message/factory.go b/src/gnunet/message/factory.go
index 23da078..8f664b0 100644
--- a/src/gnunet/message/factory.go
+++ b/src/gnunet/message/factory.go
@@ -20,95 +20,96 @@ package message
import (
"fmt"
+ "gnunet/enums"
)
// NewEmptyMessage creates a new empty message object for the given type.
-func NewEmptyMessage(msgType uint16) (Message, error) {
+func NewEmptyMessage(msgType enums.MsgType) (Message, error) {
switch msgType {
//------------------------------------------------------------------
// Transport
//------------------------------------------------------------------
- case TRANSPORT_TCP_WELCOME:
+ case enums.MSG_TRANSPORT_TCP_WELCOME:
return NewTransportTCPWelcomeMsg(nil), nil
- case HELLO:
+ case enums.MSG_HELLO:
return NewHelloMsg(nil), nil
- case TRANSPORT_SESSION_QUOTA:
+ case enums.MSG_TRANSPORT_SESSION_QUOTA:
return NewSessionQuotaMsg(0), nil
- case TRANSPORT_SESSION_SYN:
+ case enums.MSG_TRANSPORT_SESSION_SYN:
return NewSessionSynMsg(), nil
- case TRANSPORT_SESSION_SYN_ACK:
+ case enums.MSG_TRANSPORT_SESSION_SYN_ACK:
return NewSessionSynAckMsg(), nil
- case TRANSPORT_SESSION_ACK:
+ case enums.MSG_TRANSPORT_SESSION_ACK:
return new(SessionAckMsg), nil
- case TRANSPORT_PING:
+ case enums.MSG_TRANSPORT_PING:
return NewTransportPingMsg(nil, nil), nil
- case TRANSPORT_PONG:
+ case enums.MSG_TRANSPORT_PONG:
return NewTransportPongMsg(0, nil), nil
- case TRANSPORT_SESSION_KEEPALIVE:
+ case enums.MSG_TRANSPORT_SESSION_KEEPALIVE:
return NewSessionKeepAliveMsg(), nil
//------------------------------------------------------------------
// Core
//------------------------------------------------------------------
- case CORE_EPHEMERAL_KEY:
+ case enums.MSG_CORE_EPHEMERAL_KEY:
return NewEphemeralKeyMsg(), nil
//------------------------------------------------------------------
// DHT
//------------------------------------------------------------------
- case DHT_CLIENT_PUT:
+ case enums.MSG_DHT_CLIENT_PUT:
return NewDHTClientPutMsg(nil, 0, nil), nil
- case DHT_CLIENT_GET:
+ case enums.MSG_DHT_CLIENT_GET:
return NewDHTClientGetMsg(nil), nil
- case DHT_CLIENT_GET_STOP:
+ case enums.MSG_DHT_CLIENT_GET_STOP:
return NewDHTClientGetStopMsg(nil), nil
- case DHT_CLIENT_RESULT:
+ case enums.MSG_DHT_CLIENT_RESULT:
return NewDHTClientResultMsg(nil), nil
- case DHT_CLIENT_GET_RESULTS_KNOWN:
+ case enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN:
return NewDHTClientGetResultsKnownMsg(nil), nil
//------------------------------------------------------------------
// DHT-P2P
//------------------------------------------------------------------
- case DHT_P2P_HELLO:
+ case enums.MSG_DHT_P2P_HELLO:
return NewDHTP2PHelloMsg(), nil
- case DHT_P2P_GET:
+ case enums.MSG_DHT_P2P_GET:
return NewDHTP2PGetMsg(), nil
- case DHT_P2P_PUT:
+ case enums.MSG_DHT_P2P_PUT:
return NewDHTP2PPutMsg(), nil
- case DHT_P2P_RESULT:
+ case enums.MSG_DHT_P2P_RESULT:
return NewDHTP2PResultMsg(), nil
//------------------------------------------------------------------
// GNS
//------------------------------------------------------------------
- case GNS_LOOKUP:
+ case enums.MSG_GNS_LOOKUP:
return NewGNSLookupMsg(), nil
- case GNS_LOOKUP_RESULT:
+ case enums.MSG_GNS_LOOKUP_RESULT:
return NewGNSLookupResultMsg(0), nil
//------------------------------------------------------------------
// Namecache
//------------------------------------------------------------------
- case NAMECACHE_LOOKUP_BLOCK:
+ case enums.MSG_NAMECACHE_LOOKUP_BLOCK:
return NewNamecacheLookupMsg(nil), nil
- case NAMECACHE_LOOKUP_BLOCK_RESPONSE:
+ case enums.MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE:
return NewNamecacheLookupResultMsg(), nil
- case NAMECACHE_BLOCK_CACHE:
+ case enums.MSG_NAMECACHE_BLOCK_CACHE:
return NewNamecacheCacheMsg(nil), nil
- case NAMECACHE_BLOCK_CACHE_RESPONSE:
+ case enums.MSG_NAMECACHE_BLOCK_CACHE_RESPONSE:
return NewNamecacheCacheResponseMsg(), nil
//------------------------------------------------------------------
// Revocation
//------------------------------------------------------------------
- case REVOCATION_QUERY:
+ case enums.MSG_REVOCATION_QUERY:
return NewRevocationQueryMsg(nil), nil
- case REVOCATION_QUERY_RESPONSE:
+ case enums.MSG_REVOCATION_QUERY_RESPONSE:
return NewRevocationQueryResponseMsg(true), nil
- case REVOCATION_REVOKE:
+ case enums.MSG_REVOCATION_REVOKE:
return NewRevocationRevokeMsg(nil), nil
- case REVOCATION_REVOKE_RESPONSE:
+ case enums.MSG_REVOCATION_REVOKE_RESPONSE:
return NewRevocationRevokeResponseMsg(false), nil
}
return nil, fmt.Errorf("unknown message type %d", msgType)
diff --git a/src/gnunet/message/message.go b/src/gnunet/message/message.go
index 4dfa8b3..946dd6e 100644
--- a/src/gnunet/message/message.go
+++ b/src/gnunet/message/message.go
@@ -20,6 +20,7 @@ package message
import (
"errors"
+ "gnunet/enums"
"github.com/bfix/gospel/data"
)
@@ -33,8 +34,12 @@ var (
// Message is an interface for all GNUnet-specific messages.
type Message interface {
- // Header of message
- Header() *Header
+
+ // Size returns the size of the full message
+ Size() uint16
+
+ // Type returns the message type (defines the layout of the body data)
+ Type() enums.MsgType
// String returns a human-readable message
String() string
@@ -42,30 +47,30 @@ type Message interface {
//----------------------------------------------------------------------
-// Header encapsulates the common part of all GNUnet messages (at the
+// MsgHeader encapsulates the common part of all GNUnet messages (at the
// beginning of the data).
-type Header struct {
- MsgSize uint16 `order:"big"`
- MsgType uint16 `order:"big"`
+type MsgHeader struct {
+ MsgSize uint16 `order:"big"`
+ MsgType enums.MsgType `order:"big"`
}
// Size returns the total size of the message (header + body)
-func (mh *Header) Size() uint16 {
+func (mh *MsgHeader) Size() uint16 {
return mh.MsgSize
}
// Type returns the message type (defines the layout of the body data)
-func (mh *Header) Type() uint16 {
+func (mh *MsgHeader) Type() enums.MsgType {
return mh.MsgType
}
// GetMsgHeader returns the header of a message from a byte array (as the
// serialized form).
-func GetMsgHeader(b []byte) (mh *Header, err error) {
+func GetMsgHeader(b []byte) (mh *MsgHeader, err error) {
if b == nil || len(b) < 4 {
return nil, ErrMsgHeaderTooSmall
}
- mh = new(Header)
+ mh = new(MsgHeader)
err = data.Unmarshal(mh, b)
return
}
diff --git a/src/gnunet/message/msg_core.go b/src/gnunet/message/msg_core.go
index 208b438..ae1b9cf 100644
--- a/src/gnunet/message/msg_core.go
+++ b/src/gnunet/message/msg_core.go
@@ -43,8 +43,7 @@ type EphKeyBlock struct {
// EphemeralKeyMsg announces a new transient key for a peer. The key is signed
// by the issuing peer.
type EphemeralKeyMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // CORE_EPHEMERAL_KEY
(88)
+ MsgHeader
SenderStatus uint32 `order:"big"` // enum PeerStateMachine
Signature *util.PeerSignature `` // EdDSA signature
SignedBlock *EphKeyBlock
@@ -53,8 +52,7 @@ type EphemeralKeyMsg struct {
// NewEphemeralKeyMsg creates an empty message for key announcement.
func NewEphemeralKeyMsg() *EphemeralKeyMsg {
return &EphemeralKeyMsg{
- MsgSize: 160,
- MsgType: CORE_EPHEMERAL_KEY,
+ MsgHeader: MsgHeader{160, enums.MSG_CORE_EPHEMERAL_KEY},
SenderStatus: 1,
Signature: util.NewPeerSignature(nil),
SignedBlock: &EphKeyBlock{
@@ -79,11 +77,6 @@ func (m *EphemeralKeyMsg) String() string {
m.SenderStatus)
}
-// Header returns the message header in a separate instance.
-func (m *EphemeralKeyMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
// Public extracts the public key of an announcing peer.
func (m *EphemeralKeyMsg) Public() *util.PeerPublicKey {
return util.NewPeerPublicKey(m.SignedBlock.PeerID.Data)
diff --git a/src/gnunet/message/msg_dht.go b/src/gnunet/message/msg_dht.go
index 9e1a747..0f8b9cc 100644
--- a/src/gnunet/message/msg_dht.go
+++ b/src/gnunet/message/msg_dht.go
@@ -19,7 +19,6 @@
package message
import (
- "encoding/hex"
"fmt"
"gnunet/crypto"
@@ -33,9 +32,8 @@ import (
// DHTClientPutMsg is the message for putting values into the DHT
type DHTClientPutMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // DHT_CLIENT_PUT (142)
- Type uint32 `order:"big"` // The type of the data
(BLOCK_TYPE_???)
+ MsgHeader
+ BType enums.BlockType `order:"big"` // The type of the data
(BLOCK_TYPE_???)
Options uint32 `order:"big"` // Message options
(DHT_RO_???)
ReplLevel uint32 `order:"big"` // Replication level for this
message
Expire util.AbsoluteTime // Expiration time
@@ -44,7 +42,7 @@ type DHTClientPutMsg struct {
}
// NewDHTClientPutMsg creates a new default DHTClientPutMsg object.
-func NewDHTClientPutMsg(key *crypto.HashCode, btype int, data []byte)
*DHTClientPutMsg {
+func NewDHTClientPutMsg(key *crypto.HashCode, btype enums.BlockType, data
[]byte) *DHTClientPutMsg {
if key == nil {
key = new(crypto.HashCode)
}
@@ -53,9 +51,8 @@ func NewDHTClientPutMsg(key *crypto.HashCode, btype int, data
[]byte) *DHTClient
size += uint16(len(data))
}
return &DHTClientPutMsg{
- MsgSize: size,
- MsgType: DHT_CLIENT_PUT,
- Type: uint32(btype),
+ MsgHeader: MsgHeader{size, enums.MSG_DHT_CLIENT_PUT},
+ BType: btype,
Options: uint32(enums.DHT_RO_NONE),
ReplLevel: 1,
Expire: util.AbsoluteTimeNever(),
@@ -66,13 +63,8 @@ func NewDHTClientPutMsg(key *crypto.HashCode, btype int,
data []byte) *DHTClient
// String returns a human-readable representation of the message.
func (m *DHTClientPutMsg) String() string {
- return
fmt.Sprintf("DHTClientPutMsg{Type=%d,Expire=%s,Options=%d,Repl=%d,Key=%s}",
- m.Type, m.Expire, m.Options, m.ReplLevel,
hex.EncodeToString(m.Key.Bits))
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTClientPutMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return
fmt.Sprintf("DHTClientPutMsg{Type=%s,Expire=%s,Options=%d,Repl=%d,Key=%s}",
+ m.BType, m.Expire, m.Options, m.ReplLevel, m.Key)
}
//----------------------------------------------------------------------
@@ -81,11 +73,10 @@ func (m *DHTClientPutMsg) Header() *Header {
// DHTClientGetMsg is the message for getting values from the DHT
type DHTClientGetMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // DHT_CLIENT_GET (143)
+ MsgHeader
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_???)
+ BType enums.BlockType `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
@@ -97,11 +88,10 @@ func NewDHTClientGetMsg(key *crypto.HashCode)
*DHTClientGetMsg {
key = new(crypto.HashCode)
}
return &DHTClientGetMsg{
- MsgSize: 88,
- MsgType: DHT_CLIENT_GET,
+ MsgHeader: MsgHeader{88, enums.MSG_DHT_CLIENT_GET},
Options: uint32(enums.DHT_RO_NONE),
ReplLevel: 1,
- Type: uint32(enums.BLOCK_TYPE_ANY),
+ BType: enums.BLOCK_TYPE_ANY,
Key: key,
ID: 0,
XQuery: nil,
@@ -119,13 +109,8 @@ func (m *DHTClientGetMsg) SetXQuery(xq []byte) []byte {
// String returns a human-readable representation of the message.
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 (m *DHTClientGetMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return
fmt.Sprintf("DHTClientGetMsg{Id:%d,Type=%s,Options=%d,Repl=%d,Key=%s}",
+ m.ID, m.BType, m.Options, m.ReplLevel, m.Key)
}
//----------------------------------------------------------------------
@@ -134,9 +119,8 @@ func (m *DHTClientGetMsg) Header() *Header {
// DHTClientResultMsg is a message for DHT results
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
+ MsgHeader
+ BType enums.BlockType `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
@@ -153,9 +137,8 @@ func NewDHTClientResultMsg(key *crypto.HashCode)
*DHTClientResultMsg {
key = crypto.NewHashCode(nil)
}
return &DHTClientResultMsg{
- MsgSize: 64, // empty message size (no data)
- MsgType: DHT_CLIENT_RESULT,
- Type: 0,
+ MsgHeader: MsgHeader{64, enums.MSG_DHT_CLIENT_RESULT},
+ BType: 0,
PutPathLen: 0,
GetPathLen: 0,
ID: 0,
@@ -167,12 +150,7 @@ func NewDHTClientResultMsg(key *crypto.HashCode)
*DHTClientResultMsg {
// String returns a human-readable representation of the message.
func (m *DHTClientResultMsg) String() string {
- return fmt.Sprintf("DHTClientResultMsg{id:%d,expire=%s}", m.ID,
m.Expire)
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTClientResultMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTClientResultMsg{id:%d,type=%s,expire=%s}", m.ID,
m.BType, m.Expire)
}
//----------------------------------------------------------------------
@@ -181,8 +159,7 @@ func (m *DHTClientResultMsg) Header() *Header {
// DHTClientGetStopMsg stops a pending DHT operation
type DHTClientGetStopMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // DHT_CLIENT_GET_STOP (144)
+ MsgHeader
Reserved uint32 `order:"big"` // Reserved (0)
ID uint64 `order:"big"` // Unique ID identifying this
request
Key *crypto.HashCode // The key to search for
@@ -194,22 +171,16 @@ func NewDHTClientGetStopMsg(key *crypto.HashCode)
*DHTClientGetStopMsg {
key = new(crypto.HashCode)
}
return &DHTClientGetStopMsg{
- MsgSize: 80,
- MsgType: DHT_CLIENT_GET_STOP,
- Reserved: 0, // mandatory
- ID: 0,
- Key: key,
+ MsgHeader: MsgHeader{80, enums.MSG_DHT_CLIENT_GET_STOP},
+ Reserved: 0, // mandatory
+ ID: 0,
+ Key: key,
}
}
// String returns a human-readable representation of the message.
func (m *DHTClientGetStopMsg) String() string {
- return fmt.Sprintf("DHTClientGetStopMsg{Id:%d,Key=%s}", m.ID,
hex.EncodeToString(m.Key.Bits))
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTClientGetStopMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTClientGetStopMsg{Id:%d,Key=%s}", m.ID, m.Key)
}
//----------------------------------------------------------------------
@@ -218,8 +189,7 @@ func (m *DHTClientGetStopMsg) Header() *Header {
// DHTClientGetResultsKnownMsg is the message for putting values into the DHT
type DHTClientGetResultsKnownMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` //
DHT_CLIENT_GET_RESULTS_KNOWN (156)
+ MsgHeader
Reserved uint32 `order:"big"` // Reserved for further use
Key *crypto.HashCode // The key to search for
ID uint64 `order:"big"` // Unique ID identifying this
request
@@ -232,11 +202,10 @@ func NewDHTClientGetResultsKnownMsg(key *crypto.HashCode)
*DHTClientGetResultsKn
key = new(crypto.HashCode)
}
return &DHTClientGetResultsKnownMsg{
- MsgSize: 80,
- MsgType: DHT_CLIENT_GET_RESULTS_KNOWN,
- Key: key,
- ID: 0,
- Known: make([]*crypto.HashCode, 0),
+ MsgHeader: MsgHeader{80,
enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN},
+ Key: key,
+ ID: 0,
+ Known: make([]*crypto.HashCode, 0),
}
}
@@ -249,10 +218,5 @@ func (m *DHTClientGetResultsKnownMsg) AddKnown(hc
*crypto.HashCode) {
// String returns a human-readable representation of the message.
func (m *DHTClientGetResultsKnownMsg) String() string {
return fmt.Sprintf("DHTClientGetResultsKnownMsg{Id:%d,Key=%s,Num=%d}",
- m.ID, hex.EncodeToString(m.Key.Bits), len(m.Known))
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTClientGetResultsKnownMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ m.ID, m.Key.Data, len(m.Known))
}
diff --git a/src/gnunet/message/msg_dht_p2p.go
b/src/gnunet/message/msg_dht_p2p.go
index 638ff16..f6b24e2 100644
--- a/src/gnunet/message/msg_dht_p2p.go
+++ b/src/gnunet/message/msg_dht_p2p.go
@@ -29,6 +29,7 @@ import (
"gnunet/service/dht/blocks"
"gnunet/service/dht/path"
"gnunet/util"
+ "strings"
"time"
"github.com/bfix/gospel/crypto/ed25519"
@@ -46,9 +47,8 @@ import (
// DHTP2PGetMsg wire layout
type DHTP2PGetMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // DHT_P2P_GET (147)
- BType uint32 `order:"big"` // content type of the
payload
+ MsgHeader
+ BType enums.BlockType `order:"big"` // content type of the
payload
Flags uint16 `order:"big"` // processing flags
HopCount uint16 `order:"big"` // number of hops so far
ReplLevel uint16 `order:"big"` // Replication level
@@ -62,9 +62,8 @@ type DHTP2PGetMsg struct {
// NewDHTP2PGetMsg creates an empty DHT-P2P-Get message
func NewDHTP2PGetMsg() *DHTP2PGetMsg {
return &DHTP2PGetMsg{
- MsgSize: 208, // message size without
ResFiter and XQuery
- MsgType: DHT_P2P_GET, // DHT_P2P_GET (147)
- BType: 0, // no block type defined
+ MsgHeader: MsgHeader{208, enums.MSG_DHT_P2P_GET},
+ BType: enums.BLOCK_TYPE_ANY, // no block type defined
Flags: 0, // no flags defined
HopCount: 0, // no hops
ReplLevel: 0, // no replication level
defined
@@ -78,13 +77,8 @@ func NewDHTP2PGetMsg() *DHTP2PGetMsg {
// String returns a human-readable representation of the message.
func (m *DHTP2PGetMsg) String() string {
- return fmt.Sprintf("DHTP2PGetMsg{btype=%s,hops=%d,flags=%d}",
- enums.BlockType(m.BType).String(), m.HopCount, m.Flags)
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTP2PGetMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTP2PGetMsg{btype=%s,hops=%d,flags=%s}",
+ m.BType, m.HopCount, DHTFlags(m.Flags))
}
// Update message (forwarding)
@@ -92,8 +86,7 @@ func (m *DHTP2PGetMsg) Update(pf *blocks.PeerFilter, rf
blocks.ResultFilter, hop
buf := rf.Bytes()
ns := uint16(len(buf))
return &DHTP2PGetMsg{
- MsgSize: m.MsgSize - m.RfSize + ns,
- MsgType: DHT_P2P_GET,
+ MsgHeader: MsgHeader{m.MsgSize - m.RfSize + ns,
enums.MSG_DHT_P2P_GET},
BType: m.BType,
Flags: m.Flags,
HopCount: hop,
@@ -113,14 +106,13 @@ func (m *DHTP2PGetMsg) Update(pf *blocks.PeerFilter, rf
blocks.ResultFilter, hop
// DHTP2PPutMsg wire layout
type DHTP2PPutMsg struct {
- MsgSize uint16 `order:"big"` // total size of
message
- MsgType uint16 `order:"big"` // DHT_P2P_PUT (146)
- BType uint32 `order:"big"` // block type
+ MsgHeader
+ BType enums.BlockType `order:"big"` // block type
Flags uint16 `order:"big"` // processing flags
HopCount uint16 `order:"big"` // message hops
ReplLvl uint16 `order:"big"` // replication level
PathL uint16 `order:"big"` // path length
- Expiration util.AbsoluteTime `` // expiration date
+ Expire util.AbsoluteTime `` // expiration date
PeerFilter *blocks.PeerFilter `` // peer bloomfilter
Key *crypto.HashCode `` // query key to block
TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin
(if TRUNCATED flag set)
@@ -132,14 +124,13 @@ type DHTP2PPutMsg struct {
// NewDHTP2PPutMsg creates an empty new DHTP2PPutMsg
func NewDHTP2PPutMsg() *DHTP2PPutMsg {
return &DHTP2PPutMsg{
- MsgSize: 218, // total size without
path and block data
- MsgType: DHT_P2P_PUT, // DHT_P2P_PUT (146)
- BType: 0, // block type
+ MsgHeader: MsgHeader{218, enums.MSG_DHT_P2P_PUT},
+ BType: enums.BLOCK_TYPE_ANY, // block type
Flags: 0, // processing flags
HopCount: 0, // message hops
ReplLvl: 0, // replication level
PathL: 0, // no PUT path
- Expiration: util.AbsoluteTimeNever(), // expiration date
+ Expire: util.AbsoluteTimeNever(), // expiration date
PeerFilter: blocks.NewPeerFilter(), // peer bloom filter
Key: crypto.NewHashCode(nil), // query key
TruncOrigin: nil, // no truncated path
@@ -168,7 +159,7 @@ func (m *DHTP2PPutMsg) Update(p *path.Path, pf
*blocks.PeerFilter, hop uint16) *
msg.Flags = m.Flags
msg.HopCount = hop
msg.PathL = p.NumList
- msg.Expiration = m.Expiration
+ msg.Expire = m.Expire
msg.PeerFilter = pf
msg.Key = m.Key.Clone()
msg.TruncOrigin = p.TruncOrigin
@@ -186,7 +177,7 @@ func (m *DHTP2PPutMsg) Update(p *path.Path, pf
*blocks.PeerFilter, hop uint16) *
// Path returns the current path from message
func (m *DHTP2PPutMsg) Path(sender *util.PeerID) *path.Path {
// create a "real" path list from message data
- pth := path.NewPath(crypto.Hash(m.Block), m.Expiration)
+ pth := path.NewPath(crypto.Hash(m.Block), m.Expire)
// return empty path if recording is switched off
if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 {
@@ -211,7 +202,7 @@ func (m *DHTP2PPutMsg) Path(sender *util.PeerID) *path.Path
{
// handle last hop signature
if m.LastSig == nil {
logger.Printf(logger.WARN, "[path] - last hop signature
missing - path reset")
- return path.NewPath(crypto.Hash(m.Block), m.Expiration)
+ return path.NewPath(crypto.Hash(m.Block), m.Expire)
}
pth.Flags |= path.PathLastHop
pth.LastSig = m.LastSig
@@ -269,13 +260,8 @@ func (m *DHTP2PPutMsg) SetPath(p *path.Path) {
// String returns a human-readable representation of the message.
func (m *DHTP2PPutMsg) String() string {
- return fmt.Sprintf("DHTP2PPutMsg{btype=%s,hops=%d,flags=%d}",
- enums.BlockType(m.BType).String(), m.HopCount, m.Flags)
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTP2PPutMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTP2PPutMsg{btype=%s,hops=%d,flags=%s}",
+ m.BType, m.HopCount, DHTFlags(m.Flags))
}
//----------------------------------------------------------------------
@@ -285,32 +271,31 @@ func (m *DHTP2PPutMsg) Header() *Header {
// DHTP2PResultMsg wire layout
type DHTP2PResultMsg struct {
- MsgSize uint16 `order:"big"` // total size of
message
- MsgType uint16 `order:"big"` // DHT_P2P_RESULT
(148)
- BType uint32 `order:"big"` // Block type of
result
- Flags uint32 `order:"big"` // Message flags
+ MsgHeader
+ BType enums.BlockType `order:"big"` // Block type of
result
+ Flags uint16 `order:"big"` // Message flags
+ Reserved uint16 `order:"big"` // Reserved
PutPathL uint16 `order:"big"` // size of PUTPATH
field
GetPathL uint16 `order:"big"` // size of GETPATH
field
- Expires util.AbsoluteTime `` // expiration date
+ Expire util.AbsoluteTime `` // expiration date
Query *crypto.HashCode `` // Query key for
block
TruncOrigin *util.PeerID `opt:"(IsUsed)"` // truncated origin
(if TRUNCATED flag set)
PathList []*path.Entry `size:"(NumPath)"` // PATH
- LastSig *util.PeerSignature `size:"(IsUsed)"` // signature of last
hop (if RECORD_ROUTE flag is set)
+ LastSig *util.PeerSignature `opt:"(IsUsed)"` // signature of last
hop (if RECORD_ROUTE flag is set)
Block []byte `size:"*"` // block data
}
// NewDHTP2PResultMsg creates a new empty DHTP2PResultMsg
func NewDHTP2PResultMsg() *DHTP2PResultMsg {
return &DHTP2PResultMsg{
- MsgSize: 88, // size of empty
message
- MsgType: DHT_P2P_RESULT, // DHT_P2P_RESULT
(148)
- BType: uint32(enums.BLOCK_TYPE_ANY), // type of returned
block
- TruncOrigin: nil, // no truncated
origin
- PutPathL: 0, // empty putpath
- GetPathL: 0, // empty getpath
- PathList: nil, // empty path list
(put+get)
- LastSig: nil, // no recorded route
- Block: nil, // empty block
+ MsgHeader: MsgHeader{88, enums.MSG_DHT_P2P_RESULT},
+ BType: enums.BLOCK_TYPE_ANY, // type of returned block
+ TruncOrigin: nil, // no truncated origin
+ PutPathL: 0, // empty putpath
+ GetPathL: 0, // empty getpath
+ PathList: nil, // empty path list (put+get)
+ LastSig: nil, // no recorded route
+ Block: nil, // empty block
}
}
@@ -337,7 +322,7 @@ func (m *DHTP2PResultMsg) NumPath(field string) uint {
// Path returns the current path from message
func (m *DHTP2PResultMsg) Path(sender *util.PeerID) *path.Path {
// create a "real" path list from message data
- pth := path.NewPath(crypto.Hash(m.Block), m.Expires)
+ pth := path.NewPath(crypto.Hash(m.Block), m.Expire)
// return empty path if recording is switched off
if m.Flags&enums.DHT_RO_RECORD_ROUTE == 0 {
@@ -371,7 +356,7 @@ func (m *DHTP2PResultMsg) Path(sender *util.PeerID)
*path.Path {
// handle last hop signature
if m.LastSig == nil {
logger.Printf(logger.WARN, "[path] - last hop signature
missing - path reset")
- return path.NewPath(crypto.Hash(m.Block), m.Expires)
+ return path.NewPath(crypto.Hash(m.Block), m.Expire)
}
pth.Flags |= path.PathLastHop
pth.LastSig = m.LastSig
@@ -433,13 +418,12 @@ func (m *DHTP2PResultMsg) SetPath(p *path.Path) {
func (m *DHTP2PResultMsg) Update(pth *path.Path) *DHTP2PResultMsg {
// clone old message
msg := &DHTP2PResultMsg{
- MsgSize: m.MsgSize,
- MsgType: m.MsgType,
+ MsgHeader: MsgHeader{m.MsgSize, m.MsgType},
BType: m.BType,
Flags: m.Flags,
PutPathL: m.PutPathL,
GetPathL: m.GetPathL,
- Expires: m.Expires,
+ Expire: m.Expire,
Query: m.Query.Clone(),
TruncOrigin: m.TruncOrigin,
PathList: util.Clone(m.PathList),
@@ -455,13 +439,8 @@ func (m *DHTP2PResultMsg) Update(pth *path.Path)
*DHTP2PResultMsg {
// String returns a human-readable representation of the message.
func (m *DHTP2PResultMsg) String() string {
- return fmt.Sprintf("DHTP2PResultMsg{btype=%s,putl=%d,getl=%d}",
- enums.BlockType(m.BType).String(), m.PutPathL, m.GetPathL)
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTP2PResultMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTP2PResultMsg{btype=%s,putl=%d,getl=%d,flags=%s}",
+ m.BType, m.PutPathL, m.GetPathL, DHTFlags(uint16(m.Flags)))
}
//----------------------------------------------------------------------
@@ -474,26 +453,26 @@ func (m *DHTP2PResultMsg) Header() *Header {
// DHTP2PHelloMsg is a message send by peers to announce their presence
type DHTP2PHelloMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // DHT_P2P_HELLO (157)
+ MsgHeader
Reserved uint16 `order:"big"` // Reserved for further use
NumAddr uint16 `order:"big"` // Number of addresses in
list
Signature *util.PeerSignature `` // Signature
- Expires util.AbsoluteTime `` // expiration time
+ Expire util.AbsoluteTime `` // expiration time
AddrList []byte `size:"*"` // List of end-point
addresses (HelloAddress)
}
// NewHelloMsgDHT creates an empty DHT_P2P_HELLO message.
func NewDHTP2PHelloMsg() *DHTP2PHelloMsg {
- // return empty HelloMessage
- exp := time.Now().Add(HelloAddressExpiration)
+ // return empty HelloMessage with set expire date
+ t := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration))
+ exp := util.NewAbsoluteTimeEpoch(t.Epoch())
+
return &DHTP2PHelloMsg{
- MsgSize: 80, // size without
'AddrList'
- MsgType: DHT_P2P_HELLO, // DHT_P2P_HELLO (157)
+ MsgHeader: MsgHeader{80, enums.MSG_DHT_P2P_HELLO},
Reserved: 0, // not used here
NumAddr: 0, // start with empty
address list
Signature: util.NewPeerSignature(nil), // signature
- Expires: util.NewAbsoluteTime(exp), // default expiration
+ Expire: exp, // default expiration
AddrList: make([]byte, 0), // list of addresses
}
}
@@ -511,7 +490,7 @@ func (m *DHTP2PHelloMsg) Addresses() (list []*util.Address,
err error) {
if addr, err = util.ParseAddress(as); err != nil {
return
}
- addr.Expires = m.Expires
+ addr.Expire = m.Expire
list = append(list, addr)
num++
}
@@ -525,38 +504,26 @@ func (m *DHTP2PHelloMsg) Addresses() (list
[]*util.Address, err error) {
// SetAddresses adds addresses to the HELLO message.
func (m *DHTP2PHelloMsg) SetAddresses(list []*util.Address) {
// write addresses as blob and track earliest expiration
- exp := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration))
+ t := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration))
+ exp := util.NewAbsoluteTimeEpoch(t.Epoch())
wrt := new(bytes.Buffer)
for _, addr := range list {
// check if address expires before current expire
- if exp.Compare(addr.Expires) > 0 {
- exp = addr.Expires
+ if exp.Compare(addr.Expire) > 0 {
+ exp = addr.Expire
}
n, _ := wrt.Write([]byte(addr.URI()))
wrt.WriteByte(0)
m.MsgSize += uint16(n + 1)
}
m.AddrList = wrt.Bytes()
- m.Expires = exp
+ m.Expire = exp
m.NumAddr = uint16(len(list))
}
// String returns a human-readable representation of the message.
func (m *DHTP2PHelloMsg) String() string {
- addrs, _ := m.Addresses()
- aList := ""
- for i, a := range addrs {
- if i > 0 {
- aList += ","
- }
- aList += a.URI()
- }
- return fmt.Sprintf("DHTP2PHelloMsg{expire:%s,addrs=%d:[%s]}",
m.Expires, m.NumAddr, aList)
-}
-
-// Header returns the message header in a separate instance.
-func (m *DHTP2PHelloMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("DHTP2PHelloMsg{expire:%s,addrs=[%d]}", m.Expire,
m.NumAddr)
}
// Verify the message signature
@@ -590,7 +557,7 @@ func (m *DHTP2PHelloMsg) SignedData() []byte {
err := binary.Write(buf, binary.BigEndian, size)
if err == nil {
if err = binary.Write(buf, binary.BigEndian, purpose); err ==
nil {
- if err = binary.Write(buf, binary.BigEndian,
m.Expires.Epoch()*1000000); err == nil {
+ if err = binary.Write(buf, binary.BigEndian, m.Expire);
err == nil {
if n, err = buf.Write(hAddr[:]); err == nil {
if n != len(hAddr[:]) {
err = errors.New("write failed")
@@ -604,3 +571,26 @@ func (m *DHTP2PHelloMsg) SignedData() []byte {
}
return buf.Bytes()
}
+
+//----------------------------------------------------------------------
+// Helper functions
+//----------------------------------------------------------------------
+
+// get human-readable flags
+func DHTFlags(flags uint16) string {
+ var list []string
+ if flags&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0 {
+ list = append(list, "DEMUX")
+ }
+ if flags&enums.DHT_RO_RECORD_ROUTE != 0 {
+ list = append(list, "ROUTE")
+ }
+ if flags&enums.DHT_RO_FIND_APPROXIMATE != 0 {
+ list = append(list, "APPROX")
+ }
+ if flags&enums.DHT_RO_TRUNCATED != 0 {
+ list = append(list, "TRUNC")
+ }
+ s := strings.Join(list, "|")
+ return "<" + s + ">"
+}
diff --git a/src/gnunet/message/msg_gns.go b/src/gnunet/message/msg_gns.go
index 0f285ee..0b96e88 100644
--- a/src/gnunet/message/msg_gns.go
+++ b/src/gnunet/message/msg_gns.go
@@ -34,27 +34,25 @@ import (
// LookupMsg is a request message for a GNS name lookup
type LookupMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // GNS_LOOKUP (500)
+ MsgHeader
ID uint32 `order:"big"` // Unique identifier for this
request (for key collisions).
Zone *crypto.ZoneKey `` // 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
+ RType 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() *LookupMsg {
return &LookupMsg{
- MsgSize: 48, // record size with no name
- MsgType: GNS_LOOKUP,
- ID: 0,
- Zone: nil,
- Options: uint16(enums.GNS_LO_DEFAULT),
- Reserved: 0,
- Type: uint32(enums.GNS_TYPE_ANY),
- Name: nil,
+ MsgHeader: MsgHeader{48, enums.MSG_GNS_LOOKUP},
+ ID: 0,
+ Zone: nil,
+ Options: uint16(enums.GNS_LO_DEFAULT),
+ Reserved: 0,
+ RType: uint32(enums.GNS_TYPE_ANY),
+ Name: nil,
}
}
@@ -79,12 +77,7 @@ func (m *LookupMsg) GetName() string {
func (m *LookupMsg) String() string {
return fmt.Sprintf(
"GNSLookupMsg{Id=%d,Zone=%s,Options=%d,Type=%d,Name=%s}",
- m.ID, m.Zone.ID(), m.Options, m.Type, m.GetName())
-}
-
-// Header returns the message header in a separate instance.
-func (m *LookupMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ m.ID, m.Zone.ID(), m.Options, m.RType, m.GetName())
}
//----------------------------------------------------------------------
@@ -128,14 +121,14 @@ func (rs *RecordSet) SetPadding() {
rs.Padding = make([]byte, n-size)
}
-// Expires returns the earliest expiration timestamp for the records.
-func (rs *RecordSet) Expires() util.AbsoluteTime {
+// Expire returns the earliest expiration timestamp for the records.
+func (rs *RecordSet) Expire() util.AbsoluteTime {
var expires util.AbsoluteTime
for i, rr := range rs.Records {
if i == 0 {
- expires = rr.Expires
- } else if rr.Expires.Compare(expires) < 0 {
- expires = rr.Expires
+ expires = rr.Expire
+ } else if rr.Expire.Compare(expires) < 0 {
+ expires = rr.Expire
}
}
return expires
@@ -144,23 +137,22 @@ func (rs *RecordSet) Expires() util.AbsoluteTime {
// ResourceRecord is the GNUnet-specific representation of resource
// records (not to be confused with DNS resource records).
type ResourceRecord struct {
- Expires util.AbsoluteTime // 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
+ Expire util.AbsoluteTime // Expiration time for the record
+ Size uint32 `order:"big"` // Number of bytes in 'Data'
+ RType uint32 `order:"big"` // Type of the GNS/DNS record
+ Flags uint32 `order:"big"` // Flags for the record
+ Data []byte `size:"Size"` // Record data
}
// String returns a human-readable representation of the message.
func (r *ResourceRecord) String() string {
return
fmt.Sprintf("GNSResourceRecord{type=%s,expire=%s,flags=%d,size=%d}",
- enums.GNSType(r.Type).String(), r.Expires, r.Flags, r.Size)
+ enums.GNSType(r.RType).String(), r.Expire, r.Flags, r.Size)
}
// LookupResultMsg is a response message for a GNS name lookup request
type LookupResultMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // GNS_LOOKUP_RESULT (501)
+ MsgHeader
ID uint32 `order:"big"` // Unique identifier for this
request (for key collisions).
Count uint32 `order:"big"` // The number of records
contained in response
Records []*ResourceRecord `size:"Count"` // GNS resource records
@@ -169,11 +161,10 @@ type LookupResultMsg struct {
// NewGNSLookupResultMsg returns a new lookup result message
func NewGNSLookupResultMsg(id uint32) *LookupResultMsg {
return &LookupResultMsg{
- MsgSize: 12, // Empty result (no records)
- MsgType: GNS_LOOKUP_RESULT,
- ID: id,
- Count: 0,
- Records: make([]*ResourceRecord, 0),
+ MsgHeader: MsgHeader{12, enums.MSG_GNS_LOOKUP_RESULT},
+ ID: id,
+ Count: 0,
+ Records: make([]*ResourceRecord, 0),
}
}
@@ -195,6 +186,6 @@ func (m *LookupResultMsg) String() string {
}
// Header returns the message header in a separate instance.
-func (m *LookupResultMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+func (m *LookupResultMsg) Header() *MsgHeader {
+ return &MsgHeader{m.MsgSize, m.MsgType}
}
diff --git a/src/gnunet/message/msg_gns_test.go
b/src/gnunet/message/msg_gns_test.go
index ff985c3..034e1a8 100644
--- a/src/gnunet/message/msg_gns_test.go
+++ b/src/gnunet/message/msg_gns_test.go
@@ -54,22 +54,22 @@ func TestRecordsetPKEY(t *testing.T) {
Count: 2,
Records: []*ResourceRecord{
{
- Expires: util.AbsoluteTime{
+ Expire: util.AbsoluteTime{
Val: uint64(14888744139323793),
},
Size: 4,
- Type: 1,
+ RType: 1,
Flags: 0,
Data: []byte{
0x01, 0x02, 0x03, 0x04,
},
},
{
- Expires: util.AbsoluteTime{
+ Expire: util.AbsoluteTime{
Val: uint64(26147096139323793),
},
Size: 36,
- Type: crypto.ZONE_PKEY,
+ RType: crypto.ZONE_PKEY,
Flags: 2,
Data: []byte{
0x00, 0x01, 0x00, 0x00,
@@ -164,7 +164,7 @@ func TestRecordsetPKEY(t *testing.T) {
}
// check symmetric keys and nonce
- expires := RECSET.Expires()
+ expires := RECSET.Expire()
skey := zk.BlockKey(LABEL, expires)
if !bytes.Equal(skey[32:], NONCE) {
t.Logf("nonce = %s\n", hex.EncodeToString(skey[32:]))
@@ -214,22 +214,22 @@ func TestRecordsetEDKEY(t *testing.T) {
Count: 2,
Records: []*ResourceRecord{
{
- Expires: util.AbsoluteTime{
+ Expire: util.AbsoluteTime{
Val: uint64(2463385894000000),
},
Size: 4,
- Type: 1,
+ RType: 1,
Flags: 0,
Data: []byte{
0x01, 0x02, 0x03, 0x04,
},
},
{
- Expires: util.AbsoluteTime{
+ Expire: util.AbsoluteTime{
Val: uint64(49556645701000000),
},
Size: 36,
- Type: uint32(enums.GNS_TYPE_NICK),
+ RType: uint32(enums.GNS_TYPE_NICK),
Flags: 2,
Data: []byte{
0x4d, 0x79, 0x20, 0x4e, 0x69,
0x63, 0x6b, 0x00,
@@ -327,7 +327,7 @@ func TestRecordsetEDKEY(t *testing.T) {
}
// check symmetric keys and nonce
- expires := RECSET.Expires()
+ expires := RECSET.Expire()
skey := zk.BlockKey(LABEL, expires)
if !bytes.Equal(skey[32:], NONCE) {
t.Logf("nonce = %s\n", hex.EncodeToString(skey[32:]))
diff --git a/src/gnunet/message/msg_hello.go b/src/gnunet/message/msg_hello.go
index fdd9696..4cc8712 100644
--- a/src/gnunet/message/msg_hello.go
+++ b/src/gnunet/message/msg_hello.go
@@ -22,6 +22,7 @@ import (
"bytes"
"encoding/binary"
"fmt"
+ "gnunet/enums"
"gnunet/util"
"io"
"time"
@@ -43,8 +44,8 @@ type HelloAddress struct {
func NewHelloAddress(a *util.Address) *HelloAddress {
// use default expiration time, but adjust it if address expires earlier
exp := util.NewAbsoluteTime(time.Now().Add(HelloAddressExpiration))
- if exp.Compare(a.Expires) > 0 {
- exp = a.Expires
+ if exp.Compare(a.Expire) > 0 {
+ exp = a.Expire
}
// convert address
addr := &HelloAddress{
@@ -101,7 +102,7 @@ func ParseHelloAddr(rdr io.Reader) (a *HelloAddress, err
error) {
// Wrap a HelloAddress into a uitl.Address
func (a *HelloAddress) Wrap() (addr *util.Address) {
addr = util.NewAddress(a.transport, string(a.address))
- addr.Expires = a.expires
+ addr.Expire = a.expires
return
}
@@ -140,8 +141,7 @@ func (a *HelloAddress) Bytes() []byte {
// HelloMsg is a message send by peers to announce their presence
type HelloMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // HELLO (17)
+ MsgHeader
FriendsOnly uint32 `order:"big"` // Do not gossip this HELLO
message
Peer *util.PeerID `` // peer identifier for addresses
AddrList []byte `size:"*"` // List of end-point addresses
(HelloAddress)
@@ -155,8 +155,7 @@ func NewHelloMsg(peer *util.PeerID) *HelloMsg {
}
// return empty HelloMessage
return &HelloMsg{
- MsgSize: 40, // size without 'AddrList'
- MsgType: HELLO, // HELLO (17)
+ MsgHeader: MsgHeader{40, enums.MSG_HELLO},
FriendsOnly: 0, // not used here
Peer: peer, // associated peer
AddrList: make([]byte, 0), // list of addresses
@@ -194,8 +193,3 @@ func (m *HelloMsg) SetAddresses(list []*HelloAddress) {
}
m.AddrList = wrt.Bytes()
}
-
-// Header returns the message header in a separate instance.
-func (m *HelloMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
diff --git a/src/gnunet/message/msg_namecache.go
b/src/gnunet/message/msg_namecache.go
index c36ec7c..ea413a7 100644
--- a/src/gnunet/message/msg_namecache.go
+++ b/src/gnunet/message/msg_namecache.go
@@ -22,6 +22,7 @@ import (
"encoding/hex"
"fmt"
"gnunet/crypto"
+ "gnunet/enums"
"gnunet/service/dht/blocks"
"gnunet/util"
)
@@ -32,10 +33,9 @@ import (
// NamecacheLookupMsg is request message for lookups in local namecache
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
+ MsgHeader
+ ID uint32 `order:"big"` // Request Id
+ Query *crypto.HashCode // Query data
}
// NewNamecacheLookupMsg creates a new default message.
@@ -44,22 +44,16 @@ func NewNamecacheLookupMsg(query *crypto.HashCode)
*NamecacheLookupMsg {
query = crypto.NewHashCode(nil)
}
return &NamecacheLookupMsg{
- MsgSize: 72,
- MsgType: NAMECACHE_LOOKUP_BLOCK,
- ID: 0,
- Query: query,
+ MsgHeader: MsgHeader{72, enums.MSG_NAMECACHE_LOOKUP_BLOCK},
+ ID: 0,
+ Query: query,
}
}
// String returns a human-readable representation of the message.
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 (m *NamecacheLookupMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ m.ID, hex.EncodeToString(m.Query.Data))
}
//----------------------------------------------------------------------
@@ -68,8 +62,7 @@ func (m *NamecacheLookupMsg) Header() *Header {
// NamecacheLookupResultMsg is the response message for namecache lookups.
type NamecacheLookupResultMsg struct {
- MsgSize uint16 `order:"big"` // total size of
message
- MsgType uint16 `order:"big"` //
NAMECACHE_LOOKUP_BLOCK_RESPONSE (432)
+ MsgHeader
ID uint32 `order:"big"` // Request Id
Expire util.AbsoluteTime `` // Expiration time
DerivedKeySig *crypto.ZoneSignature `` // Derived public key
@@ -79,8 +72,7 @@ type NamecacheLookupResultMsg struct {
// NewNamecacheLookupResultMsg creates a new default message.
func NewNamecacheLookupResultMsg() *NamecacheLookupResultMsg {
return &NamecacheLookupResultMsg{
- MsgSize: 112,
- MsgType: NAMECACHE_LOOKUP_BLOCK_RESPONSE,
+ MsgHeader: MsgHeader{112,
enums.MSG_NAMECACHE_LOOKUP_BLOCK_RESPONSE},
ID: 0,
Expire: *new(util.AbsoluteTime),
DerivedKeySig: nil,
@@ -94,19 +86,13 @@ func (m *NamecacheLookupResultMsg) String() string {
m.ID, m.Expire)
}
-// Header returns the message header in a separate instance.
-func (m *NamecacheLookupResultMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// NAMECACHE_CACHE_BLOCK
//----------------------------------------------------------------------
// NamecacheCacheMsg is the request message to put a name into the local cache.
type NamecacheCacheMsg struct {
- MsgSize uint16 `order:"big"` // total size of
message
- MsgType uint16 `order:"big"` //
NAMECACHE_CACHE_BLOCK (433)
+ MsgHeader
ID uint32 `order:"big"` // Request Id
Expire util.AbsoluteTime `` // Expiration time
DerivedKeySig *crypto.ZoneSignature `` // Derived public key
and signature
@@ -116,8 +102,7 @@ type NamecacheCacheMsg struct {
// NewNamecacheCacheMsg creates a new default message.
func NewNamecacheCacheMsg(block *blocks.GNSBlock) *NamecacheCacheMsg {
msg := &NamecacheCacheMsg{
- MsgSize: 108,
- MsgType: NAMECACHE_BLOCK_CACHE,
+ MsgHeader: MsgHeader{108, enums.MSG_NAMECACHE_BLOCK_CACHE},
ID: 0,
Expire: *new(util.AbsoluteTime),
DerivedKeySig: nil,
@@ -140,30 +125,23 @@ func (m *NamecacheCacheMsg) String() string {
m.ID, m.Expire)
}
-// Header returns the message header in a separate instance.
-func (m *NamecacheCacheMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// NAMECACHE_BLOCK_CACHE_RESPONSE
//----------------------------------------------------------------------
// NamecacheCacheResponseMsg is the response message for a put request
type NamecacheCacheResponseMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // NAMECACHE_LOOKUP_BLOCK_RESPONSE (432)
- ID uint32 `order:"big"` // Request Id
- Result int32 `order:"big"` // Result code
+ MsgHeader
+ ID uint32 `order:"big"` // Request Id
+ Result int32 `order:"big"` // Result code
}
// NewNamecacheCacheResponseMsg creates a new default message.
func NewNamecacheCacheResponseMsg() *NamecacheCacheResponseMsg {
return &NamecacheCacheResponseMsg{
- MsgSize: 12,
- MsgType: NAMECACHE_BLOCK_CACHE_RESPONSE,
- ID: 0,
- Result: 0,
+ MsgHeader: MsgHeader{12,
enums.MSG_NAMECACHE_BLOCK_CACHE_RESPONSE},
+ ID: 0,
+ Result: 0,
}
}
@@ -172,8 +150,3 @@ func (m *NamecacheCacheResponseMsg) String() string {
return fmt.Sprintf("NamecacheCacheResponseMsg{id=%d,result=%d}",
m.ID, m.Result)
}
-
-// Header returns the message header in a separate instance.
-func (m *NamecacheCacheResponseMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
diff --git a/src/gnunet/message/msg_revocation.go
b/src/gnunet/message/msg_revocation.go
index 90f8dd1..aaef0d4 100644
--- a/src/gnunet/message/msg_revocation.go
+++ b/src/gnunet/message/msg_revocation.go
@@ -22,6 +22,7 @@ import (
"fmt"
"gnunet/crypto"
+ "gnunet/enums"
"gnunet/util"
)
@@ -31,8 +32,7 @@ import (
// RevocationQueryMsg is a request message to check if a key is revoked
type RevocationQueryMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // REVOCATION_QUERY (636)
+ MsgHeader
Reserved uint32 `order:"big"` // Reserved for future use
Zone *crypto.ZoneKey // Zone that is to be checked for revocation
}
@@ -40,10 +40,9 @@ type RevocationQueryMsg struct {
// NewRevocationQueryMsg creates a new message for a given zone.
func NewRevocationQueryMsg(zkey *crypto.ZoneKey) *RevocationQueryMsg {
return &RevocationQueryMsg{
- MsgSize: 40,
- MsgType: REVOCATION_QUERY,
- Reserved: 0,
- Zone: zkey,
+ MsgHeader: MsgHeader{40, enums.MSG_REVOCATION_QUERY},
+ Reserved: 0,
+ Zone: zkey,
}
}
@@ -52,20 +51,14 @@ func (m *RevocationQueryMsg) String() string {
return fmt.Sprintf("RevocationQueryMsg{zone=%s}", m.Zone.ID())
}
-// Header returns the message header in a separate instance.
-func (m *RevocationQueryMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// REVOCATION_QUERY_RESPONSE
//----------------------------------------------------------------------
// RevocationQueryResponseMsg is a response message for revocation checks.
type RevocationQueryResponseMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // REVOCATION_QUERY_RESPONSE (637)
- Valid uint32 `order:"big"` // revoked(0), valid(1)
+ MsgHeader
+ Valid uint32 `order:"big"` // revoked(0), valid(1)
}
// NewRevocationQueryResponseMsg creates a new response for a query.
@@ -75,9 +68,8 @@ func NewRevocationQueryResponseMsg(revoked bool)
*RevocationQueryResponseMsg {
valid = 0
}
return &RevocationQueryResponseMsg{
- MsgSize: 8,
- MsgType: REVOCATION_QUERY_RESPONSE,
- Valid: uint32(valid),
+ MsgHeader: MsgHeader{8, enums.MSG_REVOCATION_QUERY_RESPONSE},
+ Valid: uint32(valid),
}
}
@@ -86,19 +78,13 @@ func (m *RevocationQueryResponseMsg) String() string {
return fmt.Sprintf("RevocationQueryResponseMsg{valid=%d}", m.Valid)
}
-// Header returns the message header in a separate instance.
-func (m *RevocationQueryResponseMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// REVOCATION_REVOKE
//----------------------------------------------------------------------
// RevocationRevokeMsg is a request to revoke a given key with PoW data
type RevocationRevokeMsg struct {
- MsgSize uint16 `order:"big"` // total size
of message
- MsgType uint16 `order:"big"` //
REVOCATION_REVOKE (638)
+ MsgHeader
Timestamp util.AbsoluteTime `` // Timestamp
of revocation creation
TTL util.RelativeTime `` // TTL of
revocation
PoWs []uint64 `size:"32" order:"big"` // (Sorted)
list of PoW values
@@ -108,8 +94,7 @@ type RevocationRevokeMsg struct {
// NewRevocationRevokeMsg creates a new message for a given zone.
func NewRevocationRevokeMsg(zsig *crypto.ZoneSignature) *RevocationRevokeMsg {
return &RevocationRevokeMsg{
- MsgSize: 364,
- MsgType: REVOCATION_REVOKE,
+ MsgHeader: MsgHeader{364, enums.MSG_REVOCATION_REVOKE},
Timestamp: util.AbsoluteTimeNow(),
TTL: util.RelativeTime{},
PoWs: make([]uint64, 32),
@@ -119,12 +104,8 @@ func NewRevocationRevokeMsg(zsig *crypto.ZoneSignature)
*RevocationRevokeMsg {
// String returns a human-readable representation of the message.
func (m *RevocationRevokeMsg) String() string {
- return fmt.Sprintf("RevocationRevokeMsg{zone=%s}", m.ZoneKeySig.ID())
-}
-
-// Header returns the message header in a separate instance.
-func (m *RevocationRevokeMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
+ return fmt.Sprintf("RevocationRevokeMsg{zone=%s,expire=%s}",
+ m.ZoneKeySig.ID(), m.Timestamp.AddRelative(m.TTL))
}
//----------------------------------------------------------------------
@@ -133,8 +114,7 @@ func (m *RevocationRevokeMsg) Header() *Header {
// RevocationRevokeResponseMsg is a response message for a revocation request
type RevocationRevokeResponseMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // REVOCATION_REVOKE_RESPONSE (639)
+ MsgHeader
Success uint32 `order:"big"` // Revoke successful? (0=no, 1=yes)
}
@@ -145,9 +125,8 @@ func NewRevocationRevokeResponseMsg(success bool)
*RevocationRevokeResponseMsg {
status = 1
}
return &RevocationRevokeResponseMsg{
- MsgSize: 8,
- MsgType: REVOCATION_QUERY_RESPONSE,
- Success: uint32(status),
+ MsgHeader: MsgHeader{8, enums.MSG_REVOCATION_QUERY_RESPONSE},
+ Success: uint32(status),
}
}
@@ -155,8 +134,3 @@ func NewRevocationRevokeResponseMsg(success bool)
*RevocationRevokeResponseMsg {
func (m *RevocationRevokeResponseMsg) String() string {
return fmt.Sprintf("RevocationRevokeResponseMsg{success=%v}", m.Success
== 1)
}
-
-// Header returns the message header in a separate instance.
-func (m *RevocationRevokeResponseMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
diff --git a/src/gnunet/message/msg_transport.go
b/src/gnunet/message/msg_transport.go
index fca651f..410e34c 100644
--- a/src/gnunet/message/msg_transport.go
+++ b/src/gnunet/message/msg_transport.go
@@ -37,9 +37,8 @@ import (
// TransportTCPWelcomeMsg is a welcome message for new TCP connections.
type TransportTCPWelcomeMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_TCP_WELCOME (61)
- PeerID *util.PeerID // Peer identity (EdDSA public key)
+ MsgHeader
+ PeerID *util.PeerID // Peer identity (EdDSA public key)
}
// NewTransportTCPWelcomeMsg creates a new message for a given peer.
@@ -48,9 +47,8 @@ func NewTransportTCPWelcomeMsg(peerid *util.PeerID)
*TransportTCPWelcomeMsg {
peerid = util.NewPeerID(nil)
}
return &TransportTCPWelcomeMsg{
- MsgSize: 36,
- MsgType: TRANSPORT_TCP_WELCOME,
- PeerID: peerid,
+ MsgHeader: MsgHeader{36, enums.MSG_TRANSPORT_TCP_WELCOME},
+ PeerID: peerid,
}
}
@@ -59,11 +57,6 @@ func (m *TransportTCPWelcomeMsg) String() string {
return fmt.Sprintf("TransportTcpWelcomeMsg{peer=%s}", m.PeerID)
}
-// Header returns the message header in a separate instance.
-func (m *TransportTCPWelcomeMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_PING
//
@@ -75,8 +68,7 @@ func (m *TransportTCPWelcomeMsg) Header() *Header {
// TransportPingMsg is a PING request message
type TransportPingMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_PING (372)
+ MsgHeader
Challenge uint32 // Challenge code (to ensure fresh reply)
Target *util.PeerID // EdDSA public key (long-term) of target peer
Address []byte `size:"*"` // encoded address
@@ -89,8 +81,7 @@ func NewTransportPingMsg(target *util.PeerID, a
*util.Address) *TransportPingMsg
target = util.NewPeerID(nil)
}
m := &TransportPingMsg{
- MsgSize: uint16(40),
- MsgType: TRANSPORT_PING,
+ MsgHeader: MsgHeader{40, enums.MSG_TRANSPORT_PING},
Challenge: util.RndUInt32(),
Target: target,
Address: nil,
@@ -114,11 +105,6 @@ func (m *TransportPingMsg) String() string {
m.Target, a, m.Challenge)
}
-// Header returns the message header in a separate instance.
-func (m *TransportPingMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_PONG
//
@@ -160,8 +146,7 @@ func NewSignedAddress(a *util.Address) *SignedAddress {
// TransportPongMsg is a response message for a PING request
type TransportPongMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_PING (372)
+ MsgHeader
Challenge uint32 // Challenge code (to ensure fresh reply)
Signature []byte `size:"64"` // Signature of address
SignedBlock *SignedAddress // signed block of data
@@ -171,8 +156,7 @@ type TransportPongMsg struct {
// peer wants to be reached.
func NewTransportPongMsg(challenge uint32, a *util.Address) *TransportPongMsg {
m := &TransportPongMsg{
- MsgSize: 72,
- MsgType: TRANSPORT_PONG,
+ MsgHeader: MsgHeader{72, enums.MSG_TRANSPORT_PONG},
Challenge: challenge,
Signature: make([]byte, 64),
SignedBlock: new(SignedAddress),
@@ -195,11 +179,6 @@ func (m *TransportPongMsg) String() string {
return fmt.Sprintf("TransportPongMsg{addr=<unknown>,%d}", m.Challenge)
}
-// Header returns the message header in a separate instance.
-func (m *TransportPongMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
// Sign the address block of a pong message.
func (m *TransportPongMsg) Sign(prv *ed25519.PrivateKey) error {
data, err := data.Marshal(m.SignedBlock)
@@ -233,15 +212,13 @@ func (m *TransportPongMsg) Verify(pub *ed25519.PublicKey)
(bool, error) {
// SessionAckMsg is a message to acknowledge a session request
type SessionAckMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_SESSION_ACK (377)
+ MsgHeader
}
// NewSessionAckMsg creates an new message (no body required).
func NewSessionAckMsg() *SessionAckMsg {
return &SessionAckMsg{
- MsgSize: 16,
- MsgType: TRANSPORT_SESSION_ACK,
+ MsgHeader: MsgHeader{4, enums.MSG_TRANSPORT_SESSION_ACK},
}
}
@@ -250,19 +227,13 @@ func (m *SessionAckMsg) String() string {
return "SessionAck{}"
}
-// Header returns the message header in a separate instance.
-func (m *SessionAckMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_SESSION_SYN
//----------------------------------------------------------------------
// SessionSynMsg is a synchronization request message for sessions
type SessionSynMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN (375)
+ MsgHeader
Reserved uint32 `order:"big"` // reserved (=0)
Timestamp util.AbsoluteTime // usec epoch
}
@@ -270,8 +241,7 @@ type SessionSynMsg struct {
// NewSessionSynMsg creates a SYN request for the a session
func NewSessionSynMsg() *SessionSynMsg {
return &SessionSynMsg{
- MsgSize: 16,
- MsgType: TRANSPORT_SESSION_SYN,
+ MsgHeader: MsgHeader{16, enums.MSG_TRANSPORT_SESSION_SYN},
Reserved: 0,
Timestamp: util.AbsoluteTimeNow(),
}
@@ -282,19 +252,13 @@ func (m *SessionSynMsg) String() string {
return fmt.Sprintf("SessionSyn{timestamp=%s}", m.Timestamp)
}
-// Header returns the message header in a separate instance.
-func (m *SessionSynMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_SESSION_SYN_ACK
//----------------------------------------------------------------------
// SessionSynAckMsg responds to a SYN request message
type SessionSynAckMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_SESSION_SYN_ACK
(376)
+ MsgHeader
Reserved uint32 `order:"big"` // reserved (=0)
Timestamp util.AbsoluteTime // usec epoch
}
@@ -302,8 +266,7 @@ type SessionSynAckMsg struct {
// NewSessionSynAckMsg is an ACK for a SYN request
func NewSessionSynAckMsg() *SessionSynAckMsg {
return &SessionSynAckMsg{
- MsgSize: 16,
- MsgType: TRANSPORT_SESSION_SYN_ACK,
+ MsgHeader: MsgHeader{16, enums.MSG_TRANSPORT_SESSION_SYN_ACK},
Reserved: 0,
Timestamp: util.AbsoluteTimeNow(),
}
@@ -314,28 +277,22 @@ func (m *SessionSynAckMsg) String() string {
return fmt.Sprintf("SessionSynAck{timestamp=%s}", m.Timestamp)
}
-// Header returns the message header in a separate instance.
-func (m *SessionSynAckMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_SESSION_QUOTA
//----------------------------------------------------------------------
// SessionQuotaMsg is a message to announce quotas for a session
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
+ MsgHeader
+ Quota uint32 `order:"big"` // Quota in bytes per second
}
// NewSessionQuotaMsg announces a session quota to the other end of the
session.
func NewSessionQuotaMsg(quota uint32) *SessionQuotaMsg {
m := new(SessionQuotaMsg)
+ m.MsgSize = 8
+ m.MsgType = enums.MSG_TRANSPORT_SESSION_QUOTA
if quota > 0 {
- m.MsgSize = 8
- m.MsgType = TRANSPORT_SESSION_QUOTA
m.Quota = quota
}
return m
@@ -346,28 +303,21 @@ 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 (m *SessionQuotaMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_SESSION_KEEPALIVE
//----------------------------------------------------------------------
// SessionKeepAliveMsg is a message send by peers to keep a session alive.
type SessionKeepAliveMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE (381)
- Nonce uint32
+ MsgHeader
+ Nonce uint32
}
// NewSessionKeepAliveMsg creates a new request to keep a session.
func NewSessionKeepAliveMsg() *SessionKeepAliveMsg {
m := &SessionKeepAliveMsg{
- MsgSize: 8,
- MsgType: TRANSPORT_SESSION_KEEPALIVE,
- Nonce: util.RndUInt32(),
+ MsgHeader: MsgHeader{8, enums.MSG_TRANSPORT_SESSION_KEEPALIVE},
+ Nonce: util.RndUInt32(),
}
return m
}
@@ -377,28 +327,21 @@ func (m *SessionKeepAliveMsg) String() string {
return fmt.Sprintf("SessionKeepAliveMsg{%d}", m.Nonce)
}
-// Header returns the message header in a separate instance.
-func (m *SessionKeepAliveMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
-
//----------------------------------------------------------------------
// TRANSPORT_SESSION_KEEPALIVE_RESPONSE
//----------------------------------------------------------------------
// SessionKeepAliveRespMsg is a response for a peer to a "keep-alive" request.
type SessionKeepAliveRespMsg struct {
- MsgSize uint16 `order:"big"` // total size of message
- MsgType uint16 `order:"big"` // TRANSPORT_SESSION_KEEPALIVE_RESPONSE
(382)
- Nonce uint32
+ MsgHeader
+ Nonce uint32
}
// NewSessionKeepAliveRespMsg is a response message for a "keep session"
request.
func NewSessionKeepAliveRespMsg(nonce uint32) *SessionKeepAliveRespMsg {
m := &SessionKeepAliveRespMsg{
- MsgSize: 8,
- MsgType: TRANSPORT_SESSION_KEEPALIVE_RESPONSE,
- Nonce: nonce,
+ MsgHeader: MsgHeader{8,
enums.MSG_TRANSPORT_SESSION_KEEPALIVE_RESPONSE},
+ Nonce: nonce,
}
return m
}
@@ -407,8 +350,3 @@ func NewSessionKeepAliveRespMsg(nonce uint32)
*SessionKeepAliveRespMsg {
func (m *SessionKeepAliveRespMsg) String() string {
return fmt.Sprintf("SessionKeepAliveRespMsg{%d}", m.Nonce)
}
-
-// Header returns the message header in a separate instance.
-func (m *SessionKeepAliveRespMsg) Header() *Header {
- return &Header{m.MsgSize, m.MsgType}
-}
diff --git a/src/gnunet/message/types.go b/src/gnunet/message/types.go
deleted file mode 100644
index 6fa4d3a..0000000
--- a/src/gnunet/message/types.go
+++ /dev/null
@@ -1,840 +0,0 @@
-// This file is part of gnunet-go, a GNUnet-implementation in Golang.
-// Copyright (C) 2019-2022 Bernd Fix >Y<
-//
-// gnunet-go 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.
-//
-// gnunet-go 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/>.
-//
-// SPDX-License-Identifier: AGPL3.0-or-later
-
-//nolint:stylecheck // allow non-camel-case in constants
-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.
- DHT_P2P_HELLO = 157 // HELLO advertising a neighbours
addresses.
- DHT_CORE = 158 // Encapsulation of DHT messages in
CORE service.
- DHT_CLIENT_HELLO_URL = 159 // HELLO URL send between client and
service (in either direction).
- DHT_CLIENT_HELLO_GET = 161 // Client requests DHT service's
HELLO URL.
-
- //------------------------------------------------------------------
- // 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 equivalent 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 successfully 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/dht/blocks/filters.go
b/src/gnunet/service/dht/blocks/filters.go
index f617479..b3c7666 100644
--- a/src/gnunet/service/dht/blocks/filters.go
+++ b/src/gnunet/service/dht/blocks/filters.go
@@ -103,14 +103,14 @@ const (
// by the local peer.
type ResultFilter interface {
- // Add entry to filter
+ // Add block to filter
Add(Block)
// Contains returns true if block is filtered
Contains(Block) bool
// ContainsHash returns true if block hash is filtered
- ContainsHash(bh *crypto.HashCode) bool
+ ContainsHash(*crypto.HashCode) bool
// Bytes returns the binary representation of a result filter
Bytes() []byte
@@ -141,18 +141,19 @@ func NewGenericResultFilter() *GenericResultFilter {
// Add a block to the result filter.
func (rf *GenericResultFilter) Add(b Block) {
- rf.bf.Add(b.Bytes())
+ bh := crypto.Hash(b.Bytes())
+ rf.bf.Add(bh.Data)
}
// Contains returns true if a block is filtered
func (rf *GenericResultFilter) Contains(b Block) bool {
bh := crypto.Hash(b.Bytes())
- return rf.bf.Contains(bh.Bits)
+ return rf.bf.Contains(bh.Data)
}
// ContainsHash returns true if a block hash is filtered
func (rf *GenericResultFilter) ContainsHash(bh *crypto.HashCode) bool {
- return rf.bf.Contains(bh.Bits)
+ return rf.bf.Contains(bh.Data)
}
// Bytes returns the binary representation of a result filter
diff --git a/src/gnunet/service/dht/blocks/generic.go
b/src/gnunet/service/dht/blocks/generic.go
index c67213e..5741d57 100644
--- a/src/gnunet/service/dht/blocks/generic.go
+++ b/src/gnunet/service/dht/blocks/generic.go
@@ -19,7 +19,6 @@
package blocks
import (
- "encoding/hex"
"fmt"
"gnunet/crypto"
"gnunet/enums"
@@ -141,7 +140,7 @@ func (q *GenericQuery) Decrypt(b Block) error {
// String returns the human-readable representation of a block
func (q *GenericQuery) String() string {
- return fmt.Sprintf("GenericQuery{btype=%d,key=%s}", q.btype,
hex.EncodeToString(q.Key().Bits))
+ return fmt.Sprintf("GenericQuery{btype=%s,key=%s}", q.btype,
q.Key().Short())
}
// NewGenericQuery creates a simple Query from hash code.
@@ -154,47 +153,74 @@ func NewGenericQuery(key *crypto.HashCode, btype
enums.BlockType, flags uint16)
}
}
+//----------------------------------------------------------------------
+// Generic block (custom implementation unknown to gnunet-go)
//----------------------------------------------------------------------
-// GenericBlock is the block in simple binary representation
+// GenericBlock is used for custom blocks not known to the DHT
type GenericBlock struct {
- block []byte // block data
- btype enums.BlockType // block type
- expire util.AbsoluteTime // expiration date
+ BType enums.BlockType // block type
+ Expire_ util.AbsoluteTime // expiration time
+ Data []byte // block data
+}
+
+// NewGenericBlock creates a custom block instance
+func NewGenericBlock(btype enums.BlockType, expire util.AbsoluteTime, blk
[]byte) Block {
+ return &GenericBlock{
+ BType: btype,
+ Expire_: expire,
+ Data: util.Clone(blk),
+ }
}
-// Bytes returns the binary representation
+// Bytes returns the DHT block data (unstructured without type and
+// expiration information.
func (b *GenericBlock) Bytes() []byte {
- return b.block
+ return util.Clone(b.Data)
}
-// Type returns the block type
+// Return the block type
func (b *GenericBlock) Type() enums.BlockType {
- return b.btype
+ return b.BType
}
-// Expire returns the block expiration
+// Expire returns the block expiration (never for custom blocks)
func (b *GenericBlock) Expire() util.AbsoluteTime {
- return b.expire
+ return util.AbsoluteTimeNever()
+}
+
+// Verify the integrity of a block (optional). Override in custom query
+// types to implement block-specific integrity checks (see GNSBlock for
+// example). This verification is usually weaker than the verification
+// method from a Query (see GNSBlock.Verify for explanation).
+func (b *GenericBlock) Verify() (bool, error) {
+ return true, nil
}
// String returns the human-readable representation of a block
func (b *GenericBlock) String() string {
- return fmt.Sprintf("GenericBlock{type=%d,expires=%s,data=[%d]}",
- b.btype, b.expire.String(), len(b.block))
+ return fmt.Sprintf("Block{type=%s,expire=%s,data=[%d]", b.BType,
b.Expire_, len(b.Data))
}
-// Verify interface method implementation
-func (b *GenericBlock) Verify() (bool, error) {
- // no verification, no errors ;)
- return true, nil
-}
+//----------------------------------------------------------------------
+// Block factory: extend for custom block types
+//----------------------------------------------------------------------
+
+// Known block factories
+var (
+ blkFactory = map[enums.BlockType]func() Block{
+ enums.BLOCK_TYPE_GNS_NAMERECORD: NewGNSBlock,
+ enums.BLOCK_TYPE_DHT_URL_HELLO: NewHelloBlock,
+ }
+)
// NewGenericBlock creates a Block from binary data.
-func NewGenericBlock(buf []byte) *GenericBlock {
- return &GenericBlock{
- block: util.Clone(buf),
- btype: enums.BLOCK_TYPE_ANY, // unknown block type
- expire: util.AbsoluteTimeNever(), // never expires
+func NewBlock(btype enums.BlockType, expires util.AbsoluteTime, blk []byte) (b
Block, err error) {
+ fac, ok := blkFactory[btype]
+ if !ok {
+ return NewGenericBlock(btype, expires, blk), nil
}
+ b = fac()
+ err = data.Unmarshal(b, blk)
+ return
}
diff --git a/src/gnunet/service/dht/blocks/gns.go
b/src/gnunet/service/dht/blocks/gns.go
index 9668202..ec2cb71 100644
--- a/src/gnunet/service/dht/blocks/gns.go
+++ b/src/gnunet/service/dht/blocks/gns.go
@@ -128,7 +128,6 @@ type SignedGNSBlockData struct {
// An encrypted and signed container for GNS resource records that represents
// the "atomic" data structure associated with a GNS label in a given zone.
type GNSBlock struct {
- GenericBlock
// persistent
DerivedKeySig *crypto.ZoneSignature // Derived key used for signing
@@ -147,19 +146,28 @@ func (b *GNSBlock) Bytes() []byte {
return buf
}
+// Expire returns the expiration date of the block.
+func (b *GNSBlock) Expire() util.AbsoluteTime {
+ return b.Body.Expire
+}
+
+// Type returns the requested block type
+func (b *GNSBlock) Type() enums.BlockType {
+ return enums.BLOCK_TYPE_GNS_NAMERECORD
+}
+
// String returns the human-readable representation of a GNSBlock
func (b *GNSBlock) String() string {
return fmt.Sprintf("GNSBlock{Verified=%v,Decrypted=%v,data=[%d]}",
b.verified, b.decrypted, len(b.Body.Data))
}
-// NewBlock instantiates an empty GNS block
-func NewBlock() *GNSBlock {
+// NewGNSBlock instantiates an empty GNS block
+func NewGNSBlock() Block {
return &GNSBlock{
DerivedKeySig: nil,
Body: &SignedGNSBlockData{
Purpose: new(crypto.SignaturePurpose),
- Expire: *new(util.AbsoluteTime),
Data: nil,
},
checked: false,
diff --git a/src/gnunet/service/dht/blocks/hello.go
b/src/gnunet/service/dht/blocks/hello.go
index 082e914..2e23cfe 100644
--- a/src/gnunet/service/dht/blocks/hello.go
+++ b/src/gnunet/service/dht/blocks/hello.go
@@ -57,23 +57,32 @@ const helloPrefix = "gnunet://hello/"
type HelloBlock struct {
PeerID *util.PeerID `` // peer identifier
Signature *util.PeerSignature `` // signature
- Expires util.AbsoluteTime `` // Expiration date
+ Expire_ util.AbsoluteTime `` // Expiration date
AddrBin []byte `size:"*"` // raw address data
// transient attributes
addrs []*util.Address // cooked address data
}
-// NewHelloBlock initializes a new HELLO block (unsigned)
-func NewHelloBlock(peer *util.PeerID, addrs []*util.Address, ttl
time.Duration) *HelloBlock {
+// NewHelloBlock initializes an empty HELLO block
+func NewHelloBlock() Block {
+ return new(HelloBlock)
+}
+
+// InitHelloBlock initializes a new HELLO block (unsigned)
+func InitHelloBlock(peer *util.PeerID, addrs []*util.Address, ttl
time.Duration) *HelloBlock {
hb := new(HelloBlock)
hb.PeerID = peer
// limit expiration to second precision (HELLO-URL compatibility)
- hb.Expires =
util.NewAbsoluteTimeEpoch(uint64(time.Now().Add(ttl).Unix()))
+ hb.SetExpire(ttl)
hb.SetAddresses(addrs)
return hb
}
+func (h *HelloBlock) SetExpire(ttl time.Duration) {
+ h.Expire_ =
util.NewAbsoluteTimeEpoch(uint64(time.Now().Add(ttl).Unix()))
+}
+
// SetAddresses adds a bulk of addresses for this HELLO block.
func (h *HelloBlock) SetAddresses(a []*util.Address) {
if len(a) == 0 {
@@ -87,6 +96,9 @@ func (h *HelloBlock) SetAddresses(a []*util.Address) {
// Addresses returns the list of addresses
func (h *HelloBlock) Addresses() []*util.Address {
+ if h.addrs == nil {
+ h.finalize()
+ }
return util.Clone(h.addrs)
}
@@ -132,8 +144,8 @@ func ParseHelloBlockFromURL(u string, checkExpiry bool) (h
*HelloBlock, err erro
if exp, err = strconv.ParseUint(q[0], 10, 64); err != nil {
return
}
- h.Expires = util.NewAbsoluteTimeEpoch(exp)
- if checkExpiry && h.Expires.Expired() {
+ h.Expire_ = util.NewAbsoluteTimeEpoch(exp)
+ if checkExpiry && h.Expire_.Expired() {
err = ErrHelloExpired
return
}
@@ -228,13 +240,13 @@ func (h *HelloBlock) Bytes() []byte {
// Expire returns the block expiration
func (h *HelloBlock) Expire() util.AbsoluteTime {
- return h.Expires
+ return h.Expire_
}
// String returns the human-readable representation of a block
func (h *HelloBlock) String() string {
return fmt.Sprintf("HelloBlock{peer=%s,expires=%s,addrs=[%d]}",
- h.PeerID, h.Expires, len(h.Addresses()))
+ h.PeerID, h.Expire_, len(h.Addresses()))
}
// URL returns the HELLO URL for the data.
@@ -243,7 +255,7 @@ func (h *HelloBlock) URL() string {
helloPrefix,
h.PeerID.String(),
util.EncodeBinaryToString(h.Signature.Data),
- h.Expires.Epoch(),
+ h.Expire_.Epoch(),
)
for i, a := range h.addrs {
if i > 0 {
@@ -256,16 +268,16 @@ func (h *HelloBlock) URL() string {
return u
}
-// Equals returns true if two HELLOs are the same. The expiration
+// Equal returns true if two HELLOs are the same. The expiration
// timestamp is ignored in the comparison.
-func (h *HelloBlock) Equals(g *HelloBlock) bool {
- if !h.PeerID.Equals(g.PeerID) ||
- !util.Equals(h.Signature.Data, g.Signature.Data) ||
+func (h *HelloBlock) Equal(g *HelloBlock) bool {
+ if !h.PeerID.Equal(g.PeerID) ||
+ !util.Equal(h.Signature.Data, g.Signature.Data) ||
len(h.addrs) != len(g.addrs) {
return false
}
for i, a := range h.addrs {
- if !a.Equals(g.addrs[i]) {
+ if !a.Equal(g.addrs[i]) {
return false
}
}
@@ -303,7 +315,7 @@ func (h *HelloBlock) SignedData() []byte {
err := binary.Write(buf, binary.BigEndian, size)
if err == nil {
if err = binary.Write(buf, binary.BigEndian, purpose); err ==
nil {
- if err = binary.Write(buf, binary.BigEndian, h.Expires
/*.Epoch()*1000000*/); err == nil {
+ if err = binary.Write(buf, binary.BigEndian,
h.Expire_); err == nil {
if n, err = buf.Write(hAddr[:]); err == nil {
if n != len(hAddr[:]) {
err = errors.New("signed data
size mismatch")
@@ -346,7 +358,7 @@ func (bh *HelloBlockHandler) ValidateBlockKey(b Block, key
*crypto.HashCode) boo
logger.Println(logger.WARN, "[HelloHdlr] ValidateBlockKey: not
a HELLO block")
return false
}
- return key.Equals(bkey)
+ return key.Equal(bkey)
}
// DeriveBlockKey is used to synthesize the block key from the block
@@ -473,7 +485,7 @@ func (rf *HelloResultFilter) Contains(b Block) bool {
// ContainsHash checks if a block hash is contained in the result filter
func (rf *HelloResultFilter) ContainsHash(bh *crypto.HashCode) bool {
- return rf.bf.Contains(bh.Bits)
+ return rf.bf.Contains(bh.Data)
}
// Bytes returns a binary representation of a HELLO result filter
diff --git a/src/gnunet/service/dht/blocks/hello_test.go
b/src/gnunet/service/dht/blocks/hello_test.go
index deb8041..d0ef004 100644
--- a/src/gnunet/service/dht/blocks/hello_test.go
+++ b/src/gnunet/service/dht/blocks/hello_test.go
@@ -64,7 +64,7 @@ func setup(t *testing.T) {
}
// create new HELLO block
- block = NewHelloBlock(peer, addrList, time.Hour)
+ block = InitHelloBlock(peer, addrList, time.Hour)
// sign block.
sig, err := sk.EdSign(block.SignedData())
@@ -144,8 +144,8 @@ func TestHelloDebug(t *testing.T) {
t.Log("Block: " + hex.EncodeToString(buf))
t.Log("PeerID: " + hb.PeerID.String())
t.Log(" -> " + hex.EncodeToString(hb.PeerID.Bytes()))
- t.Logf("Expire: %d", hb.Expires.Val)
- t.Logf(" -> " + hb.Expires.String())
+ t.Logf("Expire: %d", hb.Expire_.Val)
+ t.Logf(" -> " + hb.Expire_.String())
var exp util.AbsoluteTime
if err = data.Unmarshal(&exp, buf[32:40]); err != nil {
t.Fatal(err)
diff --git a/src/gnunet/service/dht/local.go b/src/gnunet/service/dht/local.go
index ba76892..5b65ff5 100644
--- a/src/gnunet/service/dht/local.go
+++ b/src/gnunet/service/dht/local.go
@@ -31,7 +31,7 @@ import (
func (m *Module) lookupHelloCache(label string, addr *PeerAddress, rf
blocks.ResultFilter, approx bool) (results []*store.DHTResult) {
logger.Printf(logger.DBG, "[%s] GET message for HELLO: check cache",
label)
// find best cached HELLO
- return m.rtable.LookupHello(addr, rf, approx)
+ return m.rtable.LookupHello(addr, rf, approx, label)
}
// getLocalStorage tries to find the requested block in local storage
diff --git a/src/gnunet/service/dht/messages.go
b/src/gnunet/service/dht/messages.go
index 76a92b6..895d809 100644
--- a/src/gnunet/service/dht/messages.go
+++ b/src/gnunet/service/dht/messages.go
@@ -20,6 +20,7 @@ package dht
import (
"context"
+ "gnunet/core"
"gnunet/crypto"
"gnunet/enums"
"gnunet/message"
@@ -42,20 +43,13 @@ import (
func (m *Module) HandleMessage(ctx context.Context, sender *util.PeerID, msgIn
message.Message, back transport.Responder) bool {
// assemble log label
label := "dht"
- if v := ctx.Value("label"); v != nil {
+ if v := ctx.Value(core.CtxKey("label")); v != nil {
if s, ok := v.(string); ok && len(s) > 0 {
- label = "dht-" + s
+ label = s
}
}
- logger.Printf(logger.INFO, "[%s] message received from %s", label,
sender)
local := m.core.PeerID()
- // check for local message
- if sender.Equals(local) {
- logger.Printf(logger.WARN, "[%s] dropping local message
received: %s", label, util.Dump(msgIn, "json"))
- return false
- }
-
// process message
switch msg := msgIn.(type) {
@@ -66,10 +60,11 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
//--------------------------------------------------------------
// DHT-P2P GET
//--------------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-GET message",
label)
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-GET from %s (type %s,
flags=%s)",
+ label, sender.Short(), msg.BType,
message.DHTFlags(msg.Flags))
// assemble query and initialize (cache) results
- query := blocks.NewGenericQuery(msg.Query,
enums.BlockType(msg.BType), msg.Flags)
+ query := blocks.NewGenericQuery(msg.Query, msg.BType, msg.Flags)
var results []*store.DHTResult
//--------------------------------------------------------------
@@ -79,7 +74,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
if ok {
// validate block query
if !blockHdlr.ValidateBlockQuery(msg.Query, msg.XQuery)
{
- logger.Printf(logger.WARN, "[%s] DHT-P2P-GET
invalid query -- discarded", label)
+ logger.Printf(logger.WARN, "[%s] invalid query
-- discarded", label)
return false
}
} else {
@@ -114,14 +109,19 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
//----------------------------------------------------------
// check if we need to respond (and how) (9.4.3.3)
addr := NewQueryAddress(query.Key())
- closest := m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0)
demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0
approx := int(msg.Flags)&enums.DHT_RO_FIND_APPROXIMATE != 0
-
+ closest := false
+ // only check for closest node if we are not looking for our
own HELLO
+ if msg.Flags&enums.DHT_RO_DISCOVERY == 0 {
+ closest = m.rtable.IsClosestPeer(nil, addr,
msg.PeerFilter, 0)
+ } else {
+ // remove discovery flag
+ msg.Flags &^= enums.DHT_RO_DISCOVERY
+ }
// enforced actions
- doResult := closest || (demux && approx)
- doForward := !closest || (demux && !approx)
- logger.Printf(logger.DBG, "[%s] GET message: closest=%v,
demux=%v, approx=%v --> result=%v, forward=%v",
+ doResult, doForward := getActions(closest, demux, approx)
+ logger.Printf(logger.DBG, "[%s] Actions: closest=%v, demux=%v,
approx=%v --> result=%v, forward=%v",
label, closest, demux, approx, doResult, doForward)
//------------------------------------------------------
@@ -144,7 +144,11 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
results = append(results, lclResults...)
}
}
- // if we have results, send them as response
+ // if we have results, send them as response on the
back channel
+ rcv := "locally"
+ if back.Receiver() != nil {
+ rcv = back.Receiver().Short()
+ }
for _, result := range results {
var pth *path.Path
// check if record the route
@@ -156,9 +160,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
pth.Add(pe)
}
- logger.Printf(logger.INFO, "[%s] sending DHT
result message to caller", label)
+ logger.Printf(logger.INFO, "[%s] sending result
message to %s", label, rcv)
if err := m.sendResult(ctx, query,
result.Entry.Blk, pth, back); err != nil {
- logger.Printf(logger.ERROR, "[%s]
Failed to send DHT result message: %s", label, err.Error())
+ logger.Printf(logger.ERROR, "[%s]
Failed to send result message: %s", label, err.Error())
}
}
}
@@ -174,21 +178,22 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
for n := 0; n < numForward; n++ {
if p := m.rtable.SelectClosestPeer(addr, pf,
0); p != nil {
// forward message to peer
- logger.Printf(logger.INFO, "[%s]
forward DHT get message to %s", label, p.String())
- if err := back.Send(ctx, msgOut); err
!= nil {
- logger.Printf(logger.ERROR,
"[%s] Failed to forward DHT get message: %s", label, err.Error())
+ logger.Printf(logger.INFO, "[%s]
forward GET message to %s", label, p.Peer.Short())
+ if err := m.core.Send(ctx, p.Peer,
msgOut); err != nil {
+ logger.Printf(logger.ERROR,
"[%s] Failed to forward GET message: %s", label, err.Error())
}
pf.Add(p.Peer)
// create open get-forward result
handler
- rh := NewForwardResultHandler(msg, rf,
back)
- logger.Printf(logger.INFO, "[%s]
DHT-P2P-GET task #%d (%s) started", label, rh.ID(), rh.Key())
+ rh := NewResultHandler(msg, rf, back)
+ logger.Printf(logger.INFO, "[%s] result
handler task #%d (key %s) started",
+ label, rh.ID(),
rh.Key().Short())
m.reshdlrs.Add(rh)
} else {
break
}
}
}
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-GET message
done", label)
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-GET done", label)
//==================================================================
// DHT-P2P-PUT
@@ -197,41 +202,46 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
//----------------------------------------------------------
// DHT-P2P PUT
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-PUT message",
label)
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-PUT from %s (type %s,
flags=%s)",
+ label, sender.Short(), msg.BType,
message.DHTFlags(msg.Flags))
// assemble query and entry
- query := blocks.NewGenericQuery(msg.Key,
enums.BlockType(msg.BType), msg.Flags)
+ query := blocks.NewGenericQuery(msg.Key, msg.BType, msg.Flags)
+ blk, err := blocks.NewBlock(msg.BType, msg.Expire, msg.Block)
+ if err != nil {
+ logger.Printf(logger.ERROR, "[%s] message block
problem: %s", label, err.Error())
+ return false
+ }
entry := &store.DHTEntry{
- Blk: blocks.NewGenericBlock(msg.Block),
+ Blk: blk,
Path: nil,
}
//--------------------------------------------------------------
// check if request is expired (9.3.2.1)
- if msg.Expiration.Expired() {
- logger.Printf(logger.WARN, "[%s] DHT-P2P-PUT message
expired (%s)", label, msg.Expiration.String())
+ if msg.Expire.Expired() {
+ logger.Printf(logger.WARN, "[%s] PUT message expired
(%s) -- ignored", label, msg.Expire)
return false
}
- btype := enums.BlockType(msg.BType)
- blockHdlr, ok := blocks.BlockHandlers[btype]
+ blockHdlr, ok := blocks.BlockHandlers[msg.BType]
if ok { // (9.3.2.2)
// reconstruct block instance
if block, err := blockHdlr.ParseBlock(msg.Block); err
== nil {
// validate block key (9.3.2.3)
if !blockHdlr.ValidateBlockKey(block, msg.Key) {
- logger.Printf(logger.WARN, "[%s]
DHT-P2P-PUT invalid key -- discarded", label)
+ logger.Printf(logger.WARN, "[%s] PUT
invalid key -- discarded", label)
return false
}
// validate block payload (9.3.2.4)
if !blockHdlr.ValidateBlockStoreRequest(block) {
- logger.Printf(logger.WARN, "[%s]
DHT-P2P-PUT invalid payload -- discarded", label)
+ logger.Printf(logger.WARN, "[%s] PUT
invalid payload -- discarded", label)
return false
}
}
} else {
- logger.Printf(logger.INFO, "[%s] No validator defined
for block type %s", label, btype.String())
+ logger.Printf(logger.INFO, "[%s] No validator defined
for block type %s", label, msg.BType)
blockHdlr = nil
}
// clone peer filter
@@ -242,7 +252,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
addr := NewQueryAddress(msg.Key)
closest := m.rtable.IsClosestPeer(nil, addr, msg.PeerFilter, 0)
demux := int(msg.Flags)&enums.DHT_RO_DEMULTIPLEX_EVERYWHERE != 0
- logger.Printf(logger.DBG, "[%s] PUT message: closest=%v,
demux=%v", label, closest, demux)
+ doStore, doForward := putActions(closest, demux)
+ logger.Printf(logger.DBG, "[%s] Actions: closest=%v, demux=%v
=> doStore=%v, doForward=%v",
+ label, closest, demux, doStore, doForward)
//--------------------------------------------------------------
// check if sender is in peer filter (9.3.2.5)
@@ -259,7 +271,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
//--------------------------------------------------------------
// store locally if we are closest peer or demux is set
(9.3.2.8)
- if closest || demux {
+ if doStore {
// store in local storage
if err := m.store.Put(query, entry); err != nil {
logger.Printf(logger.ERROR, "[%s] failed to
store DHT entry: %s", label, err.Error())
@@ -268,7 +280,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
//--------------------------------------------------------------
// if the put is for a HELLO block, add the sender to the
// routing table (9.3.2.9)
- if btype == enums.BLOCK_TYPE_DHT_HELLO {
+ if msg.BType == enums.BLOCK_TYPE_DHT_HELLO {
// get addresses from HELLO block
hello, err := blocks.ParseHelloBlockFromBytes(msg.Block)
if err != nil {
@@ -290,7 +302,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
}
//--------------------------------------------------------------
// check if we need to forward
- if !closest || demux {
+ if doForward {
// add local node to filter
pf.Add(local)
@@ -310,9 +322,9 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
msgOut := msg.Update(pp, pf,
msg.HopCount+1)
// forward message to peer
- logger.Printf(logger.INFO, "[%s]
forward DHT put message to %s", label, p.String())
- if err := back.Send(ctx, msgOut); err
!= nil {
- logger.Printf(logger.ERROR,
"[%s] Failed to forward DHT put message: %s", label, err.Error())
+ logger.Printf(logger.INFO, "[%s]
forward PUT message to %s", label, p.Peer.Short())
+ if err := m.core.Send(ctx, p.Peer,
msgOut); err != nil {
+ logger.Printf(logger.ERROR,
"[%s] Failed to forward PUT message: %s", label, err.Error())
}
// add forward node to filter
pf.Add(p.Peer)
@@ -321,7 +333,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
}
}
}
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-PUT message
done", label)
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-PUT done", label)
//==================================================================
// DHT-P2P-RESULT
@@ -330,14 +342,14 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
//----------------------------------------------------------
// DHT-P2P RESULT
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-RESULT
message for type %s",
- label, enums.BlockType(msg.BType).String())
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-RESULT from %s (type
%s, flags=%s)",
+ label, sender.Short(), msg.BType,
message.DHTFlags(msg.Flags))
//--------------------------------------------------------------
// check if request is expired (9.5.2.1)
- if msg.Expires.Expired() {
- logger.Printf(logger.WARN, "[%s] DHT-P2P-RESULT message
expired (%s)",
- label, msg.Expires.String())
+ if msg.Expire.Expired() {
+ logger.Printf(logger.WARN, "[%s] message expired (%s)
-- ignoring",
+ label, msg.Expire.String())
return false
}
//--------------------------------------------------------------
@@ -349,7 +361,7 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
if block, err := blockHdlr.ParseBlock(msg.Block); err
== nil {
// validate block (9.5.2.2)
if !blockHdlr.ValidateBlockStoreRequest(block) {
- logger.Printf(logger.WARN, "[%s]
DHT-P2P-RESULT invalid block -- discarded", label)
+ logger.Printf(logger.WARN, "[%s] RESULT
invalid block -- discarded", label)
return false
}
// Compute block key (9.5.2.4)
@@ -390,19 +402,19 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
}
}
// message forwarding to responder
- key := msg.Query.String()
- logger.Printf(logger.DBG, "[%s] DHT-P2P-RESULT key = %s",
label, key)
+ logger.Printf(logger.DBG, "[%s] result key = %s", label,
msg.Query.Short())
handled := false
+ key := msg.Query.String()
if list, ok := m.reshdlrs.Get(key); ok {
for _, rh := range list {
- logger.Printf(logger.DBG, "[%s] Task #%d for
DHT-P2P-RESULT found", label, rh.ID())
+ logger.Printf(logger.DBG, "[%s] Result handler
task #%d found", label, rh.ID())
//--------------------------------------------------------------
// check task list for handler (9.5.2.6)
- if rh.Flags()&enums.DHT_RO_FIND_APPROXIMATE ==
0 && blkKey != nil && !blkKey.Equals(rh.Key()) {
+ if rh.Flags()&enums.DHT_RO_FIND_APPROXIMATE ==
0 && blkKey != nil && !blkKey.Equal(rh.Key()) {
// (9.5.2.6.a) derived key mismatch
logger.Printf(logger.ERROR, "[%s]
derived block key / query key mismatch:", label)
- logger.Printf(logger.ERROR, "[%s] -->
%s != %s", label, blkKey.String(), rh.Key().String())
+ logger.Printf(logger.ERROR, "[%s] -->
%s != %s", label, blkKey, rh.Key())
return false
}
// (9.5.2.6.b+c) check block against query
@@ -419,9 +431,10 @@ func (m *Module) HandleMessage(ctx context.Context, sender
*util.PeerID, msgIn m
}
}
if !handled {
- logger.Printf(logger.WARN, "[%s] DHT-P2P-RESULT not
processed (no handler)", label)
+ logger.Printf(logger.WARN, "[%s] RESULT not processed
(no handler)", label)
+ } else {
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-RESULT done",
label)
}
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-RESULT
message done", label)
return handled
//==================================================================
@@ -431,11 +444,11 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
//----------------------------------------------------------
// DHT-P2P HELLO
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHT-P2P-HELLO
message", label)
+ logger.Printf(logger.INFO, "[%s] DHT-P2P-HELLO from %s", label,
sender.Short())
// verify integrity of message
if ok, err := msg.Verify(sender); !ok || err != nil {
- logger.Printf(logger.WARN, "[%s] Received invalid
DHT_P2P_HELLO message", label)
+ logger.Printf(logger.WARN, "[%s] Received invalid HELLO
message", label)
if err != nil {
logger.Printf(logger.ERROR, "[%s] --> %s",
label, err.Error())
}
@@ -444,20 +457,20 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
// keep peer addresses in core for transports
aList, err := msg.Addresses()
if err != nil {
- logger.Printf(logger.ERROR, "[%s] Failed to parse
addresses from DHT_P2P_HELLO message", label)
+ logger.Printf(logger.ERROR, "[%s] Failed to parse
addresses from HELLO message", label)
return false
}
- if newPeer := m.core.Learn(ctx, sender, aList); newPeer {
+ if newPeer := m.core.Learn(ctx, sender, aList, label); newPeer {
// we added a previously unknown peer: send a HELLO
var msgOut *message.DHTP2PHelloMsg
- if msgOut, err = m.getHello(); err != nil {
+ if msgOut, err = m.getHello(label); err != nil {
return false
}
- logger.Printf(logger.INFO, "[%s] Sending HELLO to %s:
%s", label, sender, msgOut)
+ logger.Printf(logger.INFO, "[%s] Sending own HELLO to
%s", label, sender.Short())
err = m.core.Send(ctx, sender, msgOut)
// no error if the message might have been sent
if err != nil && err != transport.ErrEndpMaybeSent {
- logger.Printf(logger.ERROR, "[%s] Failed to
send HELLO message: %s", label, err.Error())
+ logger.Printf(logger.ERROR, "[%s] -> failed to
send HELLO message: %s", label, err.Error())
}
}
@@ -466,14 +479,14 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
isNew := true
if hb, ok := m.rtable.GetHello(k); ok {
// cache entry exists: is the HELLO message more recent?
- _, isNew = hb.Expires.Diff(msg.Expires)
+ _, isNew = hb.Expire_.Diff(msg.Expire)
}
// we need to cache a new(er) HELLO
if isNew {
m.rtable.CacheHello(&blocks.HelloBlock{
PeerID: sender,
Signature: msg.Signature,
- Expires: msg.Expires,
+ Expire_: msg.Expire,
AddrBin: util.Clone(msg.AddrList),
})
}
@@ -486,51 +499,68 @@ func (m *Module) HandleMessage(ctx context.Context,
sender *util.PeerID, msgIn m
//----------------------------------------------------------
// DHT PUT
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHTClientPut
message", label)
+ logger.Printf(logger.INFO, "[%s] Ignoring DHTClientPut
message", label)
case *message.DHTClientGetMsg:
//----------------------------------------------------------
// DHT GET
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHTClientGet
message", label)
+ logger.Printf(logger.INFO, "[%s] Ignoring DHTClientGet
message", label)
case *message.DHTClientGetResultsKnownMsg:
//----------------------------------------------------------
// DHT GET-RESULTS-KNOWN
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling
DHTClientGetResultsKnown message", label)
+ logger.Printf(logger.INFO, "[%s] Ignoring
DHTClientGetResultsKnown message", label)
case *message.DHTClientGetStopMsg:
//----------------------------------------------------------
// DHT GET-STOP
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHTClientGetStop
message", label)
+ logger.Printf(logger.INFO, "[%s] Ignoring DHTClientGetStop
message", label)
case *message.DHTClientResultMsg:
//----------------------------------------------------------
// DHT RESULT
//----------------------------------------------------------
- logger.Printf(logger.INFO, "[%s] Handling DHTClientResult
message", label)
+ logger.Printf(logger.INFO, "[%s] Ignoring DHTClientResult
message", label)
default:
//----------------------------------------------------------
// UNKNOWN message type received
//----------------------------------------------------------
- logger.Printf(logger.ERROR, "[%s] Unhandled message of type
(%d)\n", label, msgIn.Header().MsgType)
+ logger.Printf(logger.ERROR, "[%s] Unhandled message of type
(%s)\n", label, msgIn.Type())
return false
}
return true
}
+//----------------------------------------------------------------------
+// Helpers
+//----------------------------------------------------------------------
+
// send a result back to caller
func (m *Module) sendResult(ctx context.Context, query blocks.Query, blk
blocks.Block, pth *path.Path, back transport.Responder) error {
// assemble result message
out := message.NewDHTP2PResultMsg()
- out.BType = uint32(query.Type())
- out.Expires = blk.Expire()
+ out.BType = query.Type()
+ out.Flags = query.Flags()
+ out.Expire = blk.Expire()
out.Query = query.Key()
out.Block = blk.Bytes()
out.MsgSize += uint16(len(out.Block))
+ out.SetPath(pth)
+
// send message
return back.Send(ctx, out)
}
+
+// get enforced action for GET message
+func getActions(closest, demux, approx bool) (doResult, doForward bool) {
+ return closest || (demux && approx), !closest || (demux && !approx)
+}
+
+// get enforced action for PUT message
+func putActions(closest, demux bool) (doStore, doForward bool) {
+ return closest || demux, !closest || demux
+}
diff --git a/src/gnunet/service/dht/messages_test.go
b/src/gnunet/service/dht/messages_test.go
new file mode 100644
index 0000000..d373c85
--- /dev/null
+++ b/src/gnunet/service/dht/messages_test.go
@@ -0,0 +1,73 @@
+// This file is part of gnunet-go, a GNUnet-implementation in Golang.
+// Copyright (C) 2019-2022 Bernd Fix >Y<
+//
+// gnunet-go 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.
+//
+// gnunet-go 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/>.
+//
+// SPDX-License-Identifier: AGPL3.0-or-later
+
+package dht
+
+import "testing"
+
+func TestGetActions(t *testing.T) {
+ var data = [][]bool{
+ // closest, demux, approx => doResult, doForward
+ //
+ // | N | N | N | => | N | Y | Forward GET msg
to neighbors
+ // | Y | N | N | => | Y | N | Return block if
in DHT
+ // | N | N | Y | => | N | Y | Forward GET msg
to neighbors
+ // | Y | N | Y | => | Y | N | Return best-match
block from DHT
+ // | N | Y | N | => | N | Y | Forward GET msg
to neighbors
+ // | Y | Y | N | => | Y | Y | Return block if
in DHT and forward GET
+ // | N | Y | Y | => | Y | Y | Return best-match
block from DHT than forward GET
+ // | Y | Y | Y | => | Y | N | Return best-match
block from DHT
+ //
+ {false, false, false, false, true},
+ {true, false, false, true, false},
+ {false, false, true, false, true},
+ {true, false, true, true, false},
+ {false, true, false, false, true},
+ {true, true, false, true, true},
+ {false, true, true, true, true},
+ {true, true, true, true, false},
+ }
+ for i, d := range data {
+ r1, r2 := getActions(d[0], d[1], d[2])
+ if r1 != d[3] || r2 != d[4] {
+ t.Errorf("Failed entry #%d: %v -- got: %v,%v", i, d,
r1, r2)
+ }
+ }
+}
+
+func TestPutActions(t *testing.T) {
+ var data = [][]bool{
+ // closest, demux => doStore, doForward
+ //
+ // | N | N | => | N | Y | Forward PUT msg
+ // | Y | N | => | Y | N | store block in DHT
+ // | N | Y | => | Y | Y | Store block in DHT and
forward PUT msg
+ // | Y | Y | => | Y | Y | Store block in DHT and
forward PUT msg
+ //
+ {false, false, false, true},
+ {true, false, true, false},
+ {false, true, true, true},
+ {true, true, true, true},
+ }
+ for i, d := range data {
+ r1, r2 := putActions(d[0], d[1])
+ if r1 != d[2] || r2 != d[3] {
+ t.Errorf("Failed entry #%d: %v -- got: %v,%v", i, d,
r1, r2)
+ }
+ }
+}
diff --git a/src/gnunet/service/dht/module.go b/src/gnunet/service/dht/module.go
index 5278b13..d33034e 100644
--- a/src/gnunet/service/dht/module.go
+++ b/src/gnunet/service/dht/module.go
@@ -20,7 +20,8 @@ package dht
import (
"context"
- "errors"
+ "encoding/hex"
+ "fmt"
"gnunet/config"
"gnunet/core"
"gnunet/crypto"
@@ -71,10 +72,15 @@ func (lr *LocalBlockResponder) Send(ctx context.Context,
msg message.Message) er
case *message.DHTP2PResultMsg:
// deliver incoming blocks
go func() {
- lr.ch <- blocks.NewGenericBlock(res.Block)
+ blk, err := blocks.NewBlock(enums.BlockType(res.BType),
res.Expire, res.Block)
+ if err == nil {
+ lr.ch <- blk
+ } else {
+ logger.Println(logger.WARN, "[local] DHT-RESULT
block problem: "+err.Error())
+ }
}()
default:
- logger.Println(logger.WARN, "[local] not a DHT-RESULT --
skipped")
+ logger.Printf(logger.WARN, "[local] %d not a DHT-RESULT --
skipped", "")
}
return nil
}
@@ -133,8 +139,8 @@ func NewModule(ctx context.Context, c *core.Core, cfg
*config.DHTConfig) (m *Mod
// run periodic tasks (8.2. peer discovery)
ticker := time.NewTicker(5 * time.Minute)
- key := crypto.Hash(m.core.PeerID().Data)
- flags := uint16(enums.DHT_RO_FIND_APPROXIMATE |
enums.DHT_RO_DEMULTIPLEX_EVERYWHERE)
+ key := crypto.Hash(m.core.PeerID().Bytes())
+ flags := uint16(enums.DHT_RO_FIND_APPROXIMATE |
enums.DHT_RO_DEMULTIPLEX_EVERYWHERE | enums.DHT_RO_DISCOVERY)
var resCh <-chan blocks.Block
go func() {
for {
@@ -142,25 +148,29 @@ func NewModule(ctx context.Context, c *core.Core, cfg
*config.DHTConfig) (m *Mod
// initiate peer discovery
case <-ticker.C:
// query DHT for our own HELLO block
- query := blocks.NewGenericQuery(key,
enums.BLOCK_TYPE_DHT_HELLO, flags)
+ query := blocks.NewGenericQuery(key,
enums.BLOCK_TYPE_DHT_URL_HELLO, flags)
+ logger.Printf(logger.DBG, "[dht-discovery] own
HELLO key %s", query.Key().Short())
resCh = m.Get(ctx, query)
// handle peer discover results
case res := <-resCh:
// check for correct type
btype := res.Type()
- if btype == enums.BLOCK_TYPE_DHT_HELLO {
+ if btype == enums.BLOCK_TYPE_DHT_URL_HELLO {
hb, ok := res.(*blocks.HelloBlock)
if !ok {
- logger.Printf(logger.WARN,
"[dht] peer discovery received invalid block data")
+ logger.Println(logger.WARN,
"[dht-discovery] received invalid block data")
+ logger.Printf(logger.DBG,
"[dht-discovery] -> %s", hex.EncodeToString(res.Bytes()))
} else {
// cache HELLO block
m.rtable.CacheHello(hb)
// add sender to routing table
-
m.rtable.Add(NewPeerAddress(hb.PeerID), "dht")
+
m.rtable.Add(NewPeerAddress(hb.PeerID), "dht-discovery")
+ // learn addresses
+ m.core.Learn(ctx, hb.PeerID,
hb.Addresses(), "dht-discovery")
}
} else {
- logger.Printf(logger.WARN, "[dht] peer
discovery received invalid block type %s", btype.String())
+ logger.Printf(logger.WARN,
"[dht-discovery] received invalid block type %s", btype)
}
// termination
@@ -198,9 +208,10 @@ func (m *Module) Get(ctx context.Context, query
blocks.Query) <-chan blocks.Bloc
// assemble a new GET message
msg := message.NewDHTP2PGetMsg()
- msg.BType = uint32(query.Type())
+ msg.BType = query.Type()
msg.Flags = query.Flags()
msg.HopCount = 0
+ msg.Query = query.Key()
msg.ReplLevel = uint16(m.cfg.Routing.ReplLevel)
msg.PeerFilter = blocks.NewPeerFilter()
msg.ResFilter = rf.Bytes()
@@ -231,11 +242,6 @@ func (m *Module) Get(ctx context.Context, query
blocks.Query) <-chan blocks.Bloc
return hdlr.C()
}
-// GetApprox returns the first block not excluded ["dht:getapprox"]
-func (m *Module) GetApprox(ctx context.Context, query blocks.Query, rf
blocks.ResultFilter) (results []*store.DHTResult, err error) {
- return m.store.GetApprox("dht", query, rf)
-}
-
// Put a block into the DHT ["dht:put"]
func (m *Module) Put(ctx context.Context, query blocks.Query, block
blocks.Block) error {
// get additional query parameters
@@ -245,12 +251,12 @@ func (m *Module) Put(ctx context.Context, query
blocks.Query, block blocks.Block
}
// assemble a new PUT message
msg := message.NewDHTP2PPutMsg()
- msg.BType = uint32(query.Type())
+ msg.BType = query.Type()
msg.Flags = query.Flags()
msg.HopCount = 0
msg.PeerFilter = blocks.NewPeerFilter()
msg.ReplLvl = uint16(m.cfg.Routing.ReplLevel)
- msg.Expiration = expire
+ msg.Expire = expire
msg.Block = block.Bytes()
msg.Key = query.Key().Clone()
msg.TruncOrigin = nil
@@ -259,7 +265,9 @@ func (m *Module) Put(ctx context.Context, query
blocks.Query, block blocks.Block
msg.MsgSize += uint16(len(msg.Block))
// send message
- go m.HandleMessage(ctx, nil, msg, nil)
+ self := m.core.PeerID()
+ msg.PeerFilter.Add(self)
+ go m.HandleMessage(ctx, self, msg, nil)
return nil
}
@@ -277,16 +285,16 @@ func (m *Module) Filter() *core.EventFilter {
// messages we are interested in:
// (1) DHT_P2P messages
- f.AddMsgType(message.DHT_P2P_PUT)
- f.AddMsgType(message.DHT_P2P_GET)
- f.AddMsgType(message.DHT_P2P_RESULT)
- f.AddMsgType(message.DHT_P2P_HELLO)
+ f.AddMsgType(enums.MSG_DHT_P2P_PUT)
+ f.AddMsgType(enums.MSG_DHT_P2P_GET)
+ f.AddMsgType(enums.MSG_DHT_P2P_RESULT)
+ f.AddMsgType(enums.MSG_DHT_P2P_HELLO)
// (2) DHT messages (legacy, not implemented)
- f.AddMsgType(message.DHT_CLIENT_GET)
- f.AddMsgType(message.DHT_CLIENT_GET_RESULTS_KNOWN)
- f.AddMsgType(message.DHT_CLIENT_GET_STOP)
- f.AddMsgType(message.DHT_CLIENT_PUT)
- f.AddMsgType(message.DHT_CLIENT_RESULT)
+ f.AddMsgType(enums.MSG_DHT_CLIENT_GET)
+ f.AddMsgType(enums.MSG_DHT_CLIENT_GET_RESULTS_KNOWN)
+ f.AddMsgType(enums.MSG_DHT_CLIENT_GET_STOP)
+ f.AddMsgType(enums.MSG_DHT_CLIENT_PUT)
+ f.AddMsgType(enums.MSG_DHT_CLIENT_RESULT)
return f
}
@@ -297,27 +305,28 @@ func (m *Module) event(ctx context.Context, ev
*core.Event) {
// New peer connected:
case core.EV_CONNECT:
// Add peer to routing table
- logger.Printf(logger.INFO, "[dht-event] Peer %s connected",
ev.Peer)
+ logger.Printf(logger.INFO, "[dht-event] Peer %s connected",
ev.Peer.Short())
m.rtable.Add(NewPeerAddress(ev.Peer), "dht-event")
// Peer disconnected:
case core.EV_DISCONNECT:
// Remove peer from routing table
- logger.Printf(logger.INFO, "[dht-event] Peer %s disconnected",
ev.Peer)
- m.rtable.Remove(NewPeerAddress(ev.Peer), 0)
+ logger.Printf(logger.INFO, "[dht-event] Peer %s disconnected",
ev.Peer.Short())
+ m.rtable.Remove(NewPeerAddress(ev.Peer), "dht-event", 0)
// Message received.
case core.EV_MESSAGE:
- logger.Printf(logger.INFO, "[dht-event] Message received: %s",
ev.Msg.String())
-
+ // generate tracking label
+ label := fmt.Sprintf("dht-msg-%d", util.NextID())
+ tctx := context.WithValue(ctx, core.CtxKey("label"), label)
// check if peer is in routing table (connected peer)
- if !m.rtable.Contains(NewPeerAddress(ev.Peer)) {
- logger.Printf(logger.WARN, "[dht-event] message %d from
unregistered peer -- discarded", ev.Msg.Header().MsgType)
+ if !m.rtable.Contains(NewPeerAddress(ev.Peer), label) {
+ logger.Printf(logger.WARN, "[%s] message %d from
unregistered peer -- discarded", label, ev.Msg.Type())
return
}
// process message
- if !m.HandleMessage(ctx, ev.Peer, ev.Msg, ev.Resp) {
- logger.Println(logger.WARN, "[dht-event] Message NOT
handled!")
+ if !m.HandleMessage(tctx, ev.Peer, ev.Msg, ev.Resp) {
+ logger.Printf(logger.WARN, "[%s] %s message NOT
handled", label, ev.Msg.Type())
}
}
}
@@ -337,20 +346,20 @@ func (m *Module) heartbeat(ctx context.Context) {
//----------------------------------------------------------------------
// Send the currently active HELLO to given network address
-func (m *Module) SendHello(ctx context.Context, addr *util.Address) (err
error) {
+func (m *Module) SendHello(ctx context.Context, addr *util.Address, label
string) (err error) {
// get (buffered) HELLO
var msg *message.DHTP2PHelloMsg
- if msg, err = m.getHello(); err != nil {
+ if msg, err = m.getHello(label); err != nil {
return
}
- logger.Printf(logger.INFO, "[core] Sending HELLO to %s: %s",
addr.URI(), msg)
+ logger.Printf(logger.INFO, "[%s] Sending own HELLO to %s", label,
addr.URI())
return m.core.SendToAddr(ctx, addr, msg)
}
// get the recent HELLO if it is defined and not expired;
// create a new HELLO otherwise.
-func (m *Module) getHello() (msg *message.DHTP2PHelloMsg, err error) {
- if m.lastHello == nil || m.lastHello.Expires.Expired() {
+func (m *Module) getHello(label string) (msg *message.DHTP2PHelloMsg, err
error) {
+ if m.lastHello == nil || m.lastHello.Expire.Expired() {
// assemble new (signed) HELLO block
var addrList []*util.Address
if addrList, err = m.core.Addresses(); err != nil {
@@ -359,7 +368,7 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg,
err error) {
// assemble HELLO data
hb := new(blocks.HelloBlock)
hb.PeerID = m.core.PeerID()
- hb.Expires =
util.NewAbsoluteTime(time.Now().Add(message.HelloAddressExpiration))
+ hb.Expire_ =
util.NewAbsoluteTime(time.Now().Add(message.HelloAddressExpiration))
hb.SetAddresses(addrList)
// sign HELLO block
@@ -368,12 +377,11 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg,
err error) {
}
// assemble HELLO message
msg = message.NewDHTP2PHelloMsg()
- msg.Expires = hb.Expires
+ msg.Expire = hb.Expire_
msg.SetAddresses(hb.Addresses())
if err = m.core.Sign(msg); err != nil {
return
}
-
// save for later use
m.lastHello = msg
@@ -381,12 +389,12 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg,
err error) {
var ok bool
if ok, err = msg.Verify(m.core.PeerID()); !ok || err != nil {
if !ok {
- err = errors.New("failed to verify own HELLO")
+ err = fmt.Errorf("[%s] failed to verify own
HELLO", label)
}
logger.Println(logger.ERROR, err.Error())
return
}
- logger.Println(logger.DBG, "[dht] New HELLO: "+util.Dump(msg,
"hex"))
+ logger.Printf(logger.INFO, "[%s] new own HELLO created (expires
%s)", label, msg.Expire)
return
}
// we have a valid HELLO for re-use.
@@ -401,7 +409,6 @@ func (m *Module) getHello() (msg *message.DHTP2PHelloMsg,
err error) {
func (m *Module) Export(fcn map[string]any) {
// add exported functions from module
fcn["dht:get"] = m.Get
- fcn["dht:getapprox"] = m.GetApprox
fcn["dht:put"] = m.Put
}
diff --git a/src/gnunet/service/dht/path/elements.go
b/src/gnunet/service/dht/path/elements.go
index 53d1cfd..1384469 100644
--- a/src/gnunet/service/dht/path/elements.go
+++ b/src/gnunet/service/dht/path/elements.go
@@ -60,7 +60,7 @@ func (e *Entry) String() string {
//----------------------------------------------------------------------
// shared path element data across types
type elementData struct {
- Expiration util.AbsoluteTime // expiration date
+ Expire util.AbsoluteTime // expiration date
BlockHash *crypto.HashCode // block hash
PeerPredecessor *util.PeerID // predecessor peer
PeerSuccessor *util.PeerID // successor peer
diff --git a/src/gnunet/service/dht/path/handling.go
b/src/gnunet/service/dht/path/handling.go
index b225c82..4040511 100644
--- a/src/gnunet/service/dht/path/handling.go
+++ b/src/gnunet/service/dht/path/handling.go
@@ -129,7 +129,7 @@ func (p *Path) Clone() *Path {
func (p *Path) NewElement(pred, signer, succ *util.PeerID) *Element {
return &Element{
elementData: elementData{
- Expiration: p.Expire,
+ Expire: p.Expire,
BlockHash: p.BlkHash,
PeerPredecessor: pred,
PeerSuccessor: succ,
diff --git a/src/gnunet/service/dht/resulthandler.go
b/src/gnunet/service/dht/resulthandler.go
index 85895f8..7df405b 100644
--- a/src/gnunet/service/dht/resulthandler.go
+++ b/src/gnunet/service/dht/resulthandler.go
@@ -44,31 +44,6 @@ import (
// different GET requests and/or differnent originators).
//======================================================================
-// ResultHandler interface
-type ResultHandler interface {
-
- // ID returna the handler id
- ID() int
-
- // Done returns true if handler can be removed
- Done() bool
-
- // Key returns the query/store key as string
- Key() *crypto.HashCode
-
- // Flags returns the query flags
- Flags() uint16
-
- // Compare two result handlers
- Compare(ResultHandler) int
-
- // Merge two result handlers that are the same except for result filter
- Merge(ResultHandler) bool
-
- // Handle result message
- Handle(ctx context.Context, msg *message.DHTP2PResultMsg, pth
*path.Path, sender, local *util.PeerID) bool
-}
-
// Compare return values
//nolint:stylecheck // allow non-camel-case in constants
const (
@@ -78,24 +53,23 @@ const (
RHC_REPLACE = blocks.CMP_1 // the two result handlers are siblings
)
-//----------------------------------------------------------------------
-
-// Generic (shared) result handler data structure
-type GenericResultHandler struct {
+// ResultHandler for handling DHT-RESULT messages
+type ResultHandler struct {
id int // task identifier
key *crypto.HashCode // GET query key
- btype uint32 // content type of the payload
+ btype enums.BlockType // content type of the payload
flags uint16 // processing flags
resFilter blocks.ResultFilter // result filter
xQuery []byte // extended query
started util.AbsoluteTime // Timestamp of session start
active bool // is the task active?
+ resp transport.Responder // back-channel to deliver result
}
-// NewGenericResultHandler creates an instance from a DHT-GET message and a
+// NewResultHandler creates an instance from a DHT-GET message and a
// result filter instance.
-func NewGenericResultHandler(msg *message.DHTP2PGetMsg, rf
blocks.ResultFilter) *GenericResultHandler {
- return &GenericResultHandler{
+func NewResultHandler(msg *message.DHTP2PGetMsg, rf blocks.ResultFilter, back
transport.Responder) *ResultHandler {
+ return &ResultHandler{
id: util.NextID(),
key: msg.Query.Clone(),
btype: msg.BType,
@@ -104,37 +78,45 @@ func NewGenericResultHandler(msg *message.DHTP2PGetMsg, rf
blocks.ResultFilter)
xQuery: util.Clone(msg.XQuery),
started: util.AbsoluteTimeNow(),
active: true,
+ resp: back,
}
}
// ID returns the result handler identifier
-func (t *GenericResultHandler) ID() int {
+func (t *ResultHandler) ID() int {
return t.id
}
// Key returns the key string
-func (t *GenericResultHandler) Key() *crypto.HashCode {
+func (t *ResultHandler) Key() *crypto.HashCode {
return t.key
}
// Flags returns the query flags
-func (t *GenericResultHandler) Flags() uint16 {
+func (t *ResultHandler) Flags() uint16 {
return t.flags
}
// Done returns true if the result handler is no longer active.
-func (t *GenericResultHandler) Done() bool {
+func (t *ResultHandler) Done() bool {
return !t.active || t.started.Add(time.Hour).Expired()
}
// Compare two handlers
-func (t *GenericResultHandler) Compare(h *GenericResultHandler) int {
+func (t *ResultHandler) Compare(h *ResultHandler) int {
+ // check for same recipient
+ tRcv := t.resp.Receiver()
+ hRcv := h.resp.Receiver()
+ if !hRcv.Equal(tRcv) {
+ logger.Printf(logger.DBG, "[rh] recipients differ: %v -- %v",
hRcv, tRcv)
+ return RHC_DIFFER
+ }
// check if base attributes differ
- if !t.key.Equals(h.key) ||
+ if !t.key.Equal(h.key) ||
t.btype != h.btype ||
t.flags != h.flags ||
!bytes.Equal(t.xQuery, h.xQuery) {
- logger.Printf(logger.DBG, "[grh] base fields differ")
+ logger.Printf(logger.DBG, "[rh] base fields differ")
return RHC_DIFFER
}
// compare result filters; if they are different, replace
@@ -147,180 +129,52 @@ func (t *GenericResultHandler) Compare(h
*GenericResultHandler) int {
}
// Merge two result handlers that are the same except for result filter
-func (t *GenericResultHandler) Merge(a *GenericResultHandler) bool {
+func (t *ResultHandler) Merge(a *ResultHandler) bool {
return t.resFilter.Merge(a.resFilter)
}
// Proceed return true if the message is to be processed in derived
implementations
-func (t *GenericResultHandler) Proceed(ctx context.Context, msg
*message.DHTP2PResultMsg) bool {
- block := blocks.NewGenericBlock(msg.Block)
- if !t.resFilter.Contains(block) {
- t.resFilter.Add(block)
+func (t *ResultHandler) Proceed(ctx context.Context, msg
*message.DHTP2PResultMsg) bool {
+ blk, err := blocks.NewBlock(enums.BlockType(msg.BType), msg.Expire,
msg.Block)
+ if err == nil && !t.resFilter.Contains(blk) {
+ t.resFilter.Add(blk)
return true
}
return false
}
-//----------------------------------------------------------------------
-// Result handler for forwarded GET requests
-//----------------------------------------------------------------------
-
-// ForwardResultHandler data structure
-type ForwardResultHandler struct {
- GenericResultHandler
-
- resp transport.Responder // responder for communicating back to
originator
-}
-
-// NewForwardResultHandler derived from DHT-GET message
-func NewForwardResultHandler(msgIn message.Message, rf blocks.ResultFilter,
back transport.Responder) *ForwardResultHandler {
- // check for correct message type and handler function
- msg, ok := msgIn.(*message.DHTP2PGetMsg)
- if ok {
- return &ForwardResultHandler{
- GenericResultHandler: *NewGenericResultHandler(msg, rf),
- resp: back,
- }
- }
- return nil
-}
-
// Handle incoming DHT-P2P-RESULT message
-func (t *ForwardResultHandler) Handle(ctx context.Context, msg
*message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool {
+func (t *ResultHandler) Handle(ctx context.Context, msg
*message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool {
// don't send result if it is filtered out
if !t.Proceed(ctx, msg) {
logger.Printf(logger.DBG, "[dht-task-%d] result filtered out --
already known", t.id)
return false
}
- // extend path if route is recorded
- pp := pth.Clone()
- if msg.Flags&enums.DHT_RO_RECORD_ROUTE != 0 {
- // yes: add path element for remote receivers
- if rcv := t.resp.Receiver(); rcv != nil {
+ // check if we are delivering results to remote nodes
+ rcv := t.resp.Receiver()
+ tgt := "locally"
+ if rcv != nil {
+ // extend path if route is recorded
+ var pp *path.Path
+ if msg.Flags&enums.DHT_RO_RECORD_ROUTE != 0 {
+ pp = pth.Clone()
+ // yes: add path element
pe := pp.NewElement(sender, local, rcv)
pp.Add(pe)
}
+ // build updated PUT message
+ msg = msg.Update(pp)
+ tgt = rcv.Short()
}
-
- // build updated PUT message
- msgOut := msg.Update(pp)
-
// send result message back to originator (result forwarding).
- logger.Printf(logger.INFO, "[dht-task-%d] sending result back to
originator", t.id)
- if err := t.resp.Send(ctx, msgOut); err != nil && err !=
transport.ErrEndpMaybeSent {
- logger.Printf(logger.ERROR, "[dht-task-%d] sending result back
to originator failed: %s", t.id, err.Error())
+ logger.Printf(logger.INFO, "[dht-task-%d] sending result back %s",
t.id, tgt)
+ if err := t.resp.Send(ctx, msg); err != nil && err !=
transport.ErrEndpMaybeSent {
+ logger.Printf(logger.ERROR, "[dht-task-%d] sending result back
%s failed: %s", t.id, tgt, err.Error())
return false
}
return true
}
-// Compare two forward result filters
-func (t *ForwardResultHandler) Compare(h ResultHandler) int {
- // check for correct handler type
- ht, ok := h.(*ForwardResultHandler)
- if !ok {
- logger.Println(logger.DBG, "[frh] can't compare apples with
oranges")
- return RHC_DIFFER
- }
- // check for same recipient
- if ht.resp.Receiver().Equals(t.resp.Receiver()) {
- logger.Printf(logger.DBG, "[frh] recipients differ: %s -- %s",
ht.resp.Receiver(), t.resp.Receiver())
- return RHC_DIFFER
- }
- // check generic handler data
- return t.GenericResultHandler.Compare(&ht.GenericResultHandler)
-}
-
-// Merge two forward result handlers
-func (t *ForwardResultHandler) Merge(h ResultHandler) bool {
- // check for correct handler type
- ht, ok := h.(*ForwardResultHandler)
- if !ok {
- return false
- }
- return t.GenericResultHandler.Merge(&ht.GenericResultHandler)
-}
-
-//----------------------------------------------------------------------
-// Result handler for locally-initiated GET requests:
-//
-// Before sending the GET request a handler is added for the request:
-//
-// rc := make(chan any)
-// myRH := NewDirectResultHandler(msg, rf, MyCustomHandler, rc)
-// m.reshdlrs.Add(myRH)
-//
-// If a matching response is received, the custom handler is executed
-// in a separate go-routine. A custom handler returns a result (or error) on
-// a back channel and should be context-sensitive (termination).
-//
-// If an asynchronous behaviour is required, use 'ret := <-rc' to wait for
-// completion; synchronous execution does not require 'rc' (which can be set
-// to nil).
-//----------------------------------------------------------------------
-
-// ResultHandlerFcn is the function prototype for custom handlers:
-type ResultHandlerFcn func(context.Context, *message.DHTP2PResultMsg,
*path.Path, chan<- any) bool
-
-// DirectResultHandler for local DHT-P2P-GET requests
-type DirectResultHandler struct {
- GenericResultHandler
-
- hdlr ResultHandlerFcn // Hdlr is a custom message handler
- rc chan any // handler result channel
-}
-
-// NewDirectResultHandler create a new GET handler instance
-func NewDirectResultHandler(msgIn message.Message, rf blocks.ResultFilter,
hdlr ResultHandlerFcn, rc chan any) *DirectResultHandler {
- // check for correct message type and handler function
- msg, ok := msgIn.(*message.DHTP2PGetMsg)
- if ok {
- return &DirectResultHandler{
- GenericResultHandler: *NewGenericResultHandler(msg, rf),
- hdlr: hdlr,
- rc: rc,
- }
- }
- return nil
-}
-
-// Handle incoming DHT-P2P-RESULT message
-func (t *DirectResultHandler) Handle(ctx context.Context, msg
*message.DHTP2PResultMsg, pth *path.Path, sender, local *util.PeerID) bool {
- // don't send result if it is filtered out
- if !t.Proceed(ctx, msg) {
- logger.Printf(logger.DBG, "[dht-task-%d] result filtered out --
already known", t.id)
- return false
- }
- // check for correct message type and handler function
- if t.hdlr != nil {
- logger.Printf(logger.INFO, "[dht-task-%d] handling result
message", t.id)
- return t.hdlr(ctx, msg, pth, t.rc)
- }
- return false
-}
-
-// Compare two direct result handlers
-func (t *DirectResultHandler) Compare(h ResultHandler) int {
- // check for correct handler type
- ht, ok := h.(*DirectResultHandler)
- if !ok {
- return RHC_DIFFER
- }
- // check generic handler data
- return t.GenericResultHandler.Compare(&ht.GenericResultHandler)
-}
-
-// Merge two direct result handlers
-func (t *DirectResultHandler) Merge(h ResultHandler) bool {
- // check for correct handler type
- ht, ok := h.(*DirectResultHandler)
- if !ok {
- return false
- }
- // check generic handler data
- return t.GenericResultHandler.Merge(&ht.GenericResultHandler)
-}
-
//----------------------------------------------------------------------
// Handler list for book-keeping:
// * For each query/store key there can be multiple result handlers.
@@ -328,24 +182,24 @@ func (t *DirectResultHandler) Merge(h ResultHandler) bool
{
// ResultHandlerList holds the currently active tasks
type ResultHandlerList struct {
- list *util.Map[string, []ResultHandler] // map of handlers
+ list *util.Map[string, []*ResultHandler] // map of handlers
}
// NewResultHandlerList creates a new task list
func NewResultHandlerList() *ResultHandlerList {
return &ResultHandlerList{
- list: util.NewMap[string, []ResultHandler](),
+ list: util.NewMap[string, []*ResultHandler](),
}
}
// Add handler to list
-func (t *ResultHandlerList) Add(hdlr ResultHandler) bool {
+func (t *ResultHandlerList) Add(hdlr *ResultHandler) bool {
// get current list of handlers for key
key := hdlr.Key().String()
list, ok := t.list.Get(key, 0)
modified := false
if !ok {
- list = make([]ResultHandler, 0)
+ list = make([]*ResultHandler, 0)
} else {
// check if handler is already available
loop:
@@ -353,23 +207,23 @@ func (t *ResultHandlerList) Add(hdlr ResultHandler) bool {
switch h.Compare(hdlr) {
case RHC_SAME:
// already in list; no need to add again
- logger.Println(logger.DBG, "[rhl] SAME")
+ logger.Println(logger.DBG, "[rhl] resultfilter
compare: SAME")
return false
case RHC_MERGE:
// merge the two result handlers
oldMod := modified
modified = h.Merge(hdlr) || modified
- logger.Printf(logger.DBG, "[rhl] MERGE (%v --
%v)", oldMod, modified)
+ logger.Printf(logger.DBG, "[rhl] resultfilter
compare: MERGE (%v -- %v)", oldMod, modified)
break loop
case RHC_REPLACE:
// replace the old handler with the new one
- logger.Println(logger.DBG, "[rhl] REPLACE")
+ logger.Printf(logger.DBG, "[rhl] resultfilter
compare: REPLACE #%d with #%d", list[i].id, hdlr.id)
list[i] = hdlr
modified = true
break loop
case RHC_DIFFER:
// try next
- logger.Println(logger.DBG, "[rhl] DIFFER")
+ logger.Println(logger.DBG, "[rhl] resultfilter
compare: DIFFER")
}
}
}
@@ -382,14 +236,14 @@ func (t *ResultHandlerList) Add(hdlr ResultHandler) bool {
}
// Get handler list for given key
-func (t *ResultHandlerList) Get(key string) ([]ResultHandler, bool) {
+func (t *ResultHandlerList) Get(key string) ([]*ResultHandler, bool) {
return t.list.Get(key, 0)
}
// Cleanup removes expired tasks from list
func (t *ResultHandlerList) Cleanup() {
- err := t.list.ProcessRange(func(key string, list []ResultHandler, pid
int) error {
- var newList []ResultHandler
+ err := t.list.ProcessRange(func(key string, list []*ResultHandler, pid
int) error {
+ var newList []*ResultHandler
changed := false
for _, rh := range list {
if !rh.Done() {
@@ -404,6 +258,6 @@ func (t *ResultHandlerList) Cleanup() {
return nil
}, false)
if err != nil {
- logger.Printf(logger.ERROR, "[ResultHandlerList] clean-up
error: %s", err.Error())
+ logger.Printf(logger.ERROR, "[rh-list] clean-up error: %s",
err.Error())
}
}
diff --git a/src/gnunet/service/dht/routingtable.go
b/src/gnunet/service/dht/routingtable.go
index 20bf5fc..21c8823 100644
--- a/src/gnunet/service/dht/routingtable.go
+++ b/src/gnunet/service/dht/routingtable.go
@@ -66,7 +66,7 @@ func NewPeerAddress(peer *util.PeerID) *PeerAddress {
func NewQueryAddress(key *crypto.HashCode) *PeerAddress {
return &PeerAddress{
Peer: nil,
- Key: crypto.NewHashCode(key.Bits),
+ Key: crypto.NewHashCode(key.Data),
lastSeen: util.AbsoluteTimeNow(),
lastUsed: util.AbsoluteTimeNow(),
}
@@ -74,18 +74,18 @@ func NewQueryAddress(key *crypto.HashCode) *PeerAddress {
// String returns a human-readble representation of an address.
func (addr *PeerAddress) String() string {
- return hex.EncodeToString(addr.Key.Bits)
+ return hex.EncodeToString(addr.Key.Data)
}
-// Equals returns true if two peer addresses are the same.
-func (addr *PeerAddress) Equals(p *PeerAddress) bool {
- return bytes.Equal(addr.Key.Bits, p.Key.Bits)
+// Equal returns true if two peer addresses are the same.
+func (addr *PeerAddress) Equal(p *PeerAddress) bool {
+ return bytes.Equal(addr.Key.Data, p.Key.Data)
}
// Distance between two addresses: returns a distance value and a
// bucket index (smaller index = less distant).
func (addr *PeerAddress) Distance(p *PeerAddress) (*math.Int, int) {
- r := util.Distance(addr.Key.Bits, p.Key.Bits)
+ r := util.Distance(addr.Key.Data, p.Key.Data)
return r, 512 - r.BitLen()
}
@@ -136,24 +136,22 @@ func NewRoutingTable(ref *PeerAddress, cfg
*config.RoutingConfig) *RoutingTable
// Returns true if the entry was added, false otherwise.
func (rt *RoutingTable) Add(p *PeerAddress, label string) bool {
k := p.String()
- logger.Printf(logger.DBG, "[%s] Add(%s)", label, k)
// check if peer is already known
if px, ok := rt.list.Get(k, 0); ok {
- logger.Printf(logger.DBG, "[%s] --> already known", label)
px.lastSeen = util.AbsoluteTimeNow()
return false
}
// compute distance (bucket index) and insert address.
_, idx := p.Distance(rt.ref)
if rt.buckets[idx].Add(p) {
- logger.Printf(logger.DBG, "[%s] --> entry added", label)
p.lastUsed = util.AbsoluteTimeNow()
rt.list.Put(k, p, 0)
+ logger.Printf(logger.INFO, "[%s] %s added to routing table",
+ label, p.Peer.Short())
return true
}
// Full bucket: we did not add the address to the routing table.
- logger.Printf(logger.DBG, "[%s] --> bucket[%d] full -- discarded",
label, idx)
return false
}
@@ -178,41 +176,39 @@ func (rt *RoutingTable) Check(p *PeerAddress) int {
// Remove peer address from routing table.
// Returns true if the entry was removed, false otherwise.
-func (rt *RoutingTable) Remove(p *PeerAddress, pid int) bool {
- k := p.String()
- logger.Printf(logger.DBG, "[RT] Remove(%s)", k)
-
+func (rt *RoutingTable) Remove(p *PeerAddress, label string, pid int) bool {
// compute distance (bucket index) and remove entry from bucket
rc := false
_, idx := p.Distance(rt.ref)
if rt.buckets[idx].Remove(p) {
- logger.Println(logger.DBG, "[RT] --> entry removed from bucket
and internal lists")
+ logger.Printf(logger.DBG, "[%s] %s removed from RT (bucket and
internal lists)", label, p.Peer.Short())
rc = true
} else {
// remove from internal list
- logger.Println(logger.DBG, "[RT] --> entry removed from
internal lists only")
+ logger.Printf(logger.DBG, "[%s] %s removed from RT (internal
lists only)", label, p.Peer.Short())
}
- rt.list.Delete(k, 0)
+ rt.list.Delete(p.String(), 0)
// delete from HELLO cache
rt.helloCache.Delete(p.Peer.String(), pid)
return rc
}
// Contains checks if a peer is available in the routing table
-func (rt *RoutingTable) Contains(p *PeerAddress) bool {
+func (rt *RoutingTable) Contains(p *PeerAddress, label string) bool {
k := p.String()
- logger.Printf(logger.DBG, "[RT] Contains(%s)?", k)
// check for peer in internal list
px, ok := rt.list.Get(k, 0)
if !ok {
- logger.Println(logger.DBG, "[RT] --> NOT found in current
list:")
+ logger.Printf(logger.WARN, "[%s] %s NOT found in RT", label,
p.Peer.Short())
+ var list []string
_ = rt.list.ProcessRange(func(key string, val *PeerAddress, _
int) error {
- logger.Printf(logger.DBG, "[RT] * %s", val)
+ list = append(list, val.Peer.Short())
return nil
}, true)
+ logger.Printf(logger.DBG, "[%s] RT=%v", list)
} else {
- logger.Println(logger.DBG, "[RT] --> found in current list")
+ //logger.Println(logger.DBG, "[RT] --> found in current list")
px.lastSeen = util.AbsoluteTimeNow()
}
return ok
@@ -310,7 +306,7 @@ func (rt *RoutingTable) IsClosestPeer(p, k *PeerAddress, pf
*blocks.PeerFilter,
return d1.Cmp(d0) < 0
}
// check if p is closest peer
- return n.Equals(p)
+ return n.Equal(p)
}
// ComputeOutDegree computes the number of neighbors that a message should be
forwarded to.
@@ -340,23 +336,23 @@ func (rt *RoutingTable) ComputeOutDegree(repl, hop
uint16) int {
func (rt *RoutingTable) heartbeat(ctx context.Context) {
// check for dead or expired peers
- logger.Println(logger.DBG, "[dht] RT heartbeat...")
+ logger.Println(logger.DBG, "[dht-rt-hb] RT heartbeat...")
timeout := util.NewRelativeTime(time.Duration(rt.cfg.PeerTTL) *
time.Second)
if err := rt.list.ProcessRange(func(k string, p *PeerAddress, pid int)
error {
// check if we can/need to drop a peer
drop := timeout.Compare(p.lastSeen.Elapsed()) < 0
if drop || timeout.Compare(p.lastUsed.Elapsed()) < 0 {
- logger.Printf(logger.DBG, "[RT] removing %v: %v, %v",
p, p.lastSeen.Elapsed(), p.lastUsed.Elapsed())
- rt.Remove(p, pid)
+ logger.Printf(logger.DBG, "[dht-rt-hb] removing %v: %v,
%v", p, p.lastSeen.Elapsed(), p.lastUsed.Elapsed())
+ rt.Remove(p, "dht-rt-hb", pid)
}
return nil
}, false); err != nil {
- logger.Println(logger.ERROR, "[dht] RT heartbeat failed:
"+err.Error())
+ logger.Println(logger.ERROR, "[dht-rt-hb] RT heartbeat failed:
"+err.Error())
}
// drop expired entries from the HELLO cache
_ = rt.helloCache.ProcessRange(func(key string, val *blocks.HelloBlock,
pid int) error {
- if val.Expires.Expired() {
+ if val.Expire_.Expired() {
rt.helloCache.Delete(key, pid)
}
return nil
@@ -369,7 +365,7 @@ func (rt *RoutingTable) heartbeat(ctx context.Context) {
//----------------------------------------------------------------------
// LookupHello returns blocks from the HELLO cache for given query.
-func (rt *RoutingTable) LookupHello(addr *PeerAddress, rf blocks.ResultFilter,
approx bool) (results []*store.DHTResult) {
+func (rt *RoutingTable) LookupHello(addr *PeerAddress, rf blocks.ResultFilter,
approx bool, label string) (results []*store.DHTResult) {
// iterate over cached HELLOs to find matches;
// approximate search is limited by distance (max. diff for bucket
index is 16)
_ = rt.helloCache.ProcessRange(func(key string, hb *blocks.HelloBlock,
_ int) error {
@@ -390,7 +386,7 @@ func (rt *RoutingTable) LookupHello(addr *PeerAddress, rf
blocks.ResultFilter, a
results = append(results, result)
}
} else {
- logger.Printf(logger.DBG, "[RT] GET-HELLO: cache block
is filtered")
+ logger.Printf(logger.DBG, "[%s] LookupHello: cached
HELLO block is filtered")
}
return nil
}, true)
@@ -479,7 +475,7 @@ func (b *Bucket) Remove(p *PeerAddress) bool {
defer b.Unlock()
for i, pe := range b.list {
- if pe.Equals(p) {
+ if pe.Equal(p) {
// found entry: remove it
b.list = append(b.list[:i], b.list[i+1:]...)
return true
diff --git a/src/gnunet/service/dht/routingtable_test.go
b/src/gnunet/service/dht/routingtable_test.go
index 02ddc52..dd16064 100644
--- a/src/gnunet/service/dht/routingtable_test.go
+++ b/src/gnunet/service/dht/routingtable_test.go
@@ -101,7 +101,7 @@ func TestRT(t *testing.T) {
t.Logf("[%6d] %s %s\n", e, task.addr, msg)
}
disconnected := func(task *Entry, e int64, msg string) {
- rt.Remove(task.addr, 0)
+ rt.Remove(task.addr, "test", 0)
task.online = false
task.last = e
t.Logf("[%6d] %s %s\n", e, task.addr, msg)
diff --git a/src/gnunet/service/dht/service.go
b/src/gnunet/service/dht/service.go
index 29e3804..f5b6abd 100644
--- a/src/gnunet/service/dht/service.go
+++ b/src/gnunet/service/dht/service.go
@@ -83,7 +83,7 @@ loop:
logger.Printf(logger.INFO, "[dht:%d:%d] Received request:
%v\n", id, reqID, msg)
// handle message
- valueCtx := context.WithValue(ctx, service.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
+ valueCtx := context.WithValue(ctx, core.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
s.HandleMessage(valueCtx, nil, msg, mc)
}
// close client connection
diff --git a/src/gnunet/service/gns/block_handler.go
b/src/gnunet/service/gns/block_handler.go
index ee87065..a0e7874 100644
--- a/src/gnunet/service/gns/block_handler.go
+++ b/src/gnunet/service/gns/block_handler.go
@@ -132,10 +132,10 @@ func NewBlockHandlerList(records
[]*message.ResourceRecord, labels []string) (*B
continue
}
// check for expired record
- if rec.Expires.Expired() {
+ if rec.Expire.Expired() {
// do we have an associated shadow record?
for _, shadow := range shadows {
- if shadow.Type == rec.Type &&
!shadow.Expires.Expired() {
+ if shadow.RType == rec.RType &&
!shadow.Expire.Expired() {
// deliver un-expired shadow record
instead.
shadow.Flags &^=
uint32(enums.GNS_FLAG_SHADOW)
active = append(active, shadow)
@@ -153,7 +153,7 @@ func NewBlockHandlerList(records []*message.ResourceRecord,
labels []string) (*B
logger.Printf(logger.DBG, "[gns] handler_list: skip
%v\n", rec)
continue
}
- rrType := enums.GNSType(rec.Type)
+ rrType := enums.GNSType(rec.RType)
hl.counts.Add(rrType)
// check for custom handler type
@@ -224,12 +224,12 @@ type ZoneKeyHandler struct {
// NewZoneHandler returns a new BlockHandler instance
func NewZoneHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
// check if we have an implementation for the zone type
- if crypto.GetImplementation(rec.Type) == nil {
+ if crypto.GetImplementation(rec.RType) == nil {
return nil, ErrInvalidRecordType
}
// assemble handler
h := &ZoneKeyHandler{
- ztype: rec.Type,
+ ztype: rec.RType,
zkey: nil,
}
// add the record to the handler
@@ -242,7 +242,7 @@ func NewZoneHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandler,
// AddRecord inserts a PKEY record into the handler.
func (h *ZoneKeyHandler) AddRecord(rec *message.ResourceRecord, labels
[]string) (err error) {
// check record type
- if rec.Type != h.ztype {
+ if rec.RType != h.ztype {
return ErrInvalidRecordType
}
// check for sole zone key record in block
@@ -292,7 +292,7 @@ type Gns2DnsHandler struct {
// NewGns2DnsHandler returns a new BlockHandler instance
func NewGns2DnsHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS {
return nil, ErrInvalidRecordType
}
h := &Gns2DnsHandler{
@@ -308,7 +308,7 @@ func NewGns2DnsHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandl
// AddRecord inserts a GNS2DNS record into the handler.
func (h *Gns2DnsHandler) AddRecord(rec *message.ResourceRecord, labels
[]string) error {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_GNS2DNS {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_GNS2DNS {
return ErrInvalidRecordType
}
logger.Printf(logger.DBG, "[gns] GNS2DNS data: %s\n",
hex.EncodeToString(rec.Data))
@@ -367,7 +367,7 @@ type BoxHandler struct {
// NewBoxHandler returns a new BlockHandler instance
func NewBoxHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX {
return nil, ErrInvalidRecordType
}
h := &BoxHandler{
@@ -381,7 +381,7 @@ func NewBoxHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandler,
// AddRecord inserts a BOX record into the handler.
func (h *BoxHandler) AddRecord(rec *message.ResourceRecord, labels []string)
error {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_BOX {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_BOX {
return ErrInvalidRecordType
}
logger.Printf(logger.DBG, "[box-rr] for labels %v\n", labels)
@@ -417,9 +417,9 @@ func (h *BoxHandler) Records(kind RRTypeList)
*message.RecordSet {
if kind.HasType(enums.GNSType(box.Type)) {
// valid box found: assemble new resource record.
rr := new(message.ResourceRecord)
- rr.Expires = box.rec.Expires
+ rr.Expire = box.rec.Expire
rr.Flags = box.rec.Flags
- rr.Type = box.Type
+ rr.RType = box.Type
rr.Size = uint32(len(box.RR))
rr.Data = box.RR
rs.AddRecord(rr)
@@ -445,7 +445,7 @@ type LehoHandler struct {
// NewLehoHandler returns a new BlockHandler instance
func NewLehoHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO {
return nil, ErrInvalidRecordType
}
h := &LehoHandler{
@@ -459,7 +459,7 @@ func NewLehoHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandler,
// AddRecord inserts a LEHO record into the handler.
func (h *LehoHandler) AddRecord(rec *message.ResourceRecord, labels []string)
error {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_LEHO {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_LEHO {
return ErrInvalidRecordType
}
h.name = string(rec.Data)
@@ -500,7 +500,7 @@ type CnameHandler struct {
// NewCnameHandler returns a new BlockHandler instance
func NewCnameHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME {
return nil, ErrInvalidRecordType
}
h := &CnameHandler{
@@ -514,7 +514,7 @@ func NewCnameHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandler
// AddRecord inserts a CNAME record into the handler.
func (h *CnameHandler) AddRecord(rec *message.ResourceRecord, labels []string)
error {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_DNS_CNAME {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_DNS_CNAME {
return ErrInvalidRecordType
}
if h.rec != nil {
@@ -557,7 +557,7 @@ type VpnHandler struct {
// NewVpnHandler returns a new BlockHandler instance
func NewVpnHandler(rec *message.ResourceRecord, labels []string)
(BlockHandler, error) {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN {
return nil, ErrInvalidRecordType
}
h := &VpnHandler{}
@@ -569,7 +569,7 @@ func NewVpnHandler(rec *message.ResourceRecord, labels
[]string) (BlockHandler,
// AddRecord inserts a VPN record into the handler.
func (h *VpnHandler) AddRecord(rec *message.ResourceRecord, labels []string)
error {
- if enums.GNSType(rec.Type) != enums.GNS_TYPE_VPN {
+ if enums.GNSType(rec.RType) != enums.GNS_TYPE_VPN {
return ErrInvalidRecordType
}
if h.rec != nil {
diff --git a/src/gnunet/service/gns/dns.go b/src/gnunet/service/gns/dns.go
index 7996460..5942b94 100644
--- a/src/gnunet/service/gns/dns.go
+++ b/src/gnunet/service/gns/dns.go
@@ -176,9 +176,9 @@ func QueryDNS(id int, name string, server net.IP, kind
RRTypeList) *message.Reco
// create a new GNS resource record
rr := new(message.ResourceRecord)
expires :=
time.Now().Add(time.Duration(record.Header().Ttl) * time.Second)
- rr.Expires = util.NewAbsoluteTime(expires)
+ rr.Expire = util.NewAbsoluteTime(expires)
rr.Flags = 0
- rr.Type = uint32(record.Header().Rrtype)
+ rr.RType = uint32(record.Header().Rrtype)
rr.Size = uint32(record.Header().Rdlength)
rr.Data = make([]byte, rr.Size)
@@ -230,7 +230,7 @@ func (m *Module) ResolveDNS(
// traverse resource records for 'A' and 'AAAA' records.
rec_loop:
for _, rec := range set.Records {
- switch enums.GNSType(rec.Type) {
+ switch enums.GNSType(rec.RType) {
case enums.GNS_TYPE_DNS_AAAA:
addr = net.IP(rec.Data)
// we prefer IPv6
diff --git a/src/gnunet/service/gns/module.go b/src/gnunet/service/gns/module.go
index 0f4781d..02d69a1 100644
--- a/src/gnunet/service/gns/module.go
+++ b/src/gnunet/service/gns/module.go
@@ -113,10 +113,10 @@ func NewModule(ctx context.Context, c *core.Core) (m
*Module) {
// Filter returns the event filter for the service
func (m *Module) Filter() *core.EventFilter {
f := core.NewEventFilter()
- f.AddMsgType(message.GNS_LOOKUP)
- f.AddMsgType(message.GNS_LOOKUP_RESULT)
- f.AddMsgType(message.GNS_REVERSE_LOOKUP)
- f.AddMsgType(message.GNS_REVERSE_LOOKUP_RESULT)
+ f.AddMsgType(enums.MSG_GNS_LOOKUP)
+ f.AddMsgType(enums.MSG_GNS_LOOKUP_RESULT)
+ f.AddMsgType(enums.MSG_GNS_REVERSE_LOOKUP)
+ f.AddMsgType(enums.MSG_GNS_REVERSE_LOOKUP_RESULT)
return f
}
@@ -299,8 +299,8 @@ func (m *Module) ResolveRelative(
// the longest-living record in the current set.
expires := util.AbsoluteTimeNow()
for _, rec := range set.Records {
- if rec.Expires.Compare(expires) > 0 {
- expires = rec.Expires
+ if rec.Expire.Compare(expires) > 0 {
+ expires = rec.Expire
}
}
set.Records = append(set.Records,
m.newLEHORecord(inst.Query, expires))
@@ -340,7 +340,7 @@ func (m *Module) ResolveRelative(
set = message.NewRecordSet()
for _, rec := range records {
// is this the record type we are looking for?
- if kind.HasType(enums.GNSType(rec.Type)) {
+ if kind.HasType(enums.GNSType(rec.RType)) {
// add it to the result
if rec = hdlrs.FinalizeRecord(rec); rec != nil {
set.AddRecord(rec)
@@ -363,7 +363,7 @@ func (m *Module) ResolveRelative(
// asking for explicitly.
if set.Count > 0 {
for _, rec := range records {
- if !kind.HasType(enums.GNSType(rec.Type)) &&
(int(rec.Flags)&enums.GNS_FLAG_SUPPL) != 0 {
+ if !kind.HasType(enums.GNSType(rec.RType)) &&
(int(rec.Flags)&enums.GNS_FLAG_SUPPL) != 0 {
set.AddRecord(rec)
}
}
@@ -472,9 +472,9 @@ func (m *Module) Lookup(
// newLEHORecord creates a new supplemental GNS record of type LEHO.
func (m *Module) newLEHORecord(name string, expires util.AbsoluteTime)
*message.ResourceRecord {
rr := new(message.ResourceRecord)
- rr.Expires = expires
+ rr.Expire = expires
rr.Flags = uint32(enums.GNS_FLAG_SUPPL)
- rr.Type = uint32(enums.GNS_TYPE_LEHO)
+ rr.RType = uint32(enums.GNS_TYPE_LEHO)
rr.Size = uint32(len(name) + 1)
rr.Data = make([]byte, rr.Size)
copy(rr.Data, []byte(name))
diff --git a/src/gnunet/service/gns/service.go
b/src/gnunet/service/gns/service.go
index 45eb700..fb6aea0 100644
--- a/src/gnunet/service/gns/service.go
+++ b/src/gnunet/service/gns/service.go
@@ -96,7 +96,7 @@ func (s *Service) ServeClient(ctx context.Context, id int, mc
*service.Connectio
logger.Printf(logger.INFO, "[gns:%d:%d] Received request:
%v\n", id, reqID, msg)
// handle message
- valueCtx := context.WithValue(ctx, service.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
+ valueCtx := context.WithValue(ctx, core.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
s.HandleMessage(valueCtx, nil, msg, mc)
}
// close client connection
@@ -136,7 +136,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender
*util.PeerID, msg me
logger.Printf(logger.DBG, "[gns%s] Lookup
request finished.\n", label)
}()
- kind := NewRRTypeList(enums.GNSType(m.Type))
+ kind := NewRRTypeList(enums.GNSType(m.RType))
recset, err := s.Resolve(ctx, label, m.Zone, kind,
int(m.Options), 0)
if err != nil {
logger.Printf(logger.ERROR, "[gns%s] Failed to
lookup block: %s\n", label, err.Error())
@@ -159,7 +159,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender
*util.PeerID, msg me
logger.Printf(logger.DBG, "[gns%s]
Record #%d: %v\n", label, i, rec)
// is this the record type we are
looking for?
- if rec.Type == m.Type ||
enums.GNSType(m.Type) == enums.GNS_TYPE_ANY {
+ if rec.RType == m.RType ||
enums.GNSType(m.RType) == enums.GNS_TYPE_ANY {
// add it to the response
message
if err := resp.AddRecord(rec);
err != nil {
logger.Printf(logger.ERROR, "[gns%s] failed: %sv", label, err.Error())
@@ -173,7 +173,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender
*util.PeerID, msg me
//----------------------------------------------------------
// UNKNOWN message type received
//----------------------------------------------------------
- logger.Printf(logger.ERROR, "[gns%s] Unhandled message of type
(%d)\n", label, msg.Header().MsgType)
+ logger.Printf(logger.ERROR, "[gns%s] Unhandled message of type
(%s)\n", label, msg.Type())
return false
}
return true
@@ -238,7 +238,7 @@ func (s *Service) RevokeKey(ctx context.Context, rd
*revocation.RevData) (succes
// LookupNamecache returns a cached lookup (if available)
func (s *Service) LookupNamecache(ctx context.Context, query *blocks.GNSQuery)
(block *blocks.GNSBlock, err error) {
- logger.Printf(logger.DBG, "[gns] LookupNamecache(%s)...\n",
hex.EncodeToString(query.Key().Bits))
+ logger.Printf(logger.DBG, "[gns] LookupNamecache(%s)...\n",
hex.EncodeToString(query.Key().Data))
// assemble Namecache request
req := message.NewNamecacheLookupMsg(query.Key())
@@ -292,7 +292,7 @@ func (s *Service) LookupNamecache(ctx context.Context,
query *blocks.GNSQuery) (
break
}
default:
- logger.Printf(logger.ERROR, "[gns] Got invalid response type
(%d)\n", m.Header().MsgType)
+ logger.Printf(logger.ERROR, "[gns] Got invalid response type
(%s)\n", m.Type())
err = ErrInvalidResponseType
}
return
@@ -328,7 +328,7 @@ func (s *Service) StoreNamecache(ctx context.Context, query
*blocks.GNSQuery, bl
}
return fmt.Errorf("failed with rc=%d", m.Result)
default:
- logger.Printf(logger.ERROR, "[gns] Got invalid response type
(%d)\n", m.Header().MsgType)
+ logger.Printf(logger.ERROR, "[gns] Got invalid response type
(%s)\n", m.Type())
err = ErrInvalidResponseType
}
return
@@ -340,7 +340,7 @@ func (s *Service) StoreNamecache(ctx context.Context, query
*blocks.GNSQuery, bl
// LookupDHT gets a GNS block from the DHT for the given query key.
func (s *Service) LookupDHT(ctx context.Context, query blocks.Query) (block
blocks.Block, err error) {
- logger.Printf(logger.DBG, "[gns] LookupDHT(%s)...\n",
hex.EncodeToString(query.Key().Bits))
+ logger.Printf(logger.DBG, "[gns] LookupDHT(%s)...\n",
hex.EncodeToString(query.Key().Data))
block = nil
// client-connect to the DHT service
@@ -375,7 +375,7 @@ func (s *Service) LookupDHT(ctx context.Context, query
blocks.Query) (block bloc
reqGet := message.NewDHTClientGetMsg(query.Key())
reqGet.ID = uint64(util.NextID())
reqGet.ReplLevel = uint32(enums.GNS_REPLICATION_LEVEL)
- reqGet.Type = uint32(enums.BLOCK_TYPE_GNS_NAMERECORD)
+ reqGet.BType = enums.BLOCK_TYPE_GNS_NAMERECORD
reqGet.Options = uint32(enums.DHT_RO_DEMULTIPLEX_EVERYWHERE)
if err = interact(reqGet, true); err != nil {
@@ -413,7 +413,7 @@ func (s *Service) LookupDHT(ctx context.Context, query
blocks.Query) (block bloc
break
}
// check if result is of requested type
- if enums.BlockType(m.Type) != enums.BLOCK_TYPE_GNS_NAMERECORD {
+ if enums.BlockType(m.BType) != enums.BLOCK_TYPE_GNS_NAMERECORD {
logger.Println(logger.ERROR, "[gns] DHT response has
wrong type")
break
}
diff --git a/src/gnunet/service/module.go b/src/gnunet/service/module.go
index 8835fab..d09d41e 100644
--- a/src/gnunet/service/module.go
+++ b/src/gnunet/service/module.go
@@ -81,9 +81,6 @@ type EventHandler func(context.Context, *core.Event)
// Heartbeat is a function prototype for periodic tasks
type Heartbeat func(context.Context)
-// CtxKey is a value-context key
-type CtxKey string
-
//----------------------------------------------------------------------
// Generic module implementation
//----------------------------------------------------------------------
@@ -121,7 +118,7 @@ func (m *ModuleImpl) Run(
select {
// Handle events
case event := <-m.ch:
- hCtx := context.WithValue(ctx, CtxKey("label"),
event.Label)
+ hCtx := context.WithValue(ctx,
core.CtxKey("label"), event.Label)
hdlr(hCtx, event)
// wait for terminate signal
diff --git a/src/gnunet/service/revocation/module.go
b/src/gnunet/service/revocation/module.go
index e435dd4..2682eff 100644
--- a/src/gnunet/service/revocation/module.go
+++ b/src/gnunet/service/revocation/module.go
@@ -23,7 +23,7 @@ import (
"gnunet/config"
"gnunet/core"
"gnunet/crypto"
- "gnunet/message"
+ "gnunet/enums"
"gnunet/service"
"gnunet/service/store"
"gnunet/util"
@@ -85,10 +85,10 @@ func NewModule(ctx context.Context, c *core.Core) (m
*Module) {
// Filter returns the event filter for the service
func (m *Module) Filter() *core.EventFilter {
f := core.NewEventFilter()
- f.AddMsgType(message.REVOCATION_QUERY)
- f.AddMsgType(message.REVOCATION_QUERY_RESPONSE)
- f.AddMsgType(message.REVOCATION_REVOKE)
- f.AddMsgType(message.REVOCATION_REVOKE_RESPONSE)
+ f.AddMsgType(enums.MSG_REVOCATION_QUERY)
+ f.AddMsgType(enums.MSG_REVOCATION_QUERY_RESPONSE)
+ f.AddMsgType(enums.MSG_REVOCATION_REVOKE)
+ f.AddMsgType(enums.MSG_REVOCATION_REVOKE_RESPONSE)
return f
}
diff --git a/src/gnunet/service/revocation/service.go
b/src/gnunet/service/revocation/service.go
index 99d9b4a..0b4faee 100644
--- a/src/gnunet/service/revocation/service.go
+++ b/src/gnunet/service/revocation/service.go
@@ -75,7 +75,7 @@ func (s *Service) ServeClient(ctx context.Context, id int, mc
*service.Connectio
logger.Printf(logger.INFO, "[revocation:%d:%d] Received
request: %v\n", id, reqID, msg)
// handle message
- valueCtx := context.WithValue(ctx, service.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
+ valueCtx := context.WithValue(ctx, core.CtxKey("label"),
fmt.Sprintf(":%d:%d", id, reqID))
s.HandleMessage(valueCtx, nil, msg, mc)
}
// close client connection
@@ -157,7 +157,7 @@ func (s *Service) HandleMessage(ctx context.Context, sender
*util.PeerID, msg me
//----------------------------------------------------------
// UNKNOWN message type received
//----------------------------------------------------------
- logger.Printf(logger.ERROR, "[revocation%s] Unhandled message
of type (%d)\n", label, msg.Header().MsgType)
+ logger.Printf(logger.ERROR, "[revocation%s] Unhandled message
of type (%s)\n", label, msg.Type())
return false
}
return true
diff --git a/src/gnunet/service/store/store_dht.go
b/src/gnunet/service/store/store_dht.go
index 802cf60..54246db 100644
--- a/src/gnunet/service/store/store_dht.go
+++ b/src/gnunet/service/store/store_dht.go
@@ -166,9 +166,15 @@ func (s *DHTStore) Put(query blocks.Query, entry
*DHTEntry) (err error) {
btype := query.Type()
expire := entry.Blk.Expire()
blkSize := len(entry.Blk.Bytes())
+ pl := 0
+ if entry.Path != nil {
+ pl = int(entry.Path.NumList)
+ }
+ logger.Printf(logger.INFO, "[dht-store] storing %d bytes under key %s
(path: %d)",
+ blkSize, query.Key().Short(), pl)
// write entry to file for storage
- if err = s.writeEntry(query.Key().Bits, entry); err != nil {
+ if err = s.writeEntry(query.Key().Data, entry); err != nil {
return
}
// compile metadata
@@ -220,13 +226,13 @@ func (s *DHTStore) Get(label string, query blocks.Query,
rf blocks.ResultFilter)
}
// read entry from storage
var entry *DHTEntry
- if entry, err = s.readEntry(md.key.Bits); err != nil {
+ if entry, err = s.readEntry(md); err != nil {
logger.Printf(logger.ERROR, "[%s] can't read DHT entry:
%s", label, err)
continue
}
results = append(results, entry)
// mark the block as newly used
- if err = s.meta.Used(md.key.Bits, md.btype); err != nil {
+ if err = s.meta.Used(md.key.Data, md.btype); err != nil {
logger.Printf(logger.ERROR, "[%s] can't flag DHT entry
as used: %s", label, err)
continue
}
@@ -246,13 +252,13 @@ func (s *DHTStore) GetApprox(label string, query
blocks.Query, rf blocks.ResultF
return
}
// check distance (max. 16 bucktes off)
- dist := util.Distance(md.key.Bits, query.Key().Bits)
+ dist := util.Distance(md.key.Data, query.Key().Data)
if (512 - dist.BitLen()) > 16 {
return
}
// read entry from storage
var entry *DHTEntry
- if entry, err = s.readEntry(md.key.Bits); err != nil {
+ if entry, err = s.readEntry(md); err != nil {
logger.Printf(logger.ERROR, "[%s] failed to retrieve
block for %s", label, md.key.String())
return
}
@@ -278,9 +284,9 @@ type entryLayout struct {
}
// read entry from storage for given key
-func (s *DHTStore) readEntry(key []byte) (entry *DHTEntry, err error) {
+func (s *DHTStore) readEntry(md *FileMetadata) (entry *DHTEntry, err error) {
// get path and filename from key
- folder, fname := s.expandPath(key)
+ folder, fname := s.expandPath(md.key.Data)
// open file for reading
var file *os.File
@@ -300,7 +306,9 @@ func (s *DHTStore) readEntry(key []byte) (entry *DHTEntry,
err error) {
}
// assemble entry
entry = new(DHTEntry)
- entry.Blk = blocks.NewGenericBlock(val.Block)
+ if entry.Blk, err = blocks.NewBlock(md.btype, md.expires, val.Block);
err != nil {
+ return
+ }
entry.Path, err = path.NewPathFromBytes(val.Path)
return
}
@@ -366,12 +374,12 @@ func (s *DHTStore) dropFile(md *FileMetadata) (err error)
{
// adjust total size
s.totalSize -= md.size
// remove from database
- if err = s.meta.Drop(md.key.Bits, md.btype); err != nil {
+ if err = s.meta.Drop(md.key.Data, md.btype); err != nil {
logger.Printf(logger.ERROR, "[store] can't remove metadata
(%s,%d): %s", md.key, md.btype, err.Error())
return
}
// remove from filesystem
- h := hex.EncodeToString(md.key.Bits)
+ h := hex.EncodeToString(md.key.Data)
path := fmt.Sprintf("%s/%s/%s/%s", s.path, h[:2], h[2:4], h[4:])
if err = os.Remove(path); err != nil {
logger.Printf(logger.ERROR, "[store] can't remove file %s: %s",
path, err.Error())
diff --git a/src/gnunet/service/store/store_dht_meta.go
b/src/gnunet/service/store/store_dht_meta.go
index 9ebe387..5075d90 100644
--- a/src/gnunet/service/store/store_dht_meta.go
+++ b/src/gnunet/service/store/store_dht_meta.go
@@ -99,7 +99,7 @@ func OpenMetaDB(path string) (db *FileMetaDB, err error) {
func (db *FileMetaDB) Store(md *FileMetadata) (err error) {
sql := "replace into
meta(qkey,btype,bhash,size,stored,expires,lastUsed,usedCount)
values(?,?,?,?,?,?,?,?)"
_, err = db.conn.Exec(sql,
- md.key.Bits, md.btype, md.bhash.Bits, md.size,
md.stored.Epoch(),
+ md.key.Data, md.btype, md.bhash.Data, md.size,
md.stored.Epoch(),
md.expires.Epoch(), md.lastUsed.Epoch(), md.usedCount)
return
}
@@ -111,9 +111,9 @@ func (db *FileMetaDB) Get(query blocks.Query) (mds
[]*FileMetadata, err error) {
btype := query.Type()
var rows *sql.Rows
if btype == enums.BLOCK_TYPE_ANY {
- rows, err = db.conn.Query(stmt, query.Key().Bits)
+ rows, err = db.conn.Query(stmt, query.Key().Data)
} else {
- rows, err = db.conn.Query(stmt+" and btype=?",
query.Key().Bits, btype)
+ rows, err = db.conn.Query(stmt+" and btype=?",
query.Key().Data, btype)
}
if err != nil {
return
@@ -124,7 +124,7 @@ func (db *FileMetaDB) Get(query blocks.Query) (mds
[]*FileMetadata, err error) {
md.key = query.Key()
md.btype = btype
var st, exp, lu uint64
- if err = rows.Scan(&md.size, &md.bhash.Bits, &st, &exp, &lu,
&md.usedCount); err != nil {
+ if err = rows.Scan(&md.size, &md.bhash.Data, &st, &exp, &lu,
&md.usedCount); err != nil {
if err == sql.ErrNoRows {
md = nil
err = nil
@@ -194,7 +194,7 @@ func (db *FileMetaDB) Traverse(f func(*FileMetadata)) error
{
md := NewFileMetadata()
for rows.Next() {
var st, exp, lu uint64
- err = rows.Scan(&md.key.Bits, &md.btype, &md.bhash.Bits,
&md.size, &st, &exp, &lu, &md.usedCount)
+ err = rows.Scan(&md.key.Data, &md.btype, &md.bhash.Data,
&md.size, &st, &exp, &lu, &md.usedCount)
if err != nil {
return err
}
diff --git a/src/gnunet/service/store/store_dht_test.go
b/src/gnunet/service/store/store_dht_test.go
index 9f80380..5278634 100644
--- a/src/gnunet/service/store/store_dht_test.go
+++ b/src/gnunet/service/store/store_dht_test.go
@@ -66,6 +66,8 @@ func TestDHTFilesStore(t *testing.T) {
rf := blocks.NewGenericResultFilter()
// First round: save blocks
+ btype := enums.BLOCK_TYPE_TEST
+ expire := util.AbsoluteTimeNever()
for i := 0; i < fsNumBlocks; i++ {
// generate random block
size := 1024 + rand.Intn(62000) //nolint:gosec // good enough
for testing
@@ -73,10 +75,13 @@ func TestDHTFilesStore(t *testing.T) {
if _, err = rand.Read(buf); err != nil { //nolint:gosec // good
enough for testing
t.Fatal(err)
}
- blk := blocks.NewGenericBlock(buf)
+ var blk blocks.Block
+ if blk, err = blocks.NewBlock(btype, expire, buf); err != nil {
+ t.Fatal(err)
+ }
// generate associated key
k := crypto.Hash(buf)
- key := blocks.NewGenericQuery(k, enums.BLOCK_TYPE_ANY, 0)
+ key := blocks.NewGenericQuery(k, enums.BLOCK_TYPE_TEST, 0)
// store entry
val := &DHTEntry{
@@ -105,9 +110,9 @@ func TestDHTFilesStore(t *testing.T) {
k := crypto.Hash(buf)
// do the keys match?
- if !k.Equals(key.Key()) {
- t.Log(hex.EncodeToString(k.Bits))
- t.Log(hex.EncodeToString(key.Key().Bits))
+ if !k.Equal(key.Key()) {
+ t.Log(hex.EncodeToString(k.Data))
+ t.Log(hex.EncodeToString(key.Key().Data))
t.Fatal("key/value mismatch")
}
}
diff --git a/src/gnunet/transport/reader_writer.go
b/src/gnunet/transport/reader_writer.go
index ee76783..349dad7 100644
--- a/src/gnunet/transport/reader_writer.go
+++ b/src/gnunet/transport/reader_writer.go
@@ -41,6 +41,13 @@ func WriteMessage(ctx context.Context, wrt io.WriteCloser,
msg message.Message)
if buf, err = data.Marshal(msg); err != nil {
return
}
+ /*
+ // debug for outgoing messages
+ if msg.Type() == enums.MSG_DHT_P2P_HELLO {
+ logger.Printf(logger.DBG, "[rw_msg] msg=%s",
hex.EncodeToString(buf))
+ logger.Printf(logger.DBG, "[rw_msg] msg=%s",
util.Dump(msg, "json"))
+ }
+ */
// check message header size and packet size
mh, err := message.GetMsgHeader(buf)
if err != nil {
@@ -92,7 +99,7 @@ func ReadMessage(ctx context.Context, rdr io.ReadCloser, buf
[]byte) (msg messag
if err = get(0, 4); err != nil {
return
}
- var mh *message.Header
+ var mh *message.MsgHeader
if mh, err = message.GetMsgHeader(buf[:4]); err != nil {
return
}
@@ -108,6 +115,13 @@ func ReadMessage(ctx context.Context, rdr io.ReadCloser,
buf []byte) (msg messag
return
}
err = data.Unmarshal(msg, buf[:mh.MsgSize])
+ /*
+ // debug for incoming messages
+ if mh.MsgType == enums.MSG_DHT_P2P_RESULT {
+ logger.Printf(logger.DBG, "[rw_msg] msg=%s",
hex.EncodeToString(buf[:mh.MsgSize]))
+ logger.Printf(logger.DBG, "[rw_msg] msg=%s",
util.Dump(msg, "json"))
+ }
+ */
return
}
diff --git a/src/gnunet/util/address.go b/src/gnunet/util/address.go
index bf6f562..b672e84 100644
--- a/src/gnunet/util/address.go
+++ b/src/gnunet/util/address.go
@@ -29,7 +29,7 @@ import (
type Address struct {
Netw string // network protocol
Options uint32 // address options
- Expires AbsoluteTime // expiration date for address
+ Expire AbsoluteTime // expiration date for address
Address []byte // address data (protocol-dependent)
}
@@ -39,7 +39,7 @@ func NewAddress(transport string, addr string) *Address {
Netw: transport,
Options: 0,
Address: Clone([]byte(addr)),
- Expires: AbsoluteTimeNever(),
+ Expire: AbsoluteTimeNever(),
}
}
@@ -50,7 +50,7 @@ func NewAddressWrap(addr net.Addr) *Address {
Netw: addr.Network(),
Options: 0,
Address: []byte(addr.String()),
- Expires: AbsoluteTimeNever(),
+ Expire: AbsoluteTimeNever(),
}
}
@@ -67,8 +67,8 @@ func ParseAddress(s string) (addr *Address, err error) {
return
}
-// Equals return true if two addresses match.
-func (a *Address) Equals(b *Address) bool {
+// Equal return true if two addresses match.
+func (a *Address) Equal(b *Address) bool {
return a.Netw == b.Netw &&
a.Options == b.Options &&
bytes.Equal(a.Address, b.Address)
@@ -115,7 +115,7 @@ func NewPeerAddrList() *PeerAddrList {
func (a *PeerAddrList) Add(peer *PeerID, addr *Address) (mode int) {
// check for expired address.
mode = 0
- if !addr.Expires.Expired() {
+ if !addr.Expire.Expired() {
// run add operation
_ = a.list.Process(func(pid int) error {
id := peer.String()
@@ -125,7 +125,7 @@ func (a *PeerAddrList) Add(peer *PeerID, addr *Address)
(mode int) {
mode = 1
} else {
for _, a := range list {
- if a.Equals(addr) {
+ if a.Equal(addr) {
return nil
}
}
@@ -146,7 +146,7 @@ func (a *PeerAddrList) Get(peer *PeerID, transport string)
(res []*Address) {
if ok {
for _, addr := range list {
// check for expired address.
- if addr.Expires.Expired() {
+ if addr.Expire.Expired() {
// skip expired
continue
}
diff --git a/src/gnunet/util/array.go b/src/gnunet/util/array.go
index 954521c..97d884a 100644
--- a/src/gnunet/util/array.go
+++ b/src/gnunet/util/array.go
@@ -43,8 +43,8 @@ func Clone[T []E, E any](d T) T {
return r
}
-// Equals returns true if two arrays match.
-func Equals[T []E, E comparable](a, b T) bool {
+// Equal returns true if two arrays match.
+func Equal[T []E, E comparable](a, b T) bool {
if len(a) != len(b) {
return false
}
diff --git a/src/gnunet/util/misc.go b/src/gnunet/util/misc.go
index a157ec4..87a2149 100644
--- a/src/gnunet/util/misc.go
+++ b/src/gnunet/util/misc.go
@@ -96,6 +96,18 @@ func StripPathRight(s string) string {
return s
}
+// Shorten string for output
+func Shorten(s string, n int) string {
+ l := len(s)
+ p := n - 3
+ if p < 3 {
+ return s
+ }
+ k := p % 2
+ p /= 2
+ return s[:p+k] + "..." + s[l-p:]
+}
+
//----------------------------------------------------------------------
// Dump instance
func Dump(obj any, format string) string {
diff --git a/src/gnunet/util/peer.go b/src/gnunet/util/peer.go
index bcddad6..d16f2df 100644
--- a/src/gnunet/util/peer.go
+++ b/src/gnunet/util/peer.go
@@ -80,8 +80,11 @@ func NewPeerID(data []byte) (p *PeerID) {
}
}
-// Equals returns true if two peer IDs match.
-func (p *PeerID) Equals(q *PeerID) bool {
+// Equal returns true if two peer IDs match.
+func (p *PeerID) Equal(q *PeerID) bool {
+ if q == nil {
+ return p == nil
+ }
return bytes.Equal(p.Data, q.Data)
}
@@ -90,6 +93,11 @@ func (p *PeerID) String() string {
return EncodeBinaryToString(p.Data)
}
+// SHort returns a shortened peer id for display
+func (p *PeerID) Short() string {
+ return p.String()[:8]
+}
+
// Bytes returns the binary representation of a peer identifier.
func (p *PeerID) Bytes() []byte {
return Clone(p.Data)
diff --git a/src/gnunet/util/time.go b/src/gnunet/util/time.go
index 6e98514..cf3739a 100644
--- a/src/gnunet/util/time.go
+++ b/src/gnunet/util/time.go
@@ -81,6 +81,13 @@ func (t AbsoluteTime) Add(d time.Duration) AbsoluteTime {
}
}
+// Add a relative time to an absolute time yielding a new absolute time.
+func (t AbsoluteTime) AddRelative(d RelativeTime) AbsoluteTime {
+ return AbsoluteTime{
+ Val: t.Val + d.Val,
+ }
+}
+
// Elapsed time since 't'. Return 0 if 't' is in the future.
func (t AbsoluteTime) Elapsed() RelativeTime {
dt, elapsed := t.Diff(AbsoluteTimeNow())
@@ -107,11 +114,7 @@ func (t AbsoluteTime) Diff(t2 AbsoluteTime) (dt
RelativeTime, elapsed bool) {
// Expired returns true if the timestamp is in the past.
func (t AbsoluteTime) Expired() bool {
- // check for "never"
- if t.Val == math.MaxUint64 {
- return false
- }
- return t.Val < uint64(time.Now().Unix())
+ return t.Compare(AbsoluteTimeNow()) < 0
}
// Compare two times (-1 = (t < t2), 0 = (t == t2), 1 = (t > t2)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet-go] branch master updated: Prepared for integration test.,
gnunet <=